summaryrefslogtreecommitdiff
path: root/modules/mono/glue
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/glue')
-rw-r--r--modules/mono/glue/builtin_types_glue.h59
-rw-r--r--modules/mono/glue/cs_files/Basis.cs6
-rw-r--r--modules/mono/glue/cs_files/Color.cs26
-rw-r--r--modules/mono/glue/cs_files/DebuggingUtils.cs83
-rw-r--r--modules/mono/glue/cs_files/Error.cs47
-rw-r--r--modules/mono/glue/cs_files/ExportAttribute.cs8
-rw-r--r--modules/mono/glue/cs_files/GD.cs4
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs2
-rw-r--r--modules/mono/glue/cs_files/Plane.cs2
-rw-r--r--modules/mono/glue/cs_files/Rect2.cs12
-rw-r--r--modules/mono/glue/cs_files/SignalAttribute.cs12
-rw-r--r--modules/mono/glue/glue_header.h31
12 files changed, 203 insertions, 89 deletions
diff --git a/modules/mono/glue/builtin_types_glue.h b/modules/mono/glue/builtin_types_glue.h
new file mode 100644
index 0000000000..460de84b65
--- /dev/null
+++ b/modules/mono/glue/builtin_types_glue.h
@@ -0,0 +1,59 @@
+#ifndef BUILTIN_TYPES_GLUE_H
+#define BUILTIN_TYPES_GLUE_H
+
+#include "core/node_path.h"
+#include "core/rid.h"
+
+#include <mono/metadata/object.h>
+
+#include "../mono_gd/gd_mono_marshal.h"
+
+MonoBoolean godot_icall_NodePath_is_absolute(NodePath *p_ptr) {
+ return (MonoBoolean)p_ptr->is_absolute();
+}
+
+uint32_t godot_icall_NodePath_get_name_count(NodePath *p_ptr) {
+ return p_ptr->get_name_count();
+}
+
+MonoString *godot_icall_NodePath_get_name(NodePath *p_ptr, uint32_t p_idx) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_name(p_idx));
+}
+
+uint32_t godot_icall_NodePath_get_subname_count(NodePath *p_ptr) {
+ return p_ptr->get_subname_count();
+}
+
+MonoString *godot_icall_NodePath_get_subname(NodePath *p_ptr, uint32_t p_idx) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_subname(p_idx));
+}
+
+MonoString *godot_icall_NodePath_get_concatenated_subnames(NodePath *p_ptr) {
+ return GDMonoMarshal::mono_string_from_godot(p_ptr->get_concatenated_subnames());
+}
+
+NodePath *godot_icall_NodePath_get_as_property_path(NodePath *p_ptr) {
+ return memnew(NodePath(p_ptr->get_as_property_path()));
+}
+
+MonoBoolean godot_icall_NodePath_is_empty(NodePath *p_ptr) {
+ return (MonoBoolean)p_ptr->is_empty();
+}
+
+uint32_t godot_icall_RID_get_id(RID *p_ptr) {
+ return p_ptr->get_id();
+}
+
+void godot_register_builtin_type_icalls() {
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_as_property_path", (void *)godot_icall_NodePath_get_as_property_path);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_concatenated_subnames", (void *)godot_icall_NodePath_get_concatenated_subnames);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_name", (void *)godot_icall_NodePath_get_name);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_name_count", (void *)godot_icall_NodePath_get_name_count);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_subname", (void *)godot_icall_NodePath_get_subname);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_get_subname_count", (void *)godot_icall_NodePath_get_subname_count);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_is_absolute", (void *)godot_icall_NodePath_is_absolute);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_NodePath_is_empty", (void *)godot_icall_NodePath_is_empty);
+ mono_add_internal_call("Godot.NativeCalls::godot_icall_RID_get_id", (void *)godot_icall_RID_get_id);
+}
+
+#endif // BUILTIN_TYPES_GLUE_H
diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs
index ea92b1641b..c6cdc069ef 100644
--- a/modules/mono/glue/cs_files/Basis.cs
+++ b/modules/mono/glue/cs_files/Basis.cs
@@ -452,9 +452,9 @@ namespace Godot
public Basis(float xx, float xy, float xz, float yx, float yy, float yz, float zx, float zy, float zz)
{
- this.x = new Vector3(xx, xy, xz);
- this.y = new Vector3(yx, yy, yz);
- this.z = new Vector3(zx, zy, zz);
+ this.x = new Vector3(xx, yx, zx);
+ this.y = new Vector3(xy, yy, zy);
+ this.z = new Vector3(xz, yz, zz);
}
public static Basis operator *(Basis left, Basis right)
diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs
index db0e1fb744..f9e31e9703 100644
--- a/modules/mono/glue/cs_files/Color.cs
+++ b/modules/mono/glue/cs_files/Color.cs
@@ -336,7 +336,7 @@ namespace Godot
this.r = (rgba & 0xFF) / 255.0f;
}
- private static float _parse_col(string str, int ofs)
+ private static int _parse_col(string str, int ofs)
{
int ig = 0;
@@ -415,17 +415,17 @@ namespace Godot
if (alpha)
{
- if ((int)_parse_col(color, 0) < 0)
+ if (_parse_col(color, 0) < 0)
return false;
}
int from = alpha ? 2 : 0;
- if ((int)_parse_col(color, from + 0) < 0)
+ if (_parse_col(color, from + 0) < 0)
return false;
- if ((int)_parse_col(color, from + 2) < 0)
+ if (_parse_col(color, from + 2) < 0)
return false;
- if ((int)_parse_col(color, from + 4) < 0)
+ if (_parse_col(color, from + 4) < 0)
return false;
return true;
@@ -467,10 +467,10 @@ namespace Godot
if (alpha)
{
- a = _parse_col(rgba, 0);
+ a = _parse_col(rgba, 0) / 255f;
if (a < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Alpha is " + a + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Alpha part is not valid hexadecimal: " + rgba);
}
else
{
@@ -479,20 +479,20 @@ namespace Godot
int from = alpha ? 2 : 0;
- r = _parse_col(rgba, from + 0);
+ r = _parse_col(rgba, from + 0) / 255f;
if (r < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Red is " + r + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Red part is not valid hexadecimal: " + rgba);
- g = _parse_col(rgba, from + 2);
+ g = _parse_col(rgba, from + 2) / 255f;
if (g < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Green is " + g + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Green part is not valid hexadecimal: " + rgba);
- b = _parse_col(rgba, from + 4);
+ b = _parse_col(rgba, from + 4) / 255f;
if (b < 0)
- throw new ArgumentOutOfRangeException("Invalid color code. Blue is " + b + " but zero or greater is expected: " + rgba);
+ throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba);
}
public static bool operator ==(Color left, Color right)
diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs
new file mode 100644
index 0000000000..ffaaf00837
--- /dev/null
+++ b/modules/mono/glue/cs_files/DebuggingUtils.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+
+namespace Godot
+{
+ internal static class DebuggingUtils
+ {
+ internal static void AppendTypeName(this StringBuilder sb, Type type)
+ {
+ if (type.IsPrimitive)
+ sb.Append(type.Name);
+ else if (type == typeof(void))
+ sb.Append("void");
+ else
+ sb.Append(type.ToString());
+
+ sb.Append(" ");
+ }
+
+ public static void GetStackFrameInfo(StackFrame frame, out string fileName, out int fileLineNumber, out string methodDecl)
+ {
+ fileName = frame.GetFileName();
+ fileLineNumber = frame.GetFileLineNumber();
+
+ MethodBase methodBase = frame.GetMethod();
+
+ if (methodBase == null)
+ {
+ methodDecl = string.Empty;
+ return;
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ if (methodBase is MethodInfo)
+ sb.AppendTypeName(((MethodInfo)methodBase).ReturnType);
+
+ sb.Append(methodBase.DeclaringType.FullName);
+ sb.Append(".");
+ sb.Append(methodBase.Name);
+
+ if (methodBase.IsGenericMethod)
+ {
+ Type[] genericParams = methodBase.GetGenericArguments();
+
+ sb.Append("<");
+
+ for (int j = 0; j < genericParams.Length; j++)
+ {
+ if (j > 0)
+ sb.Append(", ");
+
+ sb.AppendTypeName(genericParams[j]);
+ }
+
+ sb.Append(">");
+ }
+
+ sb.Append("(");
+
+ bool varArgs = (methodBase.CallingConvention & CallingConventions.VarArgs) != 0;
+
+ ParameterInfo[] parameter = methodBase.GetParameters();
+
+ for (int i = 0; i < parameter.Length; i++)
+ {
+ if (i > 0)
+ sb.Append(", ");
+
+ if (i == parameter.Length - 1 && varArgs)
+ sb.Append("params ");
+
+ sb.AppendTypeName(parameter[i].ParameterType);
+ }
+
+ sb.Append(")");
+
+ methodDecl = sb.ToString();
+ }
+ }
+}
diff --git a/modules/mono/glue/cs_files/Error.cs b/modules/mono/glue/cs_files/Error.cs
deleted file mode 100644
index dee4b88f74..0000000000
--- a/modules/mono/glue/cs_files/Error.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-namespace Godot
-{
- public enum Error : int
- {
- OK = 0,
- FAILED = 1,
- ERR_UNAVAILABLE = 2,
- ERR_UNCONFIGURED = 3,
- ERR_UNAUTHORIZED = 4,
- ERR_PARAMETER_RANGE_ERROR = 5,
- ERR_OUT_OF_MEMORY = 6,
- ERR_FILE_NOT_FOUND = 7,
- ERR_FILE_BAD_DRIVE = 8,
- ERR_FILE_BAD_PATH = 9,
- ERR_FILE_NO_PERMISSION = 10,
- ERR_FILE_ALREADY_IN_USE = 11,
- ERR_FILE_CANT_OPEN = 12,
- ERR_FILE_CANT_WRITE = 13,
- ERR_FILE_CANT_READ = 14,
- ERR_FILE_UNRECOGNIZED = 15,
- ERR_FILE_CORRUPT = 16,
- ERR_FILE_MISSING_DEPENDENCIES = 17,
- ERR_FILE_EOF = 18,
- ERR_CANT_OPEN = 19,
- ERR_CANT_CREATE = 20,
- ERR_PARSE_ERROR = 43,
- ERROR_QUERY_FAILED = 21,
- ERR_ALREADY_IN_USE = 22,
- ERR_LOCKED = 23,
- ERR_TIMEOUT = 24,
- ERR_CANT_AQUIRE_RESOURCE = 28,
- ERR_INVALID_DATA = 30,
- ERR_INVALID_PARAMETER = 31,
- ERR_ALREADY_EXISTS = 32,
- ERR_DOES_NOT_EXIST = 33,
- ERR_DATABASE_CANT_READ = 34,
- ERR_DATABASE_CANT_WRITE = 35,
- ERR_COMPILATION_FAILED = 36,
- ERR_METHOD_NOT_FOUND = 37,
- ERR_LINK_FAILED = 38,
- ERR_SCRIPT_FAILED = 39,
- ERR_CYCLIC_LINK = 40,
- ERR_BUSY = 44,
- ERR_HELP = 46,
- ERR_BUG = 47
- }
-}
diff --git a/modules/mono/glue/cs_files/ExportAttribute.cs b/modules/mono/glue/cs_files/ExportAttribute.cs
index dce9cc59a0..e6f569e1bb 100644
--- a/modules/mono/glue/cs_files/ExportAttribute.cs
+++ b/modules/mono/glue/cs_files/ExportAttribute.cs
@@ -5,13 +5,13 @@ namespace Godot
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class ExportAttribute : Attribute
{
- private int hint;
- private string hint_string;
+ private PropertyHint hint;
+ private string hintString;
- public ExportAttribute(int hint = GD.PROPERTY_HINT_NONE, string hint_string = "")
+ public ExportAttribute(PropertyHint hint = PropertyHint.None, string hintString = "")
{
this.hint = hint;
- this.hint_string = hint_string;
+ this.hintString = hintString;
}
}
}
diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs
index 99fc289161..b335ef55e4 100644
--- a/modules/mono/glue/cs_files/GD.cs
+++ b/modules/mono/glue/cs_files/GD.cs
@@ -2,10 +2,8 @@ using System;
namespace Godot
{
- public static class GD
+ public static partial class GD
{
- /*{GodotGlobalConstants}*/
-
public static object Bytes2Var(byte[] bytes)
{
return NativeCalls.godot_icall_Godot_bytes2var(bytes);
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index 6951ace4fc..476396e9a3 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -71,7 +71,7 @@ namespace Godot
public static int Decimals(float step)
{
- return Decimals(step);
+ return Decimals((decimal)step);
}
public static int Decimals(decimal step)
diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs
index 6365e71826..b347c0835a 100644
--- a/modules/mono/glue/cs_files/Plane.cs
+++ b/modules/mono/glue/cs_files/Plane.cs
@@ -91,7 +91,7 @@ namespace Godot
float dist = (normal.Dot(from) - d) / den;
- // This is a ray, before the emiting pos (from) does not exist
+ // This is a ray, before the emitting pos (from) does not exist
if (dist > Mathf.Epsilon)
return new Vector3();
diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs
index f2718d7b7a..e1fbb65da5 100644
--- a/modules/mono/glue/cs_files/Rect2.cs
+++ b/modules/mono/glue/cs_files/Rect2.cs
@@ -109,14 +109,14 @@ namespace Godot
return g;
}
- public Rect2 GrowMargin(int margin, float by)
+ public Rect2 GrowMargin(Margin margin, float by)
{
Rect2 g = this;
- g.GrowIndividual((GD.MARGIN_LEFT == margin) ? by : 0,
- (GD.MARGIN_TOP == margin) ? by : 0,
- (GD.MARGIN_RIGHT == margin) ? by : 0,
- (GD.MARGIN_BOTTOM == margin) ? by : 0);
+ g.GrowIndividual((Margin.Left == margin) ? by : 0,
+ (Margin.Top == margin) ? by : 0,
+ (Margin.Right == margin) ? by : 0,
+ (Margin.Bottom == margin) ? by : 0);
return g;
}
@@ -230,4 +230,4 @@ namespace Godot
});
}
}
-} \ No newline at end of file
+}
diff --git a/modules/mono/glue/cs_files/SignalAttribute.cs b/modules/mono/glue/cs_files/SignalAttribute.cs
new file mode 100644
index 0000000000..d8a6cabb83
--- /dev/null
+++ b/modules/mono/glue/cs_files/SignalAttribute.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Godot
+{
+ [AttributeUsage(AttributeTargets.Delegate)]
+ public class SignalAttribute : Attribute
+ {
+ public SignalAttribute()
+ {
+ }
+ }
+}
diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h
index 75a4eb2b40..cedc8e9992 100644
--- a/modules/mono/glue/glue_header.h
+++ b/modules/mono/glue/glue_header.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
+#include "builtin_types_glue.h"
+
#include "../csharp_script.h"
#include "../mono_gd/gd_mono_class.h"
#include "../mono_gd/gd_mono_internals.h"
@@ -53,9 +56,11 @@
} \
Object *m_instance = ci->creation_func();
-void godot_icall_Object_Dtor(Object *ptr) {
- ERR_FAIL_NULL(ptr);
- _GodotSharp::get_singleton()->queue_dispose(ptr);
+void godot_icall_Object_Dtor(MonoObject *obj, Object *ptr) {
+#ifdef DEBUG_ENABLED
+ CRASH_COND(ptr == NULL);
+#endif
+ _GodotSharp::get_singleton()->queue_dispose(obj, ptr);
}
// -- ClassDB --
@@ -88,12 +93,6 @@ MonoString *godot_icall_NodePath_operator_String(NodePath *p_np) {
return GDMonoMarshal::mono_string_from_godot(p_np->operator String());
}
-MonoArray *godot_icall_String_md5_buffer(MonoString *p_str) {
- Vector<uint8_t> ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_buffer();
- // TODO Check possible Array/Vector<uint8_t> problem?
- return GDMonoMarshal::Array_to_mono_array(Variant(ret));
-}
-
// -- RID --
RID *godot_icall_RID_Ctor(Object *p_from) {
@@ -112,6 +111,12 @@ void godot_icall_RID_Dtor(RID *p_ptr) {
// -- String --
+MonoArray *godot_icall_String_md5_buffer(MonoString *p_str) {
+ Vector<uint8_t> ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_buffer();
+ // TODO Check possible Array/Vector<uint8_t> problem?
+ return GDMonoMarshal::Array_to_mono_array(Variant(ret));
+}
+
MonoString *godot_icall_String_md5_text(MonoString *p_str) {
String ret = GDMonoMarshal::mono_string_to_godot(p_str).md5_text();
return GDMonoMarshal::mono_string_from_godot(ret);
@@ -300,3 +305,7 @@ MonoObject *godot_icall_Godot_weakref(Object *p_obj) {
return GDMonoUtils::create_managed_for_godot_object(CACHED_CLASS(WeakRef), Reference::get_class_static(), Object::cast_to<Object>(wref.ptr()));
}
+
+void godot_register_header_icalls() {
+ godot_register_builtin_type_icalls();
+}