summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Herzog <karroffel@users.noreply.github.com>2017-04-19 16:38:33 +0200
committerGitHub <noreply@github.com>2017-04-19 16:38:33 +0200
commitd74c2bbec9fe2d46d8e92079bb704c87c1d470ef (patch)
treeaf9e575a7ada253502ee8df36df436975c782a74
parent8ee991a2a7e9bbcf3c9d1da24cb1ae8754cf4e8f (diff)
parentd4f4f14c68d6fea3fc582858ec82af2f8ae36870 (diff)
Merge pull request #8455 from karroffel/gdnative-calling-conv
[GDNative] explicit calling convention
-rw-r--r--modules/gdnative/gdnative.cpp1
-rw-r--r--modules/gdnative/godot.h43
2 files changed, 29 insertions, 15 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index a4c9085f45..09859d95bd 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -424,7 +424,6 @@ Variant GDNativeScript::_new(const Variant **p_args, int p_argcount, Variant::Ca
// @Todo support varargs for constructors.
GDNativeInstance *instance = (GDNativeInstance *)instance_create(owner);
- owner->set_script(Ref<GDNativeScript>(this).get_ref_ptr());
owner->set_script_instance(instance);
if (!instance) {
if (ref.is_null()) {
diff --git a/modules/gdnative/godot.h b/modules/gdnative/godot.h
index 0d7aece23b..88d2a9bac2 100644
--- a/modules/gdnative/godot.h
+++ b/modules/gdnative/godot.h
@@ -38,12 +38,26 @@ extern "C" {
#define GDAPI_EXPORT
#endif
-#if !defined(_WIN32) && !defined(_MSC_VER)
+#ifdef _WIN32
+#if defined(GDAPI_EXPORT)
+#define GDCALLINGCONV __cdecl
+#define GDAPI __declspec(dllexport) GDCALLINGCONV
+#else
+#define GDCALLINGCONV __cdecl
+#define GDAPI __declspec(dllimport) GDCALLINGCONV
+#endif
+#elif defined(__APPLE__)
+#include "TargetConditionals.h"
+#if TARGET_OS_IPHONE
+#define GDCALLINGCONV
#define GDAPI
-#elif defined(GDAPI_EXPORT)
-#define GDAPI __declspec(dllexport)
+#elif TARGET_OS_MAC
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
+#endif
#else
-#define GDAPI __declspec(dllimport)
+#define GDCALLINGCONV __attribute__((sysv_abi))
+#define GDAPI GDCALLINGCONV
#endif
#include <stdbool.h>
@@ -314,16 +328,16 @@ typedef struct godot_property_attributes {
typedef struct godot_instance_create_func {
// instance pointer, method_data - return user data
- void *(*create_func)(godot_object *, void *);
+ GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_create_func;
typedef struct godot_instance_destroy_func {
// instance pointer, method data, user data
- void (*destroy_func)(godot_object *, void *, void *);
+ GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_destroy_func;
void GDAPI godot_script_register_class(const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func);
@@ -332,25 +346,25 @@ void GDAPI godot_script_register_tool_class(const char *p_name, const char *p_ba
typedef struct godot_instance_method {
// instance pointer, method data, user data, num args, args - return result as varaint
- godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
+ GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_instance_method;
void GDAPI godot_script_register_method(const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method);
typedef struct godot_property_set_func {
// instance pointer, method data, user data, value
- void (*set_func)(godot_object *, void *, void *, godot_variant);
+ GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_property_set_func;
typedef struct godot_property_get_func {
// instance pointer, method data, user data, value
- godot_variant (*get_func)(godot_object *, void *, void *);
+ GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
- void (*free_func)(void *);
+ GDCALLINGCONV void (*free_func)(void *);
} godot_property_get_func;
void GDAPI godot_script_register_property(const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func);
@@ -376,6 +390,7 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *
void GDAPI *godot_native_get_userdata(godot_object *p_instance);
+// Calling convention?
typedef godot_object *(*godot_class_constructor)();
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);