summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/mono/class_db_api_json.cpp7
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/recast/register_types.cpp10
-rw-r--r--modules/visual_script/visual_script_nodes.cpp16
-rw-r--r--modules/visual_script/visual_script_nodes.h3
-rw-r--r--platform/android/api/api.cpp56
-rw-r--r--platform/android/api/api.h32
-rw-r--r--platform/android/api/java_class_wrapper.h (renamed from platform/android/java_class_wrapper.h)19
-rw-r--r--platform/android/java_class_wrapper.cpp7
-rw-r--r--platform/android/java_godot_lib_jni.cpp3
10 files changed, 135 insertions, 20 deletions
diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp
index c1d6f4dccf..b04e53bd81 100644
--- a/modules/mono/class_db_api_json.cpp
+++ b/modules/mono/class_db_api_json.cpp
@@ -71,6 +71,13 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
while ((k = t->method_map.next(k))) {
+ String name = k->operator String();
+
+ ERR_CONTINUE(name.empty());
+
+ if (name[0] == '_')
+ continue; // Ignore non-virtual methods that start with an underscore
+
snames.push_back(*k);
}
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 0f6b8357b8..210267e681 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -106,7 +106,7 @@ Error CSharpLanguage::execute_file(const String &p_path) {
void CSharpLanguage::init() {
#ifdef DEBUG_METHODS_ENABLED
- if (OS::get_singleton()->get_cmdline_args().find("--class_db_to_json")) {
+ if (OS::get_singleton()->get_cmdline_args().find("--class-db-json")) {
class_db_api_to_json("user://class_db_api.json", ClassDB::API_CORE);
#ifdef TOOLS_ENABLED
class_db_api_to_json("user://class_db_api_editor.json", ClassDB::API_EDITOR);
diff --git a/modules/recast/register_types.cpp b/modules/recast/register_types.cpp
index a1286c58c8..ea0ab00771 100644
--- a/modules/recast/register_types.cpp
+++ b/modules/recast/register_types.cpp
@@ -38,17 +38,17 @@ EditorNavigationMeshGenerator *_nav_mesh_generator = NULL;
void register_recast_types() {
#ifdef TOOLS_ENABLED
- EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
- _nav_mesh_generator = memnew(EditorNavigationMeshGenerator);
-
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
- ClassDB::register_class<EditorNavigationMeshGenerator>();
+ EditorPlugins::add_by_type<NavigationMeshEditorPlugin>();
+ _nav_mesh_generator = memnew(EditorNavigationMeshGenerator);
- ClassDB::set_current_api(prev_api);
+ ClassDB::register_class<EditorNavigationMeshGenerator>();
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationMeshGenerator", EditorNavigationMeshGenerator::get_singleton()));
+
+ ClassDB::set_current_api(prev_api);
#endif
}
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 0a9f228b0a..86c1080182 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -2377,10 +2377,7 @@ VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output
return tg;
}
-void VisualScriptEngineSingleton::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("set_singleton", "name"), &VisualScriptEngineSingleton::set_singleton);
- ClassDB::bind_method(D_METHOD("get_singleton"), &VisualScriptEngineSingleton::get_singleton);
+void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) const {
String cc;
@@ -2397,7 +2394,16 @@ void VisualScriptEngineSingleton::_bind_methods() {
cc += E->get().name;
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton");
+ property.hint = PROPERTY_HINT_ENUM;
+ property.hint_string = cc;
+}
+
+void VisualScriptEngineSingleton::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("set_singleton", "name"), &VisualScriptEngineSingleton::set_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton"), &VisualScriptEngineSingleton::get_singleton);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant"), "set_singleton", "get_singleton");
}
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index fe44af277f..0df5071491 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -614,6 +614,9 @@ class VisualScriptEngineSingleton : public VisualScriptNode {
String singleton;
+protected:
+ void _validate_property(PropertyInfo &property) const;
+
static void _bind_methods();
public:
diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp
new file mode 100644
index 0000000000..7a8ff93414
--- /dev/null
+++ b/platform/android/api/api.cpp
@@ -0,0 +1,56 @@
+#include "api.h"
+
+#include "core/engine.h"
+#include "java_class_wrapper.h"
+
+#if !defined(ANDROID_ENABLED)
+static JavaClassWrapper *java_class_wrapper = NULL;
+#endif
+
+void register_android_api() {
+
+#if !defined(ANDROID_ENABLED)
+ java_class_wrapper = memnew(JavaClassWrapper); // Dummy
+#endif
+
+ ClassDB::register_class<JavaClass>();
+ ClassDB::register_class<JavaClassWrapper>();
+ Engine::get_singleton()->add_singleton(Engine::Singleton("JavaClassWrapper", JavaClassWrapper::get_singleton()));
+}
+
+void unregister_android_api() {
+
+#if !defined(ANDROID_ENABLED)
+ memdelete(java_class_wrapper);
+#endif
+}
+
+void JavaClassWrapper::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("wrap", "name"), &JavaClassWrapper::wrap);
+}
+
+#if !defined(ANDROID_ENABLED)
+
+Variant JavaClass::call(const StringName &, const Variant **, int, Variant::CallError &) {
+ return Variant();
+}
+
+JavaClass::JavaClass() {
+}
+
+Variant JavaObject::call(const StringName &, const Variant **, int, Variant::CallError &) {
+ return Variant();
+}
+
+JavaClassWrapper *JavaClassWrapper::singleton = NULL;
+
+Ref<JavaClass> JavaClassWrapper::wrap(const String &) {
+ return Ref<JavaClass>();
+}
+
+JavaClassWrapper::JavaClassWrapper() {
+ singleton = this;
+}
+
+#endif
diff --git a/platform/android/api/api.h b/platform/android/api/api.h
new file mode 100644
index 0000000000..c7296d92a7
--- /dev/null
+++ b/platform/android/api/api.h
@@ -0,0 +1,32 @@
+/*************************************************************************/
+/* api.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 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 */
+/* "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. */
+/*************************************************************************/
+
+void register_android_api();
+void unregister_android_api();
diff --git a/platform/android/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h
index 8075b297b0..6c06d57ac1 100644
--- a/platform/android/java_class_wrapper.h
+++ b/platform/android/api/java_class_wrapper.h
@@ -32,16 +32,22 @@
#define JAVA_CLASS_WRAPPER_H
#include "core/reference.h"
+
+#ifdef ANDROID_ENABLED
#include <android/log.h>
#include <jni.h>
+#endif
+#ifdef ANDROID_ENABLED
class JavaObject;
+#endif
class JavaClass : public Reference {
GDCLASS(JavaClass, Reference);
- enum ArgumentType {
+#ifdef ANDROID_ENABLED
+ enum ArgumentType{
ARG_TYPE_VOID,
ARG_TYPE_BOOLEAN,
@@ -159,6 +165,7 @@ class JavaClass : public Reference {
friend class JavaClassWrapper;
Map<StringName, List<MethodInfo> > methods;
jclass _class;
+#endif
public:
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
@@ -170,22 +177,27 @@ class JavaObject : public Reference {
GDCLASS(JavaObject, Reference);
+#ifdef ANDROID_ENABLED
Ref<JavaClass> base_class;
friend class JavaClass;
jobject instance;
+#endif
public:
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+#ifdef ANDROID_ENABLED
JavaObject(const Ref<JavaClass> &p_base, jobject *p_instance);
~JavaObject();
+#endif
};
class JavaClassWrapper : public Object {
GDCLASS(JavaClassWrapper, Object);
+#ifdef ANDROID_ENABLED
Map<String, Ref<JavaClass> > class_cache;
friend class JavaClass;
jclass activityClass;
@@ -211,6 +223,7 @@ class JavaClassWrapper : public Object {
jobject classLoader;
bool _get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig);
+#endif
static JavaClassWrapper *singleton;
@@ -222,7 +235,11 @@ public:
Ref<JavaClass> wrap(const String &p_class);
+#ifdef ANDROID_ENABLED
JavaClassWrapper(jobject p_activity = NULL);
+#else
+ JavaClassWrapper();
+#endif
};
#endif // JAVA_CLASS_WRAPPER_H
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index feebea2738..fe2fd89710 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "java_class_wrapper.h"
+#include "api/java_class_wrapper.h"
#include "string_android.h"
#include "thread_jandroid.h"
@@ -546,11 +546,6 @@ JavaObject::~JavaObject() {
////////////////////
-void JavaClassWrapper::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("wrap", "name"), &JavaClassWrapper::wrap);
-}
-
bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig) {
jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName);
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 858ff89cbc..dedb2ee114 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -33,6 +33,7 @@
#include "java_godot_wrapper.h"
#include "android/asset_manager_jni.h"
+#include "api/java_class_wrapper.h"
#include "audio_driver_jandroid.h"
#include "core/engine.h"
#include "core/os/keyboard.h"
@@ -40,7 +41,6 @@
#include "dir_access_jandroid.h"
#include "file_access_android.h"
#include "file_access_jandroid.h"
-#include "java_class_wrapper.h"
#include "main/input_default.h"
#include "main/main.h"
#include "net_socket_android.h"
@@ -739,7 +739,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo
}
java_class_wrapper = memnew(JavaClassWrapper(godot_java->get_activity()));
- Engine::get_singleton()->add_singleton(Engine::Singleton("JavaClassWrapper", java_class_wrapper));
_initialize_java_modules();
}