Commit files changed by clang_format.sh

This commit is contained in:
Aaron Franke
2020-08-13 20:54:00 -05:00
parent 32cfbfd88a
commit bba3ce54ce
9 changed files with 53 additions and 99 deletions

View File

@@ -10,8 +10,7 @@ struct glfw {
const godot_gdnative_core_api_struct *api = NULL; const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
void window_close_callback(GLFWwindow* window) void window_close_callback(GLFWwindow *window) {
{
godot_object *instance = glfwGetWindowUserPointer(window); godot_object *instance = glfwGetWindowUserPointer(window);
// emit a signal // emit a signal
@@ -61,25 +60,22 @@ void *glfw_constructor(godot_object *instance, void *method_data);
void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data); void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data);
godot_variant glfw_create_window(godot_object *instance, void *method_data, godot_variant glfw_create_window(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args); int num_args, godot_variant **args);
godot_variant glfw_close(godot_object *instance, void *method_data, godot_variant glfw_close(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args); int num_args, godot_variant **args);
godot_variant glfw_poll_events(godot_object *instance, void *method_data, godot_variant glfw_poll_events(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args); int num_args, godot_variant **args);
godot_variant glfw_is_closed(godot_object *instance, void *method_data, godot_variant glfw_is_closed(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args); int num_args, godot_variant **args);
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) {
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options)
{
api = p_options->api_struct; api = p_options->api_struct;
// now find our extensions // now find our extensions
@@ -88,13 +84,13 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options)
case GDNATIVE_EXT_NATIVESCRIPT: { case GDNATIVE_EXT_NATIVESCRIPT: {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i]; nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
}; break; }; break;
default: break; default:
break;
}; };
}; };
} }
void GDN_EXPORT godot_nativescript_init(void *p_handle) void GDN_EXPORT godot_nativescript_init(void *p_handle) {
{
if (!glfwInit()) { if (!glfwInit()) {
fprintf(stderr, "can't initialize GLFW\n"); fprintf(stderr, "can't initialize GLFW\n");
return; return;
@@ -128,7 +124,6 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle)
nativescript_api->godot_nativescript_register_method(p_handle, "GLFW", "close", attributes, close_window); nativescript_api->godot_nativescript_register_method(p_handle, "GLFW", "close", attributes, close_window);
} }
{ {
godot_instance_method poll_events = {}; godot_instance_method poll_events = {};
poll_events.method = &glfw_poll_events; poll_events.method = &glfw_poll_events;
@@ -162,15 +157,13 @@ void GDN_EXPORT godot_nativescript_init(void *p_handle)
} }
} }
void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) {
{
glfwTerminate(); glfwTerminate();
} }
godot_variant glfw_create_window(godot_object *instance, void *method_data, godot_variant glfw_create_window(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args) int num_args, godot_variant **args) {
{
godot_variant ret; godot_variant ret;
api->godot_variant_new_nil(&ret); api->godot_variant_new_nil(&ret);
@@ -197,12 +190,9 @@ godot_variant glfw_create_window(godot_object *instance, void *method_data,
return ret; return ret;
} }
godot_variant glfw_close(godot_object *instance, void *method_data, godot_variant glfw_close(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args) int num_args, godot_variant **args) {
{
godot_variant ret; godot_variant ret;
api->godot_variant_new_nil(&ret); api->godot_variant_new_nil(&ret);
@@ -214,22 +204,18 @@ godot_variant glfw_close(godot_object *instance, void *method_data,
return ret; return ret;
} }
godot_variant glfw_is_closed(godot_object *instance, void *method_data, godot_variant glfw_is_closed(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args) int num_args, godot_variant **args) {
{
godot_variant ret; godot_variant ret;
api->godot_variant_new_bool(&ret, user_data->window == NULL); api->godot_variant_new_bool(&ret, user_data->window == NULL);
return ret; return ret;
} }
godot_variant glfw_poll_events(godot_object *instance, void *method_data, godot_variant glfw_poll_events(godot_object *instance, void *method_data,
struct glfw *user_data, struct glfw *user_data,
int num_args, godot_variant **args) int num_args, godot_variant **args) {
{
godot_variant ret; godot_variant ret;
api->godot_variant_new_nil(&ret); api->godot_variant_new_nil(&ret);
@@ -238,12 +224,7 @@ godot_variant glfw_poll_events(godot_object *instance, void *method_data,
return ret; return ret;
} }
void *glfw_constructor(godot_object *instance, void *method_data) {
void *glfw_constructor(godot_object *instance, void *method_data)
{
printf("GLFW._init()\n"); printf("GLFW._init()\n");
struct glfw *user_data = api->godot_alloc(sizeof(struct glfw)); struct glfw *user_data = api->godot_alloc(sizeof(struct glfw));
@@ -252,8 +233,7 @@ void *glfw_constructor(godot_object *instance, void *method_data)
return user_data; return user_data;
} }
void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data) void glfw_destructor(godot_object *instance, void *method_data, struct glfw *user_data) {
{
// destroy window // destroy window
if (user_data->window) { if (user_data->window) {

View File

@@ -3,7 +3,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
const godot_gdnative_core_api_struct *api = NULL; const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
const godot_gdnative_ext_nativescript_1_1_api_struct *nativescript_1_1_api = NULL; const godot_gdnative_ext_nativescript_1_1_api_struct *nativescript_1_1_api = NULL;
@@ -24,8 +23,7 @@ typedef struct wrapper_object {
char *message; char *message;
} wrapper_object; } wrapper_object;
void *create_wrapper_object(void *data, godot_object *object) void *create_wrapper_object(void *data, godot_object *object) {
{
printf("we are now creating a wrapper object...\n"); printf("we are now creating a wrapper object...\n");
fflush(stdout); fflush(stdout);
@@ -38,17 +36,14 @@ void *create_wrapper_object(void *data, godot_object *object)
return wrapper; return wrapper;
} }
void destroy_wrapper_object(void *data, void *wrapper) void destroy_wrapper_object(void *data, void *wrapper) {
{
api->godot_free(wrapper); api->godot_free(wrapper);
printf("the wrapper object got destroyed.\n"); printf("the wrapper object got destroyed.\n");
fflush(stdout); fflush(stdout);
} }
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options) {
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options)
{
api = options->api_struct; api = options->api_struct;
// now find our extensions // now find our extensions
@@ -61,25 +56,22 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options)
break; break;
if (nativescript_api->next->version.major == 1 && nativescript_api->next->version.minor == 1) { if (nativescript_api->next->version.major == 1 && nativescript_api->next->version.minor == 1) {
nativescript_1_1_api = (const godot_gdnative_ext_nativescript_1_1_api_struct *) nativescript_api->next; nativescript_1_1_api = (const godot_gdnative_ext_nativescript_1_1_api_struct *)nativescript_api->next;
} }
}; break; }; break;
default: break; default:
break;
}; };
}; };
} }
void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *options) {
{
api = NULL; api = NULL;
nativescript_api = NULL; nativescript_api = NULL;
nativescript_1_1_api = NULL; nativescript_1_1_api = NULL;
} }
void GDN_EXPORT godot_nativescript_init(void *handle) {
void GDN_EXPORT godot_nativescript_init(void *handle)
{
printf("nativescript_init\n"); printf("nativescript_init\n");
fflush(stdout); fflush(stdout);
@@ -102,17 +94,14 @@ void GDN_EXPORT godot_nativescript_init(void *handle)
destructor.destroy_func = &ibd_destructor; destructor.destroy_func = &ibd_destructor;
nativescript_api->godot_nativescript_register_class(handle, "InstanceBindingDemo", "Reference", constructor, destructor); nativescript_api->godot_nativescript_register_class(handle, "InstanceBindingDemo", "Reference", constructor, destructor);
} }
} }
void GDN_EXPORT godot_nativescript_terminate(void *handle) void GDN_EXPORT godot_nativescript_terminate(void *handle) {
{
nativescript_1_1_api->godot_nativescript_unregister_instance_binding_data_functions(language_binding_index); nativescript_1_1_api->godot_nativescript_unregister_instance_binding_data_functions(language_binding_index);
} }
GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data) GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data) {
{
wrapper_object *wrapper = nativescript_1_1_api->godot_nativescript_get_instance_binding_data(language_binding_index, instance); wrapper_object *wrapper = nativescript_1_1_api->godot_nativescript_get_instance_binding_data(language_binding_index, instance);
printf("message is: %s\n", wrapper->message); printf("message is: %s\n", wrapper->message);
@@ -121,6 +110,5 @@ GDCALLINGCONV void *ibd_constructor(godot_object *instance, void *method_data)
return NULL; return NULL;
} }
GDCALLINGCONV void ibd_destructor(godot_object *instance, void *method_data, void *user_data) GDCALLINGCONV void ibd_destructor(godot_object *instance, void *method_data, void *user_data) {
{
} }

