diff --git a/csharp_script.cpp b/csharp_script.cpp index c0f2367..5941df3 100644 --- a/csharp_script.cpp +++ b/csharp_script.cpp @@ -409,15 +409,17 @@ bool CSharpLanguage::supports_builtin_mode() const { #ifdef TOOLS_ENABLED static String variant_type_to_managed_name(const String &p_var_type_name) { - if (p_var_type_name.empty()) + if (p_var_type_name.empty()) { return "object"; + } if (!ClassDB::class_exists(p_var_type_name)) { return p_var_type_name; } - if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) + if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) { return "Godot.Object"; + } if (p_var_type_name == Variant::get_type_name(Variant::REAL)) { #ifdef REAL_T_IS_DOUBLE @@ -427,19 +429,26 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { #endif } - if (p_var_type_name == Variant::get_type_name(Variant::STRING)) + if (p_var_type_name == Variant::get_type_name(Variant::STRING)) { return "string"; // I prefer this one >:[ + } - if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY)) + if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY)) { return "Collections.Dictionary"; + } - if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) + if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) { return "Collections.Array"; + } - if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY)) + if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY)) { return "byte[]"; - if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY)) + } + + if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY)) { return "int[]"; + } + if (p_var_type_name == Variant::get_type_name(Variant::POOL_REAL_ARRAY)) { #ifdef REAL_T_IS_DOUBLE return "double[]"; @@ -447,14 +456,21 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { return "float[]"; #endif } - if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY)) + if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY)) { return "string[]"; - if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY)) + } + + if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY)) { return "Vector2[]"; - if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY)) + } + + if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY)) { return "Vector3[]"; - if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY)) + } + + if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY)) { return "Color[]"; + } Variant::Type var_types[] = { Variant::BOOL, @@ -474,8 +490,9 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { }; for (unsigned int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) { - if (p_var_type_name == Variant::get_type_name(var_types[i])) + if (p_var_type_name == Variant::get_type_name(var_types[i])) { return p_var_type_name; + } } return "object"; diff --git a/glue/GodotSharp/GodotSharp/Core/Projection.cs b/glue/GodotSharp/GodotSharp/Core/Projection.cs new file mode 100644 index 0000000..e552ff0 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Projection.cs @@ -0,0 +1,109 @@ +#if REAL_T_IS_DOUBLE +using real_t = System.Double; +#else +using real_t = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Projection : IEquatable + { + /// + /// Row 0 of the basis matrix. Shows which vectors contribute + /// to the X direction. Rows are not very useful for user code, + /// but are more efficient for some internal calculations. + /// + public Vector4 Row0; + + /// + /// Row 1 of the basis matrix. Shows which vectors contribute + /// to the Y direction. Rows are not very useful for user code, + /// but are more efficient for some internal calculations. + /// + public Vector4 Row1; + + /// + /// Row 2 of the basis matrix. Shows which vectors contribute + /// to the Z direction. Rows are not very useful for user code, + /// but are more efficient for some internal calculations. + /// + public Vector4 Row2; + + + public Vector4 Row3; + + + /// + /// Returns if the is + /// exactly equal to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The object to compare with. + /// Whether or not the basis matrix and the object are exactly equal. + public override bool Equals(object obj) + { + if (obj is Projection) + { + return Equals((Projection)obj); + } + + return false; + } + + /// + /// Returns if the basis matrices are exactly + /// equal. Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The other basis. + /// Whether or not the basis matrices are exactly equal. + public bool Equals(Projection other) + { + return Row0.Equals(other.Row0) && Row1.Equals(other.Row1) && Row2.Equals(other.Row2) && Row3.Equals(other.Row2); + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this basis. + public override int GetHashCode() + { + return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode()^ Row3.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this basis. + public override string ToString() + { + return String.Format("({0}, {1}, {2}, {3})", new object[] + { + Row0.ToString(), + Row1.ToString(), + Row2.ToString(), + Row3.ToString() + }); + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this basis. + public string ToString(string format) + { + return String.Format("({0}, {1}, {2}, {3})", new object[] + { + Row0.ToString(format), + Row1.ToString(format), + Row2.ToString(format), + Row3.ToString(format) + }); + } + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/Rect2I.cs b/glue/GodotSharp/GodotSharp/Core/Rect2I.cs new file mode 100644 index 0000000..48af36a --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Rect2I.cs @@ -0,0 +1,151 @@ +#if REAL_T_IS_DOUBLE +using real_t = System.Double; +#else +using real_t = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + /// + /// 2D axis-aligned bounding box. Rect2I consists of a position, a size, and + /// several utility functions. It is typically used for fast overlap tests. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Rect2I : IEquatable + { + private Vector2I _position; + private Vector2I _size; + + /// + /// Beginning corner. Typically has values lower than . + /// + /// Directly uses a private field. + public Vector2I Position + { + get { return _position; } + set { _position = value; } + } + + /// + /// Size from to . Typically all components are positive. + /// If the size is negative, you can use to fix it. + /// + /// Directly uses a private field. + public Vector2I Size + { + get { return _size; } + set { _size = value; } + } + + /// + /// Constructs a from a position and size. + /// + /// The position. + /// The size. + public Rect2I(Vector2I position, Vector2I size) + { + _position = position; + _size = size; + } + + /// + /// Constructs a from a position, width, and height. + /// + /// The position. + /// The width. + /// The height. + public Rect2I(Vector2I position, real_t width, real_t height) + { + _position = position; + _size = new Vector2I(width, height); + } + + /// + /// Constructs a from x, y, and size. + /// + /// The position's X coordinate. + /// The position's Y coordinate. + /// The size. + public Rect2I(real_t x, real_t y, Vector2I size) + { + _position = new Vector2I(x, y); + _size = size; + } + + /// + /// Constructs a from x, y, width, and height. + /// + /// The position's X coordinate. + /// The position's Y coordinate. + /// The width. + /// The height. + public Rect2I(real_t x, real_t y, real_t width, real_t height) + { + _position = new Vector2I(x, y); + _size = new Vector2I(width, height); + } + + /// + /// Returns if this rect and are equal. + /// + /// The other object to compare. + /// Whether or not the rect and the other object are exactly equal. + public override bool Equals(object obj) + { + if (obj is Rect2I) + { + return Equals((Rect2I)obj); + } + + return false; + } + + /// + /// Returns if this rect and are equal. + /// + /// The other rect to compare. + /// Whether or not the rects are exactly equal. + public bool Equals(Rect2I other) + { + return _position.Equals(other._position) && _size.Equals(other._size); + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this rect. + public override int GetHashCode() + { + return _position.GetHashCode() ^ _size.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this rect. + public override string ToString() + { + return String.Format("({0}, {1})", new object[] + { + _position.ToString(), + _size.ToString() + }); + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this rect. + public string ToString(string format) + { + return String.Format("({0}, {1})", new object[] + { + _position.ToString(format), + _size.ToString(format) + }); + } + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/StringName.cs b/glue/GodotSharp/GodotSharp/Core/StringName.cs new file mode 100644 index 0000000..4a19bf0 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/StringName.cs @@ -0,0 +1,117 @@ +using System; +using System.Runtime.CompilerServices; + +namespace Godot +{ + public sealed partial class StringName : IDisposable + { + private bool _disposed = false; + + private IntPtr ptr; + + internal static IntPtr GetPtr(StringName instance) + { + if (instance == null) + throw new NullReferenceException($"The instance of type {nameof(StringName)} is null."); + + if (instance._disposed) + throw new ObjectDisposedException(instance.GetType().FullName); + + return instance.ptr; + } + + ~StringName() + { + Dispose(false); + } + + /// + /// Disposes of this . + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed) + return; + + if (ptr != IntPtr.Zero) + { + godot_icall_StringName_Dtor(ptr); + ptr = IntPtr.Zero; + } + + _disposed = true; + } + + internal StringName(IntPtr ptr) + { + this.ptr = ptr; + } + + /// + /// The pointer to the native instance of this . + /// + public IntPtr NativeInstance + { + get { return ptr; } + } + + public StringName() { + ptr = godot_icall_StringName_Ctor(path); + } + + public StringName(string path) + { + ptr = godot_icall_StringName_String_Ctor(path); + } + + public static implicit operator StringName(string from) + { + return new StringName(from); + } + + public static implicit operator string(StringName from) + { + return godot_icall_StringName_operator_String(StringName.GetPtr(from)); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this . + public override string ToString() + { + return (string)this; + } + + public static bool operator ==(StringName left, StringName right) + { + return godot_icall_StringName_operator_String(StringName.GetPtr(left), StringName.GetPtr(right)); + } + + public static bool operator !=(Rect2 left, Rect2 right) + { + return !left.Equals(right); + } + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern IntPtr godot_icall_StringName_Ctor(); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern IntPtr godot_icall_StringName_String_Ctor(string path); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern void godot_icall_StringName_Dtor(IntPtr ptr); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern string godot_icall_StringName_operator_String(IntPtr ptr); + + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern bool godot_icall_StringName_operator_Equals(IntPtr ptr1, IntPtr ptr2); + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/glue/GodotSharp/GodotSharp/Core/Vector2I.cs new file mode 100644 index 0000000..417a7d6 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Vector2I.cs @@ -0,0 +1,106 @@ +#if REAL_T_IS_DOUBLE +using int = System.Double; +#else +using int = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + /// + /// 2-element structure that can be used to represent positions in 2D space or any other pair of numeric values. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Vector2I : IEquatable + { + /// + /// The vector's X component. Also accessible by using the index position [0]. + /// + public int x; + + /// + /// The vector's Y component. Also accessible by using the index position [1]. + /// + public int y; + + + /// + /// Constructs a new with the given components. + /// + /// The vector's X component. + /// The vector's Y component. + public Vector2I(int x, int y) + { + this.x = x; + this.y = y; + } + + /// + /// Constructs a new from an existing . + /// + /// The existing . + public Vector2I(Vector2I v) + { + x = v.x; + y = v.y; + } + + /// + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The object to compare with. + /// Whether or not the vector and the object are equal. + public override bool Equals(object obj) + { + if (obj is Vector2I) + { + return Equals((Vector2I)obj); + } + return false; + } + + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The other vector. + /// Whether or not the vectors are exactly equal. + public bool Equals(Vector2I other) + { + return x == other.x && y == other.y; + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this vector. + public override int GetHashCode() + { + return y.GetHashCode() ^ x.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this vector. + public override string ToString() + { + return $"({x}, {y})"; + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this vector. + public string ToString(string format) + { + return $"({x.ToString(format)}, {y.ToString(format)})"; + } + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/glue/GodotSharp/GodotSharp/Core/Vector3I.cs new file mode 100644 index 0000000..513ab19 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Vector3I.cs @@ -0,0 +1,114 @@ +#if REAL_T_IS_DOUBLE +using int = System.Double; +#else +using int = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + /// + /// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Vector3I : IEquatable + { + /// + /// The vector's X component. Also accessible by using the index position [0]. + /// + public int x; + + /// + /// The vector's Y component. Also accessible by using the index position [1]. + /// + public int y; + + /// + /// The vector's Z component. Also accessible by using the index position [2]. + /// + public int z; + + /// + /// Constructs a new with the given components. + /// + /// The vector's X component. + /// The vector's Y component. + /// The vector's Z component. + public Vector3I(int x, int y, int z) + { + this.x = x; + this.y = y; + this.z = z; + } + + /// + /// Constructs a new from an existing . + /// + /// The existing . + public Vector3I(Vector3I v) + { + x = v.x; + y = v.y; + z = v.z; + } + + /// + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The object to compare with. + /// Whether or not the vector and the object are equal. + public override bool Equals(object obj) + { + if (obj is Vector3I) + { + return Equals((Vector3I)obj); + } + + return false; + } + + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The other vector. + /// Whether or not the vectors are exactly equal. + public bool Equals(Vector3I other) + { + return x == other.x && y == other.y && z == other.z; + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this vector. + public override int GetHashCode() + { + return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this vector. + public override string ToString() + { + return $"({x}, {y}, {z})"; + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this vector. + public string ToString(string format) + { + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)})"; + } + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/glue/GodotSharp/GodotSharp/Core/Vector4.cs new file mode 100644 index 0000000..c124d06 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -0,0 +1,118 @@ +#if REAL_T_IS_DOUBLE +using real_t = System.Double; +#else +using real_t = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + /// + /// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Vector4 : IEquatable + { + /// + /// The vector's X component. Also accessible by using the index position [0]. + /// + public real_t x; + + /// + /// The vector's Y component. Also accessible by using the index position [1]. + /// + public real_t y; + + /// + /// The vector's Z component. Also accessible by using the index position [2]. + /// + public real_t z; + + public real_t w; + + /// + /// Constructs a new with the given components. + /// + /// The vector's X component. + /// The vector's Y component. + /// The vector's Z component. + public Vector4(real_t x, real_t y, real_t z, real_t w) + { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /// + /// Constructs a new from an existing . + /// + /// The existing . + public Vector4(Vector4 v) + { + x = v.x; + y = v.y; + z = v.z; + w = v.w; + } + + /// + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The object to compare with. + /// Whether or not the vector and the object are equal. + public override bool Equals(object obj) + { + if (obj is Vector4) + { + return Equals((Vector4)obj); + } + + return false; + } + + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The other vector. + /// Whether or not the vectors are exactly equal. + public bool Equals(Vector4 other) + { + return x == other.x && y == other.y && z == other.z && w == other.w; + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this vector. + public override int GetHashCode() + { + return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this vector. + public override string ToString() + { + return $"({x}, {y}, {z}, {w})"; + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this vector. + public string ToString(string format) + { + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format), {w.ToString(format)})"; + } + } +} diff --git a/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/glue/GodotSharp/GodotSharp/Core/Vector4I.cs new file mode 100644 index 0000000..7117224 --- /dev/null +++ b/glue/GodotSharp/GodotSharp/Core/Vector4I.cs @@ -0,0 +1,118 @@ +#if REAL_T_IS_DOUBLE +using int = System.Double; +#else +using int = System.Single; +#endif +using System; +using System.Runtime.InteropServices; + +namespace Godot +{ + /// + /// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values. + /// + [Serializable] + [StructLayout(LayoutKind.Sequential)] + public struct Vector4I : IEquatable + { + /// + /// The vector's X component. Also accessible by using the index position [0]. + /// + public int x; + + /// + /// The vector's Y component. Also accessible by using the index position [1]. + /// + public int y; + + /// + /// The vector's Z component. Also accessible by using the index position [2]. + /// + public int z; + + public int w; + + /// + /// Constructs a new with the given components. + /// + /// The vector's X component. + /// The vector's Y component. + /// The vector's Z component. + public Vector4I(int x, int y, int z, int w) + { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /// + /// Constructs a new from an existing . + /// + /// The existing . + public Vector4I(Vector4I v) + { + x = v.x; + y = v.y; + z = v.z; + w = v.w; + } + + /// + /// Returns if the vector is exactly equal + /// to the given object (). + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The object to compare with. + /// Whether or not the vector and the object are equal. + public override bool Equals(object obj) + { + if (obj is Vector4I) + { + return Equals((Vector4I)obj); + } + + return false; + } + + /// + /// Returns if the vectors are exactly equal. + /// Note: Due to floating-point precision errors, consider using + /// instead, which is more reliable. + /// + /// The other vector. + /// Whether or not the vectors are exactly equal. + public bool Equals(Vector4I other) + { + return x == other.x && y == other.y && z == other.z && w == other.w; + } + + /// + /// Serves as the hash function for . + /// + /// A hash code for this vector. + public override int GetHashCode() + { + return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode(); + } + + /// + /// Converts this to a string. + /// + /// A string representation of this vector. + public override string ToString() + { + return $"({x}, {y}, {z}, {w})"; + } + + /// + /// Converts this to a string with the given . + /// + /// A string representation of this vector. + public string ToString(string format) + { + return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format), {w.ToString(format)})"; + } + } +} diff --git a/glue/glue_header.h b/glue/glue_header.h index f7e48a5..0bb6237 100644 --- a/glue/glue_header.h +++ b/glue/glue_header.h @@ -39,6 +39,7 @@ #include "nodepath_glue.h" #include "rid_glue.h" #include "string_glue.h" +#include "string_name_glue.h" /** * Registers internal calls that were not generated. This function is called @@ -51,6 +52,7 @@ void godot_register_glue_header_icalls() { godot_register_object_icalls(); godot_register_rid_icalls(); godot_register_string_icalls(); + godot_register_nodepath_icalls(); } // Used by the generated glue diff --git a/glue/string_name_glue.cpp b/glue/string_name_glue.cpp new file mode 100644 index 0000000..68c612c --- /dev/null +++ b/glue/string_name_glue.cpp @@ -0,0 +1,66 @@ +/**************************************************************************/ +/* nodepath_glue.cpp */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "string_name_glue.h" + +#ifdef MONO_GLUE_ENABLED + +#include "core/string/ustring.h" + +StringName *godot_icall_StringName_Ctor() { + return memnew(StringName()); +} + +StringName *godot_icall_StringName_String_Ctor(MonoString *p_path) { + return memnew(StringName(GDMonoMarshal::mono_string_to_godot(p_path))); +} + +void godot_icall_StringName_Dtor(StringName *p_ptr) { + ERR_FAIL_NULL(p_ptr); + memdelete(p_ptr); +} + +MonoString *godot_icall_StringName_operator_String(StringName *p_np) { + return GDMonoMarshal::mono_string_from_godot(p_np->operator String()); +} + +bool godot_icall_StringName_operator_Equals(StringName *p_sn1, StringName *p_sn2) { + return p_sn1->operator==(*p_sn2); +} + +void godot_register_stringname_icalls() { + GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_Ctor", godot_icall_StringName_Ctor); + GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_String_Ctor", godot_icall_StringName_String_Ctor); + GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_Dtor", godot_icall_StringName_Dtor); + GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_operator_String", godot_icall_StringName_operator_String); + GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_operator_Equals", godot_icall_StringName_operator_Equals); +} + +#endif // MONO_GLUE_ENABLED diff --git a/glue/string_name_glue.h b/glue/string_name_glue.h new file mode 100644 index 0000000..73a10f9 --- /dev/null +++ b/glue/string_name_glue.h @@ -0,0 +1,56 @@ +/**************************************************************************/ +/* nodepath_glue.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef NODEPATH_GLUE_H +#define NODEPATH_GLUE_H + +#ifdef MONO_GLUE_ENABLED + +#include "core/string/string_name.h" + +#include "../mono_gd/gd_mono_marshal.h" + +StringName *godot_icall_StringName_Ctor(); + +StringName *godot_icall_StringName_String_Ctor(MonoString *p_path); + +void godot_icall_StringName_Dtor(StringName *p_ptr); + +MonoString *godot_icall_StringName_operator_String(StringName *p_np); + +bool godot_icall_StringName_operator_Equals(StringName *p_sn1, StringName *p_sn2); + +// Register internal calls + +void godot_register_stringname_icalls(); + +#endif // MONO_GLUE_ENABLED + +#endif // NODEPATH_GLUE_H