Added the new variant types to the binding generator. Also fixed issue with Color default value generation.

This commit is contained in:
Relintai 2023-05-31 15:51:33 +02:00
parent 000946e5f1
commit 7327b95957

View File

@ -298,7 +298,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
# default arguments # default arguments
def escape_default_arg(_type, default_value): def escape_default_arg(_type, default_value):
if _type == "Color": if _type == "Color":
return "Color(" + default_value + ")" return "Color" + default_value
if _type == "bool" or _type == "int": if _type == "bool" or _type == "int":
return default_value.lower() return default_value.lower()
if _type == "Array": if _type == "Array":
@ -325,7 +325,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
return "Rect2" + default_value return "Rect2" + default_value
if _type == "Variant": if _type == "Variant":
return "Variant()" if default_value == "Null" else default_value return "Variant()" if default_value == "Null" else default_value
if _type == "String" or _type == "NodePath": if _type == "String" or _type == "NodePath" or type == "StringName":
return '"' + default_value + '"' return '"' + default_value + '"'
if _type == "RID": if _type == "RID":
return "RID()" return "RID()"
@ -898,32 +898,42 @@ def is_class_type(name):
def is_core_type(name): def is_core_type(name):
core_types = [ core_types = [
"Array", "String",
"Basis", "Rect2",
"Color", "Rect2i",
"Dictionary", "Vector2",
"Error", "Vector2i",
"NodePath", "Vector3",
"Vector3i",
"Vector4",
"Vector4i",
"Plane", "Plane",
"Quaternion",
"AABB",
"Basis",
"Transform",
"Transform2D",
"Projection",
"Color",
"NodePath",
"RID",
# Object
"StringName",
"Dictionary",
"Array",
"PoolByteArray", "PoolByteArray",
"PoolIntArray", "PoolIntArray",
"PoolRealArray", "PoolRealArray",
"PoolStringArray", "PoolStringArray",
"PoolVector2Array", "PoolVector2Array",
"PoolVector2iArray",
"PoolVector3Array", "PoolVector3Array",
"PoolVector3iArray",
"PoolVector4Array",
"PoolVector4iArray",
"PoolColorArray", "PoolColorArray",
"PoolIntArray", "Error",
"PoolRealArray",
"Quat",
"Rect2",
"AABB",
"RID",
"String",
"Transform",
"Transform2D",
"Variant", "Variant",
"Vector2",
"Vector3",
] ]
return name in core_types return name in core_types