From 7996654ff2909387f3724d7f7b59517057fd0e00 Mon Sep 17 00:00:00 2001 From: geekrelief Date: Tue, 6 Apr 2021 16:14:19 -0700 Subject: [PATCH] Updated the C demos - removed godot_headers submodule - updated c submodules to godot-headers - updated SConstruct to compile with windows and godot-headers submodule, msvc was not picked up properly - updated api for instance_binding.c so it compiles --- .gitmodules | 18 ++++++++-------- c/glfw/SConstruct | 5 +++-- c/glfw/{godot_headers => godot-headers} | 0 c/instance_binding/SConstruct | 5 +++-- .../{godot_headers => godot-headers} | 0 c/instance_binding/src/instance_binding.c | 21 +++++++++++-------- c/simple/SConstruct | 5 +++-- c/simple/{godot_headers => godot-headers} | 0 8 files changed, 30 insertions(+), 24 deletions(-) rename c/glfw/{godot_headers => godot-headers} (100%) rename c/instance_binding/{godot_headers => godot-headers} (100%) rename c/simple/{godot_headers => godot-headers} (100%) diff --git a/.gitmodules b/.gitmodules index 9cc1124..7be922e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "c/simple/godot_headers"] - path = c/simple/godot_headers - url = https://github.com/godotengine/godot_headers -[submodule "c/glfw/godot_headers"] - path = c/glfw/godot_headers - url = https://github.com/godotengine/godot_headers -[submodule "c/instance_binding/godot_headers"] - path = c/instance_binding/godot_headers - url = https://github.com/godotengine/godot_headers +[submodule "c/simple/godot-headers"] + path = c/simple/godot-headers + url = https://github.com/godotengine/godot-headers.git +[submodule "c/glfw/godot-headers"] + path = c/glfw/godot-headers + url = https://github.com/godotengine/godot-headers.git +[submodule "c/instance_binding/godot-headers"] + path = c/instance_binding/godot-headers + url = https://github.com/godotengine/godot-headers.git diff --git a/c/glfw/SConstruct b/c/glfw/SConstruct index 296e7b8..c053964 100644 --- a/c/glfw/SConstruct +++ b/c/glfw/SConstruct @@ -4,7 +4,7 @@ import os, subprocess opts = Variables([], ARGUMENTS) # Define the relative path to the Godot headers. -godot_headers_path = "godot_headers/" +godot_headers_path = "godot-headers/" # Gets the standard flags CC, CCX, etc. env = DefaultEnvironment() @@ -64,7 +64,8 @@ elif env["platform"] == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. - env.Append(ENV=os.environ) + env = Environment(ENV=os.environ) + opts.Update(env) env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"]) if env["target"] in ("debug", "d"): diff --git a/c/glfw/godot_headers b/c/glfw/godot-headers similarity index 100% rename from c/glfw/godot_headers rename to c/glfw/godot-headers diff --git a/c/instance_binding/SConstruct b/c/instance_binding/SConstruct index d65a2b5..3ce839c 100644 --- a/c/instance_binding/SConstruct +++ b/c/instance_binding/SConstruct @@ -4,7 +4,7 @@ import os, subprocess opts = Variables([], ARGUMENTS) # Define the relative path to the Godot headers. -godot_headers_path = "godot_headers/" +godot_headers_path = "godot-headers/" # Gets the standard flags CC, CCX, etc. env = DefaultEnvironment() @@ -64,7 +64,8 @@ elif env["platform"] == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. - env.Append(ENV=os.environ) + env = Environment(ENV=os.environ) + opts.Update(env) env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"]) if env["target"] in ("debug", "d"): diff --git a/c/instance_binding/godot_headers b/c/instance_binding/godot-headers similarity index 100% rename from c/instance_binding/godot_headers rename to c/instance_binding/godot-headers diff --git a/c/instance_binding/src/instance_binding.c b/c/instance_binding/src/instance_binding.c index 30780b9..5091569 100644 --- a/c/instance_binding/src/instance_binding.c +++ b/c/instance_binding/src/instance_binding.c @@ -23,7 +23,7 @@ typedef struct wrapper_object { char *message; } wrapper_object; -void *create_wrapper_object(void *data, godot_object *object) { +void *create_wrapper_object(void *data, const void *global_type_tag, godot_object *object) { printf("we are now creating a wrapper object...\n"); fflush(stdout); @@ -47,7 +47,7 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) { api = options->api_struct; // now find our extensions - for (int i = 0; i < api->num_extensions; i++) { + for (unsigned 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]; @@ -78,20 +78,23 @@ void GDN_EXPORT godot_nativescript_init(void *handle) { // register instance binding functions { - godot_instance_binding_functions bind = {}; - bind.alloc_instance_binding_data = &create_wrapper_object; - bind.free_instance_binding_data = &destroy_wrapper_object; + godot_instance_binding_functions bind = { + .alloc_instance_binding_data = &create_wrapper_object, + .free_instance_binding_data = &destroy_wrapper_object + }; language_binding_index = nativescript_1_1_api->godot_nativescript_register_instance_binding_data_functions(bind); } // register class { - godot_instance_create_func constructor = {}; - constructor.create_func = &ibd_constructor; + godot_instance_create_func constructor = { + .create_func = &ibd_constructor + }; - godot_instance_destroy_func destructor = {}; - destructor.destroy_func = &ibd_destructor; + godot_instance_destroy_func destructor = { + .destroy_func = &ibd_destructor + }; nativescript_api->godot_nativescript_register_class(handle, "InstanceBinding", "Reference", constructor, destructor); } diff --git a/c/simple/SConstruct b/c/simple/SConstruct index babd99a..220c7b4 100644 --- a/c/simple/SConstruct +++ b/c/simple/SConstruct @@ -4,7 +4,7 @@ import os, subprocess opts = Variables([], ARGUMENTS) # Define the relative path to the Godot headers. -godot_headers_path = "godot_headers/" +godot_headers_path = "godot-headers/" # Gets the standard flags CC, CCX, etc. env = DefaultEnvironment() @@ -64,7 +64,8 @@ elif env["platform"] == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. - env.Append(ENV=os.environ) + env = Environment(ENV=os.environ) + opts.Update(env) env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"]) if env["target"] in ("debug", "d"): diff --git a/c/simple/godot_headers b/c/simple/godot-headers similarity index 100% rename from c/simple/godot_headers rename to c/simple/godot-headers