View File

@@ -23,7 +23,8 @@ void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options) {
case GDNATIVE_EXT_NATIVESCRIPT: { case GDNATIVE_EXT_NATIVESCRIPT: {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i]; nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
}; break; }; break;
default: break; default:
break;
}; };
}; };
} }
@@ -68,7 +69,7 @@ GDCALLINGCONV void simple_destructor(godot_object *p_instance, void *p_method_da
godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, void *p_user_data, int p_num_args, godot_variant **p_args) { godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, void *p_user_data, int p_num_args, godot_variant **p_args) {
godot_string data; godot_string data;
godot_variant ret; godot_variant ret;
user_data_struct * user_data = (user_data_struct *) p_user_data; user_data_struct *user_data = (user_data_struct *)p_user_data;
api->godot_string_new(&data); api->godot_string_new(&data);
api->godot_string_parse_utf8(&data, user_data->data); api->godot_string_parse_utf8(&data, user_data->data);

View File

@@ -2,33 +2,27 @@
#include "Input.hpp" #include "Input.hpp"
void Simple::_register_methods() void Simple::_register_methods() {
{
godot::register_method("get_data", &Simple::get_data); godot::register_method("get_data", &Simple::get_data);
} }
void Simple::_init() void Simple::_init() {
{
data = "Hello World from C++"; data = "Hello World from C++";
} }
godot::String Simple::get_data() const godot::String Simple::get_data() const {
{
return data; return data;
} }
void SimpleSprite::_register_methods() void SimpleSprite::_register_methods() {
{
godot::register_method("_process", &SimpleSprite::_process); godot::register_method("_process", &SimpleSprite::_process);
} }
void SimpleSprite::_init() void SimpleSprite::_init() {
{
godot::Godot::print("Wheeeeey"); godot::Godot::print("Wheeeeey");
} }
void SimpleSprite::_process(double delta) void SimpleSprite::_process(double delta) {
{
godot::Vector2 input_dir(0, 0); godot::Vector2 input_dir(0, 0);
if (godot::Input::get_singleton()->is_action_pressed("ui_right")) { if (godot::Input::get_singleton()->is_action_pressed("ui_right")) {

View File

@@ -7,8 +7,8 @@ class Simple : public godot::Reference {
GODOT_CLASS(Simple, godot::Reference) GODOT_CLASS(Simple, godot::Reference)
godot::String data; godot::String data;
public:
public:
static void _register_methods(); static void _register_methods();
void _init(); void _init();

View File

@@ -2,21 +2,17 @@
#include "Simple.hpp" #include "Simple.hpp"
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
{
godot::Godot::gdnative_init(o); godot::Godot::gdnative_init(o);
} }
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
{
godot::Godot::gdnative_terminate(o); godot::Godot::gdnative_terminate(o);
} }
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
{
godot::Godot::nativescript_init(handle); godot::Godot::nativescript_init(handle);
godot::register_class<Simple>(); godot::register_class<Simple>();
godot::register_class<SimpleSprite>(); godot::register_class<SimpleSprite>();
} }

View File

@@ -1,10 +1,9 @@
#include <File.hpp>
#include <Reference.hpp> #include <Reference.hpp>
#include <Timer.hpp> #include <Timer.hpp>
#include <File.hpp>
#include <Ref.hpp> #include <Ref.hpp>
#include <stdio.h> #include <stdio.h>
using namespace godot; using namespace godot;
@@ -15,7 +14,6 @@ class TestClass : public Reference {
int count; int count;
public: public:
void _init() { void _init() {
count = 34; count = 34;
} }

View File

@@ -2,18 +2,15 @@
#include "TestClass.hpp" #include "TestClass.hpp"
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
{
godot::Godot::gdnative_init(o); godot::Godot::gdnative_init(o);
} }
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
{
godot::Godot::gdnative_terminate(o); godot::Godot::gdnative_terminate(o);
} }
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
{
godot::Godot::nativescript_init(handle); godot::Godot::nativescript_init(handle);
godot::register_class<TestClass>(); godot::register_class<TestClass>();

View File

@@ -36,6 +36,6 @@ public:
static void _register_methods(); static void _register_methods();
}; };
} } // namespace godot
#endif // COLWORLD_H #endif // COLWORLD_H