Merge pull request #13094 from karroffel/gdnative-api-register-nativecall
[GDNative] add a way to register call types
This commit is contained in:
commit
30a82e5e00
4 changed files with 16 additions and 3 deletions
|
@ -99,12 +99,10 @@ public:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef godot_variant (*native_call_cb)(void *, godot_array *);
|
|
||||||
|
|
||||||
struct GDNativeCallRegistry {
|
struct GDNativeCallRegistry {
|
||||||
static GDNativeCallRegistry *singleton;
|
static GDNativeCallRegistry *singleton;
|
||||||
|
|
||||||
inline GDNativeCallRegistry *get_singleton() {
|
inline static GDNativeCallRegistry *get_singleton() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,10 @@ godot_dictionary GDAPI godot_get_global_constants() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// System functions
|
// System functions
|
||||||
|
void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback) {
|
||||||
|
GDNativeCallRegistry::get_singleton()->register_native_call_type(StringName(p_call_type), p_callback);
|
||||||
|
}
|
||||||
|
|
||||||
void GDAPI *godot_alloc(int p_bytes) {
|
void GDAPI *godot_alloc(int p_bytes) {
|
||||||
return memalloc(p_bytes);
|
return memalloc(p_bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5548,6 +5548,14 @@
|
||||||
["const char *", "p_classname"]
|
["const char *", "p_classname"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "godot_register_native_call_type",
|
||||||
|
"return_type": "void",
|
||||||
|
"arguments": [
|
||||||
|
["const char *", "call_type"],
|
||||||
|
["native_call_cb", "p_callback"]
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "godot_alloc",
|
"name": "godot_alloc",
|
||||||
"return_type": "void *",
|
"return_type": "void *",
|
||||||
|
|
|
@ -274,6 +274,9 @@ typedef godot_variant (*godot_gdnative_procedure_fn)(godot_array *);
|
||||||
|
|
||||||
////// System Functions
|
////// System Functions
|
||||||
|
|
||||||
|
typedef godot_variant (*native_call_cb)(void *, godot_array *);
|
||||||
|
void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback);
|
||||||
|
|
||||||
//using these will help Godot track how much memory is in use in debug mode
|
//using these will help Godot track how much memory is in use in debug mode
|
||||||
void GDAPI *godot_alloc(int p_bytes);
|
void GDAPI *godot_alloc(int p_bytes);
|
||||||
void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
|
void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
|
||||||
|
|
Loading…
Reference in a new issue