summaryrefslogtreecommitdiff
path: root/modules/dlscript/godot
diff options
context:
space:
mode:
authorKarroffel <therzog@mail.de>2017-04-04 19:38:46 +0200
committerKarroffel <therzog@mail.de>2017-04-04 23:02:46 +0200
commit6c49fe9c62b3401323a6497447679fdfded6f116 (patch)
tree8ba50859dedf9ef940d37ccd132234a20abb7818 /modules/dlscript/godot
parent46bc14e66fe90430f1d74cdab6cca6acb5b2a3f6 (diff)
[DLScript] added variant constructor and a function to get userdata of a script
The godot_dlinstance_get_userdata() function can be used to get the DLScript userdata pointer of any object that has a DLScript attached to it. This is particularly useful and even required for language bindings to work properly. This also fixes non-tool builds.
Diffstat (limited to 'modules/dlscript/godot')
-rw-r--r--modules/dlscript/godot/godot_variant.cpp20
-rw-r--r--modules/dlscript/godot/godot_variant.h8
2 files changed, 20 insertions, 8 deletions
diff --git a/modules/dlscript/godot/godot_variant.cpp b/modules/dlscript/godot/godot_variant.cpp
index e7c47ff9ff..3681f89753 100644
--- a/modules/dlscript/godot/godot_variant.cpp
+++ b/modules/dlscript/godot/godot_variant.cpp
@@ -34,7 +34,12 @@ void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b) {
memnew_placement_custom(v, Variant, Variant(p_b));
}
-void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i) {
+void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i) {
+ Variant *v = (Variant *)p_v;
+ memnew_placement_custom(v, Variant, Variant(p_i));
+}
+
+void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i) {
Variant *v = (Variant *)p_v;
memnew_placement_custom(v, Variant, Variant(p_i));
}
@@ -199,14 +204,19 @@ godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v) {
return v->operator bool();
}
-uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v) {
+uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v) {
+ const Variant *v = (const Variant *)p_v;
+ return v->operator uint64_t();
+}
+
+int64_t GDAPI godot_variant_as_int(const godot_variant *p_v) {
const Variant *v = (const Variant *)p_v;
- return v->operator godot_int();
+ return v->operator int64_t();
}
-godot_real GDAPI godot_variant_as_real(const godot_variant *p_v) {
+double GDAPI godot_variant_as_real(const godot_variant *p_v) {
const Variant *v = (const Variant *)p_v;
- return v->operator godot_real();
+ return v->operator double();
}
godot_string GDAPI godot_variant_as_string(const godot_variant *p_v) {
diff --git a/modules/dlscript/godot/godot_variant.h b/modules/dlscript/godot/godot_variant.h
index 0b91af863d..1ff5ba4a57 100644
--- a/modules/dlscript/godot/godot_variant.h
+++ b/modules/dlscript/godot/godot_variant.h
@@ -71,7 +71,8 @@ void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src)
void GDAPI godot_variant_new_nil(godot_variant *p_v);
void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b);
-void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i);
+void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i);
+void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i);
void GDAPI godot_variant_new_real(godot_variant *p_v, const double p_r);
void GDAPI godot_variant_new_string(godot_variant *p_v, const godot_string *p_s);
void GDAPI godot_variant_new_vector2(godot_variant *p_v, const godot_vector2 *p_v2);
@@ -100,8 +101,9 @@ void GDAPI godot_variant_new_pool_vector3_array(godot_variant *p_v, const godot_
void GDAPI godot_variant_new_pool_color_array(godot_variant *p_v, const godot_pool_color_array *p_pca);
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v);
-uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v);
-godot_real GDAPI godot_variant_as_real(const godot_variant *p_v);
+uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v);
+int64_t GDAPI godot_variant_as_int(const godot_variant *p_v);
+double GDAPI godot_variant_as_real(const godot_variant *p_v);
godot_string GDAPI godot_variant_as_string(const godot_variant *p_v);
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_v);
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_v);