Merge pull request #17235 from paulloz/mono-glue-enhancements

[Mono] change function names to PascalCase and set abstract classes as abstract
This commit is contained in:
Ignacio Etcheverry 2018-03-13 17:00:28 +01:00 committed by GitHub
commit d6c802f3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 21 deletions

View File

@ -103,7 +103,7 @@
#define C_METHOD_MANAGED_TO_DICT C_NS_MONOMARSHAL "::mono_object_to_Dictionary" #define C_METHOD_MANAGED_TO_DICT C_NS_MONOMARSHAL "::mono_object_to_Dictionary"
#define C_METHOD_MANAGED_FROM_DICT C_NS_MONOMARSHAL "::Dictionary_to_mono_object" #define C_METHOD_MANAGED_FROM_DICT C_NS_MONOMARSHAL "::Dictionary_to_mono_object"
#define BINDINGS_GENERATOR_VERSION UINT32_C(1) #define BINDINGS_GENERATOR_VERSION UINT32_C(2)
const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN = "\t%0 %1_in = %1;\n"; const char *BindingsGenerator::TypeInterface::DEFAULT_VARARG_C_IN = "\t%0 %1_in = %1;\n";
@ -730,7 +730,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
} }
output.push_back(INDENT1 "public "); output.push_back(INDENT1 "public ");
output.push_back(itype.is_singleton ? "static class " : "class "); bool is_abstract = !ClassDB::can_instance(itype.name) && ClassDB::is_class_enabled(itype.name); // can_instance returns true if there's a constructor and the class is not 'disabled'
output.push_back(itype.is_singleton ? "static class " : (is_abstract ? "abstract class " : "class "));
output.push_back(itype.proxy_name); output.push_back(itype.proxy_name);
if (itype.is_singleton) { if (itype.is_singleton) {

View File

@ -287,7 +287,7 @@ namespace Godot
if (sep == -1) if (sep == -1)
return @base; return @base;
return @base + rs.substr(0, sep); return @base + rs.Substr(0, sep);
} }
// <summary> // <summary>
@ -478,7 +478,7 @@ namespace Godot
// </summary> // </summary>
public static bool IsValidIpAddress(this string instance) public static bool IsValidIpAddress(this string instance)
{ {
string[] ip = instance.split("."); string[] ip = instance.Split(".");
if (ip.Length != 4) if (ip.Length != 4)
return false; return false;
@ -489,7 +489,7 @@ namespace Godot
if (!n.IsValidInteger()) if (!n.IsValidInteger())
return false; return false;
int val = n.to_int(); int val = n.ToInt();
if (val < 0 || val > 255) if (val < 0 || val > 255)
return false; return false;
} }
@ -571,7 +571,7 @@ namespace Godot
// <summary> // <summary>
// Do a simple case insensitive expression match, using ? and * wildcards (see [method expr_match]). // Do a simple case insensitive expression match, using ? and * wildcards (see [method expr_match]).
// </summary> // </summary>
public static bool matchn(this string instance, string expr) public static bool Matchn(this string instance, string expr)
{ {
return instance.ExprMatch(expr, false); return instance.ExprMatch(expr, false);
} }
@ -830,7 +830,7 @@ namespace Godot
// <summary> // <summary>
// Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return ["One","Two","Three"] if split by ",". // Split the string by a divisor string, return an array of the substrings. Example "One,Two,Three" will return ["One","Two","Three"] if split by ",".
// </summary> // </summary>
public static string[] split(this string instance, string divisor, bool allow_empty = true) public static string[] Split(this string instance, string divisor, bool allow_empty = true)
{ {
return instance.Split(new string[] { divisor }, StringSplitOptions.RemoveEmptyEntries); return instance.Split(new string[] { divisor }, StringSplitOptions.RemoveEmptyEntries);
} }
@ -838,7 +838,7 @@ namespace Godot
// <summary> // <summary>
// Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return [1,2.5,3] if split by ",". // Split the string in floats by using a divisor string, return an array of the substrings. Example "1,2.5,3" will return [1,2.5,3] if split by ",".
// </summary> // </summary>
public static float[] split_floats(this string instance, string divisor, bool allow_empty = true) public static float[] SplitFloats(this string instance, string divisor, bool allow_empty = true)
{ {
List<float> ret = new List<float>(); List<float> ret = new List<float>();
int from = 0; int from = 0;
@ -872,7 +872,7 @@ namespace Godot
// <summary> // <summary>
// Return a copy of the string stripped of any non-printable character at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively. // Return a copy of the string stripped of any non-printable character at the beginning and the end. The optional arguments are used to toggle stripping on the left and right edges respectively.
// </summary> // </summary>
public static string strip_edges(this string instance, bool left = true, bool right = true) public static string StripEdges(this string instance, bool left = true, bool right = true)
{ {
if (left) if (left)
{ {
@ -890,7 +890,7 @@ namespace Godot
// <summary> // <summary>
// Return part of the string from the position [code]from[/code], with length [code]len[/code]. // Return part of the string from the position [code]from[/code], with length [code]len[/code].
// </summary> // </summary>
public static string substr(this string instance, int from, int len) public static string Substr(this string instance, int from, int len)
{ {
return instance.Substring(from, len); return instance.Substring(from, len);
} }
@ -898,7 +898,7 @@ namespace Godot
// <summary> // <summary>
// Convert the String (which is a character array) to PoolByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters. // Convert the String (which is a character array) to PoolByteArray (which is an array of bytes). The conversion is speeded up in comparison to to_utf8() with the assumption that all the characters the String contains are only ASCII characters.
// </summary> // </summary>
public static byte[] to_ascii(this string instance) public static byte[] ToAscii(this string instance)
{ {
return Encoding.ASCII.GetBytes(instance); return Encoding.ASCII.GetBytes(instance);
} }
@ -906,7 +906,7 @@ namespace Godot
// <summary> // <summary>
// Convert a string, containing a decimal number, into a [code]float[/code]. // Convert a string, containing a decimal number, into a [code]float[/code].
// </summary> // </summary>
public static float to_float(this string instance) public static float ToFloat(this string instance)
{ {
return float.Parse(instance); return float.Parse(instance);
} }
@ -914,7 +914,7 @@ namespace Godot
// <summary> // <summary>
// Convert a string, containing an integer number, into an [code]int[/code]. // Convert a string, containing an integer number, into an [code]int[/code].
// </summary> // </summary>
public static int to_int(this string instance) public static int ToInt(this string instance)
{ {
return int.Parse(instance); return int.Parse(instance);
} }
@ -922,7 +922,7 @@ namespace Godot
// <summary> // <summary>
// Return the string converted to lowercase. // Return the string converted to lowercase.
// </summary> // </summary>
public static string to_lower(this string instance) public static string ToLower(this string instance)
{ {
return instance.ToLower(); return instance.ToLower();
} }
@ -930,7 +930,7 @@ namespace Godot
// <summary> // <summary>
// Return the string converted to uppercase. // Return the string converted to uppercase.
// </summary> // </summary>
public static string to_upper(this string instance) public static string ToUpper(this string instance)
{ {
return instance.ToUpper(); return instance.ToUpper();
} }
@ -938,7 +938,7 @@ namespace Godot
// <summary> // <summary>
// Convert the String (which is an array of characters) to PoolByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii(). // Convert the String (which is an array of characters) to PoolByteArray (which is an array of bytes). The conversion is a bit slower than to_ascii(), but supports all UTF-8 characters. Therefore, you should prefer this function over to_ascii().
// </summary> // </summary>
public static byte[] to_utf8(this string instance) public static byte[] ToUtf8(this string instance)
{ {
return Encoding.UTF8.GetBytes(instance); return Encoding.UTF8.GetBytes(instance);
} }
@ -946,7 +946,7 @@ namespace Godot
// <summary> // <summary>
// Return a copy of the string with special characters escaped using the XML standard. // Return a copy of the string with special characters escaped using the XML standard.
// </summary> // </summary>
public static string xml_escape(this string instance) public static string XmlEscape(this string instance)
{ {
return SecurityElement.Escape(instance); return SecurityElement.Escape(instance);
} }
@ -954,7 +954,7 @@ namespace Godot
// <summary> // <summary>
// Return a copy of the string with escaped characters replaced by their meanings according to the XML standard. // Return a copy of the string with escaped characters replaced by their meanings according to the XML standard.
// </summary> // </summary>
public static string xml_unescape(this string instance) public static string XmlUnescape(this string instance)
{ {
return SecurityElement.FromString(instance).Text; return SecurityElement.FromString(instance).Text;
} }

View File

@ -24,7 +24,7 @@ namespace Godot
public Transform LookingAt(Vector3 target, Vector3 up) public Transform LookingAt(Vector3 target, Vector3 up)
{ {
Transform t = this; Transform t = this;
t.set_look_at(origin, target, up); t.SetLookAt(origin, target, up);
return t; return t;
} }
@ -43,7 +43,7 @@ namespace Godot
return new Transform(basis.Scaled(scale), origin * scale); return new Transform(basis.Scaled(scale), origin * scale);
} }
public void set_look_at(Vector3 eye, Vector3 target, Vector3 up) public void SetLookAt(Vector3 eye, Vector3 target, Vector3 up)
{ {
// Make rotation matrix // Make rotation matrix
// Z vector // Z vector

View File

@ -1 +1 @@
1 2