Fix const qualifier for parameters in GDExtension api functions

pull/897/head
Emmanuel Leblond 2022-11-13 00:37:55 +01:00
parent f1d501f977
commit fe86a94dcf
No known key found for this signature in database
GPG Key ID: C360860E645EFFC0
20 changed files with 271 additions and 272 deletions

View File

@ -76,7 +76,7 @@ extern "C" {
// Initialization. // Initialization.
GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module); init_obj.register_initializer(initialize_example_module);

View File

@ -861,7 +861,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
if f'get_{member["name"]}' not in method_list: if f'get_{member["name"]}' not in method_list:
result.append(f'{correct_type(member["type"])} {class_name}::get_{member["name"]}() const {{') result.append(f'{correct_type(member["type"])} {class_name}::get_{member["name"]}() const {{')
result.append( result.append(
f'\treturn internal::_call_builtin_ptr_getter<{correct_type(member["type"])}>(_method_bindings.member_{member["name"]}_getter, (const GDNativeTypePtr)&opaque);' f'\treturn internal::_call_builtin_ptr_getter<{correct_type(member["type"])}>(_method_bindings.member_{member["name"]}_getter, (GDNativeConstTypePtr)&opaque);'
) )
result.append("}") result.append("}")
@ -870,7 +870,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
(encode, arg_name) = get_encoded_arg("value", member["type"], None) (encode, arg_name) = get_encoded_arg("value", member["type"], None)
result += encode result += encode
result.append( result.append(
f'\t_method_bindings.member_{member["name"]}_setter((const GDNativeTypePtr)&opaque, (const GDNativeTypePtr){arg_name});' f'\t_method_bindings.member_{member["name"]}_setter((GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr){arg_name});'
) )
result.append("}") result.append("}")
@ -886,7 +886,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<{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});' 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"]}, (GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr){arg_name});'
) )
result.append("}") result.append("}")
else: else:
@ -894,7 +894,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<{get_gdnative_type(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"])}, (GDNativeConstTypePtr)&opaque, (GDNativeConstTypePtr)nullptr);'
) )
result.append("}") result.append("}")
result.append("") result.append("")
@ -1401,7 +1401,7 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
else: # vararg. else: # vararg.
result.append("\tGDNativeCallError error;") result.append("\tGDNativeCallError error;")
result.append("\tVariant ret;") result.append("\tVariant ret;")
method_call += "internal::gdn_interface->object_method_bind_call(___method_bind, _owner, (const GDNativeVariantPtr *)args, arg_count, &ret, &error" method_call += "internal::gdn_interface->object_method_bind_call(___method_bind, _owner, reinterpret_cast<GDNativeConstVariantPtr *>(args), arg_count, &ret, &error"
if is_ref: if is_ref:
method_call += ")" # Close Ref<> constructor. method_call += ")" # Close Ref<> constructor.
@ -1627,7 +1627,7 @@ def generate_utility_functions(api, output_dir):
function_call += ", ".join(arguments) function_call += ", ".join(arguments)
else: else:
source.append("\tVariant ret;") source.append("\tVariant ret;")
function_call += "___function(&ret, (const GDNativeVariantPtr *)args, arg_count" function_call += "___function(&ret, reinterpret_cast<GDNativeConstVariantPtr *>(args), arg_count"
function_call += ");" function_call += ");"
source.append(function_call) source.append(function_call)

View File

