Merge pull request #879 from touilleMan/fix-variant-type-in-extension-api-dump

Fix Variant types displayed as `Nil` in extension_api.json
pull/891/head
Rémi Verschelde 2022-10-10 13:51:14 +02:00
commit 16a3c32da9
2 changed files with 91 additions and 90 deletions

View File

@ -280,10 +280,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
if "operators" in builtin_api:
for operator in builtin_api["operators"]:
if "right_type" in operator:
# FIXME Temporary workaround for incorrect JSON
if operator["right_type"] == "Nil":
used_classes.add("Variant")
elif is_included(operator["right_type"], class_name):
if is_included(operator["right_type"], class_name):
used_classes.add(operator["right_type"])
for type_name in fully_used_classes:
@ -728,8 +725,12 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
if "operators" in builtin_api:
for operator in builtin_api["operators"]:
if "right_type" in operator:
if operator["right_type"] == "Variant":
right_type_variant_type = "GDNATIVE_VARIANT_TYPE_NIL"
else:
right_type_variant_type = f"GDNATIVE_VARIANT_TYPE_{camel_to_snake(operator['right_type']).upper()}"
result.append(
f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]} = internal::gdn_interface->variant_get_ptr_operator_evaluator(GDNATIVE_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, GDNATIVE_VARIANT_TYPE_{camel_to_snake(operator["right_type"]).upper()});'
f'\t_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]} = internal::gdn_interface->variant_get_ptr_operator_evaluator(GDNATIVE_VARIANT_OP_{get_operator_id_name(operator["name"]).upper()}, {enum_type_name}, {right_type_variant_type});'
)
else:
result.append(

View File

@ -5715,17 +5715,17 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "or",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -6172,7 +6172,7 @@
"arguments": [
{
"name": "from",
"type": "Nil"
"type": "Variant"
}
]
}
@ -6185,27 +6185,27 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "and",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "or",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "xor",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -6343,12 +6343,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -6365,17 +6365,17 @@
},
{
"name": "and",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "or",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "xor",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -6703,12 +6703,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -6721,17 +6721,17 @@
},
{
"name": "and",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "or",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "xor",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -7025,17 +7025,17 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "%",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "String"
},
{
@ -8648,12 +8648,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -9404,12 +9404,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -9645,12 +9645,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -9953,12 +9953,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -10319,12 +10319,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -11126,12 +11126,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -11381,12 +11381,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -11848,12 +11848,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -12394,12 +12394,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -12660,12 +12660,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -12970,12 +12970,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -13372,12 +13372,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -13819,12 +13819,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -14184,12 +14184,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -15889,12 +15889,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -16449,12 +16449,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -16564,12 +16564,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -16718,12 +16718,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -16797,12 +16797,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -16998,12 +16998,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -17158,12 +17158,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -17367,12 +17367,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -18032,7 +18032,7 @@
},
{
"name": "script",
"type": "Nil"
"type": "Variant"
}
]
},
@ -18127,12 +18127,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -19006,12 +19006,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -19347,12 +19347,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -19688,12 +19688,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -20029,12 +20029,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -20370,12 +20370,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -20711,12 +20711,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -21057,12 +21057,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
@ -21403,12 +21403,12 @@
"operators": [
{
"name": "==",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{
"name": "!=",
"right_type": "Nil",
"right_type": "Variant",
"return_type": "bool"
},
{