Fix return type encoding for ptrcall.

pull/721/head
bruvzg 2022-03-09 12:37:48 +02:00
parent 024f09e1ea
commit b8b9a2fad9
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
1 changed files with 11 additions and 5 deletions

View File

@ -709,7 +709,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
(encode, arg_name) = get_encoded_arg("other", operator["right_type"], None) (encode, arg_name) = get_encoded_arg("other", operator["right_type"], None)
result += encode result += encode
result.append( result.append(
f'\treturn internal::_call_builtin_operator_ptr<{correct_type(operator["return_type"])}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr){arg_name});' f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}_{operator["right_type"]}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr){arg_name});'
) )
result.append("}") result.append("}")
else: else:
@ -717,7 +717,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
f'{correct_type(operator["return_type"])} {class_name}::operator{operator["name"].replace("unary", "")}() const {{' f'{correct_type(operator["return_type"])} {class_name}::operator{operator["name"].replace("unary", "")}() const {{'
) )
result.append( result.append(
f'\treturn internal::_call_builtin_operator_ptr<{correct_type(operator["return_type"])}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr)nullptr);' f'\treturn internal::_call_builtin_operator_ptr<{get_gdnative_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (const GDNativeTypePtr)&opaque, (const GDNativeTypePtr)nullptr);'
) )
result.append("}") result.append("}")
result.append("") result.append("")
@ -1103,7 +1103,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
return_type = method["return_value"]["type"] return_type = method["return_value"]["type"]
meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None
if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type): if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type):
method_call += f"return internal::_call_native_mb_ret<{correct_type(return_type, meta_type)}>(___method_bind, _owner" method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, _owner"
elif is_refcounted(return_type): elif is_refcounted(return_type):
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner" method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
is_ref = True is_ref = True
@ -1331,7 +1331,7 @@ def generate_utility_functions(api, output_dir):
if function["return_type"] == "Object": if function["return_type"] == "Object":
function_call += "internal::_call_utility_ret_obj(___function" function_call += "internal::_call_utility_ret_obj(___function"
else: else:
function_call += f'internal::_call_utility_ret<{correct_type(function["return_type"])}>(___function' function_call += f'internal::_call_utility_ret<{get_gdnative_type(correct_type(function["return_type"]))}>(___function'
else: else:
function_call += "internal::_call_utility_no_ret(___function" function_call += "internal::_call_utility_no_ret(___function"
@ -1725,7 +1725,13 @@ def correct_type(type_name, meta=None):
def get_gdnative_type(type_name): def get_gdnative_type(type_name):
type_conversion_map = { type_conversion_map = {
"bool": "uint32_t", "bool": "int8_t",
"uint8_t": "int64_t",
"int8_t": "int64_t",
"uint16_t": "int64_t",
"int16_t": "int64_t",
"uint32_t": "int64_t",
"int32_t": "int64_t",
"int": "int64_t", "int": "int64_t",
"float": "double", "float": "double",
} }