@ -141,12 +141,16 @@ typedef enum {
} GDNativeVariantOperator; } GDNativeVariantOperator;
typedef void *GDNativeVariantPtr; typedef void *GDNativeVariantPtr;
typedef const void *GDNativeConstVariantPtr;
typedef void *GDNativeStringNamePtr; typedef void *GDNativeStringNamePtr;
typedef const void *GDNativeConstStringNamePtr;
typedef void *GDNativeStringPtr; typedef void *GDNativeStringPtr;
typedef const void *GDNativeConstStringPtr;
typedef void *GDNativeObjectPtr; typedef void *GDNativeObjectPtr;
typedef const void *GDNativeConstObjectPtr;
typedef void *GDNativeTypePtr; typedef void *GDNativeTypePtr;
typedef void *GDNativeExtensionPtr; typedef const void *GDNativeConstTypePtr;
typedef void *GDNativeMethodBindPtr; typedef const void *GDNativeMethodBindPtr;
typedef int64_t GDNativeInt; typedef int64_t GDNativeInt;
typedef uint8_t GDNativeBool; typedef uint8_t GDNativeBool;
typedef uint64_t GDObjectInstanceID; typedef uint64_t GDObjectInstanceID;
@ -171,18 +175,18 @@ typedef struct {
typedef void (*GDNativeVariantFromTypeConstructorFunc)(GDNativeVariantPtr, GDNativeTypePtr); typedef void (*GDNativeVariantFromTypeConstructorFunc)(GDNativeVariantPtr, GDNativeTypePtr);
typedef void (*GDNativeTypeFromVariantConstructorFunc)(GDNativeTypePtr, GDNativeVariantPtr); typedef void (*GDNativeTypeFromVariantConstructorFunc)(GDNativeTypePtr, GDNativeVariantPtr);
typedef void (*GDNativePtrOperatorEvaluator)(const GDNativeTypePtr p_left, const GDNativeTypePtr p_right, GDNativeTypePtr r_result); typedef void (*GDNativePtrOperatorEvaluator)(GDNativeConstTypePtr p_left, GDNativeConstTypePtr p_right, GDNativeTypePtr r_result);
typedef void (*GDNativePtrBuiltInMethod)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return, int p_argument_count); typedef void (*GDNativePtrBuiltInMethod)(GDNativeTypePtr p_base, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return, int p_argument_count);
typedef void (*GDNativePtrConstructor)(GDNativeTypePtr p_base, const GDNativeTypePtr *p_args); typedef void (*GDNativePtrConstructor)(GDNativeTypePtr p_base, GDNativeConstTypePtr *p_args);
typedef void (*GDNativePtrDestructor)(GDNativeTypePtr p_base); typedef void (*GDNativePtrDestructor)(GDNativeTypePtr p_base);
typedef void (*GDNativePtrSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_value); typedef void (*GDNativePtrSetter)(GDNativeTypePtr p_base, GDNativeConstTypePtr p_value);
typedef void (*GDNativePtrGetter)(const GDNativeTypePtr p_base, GDNativeTypePtr r_value); typedef void (*GDNativePtrGetter)(GDNativeConstTypePtr p_base, GDNativeTypePtr r_value);
typedef void (*GDNativePtrIndexedSetter)(GDNativeTypePtr p_base, GDNativeInt p_index, const GDNativeTypePtr p_value); typedef void (*GDNativePtrIndexedSetter)(GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeConstTypePtr p_value);
typedef void (*GDNativePtrIndexedGetter)(const GDNativeTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value); typedef void (*GDNativePtrIndexedGetter)(GDNativeConstTypePtr p_base, GDNativeInt p_index, GDNativeTypePtr r_value);
typedef void (*GDNativePtrKeyedSetter)(GDNativeTypePtr p_base, const GDNativeTypePtr p_key, const GDNativeTypePtr p_value); typedef void (*GDNativePtrKeyedSetter)(GDNativeTypePtr p_base, GDNativeConstTypePtr p_key, GDNativeConstTypePtr p_value);
typedef void (*GDNativePtrKeyedGetter)(const GDNativeTypePtr p_base, const GDNativeTypePtr p_key, GDNativeTypePtr r_value); typedef void (*GDNativePtrKeyedGetter)(GDNativeConstTypePtr p_base, GDNativeConstTypePtr p_key, GDNativeTypePtr r_value);
typedef uint32_t (*GDNativePtrKeyedChecker)(const GDNativeVariantPtr p_base, const GDNativeVariantPtr p_key); typedef uint32_t (*GDNativePtrKeyedChecker)(GDNativeConstVariantPtr p_base, GDNativeConstVariantPtr p_key);
typedef void (*GDNativePtrUtilityFunction)(GDNativeTypePtr r_return, const GDNativeTypePtr *p_arguments, int p_argument_count); typedef void (*GDNativePtrUtilityFunction)(GDNativeTypePtr r_return, GDNativeConstTypePtr *p_arguments, int p_argument_count);
typedef GDNativeObjectPtr (*GDNativeClassConstructor)(); typedef GDNativeObjectPtr (*GDNativeClassConstructor)();
@ -200,8 +204,8 @@ typedef struct {
typedef void *GDExtensionClassInstancePtr; typedef void *GDExtensionClassInstancePtr;
typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value);
typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret);
typedef uint64_t (*GDNativeExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance); typedef uint64_t (*GDNativeExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
typedef struct { typedef struct {
@ -230,16 +234,16 @@ typedef struct {
typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count); typedef const GDNativePropertyInfo *(*GDNativeExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list); typedef void (*GDNativeExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list);
typedef GDNativeBool (*GDNativeExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name); typedef GDNativeBool (*GDNativeExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name);
typedef GDNativeBool (*GDNativeExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef GDNativeBool (*GDNativeExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret);
typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what); typedef void (*GDNativeExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what);
typedef void (*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr p_out); typedef void (*GDNativeExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr p_out);
typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret);
typedef GDNativeObjectPtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata); typedef GDNativeObjectPtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata);
typedef void (*GDNativeExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance);
typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, const GDNativeStringNamePtr p_name); typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, GDNativeConstStringNamePtr p_name);
typedef struct { typedef struct {
GDNativeBool is_virtual; GDNativeBool is_virtual;
@ -289,8 +293,8 @@ typedef enum {
GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
} GDNativeExtensionClassMethodArgumentMetadata; } GDNativeExtensionClassMethodArgumentMetadata;
typedef void (*GDNativeExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); typedef void (*GDNativeExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
typedef void (*GDNativeExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); typedef void (*GDNativeExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret);
typedef struct { typedef struct {
GDNativeStringNamePtr name; GDNativeStringNamePtr name;
@ -320,25 +324,25 @@ typedef struct {
typedef void *GDNativeExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation. typedef void *GDNativeExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
typedef GDNativeBool (*GDNativeExtensionScriptInstanceSet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); typedef GDNativeBool (*GDNativeExtensionScriptInstanceSet)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value);
typedef GDNativeBool (*GDNativeExtensionScriptInstanceGet)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef GDNativeBool (*GDNativeExtensionScriptInstanceGet)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret);
typedef const GDNativePropertyInfo *(*GDNativeExtensionScriptInstanceGetPropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef const GDNativePropertyInfo *(*GDNativeExtensionScriptInstanceGetPropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
typedef void (*GDNativeExtensionScriptInstanceFreePropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo *p_list); typedef void (*GDNativeExtensionScriptInstanceFreePropertyList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativePropertyInfo *p_list);
typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeBool *r_is_valid); typedef GDNativeVariantType (*GDNativeExtensionScriptInstanceGetPropertyType)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeBool *r_is_valid);
typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyCanRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyCanRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name);
typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyGetRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); typedef GDNativeBool (*GDNativeExtensionScriptInstancePropertyGetRevert)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret);
typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetOwner)(GDNativeExtensionScriptInstanceDataPtr p_instance); typedef GDNativeObjectPtr (*GDNativeExtensionScriptInstanceGetOwner)(GDNativeExtensionScriptInstanceDataPtr p_instance);
typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value, void *p_userdata); typedef void (*GDNativeExtensionScriptInstancePropertyStateAdd)(GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value, void *p_userdata);
typedef void (*GDNativeExtensionScriptInstanceGetPropertyState)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata); typedef void (*GDNativeExtensionScriptInstanceGetPropertyState)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
typedef const GDNativeMethodInfo *(*GDNativeExtensionScriptInstanceGetMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef const GDNativeMethodInfo *(*GDNativeExtensionScriptInstanceGetMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
typedef void (*GDNativeExtensionScriptInstanceFreeMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeMethodInfo *p_list); typedef void (*GDNativeExtensionScriptInstanceFreeMethodList)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeMethodInfo *p_list);
typedef GDNativeBool (*GDNativeExtensionScriptInstanceHasMethod)(GDNativeExtensionScriptInstanceDataPtr p_instance, const GDNativeStringNamePtr p_name); typedef GDNativeBool (*GDNativeExtensionScriptInstanceHasMethod)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeConstStringNamePtr p_name);
typedef void (*GDNativeExtensionScriptInstanceCall)(GDNativeExtensionScriptInstanceDataPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); typedef void (*GDNativeExtensionScriptInstanceCall)(GDNativeExtensionScriptInstanceDataPtr p_self, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
typedef void (*GDNativeExtensionScriptInstanceNotification)(GDNativeExtensionScriptInstanceDataPtr p_instance, int32_t p_what); typedef void (*GDNativeExtensionScriptInstanceNotification)(GDNativeExtensionScriptInstanceDataPtr p_instance, int32_t p_what);
typedef void (*GDNativeExtensionScriptInstanceToString)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out); typedef void (*GDNativeExtensionScriptInstanceToString)(GDNativeExtensionScriptInstanceDataPtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out);
@ -413,41 +417,41 @@ typedef struct {
void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line); void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line); void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
uint64_t (*get_native_struct_size)(const GDNativeStringNamePtr p_name); uint64_t (*get_native_struct_size)(GDNativeConstStringNamePtr p_name);
/* GODOT VARIANT */ /* GODOT VARIANT */
/* variant general */ /* variant general */
void (*variant_new_copy)(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src); void (*variant_new_copy)(GDNativeVariantPtr r_dest, GDNativeConstVariantPtr p_src);
void (*variant_new_nil)(GDNativeVariantPtr r_dest); void (*variant_new_nil)(GDNativeVariantPtr r_dest);
void (*variant_destroy)(GDNativeVariantPtr p_self); void (*variant_destroy)(GDNativeVariantPtr p_self);
/* variant type */ /* variant type */
void (*variant_call)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); void (*variant_call)(GDNativeVariantPtr p_self, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
void (*variant_call_static)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); void (*variant_call_static)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_method, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
void (*variant_evaluate)(GDNativeVariantOperator p_op, const GDNativeVariantPtr p_a, const GDNativeVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid); void (*variant_evaluate)(GDNativeVariantOperator p_op, GDNativeConstVariantPtr p_a, GDNativeConstVariantPtr p_b, GDNativeVariantPtr r_return, GDNativeBool *r_valid);
void (*variant_set)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); void (*variant_set)(GDNativeVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid);
void (*variant_set_named)(GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); void (*variant_set_named)(GDNativeVariantPtr p_self, GDNativeConstStringNamePtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid);
void (*variant_set_keyed)(GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, const GDNativeVariantPtr p_value, GDNativeBool *r_valid); void (*variant_set_keyed)(GDNativeVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid);
void (*variant_set_indexed)(GDNativeVariantPtr p_self, GDNativeInt p_index, const GDNativeVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob); void (*variant_set_indexed)(GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeConstVariantPtr p_value, GDNativeBool *r_valid, GDNativeBool *r_oob);
void (*variant_get)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); void (*variant_get)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
void (*variant_get_named)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); void (*variant_get_named)(GDNativeConstVariantPtr p_self, GDNativeConstStringNamePtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
void (*variant_get_keyed)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); void (*variant_get_keyed)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
void (*variant_get_indexed)(const GDNativeVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob); void (*variant_get_indexed)(GDNativeConstVariantPtr p_self, GDNativeInt p_index, GDNativeVariantPtr r_ret, GDNativeBool *r_valid, GDNativeBool *r_oob);
GDNativeBool (*variant_iter_init)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); GDNativeBool (*variant_iter_init)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid);
GDNativeBool (*variant_iter_next)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid); GDNativeBool (*variant_iter_next)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeBool *r_valid);
void (*variant_iter_get)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid); void (*variant_iter_get)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_iter, GDNativeVariantPtr r_ret, GDNativeBool *r_valid);
GDNativeInt (*variant_hash)(const GDNativeVariantPtr p_self); GDNativeInt (*variant_hash)(GDNativeConstVariantPtr p_self);
GDNativeInt (*variant_recursive_hash)(const GDNativeVariantPtr p_self, GDNativeInt p_recursion_count); GDNativeInt (*variant_recursive_hash)(GDNativeConstVariantPtr p_self, GDNativeInt p_recursion_count);
GDNativeBool (*variant_hash_compare)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_other); GDNativeBool (*variant_hash_compare)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_other);
GDNativeBool (*variant_booleanize)(const GDNativeVariantPtr p_self); GDNativeBool (*variant_booleanize)(GDNativeConstVariantPtr p_self);
void (*variant_duplicate)(const GDNativeVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep); void (*variant_duplicate)(GDNativeConstVariantPtr p_self, GDNativeVariantPtr r_ret, GDNativeBool p_deep);
void (*variant_stringify)(const GDNativeVariantPtr p_self, GDNativeStringPtr r_ret); void (*variant_stringify)(GDNativeConstVariantPtr p_self, GDNativeStringPtr r_ret);
GDNativeVariantType (*variant_get_type)(const GDNativeVariantPtr p_self); GDNativeVariantType (*variant_get_type)(GDNativeConstVariantPtr p_self);
GDNativeBool (*variant_has_method)(const GDNativeVariantPtr p_self, const GDNativeStringNamePtr p_method); GDNativeBool (*variant_has_method)(GDNativeConstVariantPtr p_self, GDNativeConstStringNamePtr p_method);
GDNativeBool (*variant_has_member)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); GDNativeBool (*variant_has_member)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member);
GDNativeBool (*variant_has_key)(const GDNativeVariantPtr p_self, const GDNativeVariantPtr p_key, GDNativeBool *r_valid); GDNativeBool (*variant_has_key)(GDNativeConstVariantPtr p_self, GDNativeConstVariantPtr p_key, GDNativeBool *r_valid);
void (*variant_get_type_name)(GDNativeVariantType p_type, GDNativeStringPtr r_name); void (*variant_get_type_name)(GDNativeVariantType p_type, GDNativeStringPtr r_name);
GDNativeBool (*variant_can_convert)(GDNativeVariantType p_from, GDNativeVariantType p_to); GDNativeBool (*variant_can_convert)(GDNativeVariantType p_from, GDNativeVariantType p_to);
GDNativeBool (*variant_can_convert_strict)(GDNativeVariantType p_from, GDNativeVariantType p_to); GDNativeBool (*variant_can_convert_strict)(GDNativeVariantType p_from, GDNativeVariantType p_to);
@ -456,19 +460,19 @@ typedef struct {
GDNativeVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDNativeVariantType p_type); GDNativeVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDNativeVariantType p_type);
GDNativeTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDNativeVariantType p_type); GDNativeTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDNativeVariantType p_type);
GDNativePtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b); GDNativePtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDNativeVariantOperator p_operator, GDNativeVariantType p_type_a, GDNativeVariantType p_type_b);
GDNativePtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_method, GDNativeInt p_hash); GDNativePtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_method, GDNativeInt p_hash);
GDNativePtrConstructor (*variant_get_ptr_constructor)(GDNativeVariantType p_type, int32_t p_constructor); GDNativePtrConstructor (*variant_get_ptr_constructor)(GDNativeVariantType p_type, int32_t p_constructor);
GDNativePtrDestructor (*variant_get_ptr_destructor)(GDNativeVariantType p_type); GDNativePtrDestructor (*variant_get_ptr_destructor)(GDNativeVariantType p_type);
void (*variant_construct)(GDNativeVariantType p_type, GDNativeVariantPtr p_base, const GDNativeVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error); void (*variant_construct)(GDNativeVariantType p_type, GDNativeVariantPtr p_base, GDNativeConstVariantPtr *p_args, int32_t p_argument_count, GDNativeCallError *r_error);
GDNativePtrSetter (*variant_get_ptr_setter)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); GDNativePtrSetter (*variant_get_ptr_setter)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member);
GDNativePtrGetter (*variant_get_ptr_getter)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_member); GDNativePtrGetter (*variant_get_ptr_getter)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_member);
GDNativePtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDNativeVariantType p_type); GDNativePtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDNativeVariantType p_type);
GDNativePtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDNativeVariantType p_type); GDNativePtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDNativeVariantType p_type);
GDNativePtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDNativeVariantType p_type); GDNativePtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDNativeVariantType p_type);
GDNativePtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDNativeVariantType p_type); GDNativePtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDNativeVariantType p_type);
GDNativePtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDNativeVariantType p_type); GDNativePtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDNativeVariantType p_type);
void (*variant_get_constant_value)(GDNativeVariantType p_type, const GDNativeStringNamePtr p_constant, GDNativeVariantPtr r_ret); void (*variant_get_constant_value)(GDNativeVariantType p_type, GDNativeConstStringNamePtr p_constant, GDNativeVariantPtr r_ret);
GDNativePtrUtilityFunction (*variant_get_ptr_utility_function)(const GDNativeStringNamePtr p_function, GDNativeInt p_hash); GDNativePtrUtilityFunction (*variant_get_ptr_utility_function)(GDNativeConstStringNamePtr p_function, GDNativeInt p_hash);
/* extra utilities */ /* extra utilities */
void (*string_new_with_latin1_chars)(GDNativeStringPtr r_dest, const char *p_contents); void (*string_new_with_latin1_chars)(GDNativeStringPtr r_dest, const char *p_contents);
@ -476,12 +480,11 @@ typedef struct {
void (*string_new_with_utf16_chars)(GDNativeStringPtr r_dest, const char16_t *p_contents); void (*string_new_with_utf16_chars)(GDNativeStringPtr r_dest, const char16_t *p_contents);
void (*string_new_with_utf32_chars)(GDNativeStringPtr r_dest, const char32_t *p_contents); void (*string_new_with_utf32_chars)(GDNativeStringPtr r_dest, const char32_t *p_contents);
void (*string_new_with_wide_chars)(GDNativeStringPtr r_dest, const wchar_t *p_contents); void (*string_new_with_wide_chars)(GDNativeStringPtr r_dest, const wchar_t *p_contents);
void (*string_new_with_latin1_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size); void (*string_new_with_latin1_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, GDNativeInt p_size);
void (*string_new_with_utf8_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, const GDNativeInt p_size); void (*string_new_with_utf8_chars_and_len)(GDNativeStringPtr r_dest, const char *p_contents, GDNativeInt p_size);
void (*string_new_with_utf16_chars_and_len)(GDNativeStringPtr r_dest, const char16_t *p_contents, const GDNativeInt p_size); void (*string_new_with_utf16_chars_and_len)(GDNativeStringPtr r_dest, const char16_t *p_contents, GDNativeInt p_size);
void (*string_new_with_utf32_chars_and_len)(GDNativeStringPtr r_dest, const char32_t *p_contents, const GDNativeInt p_size); void (*string_new_with_utf32_chars_and_len)(GDNativeStringPtr r_dest, const char32_t *p_contents, GDNativeInt p_size);
void (*string_new_with_wide_chars_and_len)(GDNativeStringPtr r_dest, const wchar_t *p_contents, const GDNativeInt p_size); void (*string_new_with_wide_chars_and_len)(GDNativeStringPtr r_dest, const wchar_t *p_contents, GDNativeInt p_size);
/* Information about the following functions: /* Information about the following functions:
* - The return value is the resulting encoded string length. * - The return value is the resulting encoded string length.
* - The length returned is in characters, not in bytes. It also does not include a trailing zero. * - The length returned is in characters, not in bytes. It also does not include a trailing zero.
@ -490,63 +493,63 @@ typedef struct {
* - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL. * - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL.
* - p_max_write_length argument does not affect the return value, it's only to cap write length. * - p_max_write_length argument does not affect the return value, it's only to cap write length.
*/ */
GDNativeInt (*string_to_latin1_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); GDNativeInt (*string_to_latin1_chars)(GDNativeConstStringPtr p_self, char *r_text, GDNativeInt p_max_write_length);
GDNativeInt (*string_to_utf8_chars)(const GDNativeStringPtr p_self, char *r_text, GDNativeInt p_max_write_length); GDNativeInt (*string_to_utf8_chars)(GDNativeConstStringPtr p_self, char *r_text, GDNativeInt p_max_write_length);
GDNativeInt (*string_to_utf16_chars)(const GDNativeStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length); GDNativeInt (*string_to_utf16_chars)(GDNativeConstStringPtr p_self, char16_t *r_text, GDNativeInt p_max_write_length);
GDNativeInt (*string_to_utf32_chars)(const GDNativeStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length); GDNativeInt (*string_to_utf32_chars)(GDNativeConstStringPtr p_self, char32_t *r_text, GDNativeInt p_max_write_length);
GDNativeInt (*string_to_wide_chars)(const GDNativeStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length); GDNativeInt (*string_to_wide_chars)(GDNativeConstStringPtr p_self, wchar_t *r_text, GDNativeInt p_max_write_length);
char32_t *(*string_operator_index)(GDNativeStringPtr p_self, GDNativeInt p_index); char32_t *(*string_operator_index)(GDNativeStringPtr p_self, GDNativeInt p_index);
const char32_t *(*string_operator_index_const)(const GDNativeStringPtr p_self, GDNativeInt p_index); const char32_t *(*string_operator_index_const)(GDNativeConstStringPtr p_self, GDNativeInt p_index);
/* Packed array functions */ /* Packed array functions */
uint8_t *(*packed_byte_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray uint8_t *(*packed_byte_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray
const uint8_t *(*packed_byte_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray const uint8_t *(*packed_byte_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedByteArray
GDNativeTypePtr (*packed_color_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr GDNativeTypePtr (*packed_color_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr
GDNativeTypePtr (*packed_color_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr GDNativeTypePtr (*packed_color_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedColorArray, returns Color ptr
float *(*packed_float32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array float *(*packed_float32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array
const float *(*packed_float32_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array const float *(*packed_float32_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat32Array
double *(*packed_float64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array double *(*packed_float64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array
const double *(*packed_float64_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array const double *(*packed_float64_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedFloat64Array
int32_t *(*packed_int32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array int32_t *(*packed_int32_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array
const int32_t *(*packed_int32_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array const int32_t *(*packed_int32_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array
int64_t *(*packed_int64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array int64_t *(*packed_int64_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array
const int64_t *(*packed_int64_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array const int64_t *(*packed_int64_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedInt32Array
GDNativeStringPtr (*packed_string_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray GDNativeStringPtr (*packed_string_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray
GDNativeStringPtr (*packed_string_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray GDNativeStringPtr (*packed_string_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedStringArray
GDNativeTypePtr (*packed_vector2_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr GDNativeTypePtr (*packed_vector2_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
GDNativeTypePtr (*packed_vector2_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr GDNativeTypePtr (*packed_vector2_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
GDNativeTypePtr (*packed_vector3_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr GDNativeTypePtr (*packed_vector3_array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
GDNativeTypePtr (*packed_vector3_array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr GDNativeTypePtr (*packed_vector3_array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
GDNativeVariantPtr (*array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr GDNativeVariantPtr (*array_operator_index)(GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr
GDNativeVariantPtr (*array_operator_index_const)(const GDNativeTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr GDNativeVariantPtr (*array_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeInt p_index); // p_self should be an Array ptr
/* Dictionary functions */ /* Dictionary functions */
GDNativeVariantPtr (*dictionary_operator_index)(GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr GDNativeVariantPtr (*dictionary_operator_index)(GDNativeTypePtr p_self, GDNativeConstVariantPtr p_key); // p_self should be an Dictionary ptr
GDNativeVariantPtr (*dictionary_operator_index_const)(const GDNativeTypePtr p_self, const GDNativeVariantPtr p_key); // p_self should be an Dictionary ptr GDNativeVariantPtr (*dictionary_operator_index_const)(GDNativeConstTypePtr p_self, GDNativeConstVariantPtr p_key); // p_self should be an Dictionary ptr
/* OBJECT */ /* OBJECT */
void (*object_method_bind_call)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error); void (*object_method_bind_call)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeVariantPtr r_ret, GDNativeCallError *r_error);
void (*object_method_bind_ptrcall)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); void (*object_method_bind_ptrcall)(GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret);
void (*object_destroy)(GDNativeObjectPtr p_o); void (*object_destroy)(GDNativeObjectPtr p_o);
GDNativeObjectPtr (*global_get_singleton)(const GDNativeStringNamePtr p_name); GDNativeObjectPtr (*global_get_singleton)(GDNativeConstStringNamePtr p_name);
void *(*object_get_instance_binding)(GDNativeObjectPtr p_o, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks); void *(*object_get_instance_binding)(GDNativeObjectPtr p_o, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks);
void (*object_set_instance_binding)(GDNativeObjectPtr p_o, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks); void (*object_set_instance_binding)(GDNativeObjectPtr p_o, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks);
void (*object_set_instance)(GDNativeObjectPtr p_o, const GDNativeStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ void (*object_set_instance)(GDNativeObjectPtr p_o, GDNativeConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */
GDNativeObjectPtr (*object_cast_to)(const GDNativeObjectPtr p_object, void *p_class_tag); GDNativeObjectPtr (*object_cast_to)(GDNativeConstObjectPtr p_object, void *p_class_tag);
GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id);
GDObjectInstanceID (*object_get_instance_id)(const GDNativeObjectPtr p_object); GDObjectInstanceID (*object_get_instance_id)(GDNativeConstObjectPtr p_object);
/* SCRIPT INSTANCE */ /* SCRIPT INSTANCE */
@ -554,23 +557,23 @@ typedef struct {
/* CLASSDB */ /* CLASSDB */
GDNativeObjectPtr (*classdb_construct_object)(const GDNativeStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ GDNativeObjectPtr (*classdb_construct_object)(GDNativeConstStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */
GDNativeMethodBindPtr (*classdb_get_method_bind)(const GDNativeStringNamePtr p_classname, const GDNativeStringNamePtr p_methodname, GDNativeInt p_hash); GDNativeMethodBindPtr (*classdb_get_method_bind)(GDNativeConstStringNamePtr p_classname, GDNativeConstStringNamePtr p_methodname, GDNativeInt p_hash);
void *(*classdb_get_class_tag)(const GDNativeStringNamePtr p_classname); void *(*classdb_get_class_tag)(GDNativeConstStringNamePtr p_classname);
/* CLASSDB EXTENSION */ /* CLASSDB EXTENSION */
/* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */ /* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */
void (*classdb_register_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs); void (*classdb_register_extension_class)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_parent_class_name, const GDNativeExtensionClassCreationInfo *p_extension_funcs);
void (*classdb_register_extension_class_method)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info); void (*classdb_register_extension_class_method)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, const GDNativeExtensionClassMethodInfo *p_method_info);
void (*classdb_register_extension_class_integer_constant)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_enum_name, const GDNativeStringNamePtr p_constant_name, GDNativeInt p_constant_value, GDNativeBool p_is_bitfield); void (*classdb_register_extension_class_integer_constant)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_enum_name, GDNativeConstStringNamePtr p_constant_name, GDNativeInt p_constant_value, GDNativeBool p_is_bitfield);
void (*classdb_register_extension_class_property)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativePropertyInfo *p_info, const GDNativeStringNamePtr p_setter, const GDNativeStringNamePtr p_getter); void (*classdb_register_extension_class_property)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, const GDNativePropertyInfo *p_info, GDNativeConstStringNamePtr p_setter, GDNativeConstStringNamePtr p_getter);
void (*classdb_register_extension_class_property_group)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringPtr p_group_name, const GDNativeStringPtr p_prefix); void (*classdb_register_extension_class_property_group)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringPtr p_group_name, GDNativeConstStringPtr p_prefix);
void (*classdb_register_extension_class_property_subgroup)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringPtr p_subgroup_name, const GDNativeStringPtr p_prefix); void (*classdb_register_extension_class_property_subgroup)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringPtr p_subgroup_name, GDNativeConstStringPtr p_prefix);
void (*classdb_register_extension_class_signal)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name, const GDNativeStringNamePtr p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count); void (*classdb_register_extension_class_signal)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name, GDNativeConstStringNamePtr p_signal_name, const GDNativePropertyInfo *p_argument_info, GDNativeInt p_argument_count);
void (*classdb_unregister_extension_class)(const GDNativeExtensionClassLibraryPtr p_library, const GDNativeStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */ void (*classdb_unregister_extension_class)(GDNativeExtensionClassLibraryPtr p_library, GDNativeConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
void (*get_library_path)(const GDNativeExtensionClassLibraryPtr p_library, GDNativeStringPtr r_path); void (*get_library_path)(GDNativeExtensionClassLibraryPtr p_library, GDNativeStringPtr r_path);
} GDNativeInterface; } GDNativeInterface;
@ -600,7 +603,7 @@ typedef struct {
* It can be used to set up different init levels, which are called during various stages of initialization/shutdown. * It can be used to set up different init levels, which are called during various stages of initialization/shutdown.
* The function name must be a unique one specified in the .gdextension config file. * The function name must be a unique one specified in the .gdextension config file.
*/ */
typedef GDNativeBool (*GDNativeInitializationFunction)(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); typedef GDNativeBool (*GDNativeInitializationFunction)(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -240,13 +240,13 @@ public:
template <class T> template <class T>
struct PtrToArg<Ref<T>> { struct PtrToArg<Ref<T>> {
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) { _FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
return Ref<T>(reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks))); return Ref<T>(reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast<GDNativeObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks)));
} }
typedef Ref<T> EncodeT; typedef Ref<T> EncodeT;
_FORCE_INLINE_ static void encode(Ref<T> p_val, const void *p_ptr) { _FORCE_INLINE_ static void encode(Ref<T> p_val, void *p_ptr) {
*(void **)p_ptr = p_val->_owner; *reinterpret_cast<const GodotObject **>(p_ptr) = p_val->_owner;
} }
}; };
@ -255,7 +255,7 @@ struct PtrToArg<const Ref<T> &> {
typedef Ref<T> EncodeT; typedef Ref<T> EncodeT;
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) { _FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
return Ref<T>(reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks))); return Ref<T>(reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast<GDNativeObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks)));
} }
}; };

View File

@ -61,12 +61,12 @@ protected:
String _to_string() const { return "[" + String(get_class_static()) + ":" + itos(get_instance_id()) + "]"; } String _to_string() const { return "[" + String(get_class_static()) + ":" + itos(get_instance_id()) + "]"; }
static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what) {} static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what) {}
static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value) { return false; } static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value) { return false; }
static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; }
static const GDNativePropertyInfo *get_property_list_bind(GDExtensionClassInstancePtr p_instance, uint32_t *r_count) { return nullptr; } static const GDNativePropertyInfo *get_property_list_bind(GDExtensionClassInstancePtr p_instance, uint32_t *r_count) { return nullptr; }
static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list) {} static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDNativePropertyInfo *p_list) {}
static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name) { return false; } static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name) { return false; }
static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; } static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { return false; }
static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out) {} static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDNativeBool *r_is_valid, GDNativeStringPtr r_out) {}
::godot::List<::godot::PropertyInfo> plist_owned; ::godot::List<::godot::PropertyInfo> plist_owned;
@ -184,7 +184,7 @@ public:
} \ } \
} \ } \
\ \
static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value) { \ static GDNativeBool set_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeConstVariantPtr p_value) { \
if (p_instance && m_class::_get_set()) { \ if (p_instance && m_class::_get_set()) { \
if (m_class::_get_set() != m_inherits::_get_set()) { \ if (m_class::_get_set() != m_inherits::_get_set()) { \
m_class *cls = reinterpret_cast<m_class *>(p_instance); \ m_class *cls = reinterpret_cast<m_class *>(p_instance); \
@ -195,7 +195,7 @@ public:
return false; \ return false; \
} \ } \
\ \
static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ static GDNativeBool get_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { \
if (p_instance && m_class::_get_get()) { \ if (p_instance && m_class::_get_get()) { \
if (m_class::_get_get() != m_inherits::_get_get()) { \ if (m_class::_get_get() != m_inherits::_get_get()) { \
m_class *cls = reinterpret_cast<m_class *>(p_instance); \ m_class *cls = reinterpret_cast<m_class *>(p_instance); \
@ -243,7 +243,7 @@ public:
} \ } \
} \ } \
\ \
static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name) { \ static GDNativeBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name) { \
if (p_instance && m_class::_get_property_can_revert()) { \ if (p_instance && m_class::_get_property_can_revert()) { \
if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \ if (m_class::_get_property_can_revert() != m_inherits::_get_property_can_revert()) { \
m_class *cls = reinterpret_cast<m_class *>(p_instance); \ m_class *cls = reinterpret_cast<m_class *>(p_instance); \
@ -254,7 +254,7 @@ public:
return false; \ return false; \
} \ } \
\ \
static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret) { \ static GDNativeBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDNativeConstStringNamePtr p_name, GDNativeVariantPtr r_ret) { \
if (p_instance && m_class::_get_property_get_revert()) { \ if (p_instance && m_class::_get_property_get_revert()) { \
if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \ if (m_class::_get_property_get_revert() != m_inherits::_get_property_get_revert()) { \
m_class *cls = reinterpret_cast<m_class *>(p_instance); \ m_class *cls = reinterpret_cast<m_class *>(p_instance); \

View File

@ -41,46 +41,46 @@
namespace godot { namespace godot {
#define VARIANT_ENUM_CAST(m_class, m_enum) \ #define VARIANT_ENUM_CAST(m_class, m_enum) \
namespace godot { \ namespace godot { \
MAKE_ENUM_TYPE_INFO(m_class, m_enum) \ MAKE_ENUM_TYPE_INFO(m_class, m_enum) \
template <> \ template <> \
struct VariantCaster<m_class::m_enum> { \ struct VariantCaster<m_class::m_enum> { \
static _FORCE_INLINE_ m_class::m_enum cast(const Variant &p_variant) { \ static _FORCE_INLINE_ m_class::m_enum cast(const Variant &p_variant) { \
return (m_class::m_enum)p_variant.operator int64_t(); \ return (m_class::m_enum)p_variant.operator int64_t(); \
} \ } \
}; \ }; \
template <> \ template <> \
struct PtrToArg<m_class::m_enum> { \ struct PtrToArg<m_class::m_enum> { \
_FORCE_INLINE_ static m_class::m_enum convert(const void *p_ptr) { \ _FORCE_INLINE_ static m_class::m_enum convert(const void *p_ptr) { \
return m_class::m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \ return m_class::m_enum(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \ } \
typedef int64_t EncodeT; \ typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(m_class::m_enum p_val, const void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_class::m_enum p_val, void *p_ptr) { \
*(int64_t *)p_ptr = p_val; \ *reinterpret_cast<int64_t *>(p_ptr) = p_val; \
} \ } \
}; \ }; \
} }
#define VARIANT_BITFIELD_CAST(m_class, m_enum) \ #define VARIANT_BITFIELD_CAST(m_class, m_enum) \
namespace godot { \ namespace godot { \
MAKE_BITFIELD_TYPE_INFO(m_class, m_enum) \ MAKE_BITFIELD_TYPE_INFO(m_class, m_enum) \
template <> \ template <> \
struct VariantCaster<BitField<m_class::m_enum>> { \ struct VariantCaster<BitField<m_class::m_enum>> { \
static _FORCE_INLINE_ BitField<m_class::m_enum> cast(const Variant &p_variant) { \ static _FORCE_INLINE_ BitField<m_class::m_enum> cast(const Variant &p_variant) { \
return BitField<m_class::m_enum>(p_variant.operator int64_t()); \ return BitField<m_class::m_enum>(p_variant.operator int64_t()); \
} \ } \
}; \ }; \
template <> \ template <> \
struct PtrToArg<BitField<m_class::m_enum>> { \ struct PtrToArg<BitField<m_class::m_enum>> { \
_FORCE_INLINE_ static BitField<m_class::m_enum> convert(const void *p_ptr) { \ _FORCE_INLINE_ static BitField<m_class::m_enum> convert(const void *p_ptr) { \
return BitField<m_class::m_enum>(*reinterpret_cast<const int64_t *>(p_ptr)); \ return BitField<m_class::m_enum>(*reinterpret_cast<const int64_t *>(p_ptr)); \
} \ } \
typedef int64_t EncodeT; \ typedef int64_t EncodeT; \
_FORCE_INLINE_ static void encode(BitField<m_class::m_enum> p_val, const void *p_ptr) { \ _FORCE_INLINE_ static void encode(BitField<m_class::m_enum> p_val, void *p_ptr) { \
*(int64_t *)p_ptr = p_val; \ *reinterpret_cast<int64_t *>(p_ptr) = p_val; \
} \ } \
}; \ }; \
} }
template <class T> template <class T>
@ -169,42 +169,42 @@ struct VariantCasterAndValidate<const T &> {
}; };
template <class T, class... P, size_t... Is> template <class T, class... P, size_t... Is>
void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), const GDNativeTypePtr *p_args, IndexSequence<Is...>) { void call_with_ptr_args_helper(T *p_instance, void (T::*p_method)(P...), GDNativeConstTypePtr *p_args, IndexSequence<Is...>) {
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...); (p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
} }
template <class T, class... P, size_t... Is> template <class T, class... P, size_t... Is>
void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, IndexSequence<Is...>) { void call_with_ptr_argsc_helper(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, IndexSequence<Is...>) {
(p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...); (p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...);
} }
template <class T, class R, class... P, size_t... Is> template <class T, class R, class... P, size_t... Is>
void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_ret_helper(T *p_instance, R (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret); PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
} }
template <class T, class R, class... P, size_t... Is> template <class T, class R, class... P, size_t... Is>
void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_retc_helper(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret); PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
} }
template <class T, class... P> template <class T, class... P>
void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), const GDNativeTypePtr *p_args, void * /*ret*/) { void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void * /*ret*/) {
call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class... P> template <class T, class... P>
void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void * /*ret*/) { void call_with_ptr_args(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void * /*ret*/) {
call_with_ptr_argsc_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_argsc_helper<T, P...>(p_instance, p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <class T, class R, class... P>
void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret) { void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret) {
call_with_ptr_args_ret_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_ret_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
template <class T, class R, class... P> template <class T, class R, class... P>
void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, const GDNativeTypePtr *p_args, void *r_ret) { void call_with_ptr_args(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstTypePtr *p_args, void *r_ret) {
call_with_ptr_args_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_retc_helper<T, R, P...>(p_instance, p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }
@ -256,7 +256,7 @@ void call_with_variant_args_retc_helper(T *p_instance, R (T::*p_method)(P...) co
} }
template <class T, class... P> template <class T, class... P>
void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -291,7 +291,7 @@ void call_with_variant_args_dv(T *p_instance, void (T::*p_method)(P...), const G
} }
template <class T, class... P> template <class T, class... P>
void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const, GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -326,7 +326,7 @@ void call_with_variant_argsc_dv(T *p_instance, void (T::*p_method)(P...) const,
} }
template <class T, class R, class... P> template <class T, class R, class... P>
void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -361,7 +361,7 @@ void call_with_variant_args_ret_dv(T *p_instance, R (T::*p_method)(P...), const
} }
template <class T, class R, class... P> template <class T, class R, class... P>
void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_args_retc_dv(T *p_instance, R (T::*p_method)(P...) const, GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -473,7 +473,7 @@ void call_with_variant_args_static(void (*p_method)(P...), const Variant **p_arg
} }
template <class... P> template <class... P>
void call_with_variant_args_static_dv(void (*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_args_static_dv(void (*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -508,12 +508,12 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const GDNativeVari
} }
template <class... P, size_t... Is> template <class... P, size_t... Is>
void call_with_ptr_args_static_method_helper(void (*p_method)(P...), const GDNativeTypePtr *p_args, IndexSequence<Is...>) { void call_with_ptr_args_static_method_helper(void (*p_method)(P...), GDNativeConstTypePtr *p_args, IndexSequence<Is...>) {
p_method(PtrToArg<P>::convert(p_args[Is])...); p_method(PtrToArg<P>::convert(p_args[Is])...);
} }
template <class... P> template <class... P>
void call_with_ptr_args_static_method(void (*p_method)(P...), const GDNativeTypePtr *p_args) { void call_with_ptr_args_static_method(void (*p_method)(P...), GDNativeConstTypePtr *p_args) {
call_with_ptr_args_static_method_helper<P...>(p_method, p_args, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_static_method_helper<P...>(p_method, p_args, BuildIndexSequence<sizeof...(P)>{});
} }
@ -529,7 +529,7 @@ void call_with_variant_args_static_ret(R (*p_method)(P...), const Variant **p_ar
} }
template <class R, class... P> template <class R, class... P>
void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDNativeVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) { void call_with_variant_args_static_ret_dv(R (*p_method)(P...), GDNativeConstVariantPtr *p_args, int p_argcount, Variant &r_ret, GDNativeCallError &r_error, const std::vector<Variant> &default_values) {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
if ((size_t)p_argcount > sizeof...(P)) { if ((size_t)p_argcount > sizeof...(P)) {
r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS; r_error.error = GDNATIVE_CALL_ERROR_TOO_MANY_ARGUMENTS;
@ -564,12 +564,12 @@ void call_with_variant_args_static_ret_dv(R (*p_method)(P...), const GDNativeVar
} }
template <class R, class... P, size_t... Is> template <class R, class... P, size_t... Is>
void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret, IndexSequence<Is...>) { void call_with_ptr_args_static_method_ret_helper(R (*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret, IndexSequence<Is...>) {
PtrToArg<R>::encode(p_method(PtrToArg<P>::convert(p_args[Is])...), r_ret); PtrToArg<R>::encode(p_method(PtrToArg<P>::convert(p_args[Is])...), r_ret);
} }
template <class R, class... P> template <class R, class... P>
void call_with_ptr_args_static_method_ret(R (*p_method)(P...), const GDNativeTypePtr *p_args, void *r_ret) { void call_with_ptr_args_static_method_ret(R (*p_method)(P...), GDNativeConstTypePtr *p_args, void *r_ret) {
call_with_ptr_args_static_method_ret_helper<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{}); call_with_ptr_args_static_method_ret_helper<R, P...>(p_method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
} }

View File

@ -41,33 +41,33 @@ namespace internal {
template <class... Args> template <class... Args>
void _call_builtin_constructor(const GDNativePtrConstructor constructor, GDNativeTypePtr base, Args... args) { void _call_builtin_constructor(const GDNativePtrConstructor constructor, GDNativeTypePtr base, Args... args) {
std::array<const GDNativeTypePtr, sizeof...(Args)> call_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> call_args = { { (GDNativeConstTypePtr)args... } };
constructor(base, call_args.data()); constructor(base, call_args.data());
} }
template <class T, class... Args> template <class T, class... Args>
T _call_builtin_method_ptr_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) { T _call_builtin_method_ptr_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) {
T ret; T ret;
std::array<const GDNativeTypePtr, sizeof...(Args)> call_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> call_args = { { (GDNativeConstTypePtr)args... } };
method(base, call_args.data(), &ret, sizeof...(Args)); method(base, call_args.data(), &ret, sizeof...(Args));
return ret; return ret;
} }
template <class... Args> template <class... Args>
void _call_builtin_method_ptr_no_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) { void _call_builtin_method_ptr_no_ret(const GDNativePtrBuiltInMethod method, GDNativeTypePtr base, Args... args) {
std::array<const GDNativeTypePtr, sizeof...(Args)> call_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> call_args = { { (GDNativeConstTypePtr)args... } };
method(base, call_args.data(), nullptr, sizeof...(Args)); method(base, call_args.data(), nullptr, sizeof...(Args));
} }
template <class T> template <class T>
T _call_builtin_operator_ptr(const GDNativePtrOperatorEvaluator op, const GDNativeTypePtr left, const GDNativeTypePtr right) { T _call_builtin_operator_ptr(const GDNativePtrOperatorEvaluator op, GDNativeConstTypePtr left, GDNativeConstTypePtr right) {
T ret; T ret;
op(left, right, &ret); op(left, right, &ret);
return ret; return ret;
} }
template <class T> template <class T>
T _call_builtin_ptr_getter(const GDNativePtrGetter getter, const GDNativeTypePtr base) { T _call_builtin_ptr_getter(const GDNativePtrGetter getter, GDNativeConstTypePtr base) {
T ret; T ret;
getter(base, &ret); getter(base, &ret);
return ret; return ret;

View File

@ -136,7 +136,7 @@ public:
static MethodBind *get_method(const StringName &p_class, const StringName &p_method); static MethodBind *get_method(const StringName &p_class, const StringName &p_method);
static GDNativeExtensionClassCallVirtual get_virtual_func(void *p_userdata, const GDNativeStringNamePtr p_name); static GDNativeExtensionClassCallVirtual get_virtual_func(void *p_userdata, GDNativeConstStringNamePtr p_name);
static void initialize(GDNativeInitializationLevel p_level); static void initialize(GDNativeInitializationLevel p_level);
static void deinitialize(GDNativeInitializationLevel p_level); static void deinitialize(GDNativeInitializationLevel p_level);
@ -151,12 +151,12 @@ public:
#define BIND_BITFIELD_FLAG(m_constant) \ #define BIND_BITFIELD_FLAG(m_constant) \
godot::ClassDB::bind_integer_constant(get_class_static(), godot::__constant_get_bitfield_name(m_constant, #m_constant), #m_constant, m_constant, true); godot::ClassDB::bind_integer_constant(get_class_static(), godot::__constant_get_bitfield_name(m_constant, #m_constant), #m_constant, m_constant, true);
#define BIND_VIRTUAL_METHOD(m_class, m_method) \ #define BIND_VIRTUAL_METHOD(m_class, m_method) \
{ \ { \
auto ___call##m_method = [](GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr p_ret) -> void { \ auto ___call##m_method = [](GDNativeObjectPtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr p_ret) -> void { \
call_with_ptr_args(reinterpret_cast<m_class *>(p_instance), &m_class::m_method, p_args, p_ret); \ call_with_ptr_args(reinterpret_cast<m_class *>(p_instance), &m_class::m_method, p_args, p_ret); \
}; \ }; \
godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, ___call##m_method); \ godot::ClassDB::bind_virtual_method(m_class::get_class_static(), #m_method, ___call##m_method); \
} }
template <class T, bool is_abstract> template <class T, bool is_abstract>

View File

@ -46,7 +46,7 @@ namespace internal {
template <class O, class... Args> template <class O, class... Args>
O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
GodotObject *ret = nullptr; GodotObject *ret = nullptr;
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
if (ret == nullptr) { if (ret == nullptr) {
return nullptr; return nullptr;
@ -57,21 +57,21 @@ O *_call_native_mb_ret_obj(const GDNativeMethodBindPtr mb, void *instance, const
template <class R, class... Args> template <class R, class... Args>
R _call_native_mb_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { R _call_native_mb_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
R ret; R ret;
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret); internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), &ret);
return ret; return ret;
} }
template <class... Args> template <class... Args>
void _call_native_mb_no_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) { void _call_native_mb_no_ret(const GDNativeMethodBindPtr mb, void *instance, const Args &...args) {
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr); internal::gdn_interface->object_method_bind_ptrcall(mb, instance, mb_args.data(), nullptr);
} }
template <class R, class... Args> template <class R, class... Args>
R _call_utility_ret(GDNativePtrUtilityFunction func, const Args &...args) { R _call_utility_ret(GDNativePtrUtilityFunction func, const Args &...args) {
R ret; R ret;
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
func(&ret, mb_args.data(), mb_args.size()); func(&ret, mb_args.data(), mb_args.size());
return ret; return ret;
} }
@ -79,14 +79,14 @@ R _call_utility_ret(GDNativePtrUtilityFunction func, const Args &...args) {
template <class... Args> template <class... Args>
Object *_call_utility_ret_obj(const GDNativePtrUtilityFunction func, void *instance, const Args &...args) { Object *_call_utility_ret_obj(const GDNativePtrUtilityFunction func, void *instance, const Args &...args) {
GodotObject *ret = nullptr; GodotObject *ret = nullptr;
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
func(&ret, mb_args.data(), mb_args.size()); func(&ret, mb_args.data(), mb_args.size());
return (Object *)internal::gdn_interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks); return (Object *)internal::gdn_interface->object_get_instance_binding(ret, internal::token, &Object::___binding_callbacks);
} }
template <class... Args> template <class... Args>
void _call_utility_no_ret(const GDNativePtrUtilityFunction func, const Args &...args) { void _call_utility_no_ret(const GDNativePtrUtilityFunction func, const Args &...args) {
std::array<const GDNativeTypePtr, sizeof...(Args)> mb_args = { { (const GDNativeTypePtr)args... } }; std::array<GDNativeConstTypePtr, sizeof...(Args)> mb_args = { { (GDNativeConstTypePtr)args... } };
func(nullptr, mb_args.data(), mb_args.size()); func(nullptr, mb_args.data(), mb_args.size());
} }

View File

@ -136,11 +136,11 @@ public:
return vec; return vec;
} }
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const = 0; virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const = 0;
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const = 0; virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) const = 0;
static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error); static void bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error);
static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return); static void bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return);
virtual ~MethodBind(); virtual ~MethodBind();
}; };
@ -171,7 +171,7 @@ public:
return GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE; return GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE;
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) const { virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) const {
ERR_FAIL(); // Can't call. ERR_FAIL(); // Can't call.
} }
@ -211,7 +211,7 @@ class MethodBindVarArgT : public MethodBindVarArgBase<MethodBindVarArgT<T>, T, v
friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>; friend class MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>;
public: public:
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
(static_cast<T *>(p_instance)->*MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>::method)((const Variant **)p_args, p_argument_count, r_error); (static_cast<T *>(p_instance)->*MethodBindVarArgBase<MethodBindVarArgT<T>, T, void, false>::method)((const Variant **)p_args, p_argument_count, r_error);
return {}; return {};
} }
@ -241,7 +241,7 @@ class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>,
friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>; friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>;
public: public:
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
return (static_cast<T *>(p_instance)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)((const Variant **)p_args, p_argument_count, r_error); return (static_cast<T *>(p_instance)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)((const Variant **)p_args, p_argument_count, r_error);
} }
@ -314,7 +314,7 @@ public:
return call_get_argument_metadata<P...>(p_argument); return call_get_argument_metadata<P...>(p_argument);
} }
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); call_with_variant_args_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
#else #else
@ -322,7 +322,7 @@ public:
#endif #endif
return Variant(); return Variant();
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_ptr_args<T, P...>(static_cast<T *>(p_instance), method, p_args, nullptr); call_with_ptr_args<T, P...>(static_cast<T *>(p_instance), method, p_args, nullptr);
#else #else
@ -390,7 +390,7 @@ public:
return call_get_argument_metadata<P...>(p_argument); return call_get_argument_metadata<P...>(p_argument);
} }
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments()); call_with_variant_argsc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, r_error, get_default_arguments());
#else #else
@ -398,7 +398,7 @@ public:
#endif #endif
return Variant(); return Variant();
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_ptr_args<T, P...>(static_cast<T *>(p_instance), method, p_args, nullptr); call_with_ptr_args<T, P...>(static_cast<T *>(p_instance), method, p_args, nullptr);
#else #else
@ -471,7 +471,7 @@ public:
} }
} }
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
Variant ret; Variant ret;
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); call_with_variant_args_ret_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
@ -480,7 +480,7 @@ public:
#endif #endif
return ret; return ret;
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_ptr_args<T, R, P...>(static_cast<T *>(p_instance), method, p_args, r_ret); call_with_ptr_args<T, R, P...>(static_cast<T *>(p_instance), method, p_args, r_ret);
#else #else
@ -554,7 +554,7 @@ public:
} }
} }
virtual Variant call(GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeCallError &r_error) const {
Variant ret; Variant ret;
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments()); call_with_variant_args_retc_dv(static_cast<T *>(p_instance), method, p_args, (int)p_argument_count, ret, r_error, get_default_arguments());
@ -563,7 +563,7 @@ public:
#endif #endif
return ret; return ret;
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
#ifdef TYPED_METHOD_BIND #ifdef TYPED_METHOD_BIND
call_with_ptr_args<T, R, P...>(static_cast<T *>(p_instance), method, p_args, r_ret); call_with_ptr_args<T, R, P...>(static_cast<T *>(p_instance), method, p_args, r_ret);
#else #else
@ -630,13 +630,13 @@ public:
return call_get_argument_metadata<P...>(p_arg); return call_get_argument_metadata<P...>(p_arg);
} }
virtual Variant call(GDExtensionClassInstancePtr p_object, const GDNativeVariantPtr *p_args, const GDNativeInt p_arg_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_object, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeCallError &r_error) const {
(void)p_object; // unused (void)p_object; // unused
call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments()); call_with_variant_args_static_dv(function, p_args, p_arg_count, r_error, get_default_arguments());
return Variant(); return Variant();
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_object, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
(void)p_object; (void)p_object;
(void)r_ret; (void)r_ret;
call_with_ptr_args_static_method(function, p_args); call_with_ptr_args_static_method(function, p_args);
@ -700,13 +700,13 @@ public:
} }
} }
virtual Variant call(GDExtensionClassInstancePtr p_object, const GDNativeVariantPtr *p_args, const GDNativeInt p_arg_count, GDNativeCallError &r_error) const { virtual Variant call(GDExtensionClassInstancePtr p_object, GDNativeConstVariantPtr *p_args, GDNativeInt p_arg_count, GDNativeCallError &r_error) const {
Variant ret; Variant ret;
call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments()); call_with_variant_args_static_ret_dv(function, p_args, p_arg_count, ret, r_error, get_default_arguments());
return ret; return ret;
} }
virtual void ptrcall(GDExtensionClassInstancePtr p_object, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret) const { virtual void ptrcall(GDExtensionClassInstancePtr p_object, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_ret) const {
(void)p_object; (void)p_object;
call_with_ptr_args_static_method_ret(function, p_args, r_ret); call_with_ptr_args_static_method_ret(function, p_args, r_ret);
} }

