Add test for extended object creation/deletion.
parent
42dd64f22f
commit
59d38a4119
|
@ -10,6 +10,7 @@ func _ready():
|
||||||
($Example as Example).simple_const_func() # Force use of ptrcall
|
($Example as Example).simple_const_func() # Force use of ptrcall
|
||||||
prints("returned", $Example.return_something("some string"))
|
prints("returned", $Example.return_something("some string"))
|
||||||
prints("returned const", $Example.return_something_const())
|
prints("returned const", $Example.return_something_const())
|
||||||
|
prints("returned ref", $Example.return_extended_ref())
|
||||||
prints("vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
|
prints("vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
|
||||||
|
|
||||||
# Use properties.
|
# Use properties.
|
||||||
|
|
|
@ -38,12 +38,21 @@
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
|
ExampleRef::ExampleRef() {
|
||||||
|
UtilityFunctions::print("ExampleRef created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExampleRef::~ExampleRef() {
|
||||||
|
UtilityFunctions::print("ExampleRef destroyed.");
|
||||||
|
}
|
||||||
|
|
||||||
void Example::_bind_methods() {
|
void Example::_bind_methods() {
|
||||||
// Methods.
|
// Methods.
|
||||||
ClassDB::bind_method(D_METHOD("simple_func"), &Example::simple_func);
|
ClassDB::bind_method(D_METHOD("simple_func"), &Example::simple_func);
|
||||||
ClassDB::bind_method(D_METHOD("simple_const_func"), &Example::simple_const_func);
|
ClassDB::bind_method(D_METHOD("simple_const_func"), &Example::simple_const_func);
|
||||||
ClassDB::bind_method(D_METHOD("return_something"), &Example::return_something);
|
ClassDB::bind_method(D_METHOD("return_something"), &Example::return_something);
|
||||||
ClassDB::bind_method(D_METHOD("return_something_const"), &Example::return_something_const);
|
ClassDB::bind_method(D_METHOD("return_something_const"), &Example::return_something_const);
|
||||||
|
ClassDB::bind_method(D_METHOD("return_extended_ref"), &Example::return_extended_ref);
|
||||||
|
|
||||||
{
|
{
|
||||||
MethodInfo mi;
|
MethodInfo mi;
|
||||||
|
@ -94,6 +103,10 @@ Viewport *Example::return_something_const() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExampleRef *Example::return_extended_ref() const {
|
||||||
|
return memnew(ExampleRef());
|
||||||
|
}
|
||||||
|
|
||||||
Variant Example::varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) {
|
Variant Example::varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error) {
|
||||||
UtilityFunctions::print("Varargs called with ", String::num(arg_count), " arguments");
|
UtilityFunctions::print("Varargs called with ", String::num(arg_count), " arguments");
|
||||||
return arg_count;
|
return arg_count;
|
||||||
|
|
|
@ -39,6 +39,17 @@
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
|
class ExampleRef : public RefCounted {
|
||||||
|
GDCLASS(ExampleRef, RefCounted);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
ExampleRef();
|
||||||
|
~ExampleRef();
|
||||||
|
};
|
||||||
|
|
||||||
class Example : public Control {
|
class Example : public Control {
|
||||||
GDCLASS(Example, Control);
|
GDCLASS(Example, Control);
|
||||||
|
|
||||||
|
@ -64,6 +75,7 @@ public:
|
||||||
void simple_const_func() const;
|
void simple_const_func() const;
|
||||||
String return_something(const String &base);
|
String return_something(const String &base);
|
||||||
Viewport *return_something_const() const;
|
Viewport *return_something_const() const;
|
||||||
|
ExampleRef *return_extended_ref() const;
|
||||||
Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
||||||
void emit_custom_signal(const String &name, int value);
|
void emit_custom_signal(const String &name, int value);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
void register_example_types() {
|
void register_example_types() {
|
||||||
|
ClassDB::register_class<ExampleRef>();
|
||||||
ClassDB::register_class<Example>();
|
ClassDB::register_class<Example>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue