Update bindings to use new Api extensions and rename Rect3->AABB

This commit is contained in:
BastiaanOlij
2017-11-23 22:50:05 +11:00
parent e72f4beec1
commit 0f773c2d72
16 changed files with 154 additions and 95 deletions

View File

@@ -5,7 +5,8 @@
namespace godot {
void *_RegisterState::nativescript_handle;
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;
void Godot::print(const String& message)
{
@@ -14,12 +15,54 @@ void Godot::print(const String& message)
void Godot::print_warning(const String& description, const String& function, const String& file, int line)
{
godot::api->godot_print_warning(description.c_string(), function.c_string(), file.c_string(), line);
int len;
description.get_c_string(NULL, &len);
char * c_desc = (char *)godot::api->godot_alloc(len + 1);
description.get_c_string(c_desc, &len);
c_desc[len] = '\0';
function.get_c_string(NULL, &len);
char * c_func = (char *)godot::api->godot_alloc(len + 1);
function.get_c_string(c_func, &len);
c_func[len] = '\0';
file.get_c_string(NULL, &len);
char * c_file = (char *)godot::api->godot_alloc(len + 1);
file.get_c_string(c_file, &len);
c_file[len] = '\0';
godot::api->godot_print_warning(c_desc, c_func, c_file, line);
godot::api->godot_free(c_desc);
godot::api->godot_free(c_func);
godot::api->godot_free(c_file);
}
void Godot::print_error(const String& description, const String& function, const String& file, int line)
{
godot::api->godot_print_error(description.c_string(), function.c_string(), file.c_string(), line);
int len;
description.get_c_string(NULL, &len);
char * c_desc = (char *)godot::api->godot_alloc(len + 1);
description.get_c_string(c_desc, &len);
c_desc[len] = '\0';
function.get_c_string(NULL, &len);
char * c_func = (char *)godot::api->godot_alloc(len + 1);
function.get_c_string(c_func, &len);
c_func[len] = '\0';
file.get_c_string(NULL, &len);
char * c_file = (char *)godot::api->godot_alloc(len + 1);
file.get_c_string(c_file, &len);
c_file[len] = '\0';
godot::api->godot_print_error(c_desc, c_func, c_file, line);
godot::api->godot_free(c_desc);
godot::api->godot_free(c_func);
godot::api->godot_free(c_file);
}
};
@@ -28,6 +71,17 @@ void gdnative_init(godot_gdnative_init_options *options);
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options)
{
godot::api = options->api_struct;
// now find our extensions
for (int i = 0; i < godot::api->num_extensions; i++) {
switch (godot::api->extensions[i]->type) {
case GDNATIVE_EXT_NATIVESCRIPT: {
godot::nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)godot::api->extensions[i];
}; break;
default: break;
};
};
gdnative_init(options);
}