From d6101538e695b0a38223fb1fa5ee32ce55e3223c Mon Sep 17 00:00:00 2001 From: O01eg Date: Sat, 28 Nov 2020 12:05:00 +0300 Subject: Test build GNnative library in CI --- test/src/init.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 test/src/init.cpp (limited to 'test/src/init.cpp') diff --git a/test/src/init.cpp b/test/src/init.cpp new file mode 100644 index 0000000..9164ba5 --- /dev/null +++ b/test/src/init.cpp @@ -0,0 +1,70 @@ +#include +#include + +using namespace godot; + +class SimpleClass : public Reference { + GODOT_CLASS(SimpleClass, Reference); + +public: + SimpleClass() {} + + /** `_init` must exist as it is called by Godot. */ + void _init() {} + + void test_void_method() { + Godot::print("This is test"); + } + + Variant method(Variant arg) { + Variant ret; + ret = arg; + + return ret; + } + + static void _register_methods() { + register_method("method", &SimpleClass::method); + + /** + * The line below is equivalent to the following GDScript export: + * export var _name = "SimpleClass" + **/ + register_property("base/name", &SimpleClass::_name, String("SimpleClass")); + + /** Alternatively, with getter and setter methods: */ + register_property("base/value", &SimpleClass::set_value, &SimpleClass::get_value, 0); + + /** Registering a signal: **/ + register_signal("signal_name0"); + register_signal("signal_name1", "string_argument", GODOT_VARIANT_TYPE_STRING); + } + + String _name; + int _value; + + void set_value(int p_value) { + _value = p_value; + } + + int get_value() const { + return _value; + } +}; + +/** GDNative Initialize **/ +extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { + godot::Godot::gdnative_init(o); +} + +/** GDNative Terminate **/ +extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { + godot::Godot::gdnative_terminate(o); +} + +/** NativeScript Initialize **/ +extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { + godot::Godot::nativescript_init(handle); + + godot::register_class(); +} -- cgit v1.2.3 From c55ef5adcfa5a608fa69e53c69ba49de495de53a Mon Sep 17 00:00:00 2001 From: O01eg Date: Sat, 6 Feb 2021 23:19:40 +0300 Subject: Disable Windows compilation. --- test/src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/src/init.cpp') diff --git a/test/src/init.cpp b/test/src/init.cpp index 9164ba5..47d4fda 100644 --- a/test/src/init.cpp +++ b/test/src/init.cpp @@ -36,7 +36,7 @@ public: register_property("base/value", &SimpleClass::set_value, &SimpleClass::get_value, 0); /** Registering a signal: **/ - register_signal("signal_name0"); + register_signal("signal_name0"); // windows: error C2668: 'godot::register_signal': ambiguous call to overloaded function register_signal("signal_name1", "string_argument", GODOT_VARIANT_TYPE_STRING); } -- cgit v1.2.3 From 279d63d6c53a40ab92a0357661b837e5232a5331 Mon Sep 17 00:00:00 2001 From: O01eg Date: Sat, 28 Nov 2020 13:08:17 +0300 Subject: Run script test --- test/src/init.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/src/init.cpp') diff --git a/test/src/init.cpp b/test/src/init.cpp index 47d4fda..3eedb05 100644 --- a/test/src/init.cpp +++ b/test/src/init.cpp @@ -10,7 +10,10 @@ public: SimpleClass() {} /** `_init` must exist as it is called by Godot. */ - void _init() {} + void _init() { + _name = String("SimpleClass"); + _value = 0; + } void test_void_method() { Godot::print("This is test"); @@ -30,10 +33,10 @@ public: * The line below is equivalent to the following GDScript export: * export var _name = "SimpleClass" **/ - register_property("base/name", &SimpleClass::_name, String("SimpleClass")); + register_property("name", &SimpleClass::_name, String("SimpleClass")); /** Alternatively, with getter and setter methods: */ - register_property("base/value", &SimpleClass::set_value, &SimpleClass::get_value, 0); + register_property("value", &SimpleClass::set_value, &SimpleClass::get_value, 0); /** Registering a signal: **/ register_signal("signal_name0"); // windows: error C2668: 'godot::register_signal': ambiguous call to overloaded function -- cgit v1.2.3