summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/SCsub29
-rw-r--r--modules/gdnative/arvr/SCsub11
-rw-r--r--modules/gdnative/arvr/config.py2
-rw-r--r--modules/gdnative/gdnative.cpp2
-rw-r--r--modules/gdnative/gdnative/variant.cpp18
-rw-r--r--modules/gdnative/gdnative_api.json18
-rw-r--r--modules/gdnative/include/gdnative/variant.h44
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h7
-rw-r--r--modules/gdnative/nativescript/SCsub8
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp22
-rw-r--r--modules/gdnative/nativescript/nativescript.h4
-rw-r--r--modules/gdnative/net/SCsub9
-rw-r--r--modules/gdnative/pluginscript/SCsub7
-rw-r--r--modules/gdnative/register_types.cpp12
14 files changed, 131 insertions, 62 deletions
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 46b2a832f1..fe2d8c7ce9 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -1,35 +1,38 @@
#!/usr/bin/env python
Import('env')
+Import('env_modules')
-gdn_env = env.Clone()
-gdn_env.add_source_files(env.modules_sources, "gdnative.cpp")
-gdn_env.add_source_files(env.modules_sources, "register_types.cpp")
-gdn_env.add_source_files(env.modules_sources, "android/*.cpp")
-gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp")
-gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp")
-gdn_env.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
-gdn_env.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
+env_gdnative = env_modules.Clone()
+env_gdnative.add_source_files(env.modules_sources, "gdnative.cpp")
+env_gdnative.add_source_files(env.modules_sources, "register_types.cpp")
+env_gdnative.add_source_files(env.modules_sources, "android/*.cpp")
+env_gdnative.add_source_files(env.modules_sources, "gdnative/*.cpp")
+env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp")
+env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
+env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
-gdn_env.Append(CPPPATH=['#modules/gdnative/include/'])
+env_gdnative.Append(CPPPATH=['#modules/gdnative/include/'])
+
+Export('env_gdnative')
SConscript("net/SCsub")
SConscript("arvr/SCsub")
SConscript("pluginscript/SCsub")
+
from platform_methods import run_in_subprocess
import gdnative_builders
-
-_, gensource = gdn_env.CommandNoCache(['include/gdnative_api_struct.gen.h', 'gdnative_api_struct.gen.cpp'],
+_, gensource = env_gdnative.CommandNoCache(['include/gdnative_api_struct.gen.h', 'gdnative_api_struct.gen.cpp'],
'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_api_struct))
-gdn_env.add_source_files(env.modules_sources, [gensource])
+env_gdnative.add_source_files(env.modules_sources, [gensource])
env.use_ptrcall = True
if ARGUMENTS.get('gdnative_wrapper', False):
- gensource, = gdn_env.CommandNoCache('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_wrapper_code))
+ gensource, = env_gdnative.CommandNoCache('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_wrapper_code))
gd_wrapper_env = env.Clone()
gd_wrapper_env.Append(CPPPATH=['#modules/gdnative/include/'])
diff --git a/modules/gdnative/arvr/SCsub b/modules/gdnative/arvr/SCsub
index ecc5996108..20eaa99592 100644
--- a/modules/gdnative/arvr/SCsub
+++ b/modules/gdnative/arvr/SCsub
@@ -1,13 +1,6 @@
#!/usr/bin/env python
-import os
-import methods
-
Import('env')
-Import('env_modules')
-
-env_arvr_gdnative = env_modules.Clone()
-
-env_arvr_gdnative.Append(CPPPATH=['#modules/gdnative/include/'])
-env_arvr_gdnative.add_source_files(env.modules_sources, '*.cpp')
+Import('env_gdnative')
+env_gdnative.add_source_files(env.modules_sources, '*.cpp')
diff --git a/modules/gdnative/arvr/config.py b/modules/gdnative/arvr/config.py
index 4d1bdfe4d1..53bc827027 100644
--- a/modules/gdnative/arvr/config.py
+++ b/modules/gdnative/arvr/config.py
@@ -1,4 +1,4 @@
-def can_build(platform):
+def can_build(env, platform):
return True
def configure(env):
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 2a980c2dc8..ecde73ae1c 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -390,7 +390,7 @@ bool GDNative::terminate() {
if (library->should_load_once()) {
Vector<Ref<GDNative> > *gdnatives = &(*GDNativeLibrary::loaded_libraries)[library->get_current_library_path()];
if (gdnatives->size() > 1) {
- // there are other GDNative's still using this library, so we actually don't terminte
+ // there are other GDNative's still using this library, so we actually don't terminate
gdnatives->erase(Ref<GDNative>(this));
initialized = false;
return true;
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 423f3312e1..fd6babfc3a 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -489,6 +489,24 @@ void GDAPI godot_variant_destroy(godot_variant *p_self) {
self->~Variant();
}
+// GDNative core 1.1
+
+godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op) {
+ Variant::Operator op = (Variant::Operator)p_op;
+ godot_string raw_dest;
+ String *dest = (String *)&raw_dest;
+ memnew_placement(dest, String(Variant::get_operator_name(op))); // operator = is overloaded by String
+ return raw_dest;
+}
+
+void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid) {
+ Variant::Operator op = (Variant::Operator)p_op;
+ const Variant *a = (const Variant *)p_a;
+ const Variant *b = (const Variant *)p_b;
+ Variant *ret = (Variant *)r_ret;
+ Variant::evaluate(op, a, b, *ret, *r_valid);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index dce3d7e96b..16a34a9a33 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -94,6 +94,24 @@
["godot_transform *", "r_dest"],
["const godot_quat *", "p_quat"]
]
+ },
+ {
+ "name": "godot_variant_get_operator_name",
+ "return_type": "godot_string",
+ "arguments": [
+ ["godot_variant_operator", "p_op"]
+ ]
+ },
+ {
+ "name": "godot_variant_evaluate",
+ "return_type": "void",
+ "arguments": [
+ ["godot_variant_operator", "p_op"],
+ ["const godot_variant *", "p_a"],
+ ["const godot_variant *", "p_b"],
+ ["godot_variant *", "r_ret"],
+ ["godot_bool *", "r_valid"]
+ ]
}
]
},
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index 6779dc4092..5e71aa9f11 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -100,6 +100,45 @@ typedef struct godot_variant_call_error {
godot_variant_type expected;
} godot_variant_call_error;
+typedef enum godot_variant_operator {
+ // comparison
+ GODOT_VARIANT_OP_EQUAL,
+ GODOT_VARIANT_OP_NOT_EQUAL,
+ GODOT_VARIANT_OP_LESS,
+ GODOT_VARIANT_OP_LESS_EQUAL,
+ GODOT_VARIANT_OP_GREATER,
+ GODOT_VARIANT_OP_GREATER_EQUAL,
+
+ // mathematic
+ GODOT_VARIANT_OP_ADD,
+ GODOT_VARIANT_OP_SUBTRACT,
+ GODOT_VARIANT_OP_MULTIPLY,
+ GODOT_VARIANT_OP_DIVIDE,
+ GODOT_VARIANT_OP_NEGATE,
+ GODOT_VARIANT_OP_POSITIVE,
+ GODOT_VARIANT_OP_MODULE,
+ GODOT_VARIANT_OP_STRING_CONCAT,
+
+ // bitwise
+ GODOT_VARIANT_OP_SHIFT_LEFT,
+ GODOT_VARIANT_OP_SHIFT_RIGHT,
+ GODOT_VARIANT_OP_BIT_AND,
+ GODOT_VARIANT_OP_BIT_OR,
+ GODOT_VARIANT_OP_BIT_XOR,
+ GODOT_VARIANT_OP_BIT_NEGATE,
+
+ // logic
+ GODOT_VARIANT_OP_AND,
+ GODOT_VARIANT_OP_OR,
+ GODOT_VARIANT_OP_XOR,
+ GODOT_VARIANT_OP_NOT,
+
+ // containment
+ GODOT_VARIANT_OP_IN,
+
+ GODOT_VARIANT_OP_MAX,
+} godot_variant_operator;
+
// reduce extern "C" nesting for VS2013
#ifdef __cplusplus
}
@@ -204,6 +243,11 @@ godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self);
void GDAPI godot_variant_destroy(godot_variant *p_self);
+// GDNative core 1.1
+
+godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_op);
+void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_ret, godot_bool *r_valid);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index d6a729be47..ba044117e2 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -40,12 +40,13 @@ extern "C" {
typedef enum {
GODOT_METHOD_RPC_MODE_DISABLED,
GODOT_METHOD_RPC_MODE_REMOTE,
- GODOT_METHOD_RPC_MODE_SYNC,
GODOT_METHOD_RPC_MODE_MASTER,
- GODOT_METHOD_RPC_MODE_SLAVE,
+ GODOT_METHOD_RPC_MODE_PUPPET,
+ GODOT_METHOD_RPC_MODE_SLAVE = GODOT_METHOD_RPC_MODE_PUPPET,
GODOT_METHOD_RPC_MODE_REMOTESYNC,
+ GODOT_METHOD_RPC_MODE_SYNC = GODOT_METHOD_RPC_MODE_REMOTESYNC,
GODOT_METHOD_RPC_MODE_MASTERSYNC,
- GODOT_METHOD_RPC_MODE_SLAVESYNC,
+ GODOT_METHOD_RPC_MODE_PUPPETSYNC,
} godot_method_rpc_mode;
typedef enum {
diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub
index ee3b9c351d..5841ad5531 100644
--- a/modules/gdnative/nativescript/SCsub
+++ b/modules/gdnative/nativescript/SCsub
@@ -1,12 +1,10 @@
#!/usr/bin/env python
Import('env')
+Import('env_gdnative')
-mod_env = env.Clone()
-mod_env.add_source_files(env.modules_sources, "*.cpp")
-mod_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
+env_gdnative.add_source_files(env.modules_sources, '*.cpp')
+env_gdnative.Append(CPPFLAGS=['-DGDAPI_BUILT_IN'])
if "platform" in env and env["platform"] in ["x11", "iphone"]:
env.Append(LINKFLAGS=["-rdynamic"])
-
-Export('mod_env')
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index ea968fb0b1..641e4021d8 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -810,18 +810,16 @@ MultiplayerAPI::RPCMode NativeScriptInstance::get_rpc_mode(const StringName &p_m
return MultiplayerAPI::RPC_MODE_DISABLED;
case GODOT_METHOD_RPC_MODE_REMOTE:
return MultiplayerAPI::RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return MultiplayerAPI::RPC_MODE_SYNC;
case GODOT_METHOD_RPC_MODE_MASTER:
return MultiplayerAPI::RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return MultiplayerAPI::RPC_MODE_SLAVE;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
case GODOT_METHOD_RPC_MODE_REMOTESYNC:
return MultiplayerAPI::RPC_MODE_REMOTESYNC;
case GODOT_METHOD_RPC_MODE_MASTERSYNC:
return MultiplayerAPI::RPC_MODE_MASTERSYNC;
- case GODOT_METHOD_RPC_MODE_SLAVESYNC:
- return MultiplayerAPI::RPC_MODE_SLAVESYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
default:
return MultiplayerAPI::RPC_MODE_DISABLED;
}
@@ -846,12 +844,16 @@ MultiplayerAPI::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_
return MultiplayerAPI::RPC_MODE_DISABLED;
case GODOT_METHOD_RPC_MODE_REMOTE:
return MultiplayerAPI::RPC_MODE_REMOTE;
- case GODOT_METHOD_RPC_MODE_SYNC:
- return MultiplayerAPI::RPC_MODE_SYNC;
case GODOT_METHOD_RPC_MODE_MASTER:
return MultiplayerAPI::RPC_MODE_MASTER;
- case GODOT_METHOD_RPC_MODE_SLAVE:
- return MultiplayerAPI::RPC_MODE_SLAVE;
+ case GODOT_METHOD_RPC_MODE_PUPPET:
+ return MultiplayerAPI::RPC_MODE_PUPPET;
+ case GODOT_METHOD_RPC_MODE_REMOTESYNC:
+ return MultiplayerAPI::RPC_MODE_REMOTESYNC;
+ case GODOT_METHOD_RPC_MODE_MASTERSYNC:
+ return MultiplayerAPI::RPC_MODE_MASTERSYNC;
+ case GODOT_METHOD_RPC_MODE_PUPPETSYNC:
+ return MultiplayerAPI::RPC_MODE_PUPPETSYNC;
default:
return MultiplayerAPI::RPC_MODE_DISABLED;
}
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index a96fe5c5e3..ade8ffd280 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -70,8 +70,6 @@ struct NativeScriptDesc {
String documentation;
};
- String documentation;
-
Map<StringName, Method> methods;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
@@ -81,6 +79,8 @@ struct NativeScriptDesc {
godot_instance_create_func create_func;
godot_instance_destroy_func destroy_func;
+ String documentation;
+
const void *type_tag;
bool is_tool;
diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub
index 53f9271128..e915703935 100644
--- a/modules/gdnative/net/SCsub
+++ b/modules/gdnative/net/SCsub
@@ -1,12 +1,7 @@
#!/usr/bin/env python
-import os
-import methods
-
Import('env')
-Import('env_modules')
+Import('env_gdnative')
-env_net_gdnative = env_modules.Clone()
+env_gdnative.add_source_files(env.modules_sources, '*.cpp')
-env_net_gdnative.Append(CPPPATH=['#modules/gdnative/include/'])
-env_net_gdnative.add_source_files(env.modules_sources, '*.cpp')
diff --git a/modules/gdnative/pluginscript/SCsub b/modules/gdnative/pluginscript/SCsub
index 2031a4236b..20eaa99592 100644
--- a/modules/gdnative/pluginscript/SCsub
+++ b/modules/gdnative/pluginscript/SCsub
@@ -1,9 +1,6 @@
#!/usr/bin/env python
Import('env')
-Import('env_modules')
+Import('env_gdnative')
-env_pluginscript = env_modules.Clone()
-
-env_pluginscript.Append(CPPPATH=['#modules/gdnative/include/'])
-env_pluginscript.add_source_files(env.modules_sources, '*.cpp')
+env_gdnative.add_source_files(env.modules_sources, '*.cpp')
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 48c0fc8aef..62e87c3651 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -29,19 +29,19 @@
/*************************************************************************/
#include "register_types.h"
+
#include "gdnative/gdnative.h"
#include "gdnative.h"
-#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
-
#include "arvr/register_types.h"
#include "nativescript/register_types.h"
#include "net/register_types.h"
#include "pluginscript/register_types.h"
#include "core/engine.h"
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -148,7 +148,7 @@ protected:
};
struct LibrarySymbol {
- char *name;
+ const char *name;
bool is_required;
};
@@ -239,7 +239,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n"
"extern void add_ios_init_callback(void (*cb)());\n";
String linker_flags = "";
- for (int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
+ for (unsigned int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
String code = declare_pattern.replace("$name", full_name);
code = code.replace("$weak", expected_symbols[i].is_required ? "" : " __attribute__((weak))");
@@ -255,7 +255,7 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
additional_code += String("void $prefixinit() {\n").replace("$prefix", lib->get_symbol_prefix());
String register_pattern = " if (&$name) register_dynamic_symbol((char *)\"$name\", (void *)$name);\n";
- for (int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
+ for (unsigned int i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
additional_code += register_pattern.replace("$name", full_name);
}