mirror of
https://github.com/Relintai/mono.git
synced 2024-11-08 10:12:16 +01:00
Added the new Variant types to (hoipefully all) glue code.
This commit is contained in:
parent
86248c1889
commit
9863e95b02
@ -33,7 +33,7 @@
|
|||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/object/reference.h"
|
#include "core/object/reference.h"
|
||||||
#include "core/string_name.h"
|
#include "core/string/string_name.h"
|
||||||
|
|
||||||
#include "../csharp_script.h"
|
#include "../csharp_script.h"
|
||||||
#include "../mono_gd/gd_mono_cache.h"
|
#include "../mono_gd/gd_mono_cache.h"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/array.h"
|
#include "core/variant/array.h"
|
||||||
|
|
||||||
#include "../mono_gd/gd_mono_marshal.h"
|
#include "../mono_gd/gd_mono_marshal.h"
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@
|
|||||||
|
|
||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/array.h"
|
#include "core/variant/array.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/string/ustring.h"
|
#include "core/string/ustring.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
#include "core/variant_parser.h"
|
#include "core/variant/variant_parser.h"
|
||||||
|
|
||||||
#include "../mono_gd/gd_mono_cache.h"
|
#include "../mono_gd/gd_mono_cache.h"
|
||||||
#include "../mono_gd/gd_mono_utils.h"
|
#include "../mono_gd/gd_mono_utils.h"
|
||||||
|
@ -61,7 +61,7 @@ void godot_register_glue_header_icalls() {
|
|||||||
#include "core/object/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "core/variant/dictionary.h"
|
#include "core/variant/dictionary.h"
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/method_bind.h"
|
#include "core/object/method_bind.h"
|
||||||
#include "core/string/node_path.h"
|
#include "core/string/node_path.h"
|
||||||
#include "core/object/object.h"
|
#include "core/object/object.h"
|
||||||
#include "core/object/reference.h"
|
#include "core/object/reference.h"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/node_path.h"
|
#include "core/string/node_path.h"
|
||||||
|
|
||||||
#include "../mono_gd/gd_mono_marshal.h"
|
#include "../mono_gd/gd_mono_marshal.h"
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/resource.h"
|
#include "core/object/resource.h"
|
||||||
|
|
||||||
RID *godot_icall_RID_Ctor(Object *p_from) {
|
RID *godot_icall_RID_Ctor(Object *p_from) {
|
||||||
Resource *res_from = Object::cast_to<Resource>(p_from);
|
Resource *res_from = Object::cast_to<Resource>(p_from);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#ifdef MONO_GLUE_ENABLED
|
#ifdef MONO_GLUE_ENABLED
|
||||||
|
|
||||||
#include "core/object/object.h"
|
#include "core/object/object.h"
|
||||||
#include "core/rid.h"
|
#include "core/containers/rid.h"
|
||||||
|
|
||||||
#include "../mono_gd/gd_mono_marshal.h"
|
#include "../mono_gd/gd_mono_marshal.h"
|
||||||
|
|
||||||
|
@ -101,17 +101,24 @@ void CachedData::clear_godot_api_cache() {
|
|||||||
|
|
||||||
rawclass_Dictionary = NULL;
|
rawclass_Dictionary = NULL;
|
||||||
|
|
||||||
class_Vector2 = NULL;
|
|
||||||
class_Rect2 = NULL;
|
class_Rect2 = NULL;
|
||||||
|
class_Rect2i = NULL;
|
||||||
class_Transform2D = NULL;
|
class_Transform2D = NULL;
|
||||||
|
class_Vector2 = NULL;
|
||||||
|
class_Vector2i = NULL;
|
||||||
class_Vector3 = NULL;
|
class_Vector3 = NULL;
|
||||||
|
class_Vector3i = NULL;
|
||||||
|
class_Vector4 = NULL;
|
||||||
|
class_Vector4i = NULL;
|
||||||
class_Basis = NULL;
|
class_Basis = NULL;
|
||||||
class_Quaternion = NULL;
|
class_Quaternion = NULL;
|
||||||
class_Transform = NULL;
|
class_Transform = NULL;
|
||||||
|
class_Projection = NULL;
|
||||||
class_AABB = NULL;
|
class_AABB = NULL;
|
||||||
class_Color = NULL;
|
class_Color = NULL;
|
||||||
class_Plane = NULL;
|
class_Plane = NULL;
|
||||||
class_NodePath = NULL;
|
class_NodePath = NULL;
|
||||||
|
class_StringName = NULL;
|
||||||
class_RID = NULL;
|
class_RID = NULL;
|
||||||
class_GodotObject = NULL;
|
class_GodotObject = NULL;
|
||||||
class_GodotResource = NULL;
|
class_GodotResource = NULL;
|
||||||
@ -147,6 +154,7 @@ void CachedData::clear_godot_api_cache() {
|
|||||||
|
|
||||||
field_GodotObject_ptr = NULL;
|
field_GodotObject_ptr = NULL;
|
||||||
field_NodePath_ptr = NULL;
|
field_NodePath_ptr = NULL;
|
||||||
|
field_StringName_ptr = NULL;
|
||||||
field_Image_ptr = NULL;
|
field_Image_ptr = NULL;
|
||||||
field_RID_ptr = NULL;
|
field_RID_ptr = NULL;
|
||||||
|
|
||||||
@ -217,17 +225,24 @@ void update_corlib_cache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void update_godot_api_cache() {
|
void update_godot_api_cache() {
|
||||||
CACHE_CLASS_AND_CHECK(Vector2, GODOT_API_CLASS(Vector2));
|
|
||||||
CACHE_CLASS_AND_CHECK(Rect2, GODOT_API_CLASS(Rect2));
|
CACHE_CLASS_AND_CHECK(Rect2, GODOT_API_CLASS(Rect2));
|
||||||
|
CACHE_CLASS_AND_CHECK(Rect2i, GODOT_API_CLASS(Rect2i));
|
||||||
CACHE_CLASS_AND_CHECK(Transform2D, GODOT_API_CLASS(Transform2D));
|
CACHE_CLASS_AND_CHECK(Transform2D, GODOT_API_CLASS(Transform2D));
|
||||||
|
CACHE_CLASS_AND_CHECK(Vector2, GODOT_API_CLASS(Vector2));
|
||||||
|
CACHE_CLASS_AND_CHECK(Vector2i, GODOT_API_CLASS(Vector2i));
|
||||||
CACHE_CLASS_AND_CHECK(Vector3, GODOT_API_CLASS(Vector3));
|
CACHE_CLASS_AND_CHECK(Vector3, GODOT_API_CLASS(Vector3));
|
||||||
|
CACHE_CLASS_AND_CHECK(Vector3i, GODOT_API_CLASS(Vector3i));
|
||||||
|
CACHE_CLASS_AND_CHECK(Vector4, GODOT_API_CLASS(Vector4i));
|
||||||
|
CACHE_CLASS_AND_CHECK(Vector4i, GODOT_API_CLASS(Vector4i));
|
||||||
CACHE_CLASS_AND_CHECK(Basis, GODOT_API_CLASS(Basis));
|
CACHE_CLASS_AND_CHECK(Basis, GODOT_API_CLASS(Basis));
|
||||||
CACHE_CLASS_AND_CHECK(Quaternion, GODOT_API_CLASS(Quaternion));
|
CACHE_CLASS_AND_CHECK(Quaternion, GODOT_API_CLASS(Quaternion));
|
||||||
CACHE_CLASS_AND_CHECK(Transform, GODOT_API_CLASS(Transform));
|
CACHE_CLASS_AND_CHECK(Transform, GODOT_API_CLASS(Transform));
|
||||||
|
CACHE_CLASS_AND_CHECK(Projection, GODOT_API_CLASS(Projection));
|
||||||
CACHE_CLASS_AND_CHECK(AABB, GODOT_API_CLASS(AABB));
|
CACHE_CLASS_AND_CHECK(AABB, GODOT_API_CLASS(AABB));
|
||||||
CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color));
|
CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color));
|
||||||
CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane));
|
CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane));
|
||||||
CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath));
|
CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath));
|
||||||
|
CACHE_CLASS_AND_CHECK(StringName, GODOT_API_CLASS(StringName));
|
||||||
CACHE_CLASS_AND_CHECK(RID, GODOT_API_CLASS(RID));
|
CACHE_CLASS_AND_CHECK(RID, GODOT_API_CLASS(RID));
|
||||||
CACHE_CLASS_AND_CHECK(GodotObject, GODOT_API_CLASS(Object));
|
CACHE_CLASS_AND_CHECK(GodotObject, GODOT_API_CLASS(Object));
|
||||||
CACHE_CLASS_AND_CHECK(GodotResource, GODOT_API_CLASS(Resource));
|
CACHE_CLASS_AND_CHECK(GodotResource, GODOT_API_CLASS(Resource));
|
||||||
@ -263,6 +278,7 @@ void update_godot_api_cache() {
|
|||||||
|
|
||||||
CACHE_FIELD_AND_CHECK(GodotObject, ptr, CACHED_CLASS(GodotObject)->get_field(BINDINGS_PTR_FIELD));
|
CACHE_FIELD_AND_CHECK(GodotObject, ptr, CACHED_CLASS(GodotObject)->get_field(BINDINGS_PTR_FIELD));
|
||||||
CACHE_FIELD_AND_CHECK(NodePath, ptr, CACHED_CLASS(NodePath)->get_field(BINDINGS_PTR_FIELD));
|
CACHE_FIELD_AND_CHECK(NodePath, ptr, CACHED_CLASS(NodePath)->get_field(BINDINGS_PTR_FIELD));
|
||||||
|
CACHE_FIELD_AND_CHECK(StringName, ptr, CACHED_CLASS(StringName)->get_field(BINDINGS_PTR_FIELD));
|
||||||
CACHE_FIELD_AND_CHECK(RID, ptr, CACHED_CLASS(RID)->get_field(BINDINGS_PTR_FIELD));
|
CACHE_FIELD_AND_CHECK(RID, ptr, CACHED_CLASS(RID)->get_field(BINDINGS_PTR_FIELD));
|
||||||
|
|
||||||
CACHE_METHOD_THUNK_AND_CHECK(GodotObject, Dispose, CACHED_CLASS(GodotObject)->get_method("Dispose", 0));
|
CACHE_METHOD_THUNK_AND_CHECK(GodotObject, Dispose, CACHED_CLASS(GodotObject)->get_method("Dispose", 0));
|
||||||
|
@ -72,17 +72,24 @@ struct CachedData {
|
|||||||
MonoClass *rawclass_Dictionary;
|
MonoClass *rawclass_Dictionary;
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
|
|
||||||
GDMonoClass *class_Vector2;
|
|
||||||
GDMonoClass *class_Rect2;
|
GDMonoClass *class_Rect2;
|
||||||
|
GDMonoClass *class_Rect2i;
|
||||||
GDMonoClass *class_Transform2D;
|
GDMonoClass *class_Transform2D;
|
||||||
|
GDMonoClass *class_Vector2;
|
||||||
|
GDMonoClass *class_Vector2i;
|
||||||
GDMonoClass *class_Vector3;
|
GDMonoClass *class_Vector3;
|
||||||
|
GDMonoClass *class_Vector3i;
|
||||||
|
GDMonoClass *class_Vector4;
|
||||||
|
GDMonoClass *class_Vector4i;
|
||||||
GDMonoClass *class_Basis;
|
GDMonoClass *class_Basis;
|
||||||
GDMonoClass *class_Quaternion;
|
GDMonoClass *class_Quaternion;
|
||||||
GDMonoClass *class_Transform;
|
GDMonoClass *class_Transform;
|
||||||
|
GDMonoClass *class_Projection;
|
||||||
GDMonoClass *class_AABB;
|
GDMonoClass *class_AABB;
|
||||||
GDMonoClass *class_Color;
|
GDMonoClass *class_Color;
|
||||||
GDMonoClass *class_Plane;
|
GDMonoClass *class_Plane;
|
||||||
GDMonoClass *class_NodePath;
|
GDMonoClass *class_NodePath;
|
||||||
|
GDMonoClass *class_StringName;
|
||||||
GDMonoClass *class_RID;
|
GDMonoClass *class_RID;
|
||||||
GDMonoClass *class_GodotObject;
|
GDMonoClass *class_GodotObject;
|
||||||
GDMonoClass *class_GodotResource;
|
GDMonoClass *class_GodotResource;
|
||||||
@ -118,6 +125,7 @@ struct CachedData {
|
|||||||
|
|
||||||
GDMonoField *field_GodotObject_ptr;
|
GDMonoField *field_GodotObject_ptr;
|
||||||
GDMonoField *field_NodePath_ptr;
|
GDMonoField *field_NodePath_ptr;
|
||||||
|
GDMonoField *field_StringName_ptr;
|
||||||
GDMonoField *field_Image_ptr;
|
GDMonoField *field_Image_ptr;
|
||||||
GDMonoField *field_RID_ptr;
|
GDMonoField *field_RID_ptr;
|
||||||
|
|
||||||
|
@ -71,80 +71,147 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
|
|||||||
case MONO_TYPE_VALUETYPE: {
|
case MONO_TYPE_VALUETYPE: {
|
||||||
GDMonoClass *vtclass = p_type.type_class;
|
GDMonoClass *vtclass = p_type.type_class;
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Vector2))
|
if (vtclass == CACHED_CLASS(Vector2)) {
|
||||||
return Variant::VECTOR2;
|
return Variant::VECTOR2;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Rect2))
|
if (vtclass == CACHED_CLASS(Vector2i)) {
|
||||||
|
return Variant::VECTOR2I;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Rect2)) {
|
||||||
return Variant::RECT2;
|
return Variant::RECT2;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Transform2D))
|
if (vtclass == CACHED_CLASS(Rect2i)) {
|
||||||
|
return Variant::RECT2I;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Transform2D)) {
|
||||||
return Variant::TRANSFORM2D;
|
return Variant::TRANSFORM2D;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Vector3))
|
if (vtclass == CACHED_CLASS(Vector3)) {
|
||||||
return Variant::VECTOR3;
|
return Variant::VECTOR3;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Basis))
|
if (vtclass == CACHED_CLASS(Vector3i)) {
|
||||||
|
return Variant::VECTOR3I;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Vector4)) {
|
||||||
|
return Variant::VECTOR4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Vector4i)) {
|
||||||
|
return Variant::VECTOR4I;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Basis)) {
|
||||||
return Variant::BASIS;
|
return Variant::BASIS;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Quaternion))
|
if (vtclass == CACHED_CLASS(Quaternion)) {
|
||||||
return Variant::QUATERNION;
|
return Variant::QUATERNION;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Transform))
|
if (vtclass == CACHED_CLASS(Transform)) {
|
||||||
return Variant::TRANSFORM;
|
return Variant::TRANSFORM;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(AABB))
|
if (vtclass == CACHED_CLASS(Projection)) {
|
||||||
|
return Variant::PROJECTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(AABB)) {
|
||||||
return Variant::AABB;
|
return Variant::AABB;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Color))
|
if (vtclass == CACHED_CLASS(Color)) {
|
||||||
return Variant::COLOR;
|
return Variant::COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Plane))
|
if (vtclass == CACHED_CLASS(Plane)) {
|
||||||
return Variant::PLANE;
|
return Variant::PLANE;
|
||||||
|
}
|
||||||
|
|
||||||
if (mono_class_is_enum(vtclass->get_mono_ptr()))
|
if (mono_class_is_enum(vtclass->get_mono_ptr())) {
|
||||||
return Variant::INT;
|
return Variant::INT;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MONO_TYPE_ARRAY:
|
case MONO_TYPE_ARRAY:
|
||||||
case MONO_TYPE_SZARRAY: {
|
case MONO_TYPE_SZARRAY: {
|
||||||
MonoClass *elem_class = mono_class_get_element_class(p_type.type_class->get_mono_ptr());
|
MonoClass *elem_class = mono_class_get_element_class(p_type.type_class->get_mono_ptr());
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(MonoObject))
|
if (elem_class == CACHED_CLASS_RAW(MonoObject)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(uint8_t))
|
if (elem_class == CACHED_CLASS_RAW(uint8_t)) {
|
||||||
return Variant::POOL_BYTE_ARRAY;
|
return Variant::POOL_BYTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(int32_t))
|
if (elem_class == CACHED_CLASS_RAW(int32_t)) {
|
||||||
return Variant::POOL_INT_ARRAY;
|
return Variant::POOL_INT_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == REAL_T_MONOCLASS)
|
if (elem_class == REAL_T_MONOCLASS) {
|
||||||
return Variant::POOL_REAL_ARRAY;
|
return Variant::POOL_REAL_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(String))
|
if (elem_class == CACHED_CLASS_RAW(String)) {
|
||||||
return Variant::POOL_STRING_ARRAY;
|
return Variant::POOL_STRING_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(Vector2))
|
if (elem_class == CACHED_CLASS_RAW(Vector2)) {
|
||||||
return Variant::POOL_VECTOR2_ARRAY;
|
return Variant::POOL_VECTOR2_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(Vector3))
|
if (elem_class == CACHED_CLASS_RAW(Vector2i)) {
|
||||||
|
return Variant::POOL_VECTOR2I_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem_class == CACHED_CLASS_RAW(Vector3)) {
|
||||||
return Variant::POOL_VECTOR3_ARRAY;
|
return Variant::POOL_VECTOR3_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(Color))
|
if (elem_class == CACHED_CLASS_RAW(Vector3i)) {
|
||||||
|
return Variant::POOL_VECTOR3I_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem_class == CACHED_CLASS_RAW(Vector4)) {
|
||||||
|
return Variant::POOL_VECTOR4_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem_class == CACHED_CLASS_RAW(Vector4i)) {
|
||||||
|
return Variant::POOL_VECTOR4I_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elem_class == CACHED_CLASS_RAW(Color)) {
|
||||||
return Variant::POOL_COLOR_ARRAY;
|
return Variant::POOL_COLOR_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(NodePath))
|
if (elem_class == CACHED_CLASS_RAW(NodePath)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem_class == CACHED_CLASS_RAW(RID))
|
if (elem_class == CACHED_CLASS_RAW(StringName)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
if (mono_class_is_enum(elem_class))
|
if (elem_class == CACHED_CLASS_RAW(RID)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mono_class_is_enum(elem_class)) {
|
||||||
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(elem_class);
|
GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(elem_class);
|
||||||
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
|
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) {
|
||||||
return Variant::ARRAY;
|
return Variant::ARRAY;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MONO_TYPE_CLASS: {
|
case MONO_TYPE_CLASS: {
|
||||||
@ -159,6 +226,10 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
|
|||||||
return Variant::NODE_PATH;
|
return Variant::NODE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CACHED_CLASS(StringName) == type_class) {
|
||||||
|
return Variant::STRING_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
if (CACHED_CLASS(RID) == type_class) {
|
if (CACHED_CLASS(RID) == type_class) {
|
||||||
return Variant::RID;
|
return Variant::RID;
|
||||||
}
|
}
|
||||||
@ -307,8 +378,9 @@ String mono_to_utf16_string(MonoString *p_mono_string) {
|
|||||||
int len = mono_string_length(p_mono_string);
|
int len = mono_string_length(p_mono_string);
|
||||||
String ret;
|
String ret;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret.resize(len + 1);
|
ret.resize(len + 1);
|
||||||
ret.set(len, 0);
|
ret.set(len, 0);
|
||||||
@ -357,10 +429,26 @@ MonoArray *variant_to_mono_array(const Variant &p_var, GDMonoClass *p_type_class
|
|||||||
return PoolVector2Array_to_mono_array(p_var.operator PoolVector2Array());
|
return PoolVector2Array_to_mono_array(p_var.operator PoolVector2Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector2i)) {
|
||||||
|
return PoolVector2iArray_to_mono_array(p_var.operator PoolVector2iArray());
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
|
||||||
return PoolVector3Array_to_mono_array(p_var.operator PoolVector3Array());
|
return PoolVector3Array_to_mono_array(p_var.operator PoolVector3Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector3i)) {
|
||||||
|
return PoolVector3iArray_to_mono_array(p_var.operator PoolVector3iArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector4)) {
|
||||||
|
return PoolVector4Array_to_mono_array(p_var.operator PoolVector4Array());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector4i)) {
|
||||||
|
return PoolVector4iArray_to_mono_array(p_var.operator PoolVector4iArray());
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
|
if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
|
||||||
return PoolColorArray_to_mono_array(p_var.operator PoolColorArray());
|
return PoolColorArray_to_mono_array(p_var.operator PoolColorArray());
|
||||||
}
|
}
|
||||||
@ -369,6 +457,10 @@ MonoArray *variant_to_mono_array(const Variant &p_var, GDMonoClass *p_type_class
|
|||||||
return Array_to_mono_array(p_var.operator Array());
|
return Array_to_mono_array(p_var.operator Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(StringName)) {
|
||||||
|
return Array_to_mono_array(p_var.operator Array());
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(RID)) {
|
if (array_type->eklass == CACHED_CLASS_RAW(RID)) {
|
||||||
return Array_to_mono_array(p_var.operator Array());
|
return Array_to_mono_array(p_var.operator Array());
|
||||||
}
|
}
|
||||||
@ -390,6 +482,10 @@ MonoObject *variant_to_mono_object_of_class(const Variant &p_var, GDMonoClass *p
|
|||||||
return GDMonoUtils::create_managed_from(p_var.operator NodePath());
|
return GDMonoUtils::create_managed_from(p_var.operator NodePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CACHED_CLASS(StringName) == p_type_class) {
|
||||||
|
return GDMonoUtils::create_managed_from(p_var.operator StringName());
|
||||||
|
}
|
||||||
|
|
||||||
if (CACHED_CLASS(RID) == p_type_class) {
|
if (CACHED_CLASS(RID) == p_type_class) {
|
||||||
return GDMonoUtils::create_managed_from(p_var.operator ::RID());
|
return GDMonoUtils::create_managed_from(p_var.operator ::RID());
|
||||||
}
|
}
|
||||||
@ -494,10 +590,30 @@ MonoObject *variant_to_mono_object(const Variant &p_var) {
|
|||||||
GDMonoMarshal::M_Rect2 from = MARSHALLED_OUT(Rect2, p_var.operator ::Rect2());
|
GDMonoMarshal::M_Rect2 from = MARSHALLED_OUT(Rect2, p_var.operator ::Rect2());
|
||||||
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Rect2), &from);
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Rect2), &from);
|
||||||
}
|
}
|
||||||
|
case Variant::VECTOR2I: {
|
||||||
|
GDMonoMarshal::M_Vector2i from = MARSHALLED_OUT(Vector2i, p_var.operator ::Vector2i());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector2i), &from);
|
||||||
|
}
|
||||||
|
case Variant::RECT2I: {
|
||||||
|
GDMonoMarshal::M_Rect2i from = MARSHALLED_OUT(Rect2i, p_var.operator ::Rect2i());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Rect2i), &from);
|
||||||
|
}
|
||||||
case Variant::VECTOR3: {
|
case Variant::VECTOR3: {
|
||||||
GDMonoMarshal::M_Vector3 from = MARSHALLED_OUT(Vector3, p_var.operator ::Vector3());
|
GDMonoMarshal::M_Vector3 from = MARSHALLED_OUT(Vector3, p_var.operator ::Vector3());
|
||||||
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector3), &from);
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector3), &from);
|
||||||
}
|
}
|
||||||
|
case Variant::VECTOR3I: {
|
||||||
|
GDMonoMarshal::M_Vector3i from = MARSHALLED_OUT(Vector3i, p_var.operator ::Vector3i());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector3i), &from);
|
||||||
|
}
|
||||||
|
case Variant::VECTOR4: {
|
||||||
|
GDMonoMarshal::M_Vector4 from = MARSHALLED_OUT(Vector4, p_var.operator ::Vector4());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector4), &from);
|
||||||
|
}
|
||||||
|
case Variant::VECTOR4I: {
|
||||||
|
GDMonoMarshal::M_Vector4i from = MARSHALLED_OUT(Vector4i, p_var.operator ::Vector4i());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Vector4i), &from);
|
||||||
|
}
|
||||||
case Variant::TRANSFORM2D: {
|
case Variant::TRANSFORM2D: {
|
||||||
GDMonoMarshal::M_Transform2D from = MARSHALLED_OUT(Transform2D, p_var.operator ::Transform2D());
|
GDMonoMarshal::M_Transform2D from = MARSHALLED_OUT(Transform2D, p_var.operator ::Transform2D());
|
||||||
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform2D), &from);
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform2D), &from);
|
||||||
@ -522,12 +638,18 @@ MonoObject *variant_to_mono_object(const Variant &p_var) {
|
|||||||
GDMonoMarshal::M_Transform from = MARSHALLED_OUT(Transform, p_var.operator ::Transform());
|
GDMonoMarshal::M_Transform from = MARSHALLED_OUT(Transform, p_var.operator ::Transform());
|
||||||
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform), &from);
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Transform), &from);
|
||||||
}
|
}
|
||||||
|
case Variant::PROJECTION: {
|
||||||
|
GDMonoMarshal::M_Projection from = MARSHALLED_OUT(Projection, p_var.operator ::Projection());
|
||||||
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Projection), &from);
|
||||||
|
}
|
||||||
case Variant::COLOR: {
|
case Variant::COLOR: {
|
||||||
GDMonoMarshal::M_Color from = MARSHALLED_OUT(Color, p_var.operator ::Color());
|
GDMonoMarshal::M_Color from = MARSHALLED_OUT(Color, p_var.operator ::Color());
|
||||||
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Color), &from);
|
return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(Color), &from);
|
||||||
}
|
}
|
||||||
case Variant::NODE_PATH:
|
case Variant::NODE_PATH:
|
||||||
return GDMonoUtils::create_managed_from(p_var.operator NodePath());
|
return GDMonoUtils::create_managed_from(p_var.operator NodePath());
|
||||||
|
case Variant::STRING_NAME:
|
||||||
|
return GDMonoUtils::create_managed_from(p_var.operator StringName());
|
||||||
case Variant::RID:
|
case Variant::RID:
|
||||||
return GDMonoUtils::create_managed_from(p_var.operator ::RID());
|
return GDMonoUtils::create_managed_from(p_var.operator ::RID());
|
||||||
case Variant::OBJECT:
|
case Variant::OBJECT:
|
||||||
@ -546,8 +668,16 @@ MonoObject *variant_to_mono_object(const Variant &p_var) {
|
|||||||
return (MonoObject *)PoolStringArray_to_mono_array(p_var.operator PoolStringArray());
|
return (MonoObject *)PoolStringArray_to_mono_array(p_var.operator PoolStringArray());
|
||||||
case Variant::POOL_VECTOR2_ARRAY:
|
case Variant::POOL_VECTOR2_ARRAY:
|
||||||
return (MonoObject *)PoolVector2Array_to_mono_array(p_var.operator PoolVector2Array());
|
return (MonoObject *)PoolVector2Array_to_mono_array(p_var.operator PoolVector2Array());
|
||||||
|
case Variant::POOL_VECTOR2I_ARRAY:
|
||||||
|
return (MonoObject *)PoolVector2iArray_to_mono_array(p_var.operator PoolVector2iArray());
|
||||||
case Variant::POOL_VECTOR3_ARRAY:
|
case Variant::POOL_VECTOR3_ARRAY:
|
||||||
return (MonoObject *)PoolVector3Array_to_mono_array(p_var.operator PoolVector3Array());
|
return (MonoObject *)PoolVector3Array_to_mono_array(p_var.operator PoolVector3Array());
|
||||||
|
case Variant::POOL_VECTOR3I_ARRAY:
|
||||||
|
return (MonoObject *)PoolVector3iArray_to_mono_array(p_var.operator PoolVector3iArray());
|
||||||
|
case Variant::POOL_VECTOR4_ARRAY:
|
||||||
|
return (MonoObject *)PoolVector4Array_to_mono_array(p_var.operator PoolVector4Array());
|
||||||
|
case Variant::POOL_VECTOR4I_ARRAY:
|
||||||
|
return (MonoObject *)PoolVector4iArray_to_mono_array(p_var.operator PoolVector4iArray());
|
||||||
case Variant::POOL_COLOR_ARRAY:
|
case Variant::POOL_COLOR_ARRAY:
|
||||||
return (MonoObject *)PoolColorArray_to_mono_array(p_var.operator PoolColorArray());
|
return (MonoObject *)PoolColorArray_to_mono_array(p_var.operator PoolColorArray());
|
||||||
default:
|
default:
|
||||||
@ -597,11 +727,17 @@ size_t variant_get_managed_unboxed_size(const ManagedType &p_type) {
|
|||||||
|
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector2);
|
RETURN_CHECK_FOR_STRUCT(Vector2);
|
||||||
RETURN_CHECK_FOR_STRUCT(Rect2);
|
RETURN_CHECK_FOR_STRUCT(Rect2);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector2i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Rect2i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector3);
|
RETURN_CHECK_FOR_STRUCT(Vector3);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector3i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Basis);
|
RETURN_CHECK_FOR_STRUCT(Basis);
|
||||||
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform);
|
RETURN_CHECK_FOR_STRUCT(Transform);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Projection);
|
||||||
RETURN_CHECK_FOR_STRUCT(AABB);
|
RETURN_CHECK_FOR_STRUCT(AABB);
|
||||||
RETURN_CHECK_FOR_STRUCT(Color);
|
RETURN_CHECK_FOR_STRUCT(Color);
|
||||||
RETURN_CHECK_FOR_STRUCT(Plane);
|
RETURN_CHECK_FOR_STRUCT(Plane);
|
||||||
@ -697,11 +833,17 @@ void *variant_to_managed_unboxed(const Variant &p_var, const ManagedType &p_type
|
|||||||
|
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector2);
|
RETURN_CHECK_FOR_STRUCT(Vector2);
|
||||||
RETURN_CHECK_FOR_STRUCT(Rect2);
|
RETURN_CHECK_FOR_STRUCT(Rect2);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector2i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Rect2i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector3);
|
RETURN_CHECK_FOR_STRUCT(Vector3);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector3i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Basis);
|
RETURN_CHECK_FOR_STRUCT(Basis);
|
||||||
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform);
|
RETURN_CHECK_FOR_STRUCT(Transform);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Projection);
|
||||||
RETURN_CHECK_FOR_STRUCT(AABB);
|
RETURN_CHECK_FOR_STRUCT(AABB);
|
||||||
RETURN_CHECK_FOR_STRUCT(Color);
|
RETURN_CHECK_FOR_STRUCT(Color);
|
||||||
RETURN_CHECK_FOR_STRUCT(Plane);
|
RETURN_CHECK_FOR_STRUCT(Plane);
|
||||||
@ -837,11 +979,17 @@ MonoObject *variant_to_mono_object(const Variant &p_var, const ManagedType &p_ty
|
|||||||
|
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector2);
|
RETURN_CHECK_FOR_STRUCT(Vector2);
|
||||||
RETURN_CHECK_FOR_STRUCT(Rect2);
|
RETURN_CHECK_FOR_STRUCT(Rect2);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector2i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Rect2i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
RETURN_CHECK_FOR_STRUCT(Transform2D);
|
||||||
RETURN_CHECK_FOR_STRUCT(Vector3);
|
RETURN_CHECK_FOR_STRUCT(Vector3);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector3i);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Vector4i);
|
||||||
RETURN_CHECK_FOR_STRUCT(Basis);
|
RETURN_CHECK_FOR_STRUCT(Basis);
|
||||||
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
RETURN_CHECK_FOR_STRUCT(Quaternion);
|
||||||
RETURN_CHECK_FOR_STRUCT(Transform);
|
RETURN_CHECK_FOR_STRUCT(Transform);
|
||||||
|
RETURN_CHECK_FOR_STRUCT(Projection);
|
||||||
RETURN_CHECK_FOR_STRUCT(AABB);
|
RETURN_CHECK_FOR_STRUCT(AABB);
|
||||||
RETURN_CHECK_FOR_STRUCT(Color);
|
RETURN_CHECK_FOR_STRUCT(Color);
|
||||||
RETURN_CHECK_FOR_STRUCT(Plane);
|
RETURN_CHECK_FOR_STRUCT(Plane);
|
||||||
@ -951,38 +1099,73 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
|
|||||||
case MONO_TYPE_VALUETYPE: {
|
case MONO_TYPE_VALUETYPE: {
|
||||||
GDMonoClass *vtclass = p_type.type_class;
|
GDMonoClass *vtclass = p_type.type_class;
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Vector2))
|
if (vtclass == CACHED_CLASS(Vector2)) {
|
||||||
return MARSHALLED_IN(Vector2, unbox_addr<GDMonoMarshal::M_Vector2>(p_obj));
|
return MARSHALLED_IN(Vector2, unbox_addr<GDMonoMarshal::M_Vector2>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Rect2))
|
if (vtclass == CACHED_CLASS(Rect2)) {
|
||||||
return MARSHALLED_IN(Rect2, unbox_addr<GDMonoMarshal::M_Rect2>(p_obj));
|
return MARSHALLED_IN(Rect2, unbox_addr<GDMonoMarshal::M_Rect2>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Transform2D))
|
if (vtclass == CACHED_CLASS(Vector2i)) {
|
||||||
|
return MARSHALLED_IN(Vector2i, unbox_addr<GDMonoMarshal::M_Vector2i>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Rect2i)) {
|
||||||
|
return MARSHALLED_IN(Rect2i, unbox_addr<GDMonoMarshal::M_Rect2i>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Transform2D)) {
|
||||||
return MARSHALLED_IN(Transform2D, unbox_addr<GDMonoMarshal::M_Transform2D>(p_obj));
|
return MARSHALLED_IN(Transform2D, unbox_addr<GDMonoMarshal::M_Transform2D>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Vector3))
|
if (vtclass == CACHED_CLASS(Vector3)) {
|
||||||
return MARSHALLED_IN(Vector3, unbox_addr<GDMonoMarshal::M_Vector3>(p_obj));
|
return MARSHALLED_IN(Vector3, unbox_addr<GDMonoMarshal::M_Vector3>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Basis))
|
if (vtclass == CACHED_CLASS(Vector3i)) {
|
||||||
|
return MARSHALLED_IN(Vector3i, unbox_addr<GDMonoMarshal::M_Vector3i>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Vector4)) {
|
||||||
|
return MARSHALLED_IN(Vector4, unbox_addr<GDMonoMarshal::M_Vector4>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Vector4i)) {
|
||||||
|
return MARSHALLED_IN(Vector4i, unbox_addr<GDMonoMarshal::M_Vector4i>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(Basis)) {
|
||||||
return MARSHALLED_IN(Basis, unbox_addr<GDMonoMarshal::M_Basis>(p_obj));
|
return MARSHALLED_IN(Basis, unbox_addr<GDMonoMarshal::M_Basis>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Quaternion))
|
if (vtclass == CACHED_CLASS(Quaternion)) {
|
||||||
return MARSHALLED_IN(Quaternion, unbox_addr<GDMonoMarshal::M_Quaternion>(p_obj));
|
return MARSHALLED_IN(Quaternion, unbox_addr<GDMonoMarshal::M_Quaternion>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Transform))
|
if (vtclass == CACHED_CLASS(Transform)) {
|
||||||
return MARSHALLED_IN(Transform, unbox_addr<GDMonoMarshal::M_Transform>(p_obj));
|
return MARSHALLED_IN(Transform, unbox_addr<GDMonoMarshal::M_Transform>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(AABB))
|
if (vtclass == CACHED_CLASS(Projection)) {
|
||||||
|
return MARSHALLED_IN(Projection, unbox_addr<GDMonoMarshal::M_Projection>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtclass == CACHED_CLASS(AABB)) {
|
||||||
return MARSHALLED_IN(AABB, unbox_addr<GDMonoMarshal::M_AABB>(p_obj));
|
return MARSHALLED_IN(AABB, unbox_addr<GDMonoMarshal::M_AABB>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Color))
|
if (vtclass == CACHED_CLASS(Color)) {
|
||||||
return MARSHALLED_IN(Color, unbox_addr<GDMonoMarshal::M_Color>(p_obj));
|
return MARSHALLED_IN(Color, unbox_addr<GDMonoMarshal::M_Color>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (vtclass == CACHED_CLASS(Plane))
|
if (vtclass == CACHED_CLASS(Plane)) {
|
||||||
return MARSHALLED_IN(Plane, unbox_addr<GDMonoMarshal::M_Plane>(p_obj));
|
return MARSHALLED_IN(Plane, unbox_addr<GDMonoMarshal::M_Plane>(p_obj));
|
||||||
|
}
|
||||||
|
|
||||||
if (mono_class_is_enum(vtclass->get_mono_ptr()))
|
if (mono_class_is_enum(vtclass->get_mono_ptr())) {
|
||||||
return unbox<int32_t>(p_obj);
|
return unbox<int32_t>(p_obj);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case MONO_TYPE_STRING: {
|
case MONO_TYPE_STRING: {
|
||||||
if (p_obj == NULL) {
|
if (p_obj == NULL) {
|
||||||
@ -994,39 +1177,70 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
|
|||||||
case MONO_TYPE_SZARRAY: {
|
case MONO_TYPE_SZARRAY: {
|
||||||
MonoArrayType *array_type = mono_type_get_array_type(p_type.type_class->get_mono_type());
|
MonoArrayType *array_type = mono_type_get_array_type(p_type.type_class->get_mono_type());
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject))
|
if (array_type->eklass == CACHED_CLASS_RAW(MonoObject)) {
|
||||||
return mono_array_to_Array((MonoArray *)p_obj);
|
return mono_array_to_Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t))
|
if (array_type->eklass == CACHED_CLASS_RAW(uint8_t)) {
|
||||||
return mono_array_to_PoolByteArray((MonoArray *)p_obj);
|
return mono_array_to_PoolByteArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(int32_t))
|
if (array_type->eklass == CACHED_CLASS_RAW(int32_t)) {
|
||||||
return mono_array_to_PoolIntArray((MonoArray *)p_obj);
|
return mono_array_to_PoolIntArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == REAL_T_MONOCLASS)
|
if (array_type->eklass == REAL_T_MONOCLASS) {
|
||||||
return mono_array_to_PoolRealArray((MonoArray *)p_obj);
|
return mono_array_to_PoolRealArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(String))
|
if (array_type->eklass == CACHED_CLASS_RAW(String)) {
|
||||||
return mono_array_to_PoolStringArray((MonoArray *)p_obj);
|
return mono_array_to_PoolStringArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(Vector2))
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector2)) {
|
||||||
return mono_array_to_PoolVector2Array((MonoArray *)p_obj);
|
return mono_array_to_PoolVector2Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(Vector3))
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector2i)) {
|
||||||
|
return mono_array_to_PoolVector2iArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
|
||||||
return mono_array_to_PoolVector3Array((MonoArray *)p_obj);
|
return mono_array_to_PoolVector3Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(Color))
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector3i)) {
|
||||||
|
return mono_array_to_PoolVector3iArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector4)) {
|
||||||
|
return mono_array_to_PoolVector4Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Vector4i)) {
|
||||||
|
return mono_array_to_PoolVector4iArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
|
||||||
return mono_array_to_PoolColorArray((MonoArray *)p_obj);
|
return mono_array_to_PoolColorArray((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(NodePath))
|
if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) {
|
||||||
return mono_array_to_Array((MonoArray *)p_obj);
|
return mono_array_to_Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_type->eklass == CACHED_CLASS_RAW(RID))
|
if (array_type->eklass == CACHED_CLASS_RAW(StringName)) {
|
||||||
return mono_array_to_Array((MonoArray *)p_obj);
|
return mono_array_to_Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_type->eklass == CACHED_CLASS_RAW(RID)) {
|
||||||
|
return mono_array_to_Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
|
GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
|
||||||
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class))
|
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) {
|
||||||
return mono_array_to_Array((MonoArray *)p_obj);
|
return mono_array_to_Array((MonoArray *)p_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (p_fail_with_err) {
|
if (p_fail_with_err) {
|
||||||
ERR_FAIL_V_MSG(Variant(), "Attempted to convert a managed array of unmarshallable element type to Variant.");
|
ERR_FAIL_V_MSG(Variant(), "Attempted to convert a managed array of unmarshallable element type to Variant.");
|
||||||
@ -1052,6 +1266,11 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
|
|||||||
return ptr ? Variant(*ptr) : Variant();
|
return ptr ? Variant(*ptr) : Variant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CACHED_CLASS(StringName) == type_class) {
|
||||||
|
StringName *ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_obj));
|
||||||
|
return ptr ? Variant(*ptr) : Variant();
|
||||||
|
}
|
||||||
|
|
||||||
if (CACHED_CLASS(RID) == type_class) {
|
if (CACHED_CLASS(RID) == type_class) {
|
||||||
RID *ptr = unbox<RID *>(CACHED_FIELD(RID, ptr)->get_value(p_obj));
|
RID *ptr = unbox<RID *>(CACHED_FIELD(RID, ptr)->get_value(p_obj));
|
||||||
return ptr ? Variant(*ptr) : Variant();
|
return ptr ? Variant(*ptr) : Variant();
|
||||||
@ -1128,8 +1347,9 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type
|
|||||||
}
|
}
|
||||||
|
|
||||||
Variant mono_object_to_variant(MonoObject *p_obj) {
|
Variant mono_object_to_variant(MonoObject *p_obj) {
|
||||||
if (!p_obj)
|
if (!p_obj) {
|
||||||
return Variant();
|
return Variant();
|
||||||
|
}
|
||||||
|
|
||||||
ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj));
|
ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj));
|
||||||
|
|
||||||
@ -1137,15 +1357,17 @@ Variant mono_object_to_variant(MonoObject *p_obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
|
Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
|
||||||
if (!p_obj)
|
if (!p_obj) {
|
||||||
return Variant();
|
return Variant();
|
||||||
|
}
|
||||||
|
|
||||||
return mono_object_to_variant_impl(p_obj, p_type);
|
return mono_object_to_variant_impl(p_obj, p_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant mono_object_to_variant_no_err(MonoObject *p_obj, const ManagedType &p_type) {
|
Variant mono_object_to_variant_no_err(MonoObject *p_obj, const ManagedType &p_type) {
|
||||||
if (!p_obj)
|
if (!p_obj) {
|
||||||
return Variant();
|
return Variant();
|
||||||
|
}
|
||||||
|
|
||||||
return mono_object_to_variant_impl(p_obj, p_type, /* fail_with_err: */ false);
|
return mono_object_to_variant_impl(p_obj, p_type, /* fail_with_err: */ false);
|
||||||
}
|
}
|
||||||
@ -1164,8 +1386,9 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) {
|
|||||||
MonoString *mono_str = GDMonoUtils::object_to_string(p_obj, &exc);
|
MonoString *mono_str = GDMonoUtils::object_to_string(p_obj, &exc);
|
||||||
|
|
||||||
if (exc) {
|
if (exc) {
|
||||||
if (r_exc)
|
if (r_exc) {
|
||||||
*r_exc = exc;
|
*r_exc = exc;
|
||||||
|
}
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1285,8 +1508,9 @@ MonoArray *Array_to_mono_array(const Array &p_array, MonoClass *p_array_type_cla
|
|||||||
|
|
||||||
Array mono_array_to_Array(MonoArray *p_array) {
|
Array mono_array_to_Array(MonoArray *p_array) {
|
||||||
Array ret;
|
Array ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
|
|
||||||
@ -1314,8 +1538,9 @@ MonoArray *PoolIntArray_to_mono_array(const PoolIntArray &p_array) {
|
|||||||
|
|
||||||
PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
|
PoolIntArray mono_array_to_PoolIntArray(MonoArray *p_array) {
|
||||||
PoolIntArray ret;
|
PoolIntArray ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolIntArray::Write w = ret.write();
|
PoolIntArray::Write w = ret.write();
|
||||||
@ -1341,8 +1566,9 @@ MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) {
|
|||||||
|
|
||||||
PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
|
PoolByteArray mono_array_to_PoolByteArray(MonoArray *p_array) {
|
||||||
PoolByteArray ret;
|
PoolByteArray ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolByteArray::Write w = ret.write();
|
PoolByteArray::Write w = ret.write();
|
||||||
@ -1368,8 +1594,9 @@ MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) {
|
|||||||
|
|
||||||
PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
|
PoolRealArray mono_array_to_PoolRealArray(MonoArray *p_array) {
|
||||||
PoolRealArray ret;
|
PoolRealArray ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolRealArray::Write w = ret.write();
|
PoolRealArray::Write w = ret.write();
|
||||||
@ -1396,8 +1623,9 @@ MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
|
|||||||
|
|
||||||
PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
|
PoolStringArray mono_array_to_PoolStringArray(MonoArray *p_array) {
|
||||||
PoolStringArray ret;
|
PoolStringArray ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolStringArray::Write w = ret.write();
|
PoolStringArray::Write w = ret.write();
|
||||||
@ -1425,8 +1653,9 @@ MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) {
|
|||||||
|
|
||||||
PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
|
PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array) {
|
||||||
PoolColorArray ret;
|
PoolColorArray ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolColorArray::Write w = ret.write();
|
PoolColorArray::Write w = ret.write();
|
||||||
@ -1453,8 +1682,9 @@ MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) {
|
|||||||
|
|
||||||
PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
|
PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
|
||||||
PoolVector2Array ret;
|
PoolVector2Array ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolVector2Array::Write w = ret.write();
|
PoolVector2Array::Write w = ret.write();
|
||||||
@ -1466,6 +1696,35 @@ PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonoArray *PoolVector2iArray_to_mono_array(const PoolVector2iArray &p_array) {
|
||||||
|
PoolVector2iArray::Read r = p_array.read();
|
||||||
|
|
||||||
|
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector2i), p_array.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < p_array.size(); i++) {
|
||||||
|
M_Vector2i *raw = (M_Vector2i *)mono_array_addr_with_size(ret, sizeof(M_Vector2i), i);
|
||||||
|
*raw = MARSHALLED_OUT(Vector2i, r[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector2iArray mono_array_to_PoolVector2iArray(MonoArray *p_array) {
|
||||||
|
PoolVector2iArray ret;
|
||||||
|
if (!p_array) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int length = mono_array_length(p_array);
|
||||||
|
ret.resize(length);
|
||||||
|
PoolVector2iArray::Write w = ret.write();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
w[i] = MARSHALLED_IN(Vector2i, (M_Vector2i *)mono_array_addr_with_size(p_array, sizeof(M_Vector2i), i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
|
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
|
||||||
PoolVector3Array::Read r = p_array.read();
|
PoolVector3Array::Read r = p_array.read();
|
||||||
|
|
||||||
@ -1481,8 +1740,9 @@ MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) {
|
|||||||
|
|
||||||
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
|
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
|
||||||
PoolVector3Array ret;
|
PoolVector3Array ret;
|
||||||
if (!p_array)
|
if (!p_array) {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
int length = mono_array_length(p_array);
|
int length = mono_array_length(p_array);
|
||||||
ret.resize(length);
|
ret.resize(length);
|
||||||
PoolVector3Array::Write w = ret.write();
|
PoolVector3Array::Write w = ret.write();
|
||||||
@ -1494,4 +1754,91 @@ PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonoArray *PoolVector3iArray_to_mono_array(const PoolVector3iArray &p_array) {
|
||||||
|
PoolVector3iArray::Read r = p_array.read();
|
||||||
|
|
||||||
|
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector3i), p_array.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < p_array.size(); i++) {
|
||||||
|
M_Vector3i *raw = (M_Vector3i *)mono_array_addr_with_size(ret, sizeof(M_Vector3i), i);
|
||||||
|
*raw = MARSHALLED_OUT(Vector3i, r[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector3iArray mono_array_to_PoolVector3iArray(MonoArray *p_array) {
|
||||||
|
PoolVector3iArray ret;
|
||||||
|
if (!p_array) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int length = mono_array_length(p_array);
|
||||||
|
ret.resize(length);
|
||||||
|
PoolVector3iArray::Write w = ret.write();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
w[i] = MARSHALLED_IN(Vector3i, (M_Vector3i *)mono_array_addr_with_size(p_array, sizeof(M_Vector3i), i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
MonoArray *PoolVector4Array_to_mono_array(const PoolVector4Array &p_array) {
|
||||||
|
PoolVector4Array::Read r = p_array.read();
|
||||||
|
|
||||||
|
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector4), p_array.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < p_array.size(); i++) {
|
||||||
|
M_Vector4 *raw = (M_Vector4 *)mono_array_addr_with_size(ret, sizeof(M_Vector4), i);
|
||||||
|
*raw = MARSHALLED_OUT(Vector4, r[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector4Array mono_array_to_PoolVector4Array(MonoArray *p_array) {
|
||||||
|
PoolVector4Array ret;
|
||||||
|
if (!p_array) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int length = mono_array_length(p_array);
|
||||||
|
ret.resize(length);
|
||||||
|
PoolVector4Array::Write w = ret.write();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
w[i] = MARSHALLED_IN(Vector4, (M_Vector4 *)mono_array_addr_with_size(p_array, sizeof(M_Vector4), i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
MonoArray *PoolVector4iArray_to_mono_array(const PoolVector4iArray &p_array) {
|
||||||
|
PoolVector4iArray::Read r = p_array.read();
|
||||||
|
|
||||||
|
MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector4i), p_array.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < p_array.size(); i++) {
|
||||||
|
M_Vector4i *raw = (M_Vector4i *)mono_array_addr_with_size(ret, sizeof(M_Vector4i), i);
|
||||||
|
*raw = MARSHALLED_OUT(Vector4i, r[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoolVector4iArray mono_array_to_PoolVector4iArray(MonoArray *p_array) {
|
||||||
|
PoolVector4iArray ret;
|
||||||
|
if (!p_array) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int length = mono_array_length(p_array);
|
||||||
|
ret.resize(length);
|
||||||
|
PoolVector4iArray::Write w = ret.write();
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
w[i] = MARSHALLED_IN(Vector4i, (M_Vector4i *)mono_array_addr_with_size(p_array, sizeof(M_Vector4i), i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GDMonoMarshal
|
} // namespace GDMonoMarshal
|
||||||
|
@ -191,16 +191,38 @@ PoolColorArray mono_array_to_PoolColorArray(MonoArray *p_array);
|
|||||||
MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array);
|
MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array);
|
||||||
PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array);
|
PoolVector2Array mono_array_to_PoolVector2Array(MonoArray *p_array);
|
||||||
|
|
||||||
|
// PoolVector2iArray
|
||||||
|
|
||||||
|
MonoArray *PoolVector2iArray_to_mono_array(const PoolVector2iArray &p_array);
|
||||||
|
PoolVector2iArray mono_array_to_PoolVector2iArray(MonoArray *p_array);
|
||||||
|
|
||||||
// PoolVector3Array
|
// PoolVector3Array
|
||||||
|
|
||||||
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array);
|
MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array);
|
||||||
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array);
|
PoolVector3Array mono_array_to_PoolVector3Array(MonoArray *p_array);
|
||||||
|
|
||||||
|
// PoolVector3iArray
|
||||||
|
|
||||||
|
MonoArray *PoolVector3iArray_to_mono_array(const PoolVector3iArray &p_array);
|
||||||
|
PoolVector3iArray mono_array_to_PoolVector3iArray(MonoArray *p_array);
|
||||||
|
|
||||||
|
// PoolVector4Array
|
||||||
|
|
||||||
|
MonoArray *PoolVector4Array_to_mono_array(const PoolVector4Array &p_array);
|
||||||
|
PoolVector4Array mono_array_to_PoolVector4Array(MonoArray *p_array);
|
||||||
|
|
||||||
|
// PoolVector4iArray
|
||||||
|
|
||||||
|
MonoArray *PoolVector4iArray_to_mono_array(const PoolVector4iArray &p_array);
|
||||||
|
PoolVector4iArray mono_array_to_PoolVector4iArray(MonoArray *p_array);
|
||||||
|
|
||||||
// Structures
|
// Structures
|
||||||
|
|
||||||
namespace InteropLayout {
|
namespace InteropLayout {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
MATCHES_int = (sizeof(int) == sizeof(int32_t)),
|
||||||
|
|
||||||
MATCHES_float = (sizeof(float) == sizeof(uint32_t)),
|
MATCHES_float = (sizeof(float) == sizeof(uint32_t)),
|
||||||
|
|
||||||
MATCHES_double = (sizeof(double) == sizeof(uint64_t)),
|
MATCHES_double = (sizeof(double) == sizeof(uint64_t)),
|
||||||
@ -219,6 +241,14 @@ enum {
|
|||||||
offsetof(Rect2, position) == (sizeof(Vector2) * 0) &&
|
offsetof(Rect2, position) == (sizeof(Vector2) * 0) &&
|
||||||
offsetof(Rect2, size) == (sizeof(Vector2) * 1)),
|
offsetof(Rect2, size) == (sizeof(Vector2) * 1)),
|
||||||
|
|
||||||
|
MATCHES_Vector2i = (MATCHES_int && (sizeof(Vector2i) == (sizeof(int32_t) * 2)) &&
|
||||||
|
offsetof(Vector2i, x) == (sizeof(int32_t) * 0) &&
|
||||||
|
offsetof(Vector2i, y) == (sizeof(int32_t) * 1)),
|
||||||
|
|
||||||
|
MATCHES_Rect2i = (MATCHES_Vector2i && (sizeof(Rect2i) == (sizeof(Vector2i) * 2)) &&
|
||||||
|
offsetof(Rect2i, position) == (sizeof(Vector2i) * 0) &&
|
||||||
|
offsetof(Rect2i, size) == (sizeof(Vector2i) * 1)),
|
||||||
|
|
||||||
MATCHES_Transform2D = (MATCHES_Vector2 && (sizeof(Transform2D) == (sizeof(Vector2) * 3))), // No field offset required, it stores an array
|
MATCHES_Transform2D = (MATCHES_Vector2 && (sizeof(Transform2D) == (sizeof(Vector2) * 3))), // No field offset required, it stores an array
|
||||||
|
|
||||||
MATCHES_Vector3 = (MATCHES_real_t && (sizeof(Vector3) == (sizeof(real_t) * 3)) &&
|
MATCHES_Vector3 = (MATCHES_real_t && (sizeof(Vector3) == (sizeof(real_t) * 3)) &&
|
||||||
@ -226,8 +256,27 @@ enum {
|
|||||||
offsetof(Vector3, y) == (sizeof(real_t) * 1) &&
|
offsetof(Vector3, y) == (sizeof(real_t) * 1) &&
|
||||||
offsetof(Vector3, z) == (sizeof(real_t) * 2)),
|
offsetof(Vector3, z) == (sizeof(real_t) * 2)),
|
||||||
|
|
||||||
|
MATCHES_Vector3i = (MATCHES_int && (sizeof(Vector3i) == (sizeof(int32_t) * 3)) &&
|
||||||
|
offsetof(Vector3i, x) == (sizeof(int32_t) * 0) &&
|
||||||
|
offsetof(Vector3i, y) == (sizeof(int32_t) * 1) &&
|
||||||
|
offsetof(Vector3i, z) == (sizeof(int32_t) * 2)),
|
||||||
|
|
||||||
|
MATCHES_Vector4 = (MATCHES_real_t && (sizeof(Vector4) == (sizeof(real_t) * 4)) &&
|
||||||
|
offsetof(Vector4, x) == (sizeof(real_t) * 0) &&
|
||||||
|
offsetof(Vector4, y) == (sizeof(real_t) * 1) &&
|
||||||
|
offsetof(Vector4, z) == (sizeof(real_t) * 2) &&
|
||||||
|
offsetof(Vector4, w) == (sizeof(real_t) * 2)),
|
||||||
|
|
||||||
|
MATCHES_Vector4i = (MATCHES_int && (sizeof(Vector4i) == (sizeof(int32_t) * 4)) &&
|
||||||
|
offsetof(Vector4i, x) == (sizeof(int32_t) * 0) &&
|
||||||
|
offsetof(Vector4i, y) == (sizeof(int32_t) * 1) &&
|
||||||
|
offsetof(Vector4i, z) == (sizeof(int32_t) * 2) &&
|
||||||
|
offsetof(Vector4i, w) == (sizeof(int32_t) * 2)),
|
||||||
|
|
||||||
MATCHES_Basis = (MATCHES_Vector3 && (sizeof(Basis) == (sizeof(Vector3) * 3))), // No field offset required, it stores an array
|
MATCHES_Basis = (MATCHES_Vector3 && (sizeof(Basis) == (sizeof(Vector3) * 3))), // No field offset required, it stores an array
|
||||||
|
|
||||||
|
MATCHES_Projection = (MATCHES_Vector4 && (sizeof(Projection) == (sizeof(Vector4) * 4))), // No field offset required, it stores an array
|
||||||
|
|
||||||
MATCHES_Quaternion = (MATCHES_real_t && (sizeof(Quaternion) == (sizeof(real_t) * 4)) &&
|
MATCHES_Quaternion = (MATCHES_real_t && (sizeof(Quaternion) == (sizeof(real_t) * 4)) &&
|
||||||
offsetof(Quaternion, x) == (sizeof(real_t) * 0) &&
|
offsetof(Quaternion, x) == (sizeof(real_t) * 0) &&
|
||||||
offsetof(Quaternion, y) == (sizeof(real_t) * 1) &&
|
offsetof(Quaternion, y) == (sizeof(real_t) * 1) &&
|
||||||
@ -293,6 +342,34 @@ struct M_Rect2 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct M_Vector2i {
|
||||||
|
int32_t x, y;
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Vector2i convert_to(const M_Vector2i &p_from) {
|
||||||
|
return Vector2(p_from.x, p_from.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Vector2i convert_from(const Vector2i &p_from) {
|
||||||
|
M_Vector2i ret = { p_from.x, p_from.y };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct M_Rect2i {
|
||||||
|
M_Vector2i position;
|
||||||
|
M_Vector2i size;
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Rect2i convert_to(const M_Rect2i &p_from) {
|
||||||
|
return Rect2i(M_Vector2i::convert_to(p_from.position),
|
||||||
|
M_Vector2i::convert_to(p_from.size));
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Rect2i convert_from(const Rect2i &p_from) {
|
||||||
|
M_Rect2i ret = { M_Vector2i::convert_from(p_from.position), M_Vector2i::convert_from(p_from.size) };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct M_Transform2D {
|
struct M_Transform2D {
|
||||||
M_Vector2 columns[3];
|
M_Vector2 columns[3];
|
||||||
|
|
||||||
@ -325,6 +402,45 @@ struct M_Vector3 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct M_Vector3i {
|
||||||
|
int32_t x, y, z;
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Vector3i convert_to(const M_Vector3i &p_from) {
|
||||||
|
return Vector3i(p_from.x, p_from.y, p_from.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Vector3i convert_from(const Vector3i &p_from) {
|
||||||
|
M_Vector3i ret = { p_from.x, p_from.y, p_from.z };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct M_Vector4 {
|
||||||
|
real_t x, y, z, w;
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Vector4 convert_to(const M_Vector4 &p_from) {
|
||||||
|
return Vector4(p_from.x, p_from.y, p_from.z, p_from.w);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Vector4 convert_from(const Vector4 &p_from) {
|
||||||
|
M_Vector4 ret = { p_from.x, p_from.y, p_from.z, p_from.w };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct M_Vector4i {
|
||||||
|
int32_t x, y, z, w;
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Vector4i convert_to(const M_Vector4i &p_from) {
|
||||||
|
return Vector4i(p_from.x, p_from.y, p_from.z, p_from.w);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Vector4i convert_from(const Vector4i &p_from) {
|
||||||
|
M_Vector4i ret = { p_from.x, p_from.y, p_from.z, p_from.w };
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct M_Basis {
|
struct M_Basis {
|
||||||
M_Vector3 rows[3];
|
M_Vector3 rows[3];
|
||||||
|
|
||||||
@ -344,6 +460,28 @@ struct M_Basis {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct M_Projection {
|
||||||
|
M_Vector4 matrix[4];
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ Projection convert_to(const M_Projection &p_from) {
|
||||||
|
return Projection(M_Vector4::convert_to(p_from.matrix[0]),
|
||||||
|
M_Vector4::convert_to(p_from.matrix[1]),
|
||||||
|
M_Vector4::convert_to(p_from.matrix[2]),
|
||||||
|
M_Vector4::convert_to(p_from.matrix[3])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _FORCE_INLINE_ M_Projection convert_from(const Projection &p_from) {
|
||||||
|
M_Projection ret = {
|
||||||
|
M_Vector4::convert_from(p_from.matrix[0]),
|
||||||
|
M_Vector4::convert_from(p_from.matrix[1]),
|
||||||
|
M_Vector4::convert_from(p_from.matrix[2]),
|
||||||
|
M_Vector4::convert_from(p_from.matrix[3])
|
||||||
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct M_Quaternion {
|
struct M_Quaternion {
|
||||||
real_t x, y, z, w;
|
real_t x, y, z, w;
|
||||||
|
|
||||||
@ -449,13 +587,19 @@ struct M_Plane {
|
|||||||
return marshalled_out_##m_type##_impl<InteropLayout::MATCHES_##m_type>(p_from); \
|
return marshalled_out_##m_type##_impl<InteropLayout::MATCHES_##m_type>(p_from); \
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Vector2)
|
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Rect2)
|
DECL_TYPE_MARSHAL_TEMPLATES(Rect2)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Rect2i)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Transform2D)
|
DECL_TYPE_MARSHAL_TEMPLATES(Transform2D)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector2)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector2i)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Vector3)
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector3)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector3i)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector4)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Vector4i)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Basis)
|
DECL_TYPE_MARSHAL_TEMPLATES(Basis)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Quaternion)
|
DECL_TYPE_MARSHAL_TEMPLATES(Quaternion)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Transform)
|
DECL_TYPE_MARSHAL_TEMPLATES(Transform)
|
||||||
|
DECL_TYPE_MARSHAL_TEMPLATES(Projection)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(AABB)
|
DECL_TYPE_MARSHAL_TEMPLATES(AABB)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Color)
|
DECL_TYPE_MARSHAL_TEMPLATES(Color)
|
||||||
DECL_TYPE_MARSHAL_TEMPLATES(Plane)
|
DECL_TYPE_MARSHAL_TEMPLATES(Plane)
|
||||||
|
@ -160,11 +160,13 @@ MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, Mono
|
|||||||
bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) {
|
bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) {
|
||||||
ERR_FAIL_NULL_V(p_attr_class, false);
|
ERR_FAIL_NULL_V(p_attr_class, false);
|
||||||
|
|
||||||
if (!attrs_fetched)
|
if (!attrs_fetched) {
|
||||||
fetch_attributes();
|
fetch_attributes();
|
||||||
|
}
|
||||||
|
|
||||||
if (!attributes)
|
if (!attributes) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return mono_custom_attrs_has_attr(attributes, p_attr_class->get_mono_ptr());
|
return mono_custom_attrs_has_attr(attributes, p_attr_class->get_mono_ptr());
|
||||||
}
|
}
|
||||||
@ -172,11 +174,13 @@ bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) {
|
|||||||
MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) {
|
MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) {
|
||||||
ERR_FAIL_NULL_V(p_attr_class, NULL);
|
ERR_FAIL_NULL_V(p_attr_class, NULL);
|
||||||
|
|
||||||
if (!attrs_fetched)
|
if (!attrs_fetched) {
|
||||||
fetch_attributes();
|
fetch_attributes();
|
||||||
|
}
|
||||||
|
|
||||||
if (!attributes)
|
if (!attributes) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
|
return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr());
|
||||||
}
|
}
|
||||||
|
@ -234,6 +234,18 @@ MonoObject *create_managed_from(const NodePath &p_from) {
|
|||||||
return mono_object;
|
return mono_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonoObject *create_managed_from(const StringName &p_from) {
|
||||||
|
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(StringName));
|
||||||
|
ERR_FAIL_NULL_V(mono_object, NULL);
|
||||||
|
|
||||||
|
// Construct
|
||||||
|
GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(StringName));
|
||||||
|
|
||||||
|
CACHED_FIELD(StringName, ptr)->set_value_raw(mono_object, memnew(StringName(p_from)));
|
||||||
|
|
||||||
|
return mono_object;
|
||||||
|
}
|
||||||
|
|
||||||
MonoObject *create_managed_from(const RID &p_from) {
|
MonoObject *create_managed_from(const RID &p_from) {
|
||||||
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(RID));
|
MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(RID));
|
||||||
ERR_FAIL_NULL_V(mono_object, NULL);
|
ERR_FAIL_NULL_V(mono_object, NULL);
|
||||||
|
@ -104,6 +104,7 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class);
|
|||||||
MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object);
|
MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object);
|
||||||
|
|
||||||
MonoObject *create_managed_from(const NodePath &p_from);
|
MonoObject *create_managed_from(const NodePath &p_from);
|
||||||
|
MonoObject *create_managed_from(const StringName &p_from);
|
||||||
MonoObject *create_managed_from(const RID &p_from);
|
MonoObject *create_managed_from(const RID &p_from);
|
||||||
MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class);
|
MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class);
|
||||||
MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class);
|
MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class);
|
||||||
|
Loading…
Reference in New Issue
Block a user