View File

@ -49,7 +49,7 @@ struct PtrToArg {};
} \ } \
typedef m_type EncodeT; \ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \ *reinterpret_cast<m_type *>(p_ptr) = p_val; \
} \ } \
}; \ }; \
template <> \ template <> \
@ -59,7 +59,7 @@ struct PtrToArg {};
} \ } \
typedef m_type EncodeT; \ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \ *reinterpret_cast<m_type *>(p_ptr) = p_val; \
} \ } \
} }
@ -71,7 +71,7 @@ struct PtrToArg {};
} \ } \
typedef m_conv EncodeT; \ typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \ *reinterpret_cast<m_conv *>(p_ptr) = static_cast<m_conv>(p_val); \
} \ } \
_FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \ _FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \
return static_cast<m_conv>(p_val); \ return static_cast<m_conv>(p_val); \
@ -84,7 +84,7 @@ struct PtrToArg {};
} \ } \
typedef m_conv EncodeT; \ typedef m_conv EncodeT; \
_FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \
*((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \ *reinterpret_cast<m_conv *>(p_ptr) = static_cast<m_conv>(p_val); \
} \ } \
_FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \ _FORCE_INLINE_ static m_conv encode_arg(m_type p_val) { \
return static_cast<m_conv>(p_val); \ return static_cast<m_conv>(p_val); \
@ -99,7 +99,7 @@ struct PtrToArg {};
} \ } \
typedef m_type EncodeT; \ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \ *reinterpret_cast<m_type *>(p_ptr) = p_val; \
} \ } \
}; \ }; \
template <> \ template <> \
@ -109,7 +109,7 @@ struct PtrToArg {};
} \ } \
typedef m_type EncodeT; \ typedef m_type EncodeT; \
_FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \
*((m_type *)p_ptr) = p_val; \ *reinterpret_cast<m_type *>(p_ptr) = p_val; \
} \ } \
} }
@ -168,47 +168,47 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
template <class T> template <class T>
struct PtrToArg<T *> { struct PtrToArg<T *> {
_FORCE_INLINE_ static T *convert(const void *p_ptr) { _FORCE_INLINE_ static T *convert(const void *p_ptr) {
return reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks)); return reinterpret_cast<T *>(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast<GDNativeConstObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks));
} }
typedef Object *EncodeT; typedef Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
*((void **)p_ptr) = p_var ? p_var->_owner : nullptr; *reinterpret_cast<const void **>(p_ptr) = p_var ? p_var->_owner : nullptr;
} }
}; };
template <class T> template <class T>
struct PtrToArg<const T *> { struct PtrToArg<const T *> {
_FORCE_INLINE_ static const T *convert(const void *p_ptr) { _FORCE_INLINE_ static const T *convert(const void *p_ptr) {
return reinterpret_cast<const T *>(godot::internal::gdn_interface->object_get_instance_binding(*(const GDNativeObjectPtr *)p_ptr, godot::internal::token, &T::___binding_callbacks)); return reinterpret_cast<const T *>(godot::internal::gdn_interface->object_get_instance_binding(*reinterpret_cast<GDNativeConstObjectPtr *>(const_cast<void *>(p_ptr)), godot::internal::token, &T::___binding_callbacks));
} }
typedef const Object *EncodeT; typedef const Object *EncodeT;
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) { _FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
*((void **)p_ptr) = p_var ? p_var->_owner : nullptr; *reinterpret_cast<const void **>(p_ptr) = p_var ? p_var->_owner : nullptr;
} }
}; };
// Pointers. // Pointers.
#define GDVIRTUAL_NATIVE_PTR(m_type) \ #define GDVIRTUAL_NATIVE_PTR(m_type) \
template <> \ template <> \
struct PtrToArg<m_type *> { \ struct PtrToArg<m_type *> { \
_FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \ _FORCE_INLINE_ static m_type *convert(const void *p_ptr) { \
return (m_type *)(*(void **)p_ptr); \ return (m_type *)(*(void **)p_ptr); \
} \ } \
typedef m_type *EncodeT; \ typedef m_type *EncodeT; \
_FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \ _FORCE_INLINE_ static void encode(m_type *p_var, void *p_ptr) { \
*((void **)p_ptr) = p_var; \ *reinterpret_cast<m_type **>(p_ptr) = p_var; \
} \ } \
}; \ }; \
\ \
template <> \ template <> \
struct PtrToArg<const m_type *> { \ struct PtrToArg<const m_type *> { \
_FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \ _FORCE_INLINE_ static const m_type *convert(const void *p_ptr) { \
return (const m_type *)(*(const void **)p_ptr); \ return (const m_type *)(*(const void **)p_ptr); \
} \ } \
typedef const m_type *EncodeT; \ typedef const m_type *EncodeT; \
_FORCE_INLINE_ static void encode(const m_type *p_var, const void *p_ptr) { \ _FORCE_INLINE_ static void encode(const m_type *p_var, void *p_ptr) { \
*((const void **)p_ptr) = p_var; \ *reinterpret_cast<const m_type **>(p_ptr) = p_var; \
} \ } \
} }
GDVIRTUAL_NATIVE_PTR(void); GDVIRTUAL_NATIVE_PTR(void);

