godot/platform/android/api/api.cpp
Ignacio Etcheverry a6105c8ea0 Fix ClassDB API portability with some android and editor classes
- `EditorNavigationMeshGenerator` was being registered as part of the Core API,
even after d3f48f88bb. We must make sure to
set Editor as the current ClassDB API type before creating an instance.

- The `VisualScriptEngineSingleton.constant` property has a property hint string
that's different between tools and non-tools builds. This commit makes the
hint string to no longer be set in `_bind_methods`, and to instead set it in
`_validate_property`. This way it's ignored when calculating the API hash.

- `JavaClassWrapper` is now registered in ClassDB on all platforms,
using a dummy implementation on platforms other than Android.
This fixes API portability between Android and other platforms.

- Updated `--class-db-json` command to ignore non-virtual methods that start
with an underscore (see: 4be87c6016).
2020-01-19 20:15:13 +01:00

57 lines
1.2 KiB
C++

#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