diff --git a/c/SimpleDemo/SIMPLE.gdns b/c/SimpleDemo/SIMPLE.gdns deleted file mode 100644 index 6fd89cf..0000000 --- a/c/SimpleDemo/SIMPLE.gdns +++ /dev/null @@ -1,22 +0,0 @@ -[gd_resource type="NativeScript" load_steps=2 format=2] - -[sub_resource type="GDNativeLibrary" id=1] - -platform/X11_32bit = "res://bin/libsimple.so" -platform/X11_64bit = "res://bin/libsimple.so" -platform/Windows_32bit = "res://bin/simple.dll" -platform/Windows_64bit = "res://bin/simple.dll" -platform/OSX = "res://bin/libsimple.dylib" -platform/Android = "" -platform/iOS_32bit = "" -platform/iOS_64bit = "" -platform/WebAssembly = "" -_sections_unfolded = [ "platform" ] - -[resource] - -resource_name = "SIMPLE" -class_name = "SIMPLE" -library = SubResource( 1 ) -_sections_unfolded = [ "Resource" ] - diff --git a/c/SimpleDemo/bin/simple.gdnlib b/c/SimpleDemo/bin/simple.gdnlib new file mode 100644 index 0000000..c7ae452 --- /dev/null +++ b/c/SimpleDemo/bin/simple.gdnlib @@ -0,0 +1,18 @@ + +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" + +[entry] + +X11.64="res://bin/libsimple.so" +Windows.64="res://bin/simple.dll" +OSX.64="res://bin/libsimple.dylib" + +[dependencies] + +X11.64=[] +Windows=[] +OSX.64=[] diff --git a/c/SimpleDemo/bin/simple.gdns b/c/SimpleDemo/bin/simple.gdns new file mode 100644 index 0000000..4bb9e31 --- /dev/null +++ b/c/SimpleDemo/bin/simple.gdns @@ -0,0 +1,11 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://bin/simple.gdnlib" type="GDNativeLibrary" id=1] + +[resource] + +resource_name = "SIMPLE" +class_name = "SIMPLE" +library = ExtResource( 1 ) +_sections_unfolded = [ "Resource" ] + diff --git a/c/SimpleDemo/main.gd b/c/SimpleDemo/main.gd index c820f75..4d2776a 100644 --- a/c/SimpleDemo/main.gd +++ b/c/SimpleDemo/main.gd @@ -1,7 +1,7 @@ extends Control # load the SIMPLE library -onready var data = preload("res://SIMPLE.gdns").new() +onready var data = preload("res://bin/SIMPLE.gdns").new() func _on_Button_pressed(): $Label.text = "Data = " + data.get_data() diff --git a/c/SimpleDemo/src/.mesh b/c/SimpleDemo/src/.mesh deleted file mode 100644 index d79c7fb..0000000 Binary files a/c/SimpleDemo/src/.mesh and /dev/null differ diff --git a/c/SimpleDemo/src/simple.c b/c/SimpleDemo/src/simple.c index 9e4f6c9..aea126f 100644 --- a/c/SimpleDemo/src/simple.c +++ b/c/SimpleDemo/src/simple.c @@ -7,7 +7,8 @@ typedef struct user_data_struct { char data[256]; } user_data_struct; -const godot_gdnative_api_struct *api = NULL; +const godot_gdnative_core_api_struct *api = NULL; +const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; GDCALLINGCONV void *simple_constructor(godot_object *p_instance, void *p_method_data); GDCALLINGCONV void simple_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data); @@ -15,10 +16,21 @@ godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, voi void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) { api = p_options->api_struct; + + // now find our extensions + for (int i = 0; i < api->num_extensions; i++) { + switch (api->extensions[i]->type) { + case GDNATIVE_EXT_NATIVESCRIPT: { + nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i]; + }; break; + default: break; + }; + }; } void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options) { api = NULL; + nativescript_api = NULL; } void GDN_EXPORT godot_nativescript_init(void *p_handle) { @@ -28,14 +40,14 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle) { godot_instance_destroy_func destroy = { NULL, NULL, NULL }; destroy.destroy_func = &simple_destructor; - api->godot_nativescript_register_class(p_handle, "SIMPLE", "Reference", create, destroy); + nativescript_api->godot_nativescript_register_class(p_handle, "SIMPLE", "Reference", create, destroy); godot_instance_method get_data = { NULL, NULL, NULL }; get_data.method = &simple_get_data; godot_method_attributes attributes = { GODOT_METHOD_RPC_MODE_DISABLED }; - api->godot_nativescript_register_method(p_handle, "SIMPLE", "get_data", attributes, get_data); + nativescript_api->godot_nativescript_register_method(p_handle, "SIMPLE", "get_data", attributes, get_data); } GDCALLINGCONV void *simple_constructor(godot_object *p_instance, void *p_method_data) {