summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/config.py2
-rw-r--r--modules/gdnative/gdnative.cpp15
-rw-r--r--modules/gdnative/godot.cpp35
-rw-r--r--modules/gdnative/godot.h7
-rw-r--r--modules/gdnative/godot/godot_variant.cpp16
-rw-r--r--modules/gdnative/godot/godot_variant.h33
6 files changed, 86 insertions, 22 deletions
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index 9f57b9bb74..4f89ca0d4c 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -1,7 +1,7 @@
def can_build(platform):
- return True
+ return False
def configure(env):
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 09859d95bd..9c8625c1e0 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -99,15 +99,15 @@ Error NativeLibrary::terminate(NativeLibrary *&p_native_lib) {
Error error = OK;
void *library_terminate;
error = OS::get_singleton()->get_dynamic_library_symbol_handle(p_native_lib->handle, GDNativeScriptLanguage::get_terminate_symbol_name(), library_terminate);
- if (error)
- return OK; // no terminate? okay, not that important lol
+ if (!error) {
- void (*library_terminate_pointer)(godot_native_terminate_options *) = (void (*)(godot_native_terminate_options *))library_terminate;
+ void (*library_terminate_pointer)(godot_native_terminate_options *) = (void (*)(godot_native_terminate_options *))library_terminate;
- godot_native_terminate_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ godot_native_terminate_options options;
+ options.in_editor = SceneTree::get_singleton()->is_editor_hint();
- library_terminate_pointer(&options);
+ library_terminate_pointer(&options);
+ }
GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
@@ -515,7 +515,6 @@ static const char *_dl_platforms_info[] = {
"unix|x11|so|X11",
"unix|server|so|Server",
"unix|android|so|Android",
- "unix|blackberry|so|Blackberry 10",
"unix|haiku|so|Haiku", // Right?
"|mac|dynlib|Mac",
"mac|ios|dynlib|iOS",
@@ -615,7 +614,6 @@ Error GDNativeLibrary::_terminate() {
}
Error ret = NativeLibrary::terminate(native_library);
-
native_library->scripts.clear();
return ret;
@@ -1218,6 +1216,7 @@ void GDNativeReloadNode::_notification(int p_what) {
Set<GDNativeScript *> scripts;
for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) {
+
if (lib->native_library->scripts.has(S->get()->get_script_name())) {
GDNativeScript *script = S->get();
script->script_data = lib->get_script_data(script->get_script_name());
diff --git a/modules/gdnative/godot.cpp b/modules/gdnative/godot.cpp
index 7477a28db6..bc53eb93f4 100644
--- a/modules/gdnative/godot.cpp
+++ b/modules/gdnative/godot.cpp
@@ -30,6 +30,7 @@
#include "godot.h"
#include "class_db.h"
+#include "error_macros.h"
#include "gdnative.h"
#include "global_config.h"
#include "global_constants.h"
@@ -115,6 +116,28 @@ void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_obj
mb->ptrcall(o, p_args, p_ret);
}
+godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error) {
+ MethodBind *mb = (MethodBind *)p_method_bind;
+ Object *o = (Object *)p_instance;
+ const Variant **args = (const Variant **)p_args;
+
+ godot_variant ret;
+ godot_variant_new_nil(&ret);
+
+ Variant *ret_val = (Variant *)&ret;
+
+ Variant::CallError r_error;
+ *ret_val = mb->call(o, args, p_arg_count, r_error);
+
+ if (p_call_error) {
+ p_call_error->error = (godot_variant_call_error_error)r_error.error;
+ p_call_error->argument = r_error.argument;
+ p_call_error->expected = (godot_variant_type)r_error.expected;
+ }
+
+ return ret;
+}
+
// @Todo
/*
void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind)
@@ -215,6 +238,18 @@ void GDAPI godot_free(void *p_ptr) {
memfree(p_ptr);
}
+void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) {
+ _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_ERROR);
+}
+
+void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) {
+ _err_print_error(p_function, p_file, p_line, p_description, ERR_HANDLER_WARNING);
+}
+
+void GDAPI godot_print(const godot_string *p_message) {
+ print_line(*(String *)p_message);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/godot.h b/modules/gdnative/godot.h
index b05cafbe50..7214ce62df 100644
--- a/modules/gdnative/godot.h
+++ b/modules/gdnative/godot.h
@@ -228,7 +228,7 @@ typedef struct godot_method_bind {
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname);
void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret);
-
+godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
////// Script API
typedef struct godot_native_init_options {
@@ -404,6 +404,11 @@ void GDAPI *godot_alloc(int p_bytes);
void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
void GDAPI godot_free(void *p_ptr);
+//print using Godot's error handler list
+void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
+void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
+void GDAPI godot_print(const godot_string *p_message);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/godot/godot_variant.cpp b/modules/gdnative/godot/godot_variant.cpp
index 2214f85056..e9fa4eb8c6 100644
--- a/modules/gdnative/godot/godot_variant.cpp
+++ b/modules/gdnative/godot/godot_variant.cpp
@@ -457,12 +457,22 @@ godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_varia
return pba;
}
-godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount /*, godot_variant_call_error *r_error */) {
+godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *p_error) {
Variant *v = (Variant *)p_v;
String *method = (String *)p_method;
- Variant **args = (Variant **)p_args;
+ const Variant **args = (const Variant **)p_args;
godot_variant res;
- memnew_placement_custom((Variant *)&res, Variant, Variant(v->call(*method, args, p_argcount)));
+ godot_variant_new_nil(&res);
+
+ Variant *ret_val = (Variant *)&res;
+
+ Variant::CallError r_error;
+ *ret_val = v->call(StringName(*method), args, p_argcount, r_error);
+ if (p_error) {
+ p_error->error = (godot_variant_call_error_error)r_error.error;
+ p_error->argument = r_error.argument;
+ p_error->expected = (godot_variant_type)r_error.expected;
+ }
return res;
}
diff --git a/modules/gdnative/godot/godot_variant.h b/modules/gdnative/godot/godot_variant.h
index 6f98b32363..bf0e2bf64e 100644
--- a/modules/gdnative/godot/godot_variant.h
+++ b/modules/gdnative/godot/godot_variant.h
@@ -45,13 +45,6 @@ typedef struct godot_variant {
struct godot_transform2d;
typedef struct godot_transform2d godot_transform2d;
-#include "godot_array.h"
-#include "godot_dictionary.h"
-#include "godot_input_event.h"
-#include "godot_node_path.h"
-#include "godot_rid.h"
-#include "godot_transform2d.h"
-
typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_NIL,
@@ -69,7 +62,7 @@ typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_TRANSFORM2D,
GODOT_VARIANT_TYPE_PLANE,
GODOT_VARIANT_TYPE_QUAT, // 10
- GODOT_VARIANT_TYPE_RECT3, //sorry naming convention fail :( not like it's used often
+ GODOT_VARIANT_TYPE_RECT3,
GODOT_VARIANT_TYPE_BASIS,
GODOT_VARIANT_TYPE_TRANSFORM,
@@ -93,6 +86,28 @@ typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY,
} godot_variant_type;
+typedef enum godot_variant_call_error_error {
+ GODOT_CALL_ERROR_CALL_OK,
+ GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD,
+ GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT,
+ GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS,
+ GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS,
+ GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL,
+} godot_variant_call_error_error;
+
+typedef struct godot_variant_call_error {
+ godot_variant_call_error_error error;
+ int argument;
+ godot_variant_type expected;
+} godot_variant_call_error;
+
+#include "godot_array.h"
+#include "godot_dictionary.h"
+#include "godot_input_event.h"
+#include "godot_node_path.h"
+#include "godot_rid.h"
+#include "godot_transform2d.h"
+
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v);
void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src);
@@ -159,7 +174,7 @@ godot_pool_vector2_array GDAPI godot_variant_as_pool_vector2_array(const godot_v
godot_pool_vector3_array GDAPI godot_variant_as_pool_vector3_array(const godot_variant *p_v);
godot_pool_color_array GDAPI godot_variant_as_pool_color_array(const godot_variant *p_v);
-godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount /*, godot_variant_call_error *r_error */);
+godot_variant GDAPI godot_variant_call(godot_variant *p_v, const godot_string *p_method, const godot_variant **p_args, const godot_int p_argcount, godot_variant_call_error *p_error);
godot_bool GDAPI godot_variant_has_method(godot_variant *p_v, const godot_string *p_method);