You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
[DLScript] added variant constructor and a function to get userdata of a script
The godot_dlinstance_get_userdata() function can be used to get the DLScript userdata pointer of any object that has a DLScript attached to it. This is particularly useful and even required for language bindings to work properly. This also fixes non-tool builds.
This commit is contained in:
@@ -175,6 +175,16 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *
|
||||
library->_register_script_signal(p_name, p_signal);
|
||||
}
|
||||
|
||||
void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) {
|
||||
Object *instance = (Object *)p_instance;
|
||||
if (!instance)
|
||||
return NULL;
|
||||
if (instance->get_script_instance() && instance->get_script_instance()->get_language() == DLScriptLanguage::get_singleton()) {
|
||||
return ((DLInstance *)instance->get_script_instance())->get_userdata();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// System functions
|
||||
void GDAPI *godot_alloc(int p_bytes) {
|
||||
return memalloc(p_bytes);
|
||||
|
||||
Reference in New Issue
Block a user