diff options
Diffstat (limited to 'modules/gdnative/nativescript/godot_nativescript.cpp')
-rw-r--r-- | modules/gdnative/nativescript/godot_nativescript.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index e19e675344..f953206a34 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -36,6 +36,7 @@ #include "core/project_settings.h" #include "core/variant.h" #include "gdnative/gdnative.h" +#include <stdint.h> #include "nativescript.h" @@ -67,6 +68,14 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char if (classes->has(p_base)) { desc.base_data = &(*classes)[p_base]; desc.base_native_type = desc.base_data->base_native_type; + + const NativeScriptDesc *b = desc.base_data; + while (b) { + desc.rpc_count += b->rpc_count; + desc.rset_count += b->rset_count; + b = b->base_data; + } + } else { desc.base_data = NULL; desc.base_native_type = p_base; @@ -87,10 +96,20 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const desc.destroy_func = p_destroy_func; desc.is_tool = true; desc.base = p_base; + desc.rpc_count = 0; + desc.rset_count = 0; if (classes->has(p_base)) { desc.base_data = &(*classes)[p_base]; desc.base_native_type = desc.base_data->base_native_type; + + const NativeScriptDesc *b = desc.base_data; + while (b) { + desc.rpc_count += b->rpc_count; + desc.rset_count += b->rset_count; + b = b->base_data; + } + } else { desc.base_data = NULL; desc.base_native_type = p_base; @@ -109,6 +128,11 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha NativeScriptDesc::Method method; method.method = p_method; method.rpc_mode = p_attr.rpc_type; + method.rpc_method_id = UINT16_MAX; + if (p_attr.rpc_type != GODOT_METHOD_RPC_MODE_DISABLED) { + method.rpc_method_id = E->get().rpc_count; + E->get().rpc_count += 1; + } method.info = MethodInfo(p_function_name); E->get().methods.insert(p_function_name, method); @@ -125,6 +149,10 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c property.default_value = *(Variant *)&p_attr->default_value; property.getter = p_get_func; property.rset_mode = p_attr->rset_type; + if (p_attr->rset_type != GODOT_METHOD_RPC_MODE_DISABLED) { + property.rset_property_id = E->get().rset_count; + E->get().rset_count += 1; + } property.setter = p_set_func; property.info = PropertyInfo((Variant::Type)p_attr->type, p_path, |