View File

@ -292,7 +292,7 @@ struct PtrToArg<TypedArray<T>> {
} }
typedef Array EncodeT; typedef Array EncodeT;
_FORCE_INLINE_ static void encode(TypedArray<T> p_val, void *p_ptr) { _FORCE_INLINE_ static void encode(TypedArray<T> p_val, void *p_ptr) {
*(Array *)p_ptr = p_val; *reinterpret_cast<Array *>(p_ptr) = p_val;
} }
}; };

View File

@ -57,7 +57,7 @@ public:
static Callback init_callback; static Callback init_callback;
static Callback terminate_callback; static Callback terminate_callback;
static GDNativeInitializationLevel minimum_initialization_level; static GDNativeInitializationLevel minimum_initialization_level;
static GDNativeBool init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization); static GDNativeBool init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization);
public: public:
static void initialize_level(void *userdata, GDNativeInitializationLevel p_level); static void initialize_level(void *userdata, GDNativeInitializationLevel p_level);
@ -65,11 +65,11 @@ public:
class InitObject { class InitObject {
const GDNativeInterface *gdn_interface; const GDNativeInterface *gdn_interface;
const GDNativeExtensionClassLibraryPtr library; GDNativeExtensionClassLibraryPtr library;
GDNativeInitialization *initialization; GDNativeInitialization *initialization;
public: public:
InitObject(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) : InitObject(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) :
gdn_interface(p_interface), gdn_interface(p_interface),
library(p_library), library(p_library),
initialization(r_initialization) {} initialization(r_initialization) {}

View File

@ -145,7 +145,7 @@ public:
Variant(); Variant();
Variant(std::nullptr_t n) : Variant(std::nullptr_t n) :
Variant() {} Variant() {}
explicit Variant(const GDNativeVariantPtr native_ptr); explicit Variant(GDNativeConstVariantPtr native_ptr);
Variant(const Variant &other); Variant(const Variant &other);
Variant(Variant &&other); Variant(Variant &&other);
Variant(bool v); Variant(bool v);
@ -257,7 +257,7 @@ public:
Variant call(const StringName &method, Args... args) { Variant call(const StringName &method, Args... args) {
Variant result; Variant result;
GDNativeCallError error; GDNativeCallError error;
std::array<const GDNativeVariantPtr, sizeof...(Args)> call_args = { Variant(args)... }; std::array<GDNativeConstVariantPtr, sizeof...(Args)> call_args = { Variant(args)... };
call(method, call_args.data(), call_args.size(), result, error); call(method, call_args.data(), call_args.size(), result, error);
return result; return result;
} }
@ -268,7 +268,7 @@ public:
static Variant call_static(Variant::Type type, const StringName &method, Args... args) { static Variant call_static(Variant::Type type, const StringName &method, Args... args) {
Variant result; Variant result;
GDNativeCallError error; GDNativeCallError error;
std::array<const GDNativeVariantPtr, sizeof...(Args)> call_args = { Variant(args)... }; std::array<GDNativeConstVariantPtr, sizeof...(Args)> call_args = { Variant(args)... };
call_static(type, method, call_args.data(), call_args.size(), result, error); call_static(type, method, call_args.data(), call_args.size(), result, error);
return result; return result;
} }

View File

@ -43,17 +43,13 @@ const StringName *Wrapped::_get_extension_class_name() const {
void Wrapped::_postinitialize() { void Wrapped::_postinitialize() {
const StringName *extension_class = _get_extension_class_name(); const StringName *extension_class = _get_extension_class_name();
if (extension_class) { if (extension_class) {
// TODO: replace C cast by a proper reinterpret_cast once `object_set_instance` signature correctly handles `const GDNativeStringNamePtr` param godot::internal::gdn_interface->object_set_instance(_owner, reinterpret_cast<GDNativeConstStringNamePtr>(extension_class), this);
// (see: https://github.com/godotengine/godot/pull/67751)
godot::internal::gdn_interface->object_set_instance(_owner, (GDNativeStringNamePtr)(extension_class), this);
} }
godot::internal::gdn_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks()); godot::internal::gdn_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
} }
Wrapped::Wrapped(const StringName p_godot_class) { Wrapped::Wrapped(const StringName p_godot_class) {
// TODO: replace C cast by a proper reinterpret_cast once `classdb_construct_object` signature correctly handles `const GDNativeStringNamePtr` param _owner = godot::internal::gdn_interface->classdb_construct_object(reinterpret_cast<GDNativeConstStringNamePtr>(p_godot_class._native_ptr()));
// (see: https://github.com/godotengine/godot/pull/67751)
_owner = godot::internal::gdn_interface->classdb_construct_object((GDNativeStringNamePtr)(p_godot_class._native_ptr()));
} }
Wrapped::Wrapped(GodotObject *p_godot_object) { Wrapped::Wrapped(GodotObject *p_godot_object) {

View File

@ -220,7 +220,7 @@ void ClassDB::bind_method_godot(const StringName &p_class_name, MethodBind *p_me
StringName name = p_method->get_name(); StringName name = p_method->get_name();
GDNativeExtensionClassMethodInfo method_info = { GDNativeExtensionClassMethodInfo method_info = {
name._native_ptr(), // const GDNativeStringNamePtr; name._native_ptr(), // GDNativeStringNamePtr;
p_method, // void *method_userdata; p_method, // void *method_userdata;
MethodBind::bind_call, // GDNativeExtensionClassMethodCall call_func; MethodBind::bind_call, // GDNativeExtensionClassMethodCall call_func;
MethodBind::bind_ptrcall, // GDNativeExtensionClassMethodPtrCall ptrcall_func; MethodBind::bind_ptrcall, // GDNativeExtensionClassMethodPtrCall ptrcall_func;
@ -261,10 +261,10 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal)
for (const PropertyInfo &par : p_signal.arguments) { for (const PropertyInfo &par : p_signal.arguments) {
parameters.push_back(GDNativePropertyInfo{ parameters.push_back(GDNativePropertyInfo{
static_cast<GDNativeVariantType>(par.type), // GDNativeVariantType type; static_cast<GDNativeVariantType>(par.type), // GDNativeVariantType type;
par.name._native_ptr(), // const GDNativeStringNamePtr name; par.name._native_ptr(), // GDNativeStringNamePtr name;
par.class_name._native_ptr(), // const GDNativeStringNamePtr class_name; par.class_name._native_ptr(), // GDNativeStringNamePtr class_name;
par.hint, // NONE //uint32_t hint; par.hint, // NONE //uint32_t hint;
par.hint_string._native_ptr(), // const GDNativeStringPtr hint_string; par.hint_string._native_ptr(), // GDNativeStringPtr hint_string;
par.usage, // DEFAULT //uint32_t usage; par.usage, // DEFAULT //uint32_t usage;
}); });
} }
@ -288,7 +288,7 @@ void ClassDB::bind_integer_constant(const StringName &p_class_name, const String
// Register it with Godot // Register it with Godot
internal::gdn_interface->classdb_register_extension_class_integer_constant(internal::library, p_class_name._native_ptr(), p_enum_name._native_ptr(), p_constant_name._native_ptr(), p_constant_value, p_is_bitfield); internal::gdn_interface->classdb_register_extension_class_integer_constant(internal::library, p_class_name._native_ptr(), p_enum_name._native_ptr(), p_constant_name._native_ptr(), p_constant_value, p_is_bitfield);
} }
GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, const GDNativeStringNamePtr p_name) { GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, GDNativeConstStringNamePtr p_name) {
// This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance. // This is called by Godot the first time it calls a virtual function, and it caches the result, per object instance.
// Because of this, it can happen from different threads at once. // Because of this, it can happen from different threads at once.
// It should be ok not using any mutex as long as we only READ data. // It should be ok not using any mutex as long as we only READ data.

View File

@ -91,7 +91,7 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
return info; return info;
} }
void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeVariantPtr *p_args, const GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) { void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstVariantPtr *p_args, GDNativeInt p_argument_count, GDNativeVariantPtr r_return, GDNativeCallError *r_error) {
const MethodBind *bind = reinterpret_cast<const MethodBind *>(p_method_userdata); const MethodBind *bind = reinterpret_cast<const MethodBind *>(p_method_userdata);
Variant ret = bind->call(p_instance, p_args, p_argument_count, *r_error); Variant ret = bind->call(p_instance, p_args, p_argument_count, *r_error);
// This assumes the return value is an empty Variant, so it doesn't need to call the destructor first. // This assumes the return value is an empty Variant, so it doesn't need to call the destructor first.
@ -99,7 +99,7 @@ void MethodBind::bind_call(void *p_method_userdata, GDExtensionClassInstancePtr
internal::gdn_interface->variant_new_copy(r_return, ret._native_ptr()); internal::gdn_interface->variant_new_copy(r_return, ret._native_ptr());
} }
void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_return) { void MethodBind::bind_ptrcall(void *p_method_userdata, GDExtensionClassInstancePtr p_instance, GDNativeConstTypePtr *p_args, GDNativeTypePtr r_return) {
const MethodBind *bind = reinterpret_cast<const MethodBind *>(p_method_userdata); const MethodBind *bind = reinterpret_cast<const MethodBind *>(p_method_userdata);
bind->ptrcall(p_instance, p_args, r_return); bind->ptrcall(p_instance, p_args, r_return);
} }

View File

@ -51,7 +51,7 @@ GDExtensionBinding::Callback GDExtensionBinding::init_callback = nullptr;
GDExtensionBinding::Callback GDExtensionBinding::terminate_callback = nullptr; GDExtensionBinding::Callback GDExtensionBinding::terminate_callback = nullptr;
GDNativeInitializationLevel GDExtensionBinding::minimum_initialization_level = GDNATIVE_INITIALIZATION_CORE; GDNativeInitializationLevel GDExtensionBinding::minimum_initialization_level = GDNATIVE_INITIALIZATION_CORE;
GDNativeBool GDExtensionBinding::init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { GDNativeBool GDExtensionBinding::init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
internal::gdn_interface = p_interface; internal::gdn_interface = p_interface;
internal::library = p_library; internal::library = p_library;
internal::token = p_library; internal::token = p_library;

View File

@ -72,7 +72,7 @@ Variant::Variant() {
internal::gdn_interface->variant_new_nil(_native_ptr()); internal::gdn_interface->variant_new_nil(_native_ptr());
} }
Variant::Variant(const GDNativeVariantPtr native_ptr) { Variant::Variant(GDNativeConstVariantPtr native_ptr) {
internal::gdn_interface->variant_new_copy(_native_ptr(), native_ptr); internal::gdn_interface->variant_new_copy(_native_ptr(), native_ptr);
} }
@ -530,11 +530,11 @@ bool Variant::operator<(const Variant &other) const {
} }
void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) { void Variant::call(const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
internal::gdn_interface->variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret._native_ptr(), &r_error); internal::gdn_interface->variant_call(_native_ptr(), method._native_ptr(), reinterpret_cast<GDNativeConstVariantPtr *>(args), argcount, r_ret._native_ptr(), &r_error);
} }
void Variant::call_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) { void Variant::call_static(Variant::Type type, const StringName &method, const Variant **args, int argcount, Variant &r_ret, GDNativeCallError &r_error) {
internal::gdn_interface->variant_call_static(static_cast<GDNativeVariantType>(type), method._native_ptr(), reinterpret_cast<const GDNativeVariantPtr *>(const_cast<Variant **>(args)), argcount, r_ret._native_ptr(), &r_error); internal::gdn_interface->variant_call_static(static_cast<GDNativeVariantType>(type), method._native_ptr(), reinterpret_cast<GDNativeConstVariantPtr *>(args), argcount, r_ret._native_ptr(), &r_error);
} }
void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) { void Variant::evaluate(const Operator &op, const Variant &a, const Variant &b, Variant &r_ret, bool &r_valid) {

View File

@ -36,7 +36,7 @@ void uninitialize_example_module(ModuleInitializationLevel p_level) {
extern "C" { extern "C" {
// Initialization. // Initialization.
GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) { GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization); godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module); init_obj.register_initializer(initialize_example_module);