mirror of
https://github.com/godotengine/godot-cpp.git
synced 2025-12-31 01:48:45 +03:00
Add variant_internal.hpp.
This module contains VariantInternalType, VariantInternal, VariantGetInternalPtr, VariantInternalAccessor and VariantDefaultInitializer, allowing to access and manipulate Variant's internal values.
This commit is contained in:
@@ -271,6 +271,9 @@ func _ready():
|
||||
# Test that we can access an engine singleton.
|
||||
assert_equal(example.test_use_engine_singleton(), OS.get_name())
|
||||
|
||||
assert_equal(example.test_get_internal(1), 1)
|
||||
assert_equal(example.test_get_internal(true), -1)
|
||||
|
||||
# Test that notifications happen on both parent and child classes.
|
||||
var example_child = $ExampleChild
|
||||
assert_equal(example_child.get_value1(), 11)
|
||||
|
||||
@@ -243,6 +243,8 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind);
|
||||
ClassDB::bind_method(D_METHOD("test_post_initialize"), &Example::test_post_initialize);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_get_internal", "a"), &Example::test_get_internal);
|
||||
|
||||
GDVIRTUAL_BIND(_do_something_virtual, "name", "value");
|
||||
ClassDB::bind_method(D_METHOD("test_virtual_implemented_in_script"), &Example::test_virtual_implemented_in_script);
|
||||
GDVIRTUAL_BIND(_do_something_virtual_with_control, "control");
|
||||
@@ -741,6 +743,14 @@ String Example::test_library_path() {
|
||||
return library_path;
|
||||
}
|
||||
|
||||
int64_t Example::test_get_internal(const Variant &p_input) const {
|
||||
if (p_input.get_type() != Variant::INT) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return *VariantInternal::get_int(&p_input);
|
||||
}
|
||||
|
||||
void ExampleRuntime::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_prop_value", "value"), &ExampleRuntime::set_prop_value);
|
||||
ClassDB::bind_method(D_METHOD("get_prop_value"), &ExampleRuntime::get_prop_value);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <godot_cpp/classes/tile_set.hpp>
|
||||
#include <godot_cpp/classes/viewport.hpp>
|
||||
#include <godot_cpp/variant/variant.hpp>
|
||||
#include <godot_cpp/variant/variant_internal.hpp>
|
||||
|
||||
#include <godot_cpp/core/binder_common.hpp>
|
||||
#include <godot_cpp/core/gdvirtual.gen.inc>
|
||||
@@ -185,6 +186,8 @@ public:
|
||||
|
||||
bool test_post_initialize() const;
|
||||
|
||||
int64_t test_get_internal(const Variant &p_input) const;
|
||||
|
||||
// Static method.
|
||||
static int test_static(int p_a, int p_b);
|
||||
static void test_static2();
|
||||
|
||||
Reference in New Issue
Block a user