Merge commit '921d0574a0' as 'engine'

This commit is contained in:
Sara Gerretsen 2026-04-04 14:46:33 +02:00
commit add768b79b
14224 changed files with 7489260 additions and 0 deletions

View file

@ -0,0 +1,142 @@
/**************************************************************************/
/* api.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#include "api.h"
#include "java_class_wrapper.h"
#include "jni_singleton.h"
#include "core/config/engine.h"
#include "core/object/class_db.h"
#if !defined(ANDROID_ENABLED)
static JavaClassWrapper *java_class_wrapper = nullptr;
#endif
void register_android_api() {
#if !defined(ANDROID_ENABLED)
// On Android platforms, the `java_class_wrapper` instantiation occurs in
// `platform/android/java_godot_lib_jni.cpp#Java_org_godotengine_godot_GodotLib_setup`
java_class_wrapper = memnew(JavaClassWrapper);
#endif
GDREGISTER_CLASS(JNISingleton);
GDREGISTER_CLASS(JavaClass);
GDREGISTER_CLASS(JavaObject);
GDREGISTER_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 JavaClass::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_java_class_name"), &JavaClass::get_java_class_name);
ClassDB::bind_method(D_METHOD("get_java_method_list"), &JavaClass::get_java_method_list);
ClassDB::bind_method(D_METHOD("get_java_parent_class"), &JavaClass::get_java_parent_class);
ClassDB::bind_method(D_METHOD("has_java_method", "method"), &JavaClass::has_java_method);
}
void JavaObject::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_java_class"), &JavaObject::get_java_class);
ClassDB::bind_method(D_METHOD("has_java_method", "method"), &JavaObject::has_java_method);
}
void JavaClassWrapper::_bind_methods() {
ClassDB::bind_method(D_METHOD("wrap", "name"), &JavaClassWrapper::wrap);
ClassDB::bind_method(D_METHOD("get_exception"), &JavaClassWrapper::get_exception);
ClassDB::bind_method(D_METHOD("create_sam_callback", "sam_interface", "callable"), &JavaClassWrapper::create_sam_callback);
ClassDB::bind_method(D_METHOD("create_proxy", "object", "interfaces"), &JavaClassWrapper::create_proxy);
}
#if !defined(ANDROID_ENABLED)
bool JavaClass::_get(const StringName &p_name, Variant &r_ret) const {
return false;
}
Variant JavaClass::callp(const StringName &, const Variant **, int, Callable::CallError &) {
return Variant();
}
String JavaClass::get_java_class_name() const {
return "";
}
TypedArray<Dictionary> JavaClass::get_java_method_list() const {
return TypedArray<Dictionary>();
}
Ref<JavaClass> JavaClass::get_java_parent_class() const {
return Ref<JavaClass>();
}
bool JavaClass::has_java_method(const StringName &) const {
return false;
}
JavaClass::JavaClass() {
}
JavaClass::~JavaClass() {
}
Variant JavaObject::callp(const StringName &, const Variant **, int, Callable::CallError &) {
return Variant();
}
Ref<JavaClass> JavaObject::get_java_class() const {
return Ref<JavaClass>();
}
bool JavaObject::has_java_method(const StringName &) const {
return false;
}
JavaClassWrapper *JavaClassWrapper::singleton = nullptr;
Ref<JavaClass> JavaClassWrapper::_wrap(const String &, bool) {
return Ref<JavaClass>();
}
Ref<JavaObject> JavaClassWrapper::create_sam_callback(const String &p_interface, const Callable &p_callable) {
return Ref<JavaObject>();
}
Ref<JavaObject> JavaClassWrapper::create_proxy(const Object *p_object, const PackedStringArray &p_interfaces) {
return Ref<JavaObject>();
}
JavaClassWrapper::JavaClassWrapper() {
singleton = this;
}
#endif

View file

@ -0,0 +1,34 @@
/**************************************************************************/
/* api.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#pragma once
void register_android_api();
void unregister_android_api();

View file

@ -0,0 +1,317 @@
/**************************************************************************/
/* java_class_wrapper.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#pragma once
#include "core/object/ref_counted.h"
#include "core/variant/typed_array.h"
#ifdef ANDROID_ENABLED
#include "core/templates/rb_map.h"
#include <android/log.h>
#include <jni.h>
#endif
#ifdef ANDROID_ENABLED
class JavaObject;
#endif
class JavaClass : public RefCounted {
GDCLASS(JavaClass, RefCounted);
#ifdef ANDROID_ENABLED
enum ArgumentType {
ARG_TYPE_VOID,
ARG_TYPE_BOOLEAN,
ARG_TYPE_BYTE,
ARG_TYPE_CHAR,
ARG_TYPE_SHORT,
ARG_TYPE_INT,
ARG_TYPE_LONG,
ARG_TYPE_FLOAT,
ARG_TYPE_DOUBLE,
ARG_TYPE_STRING, //special case
ARG_TYPE_CHARSEQUENCE,
ARG_TYPE_CALLABLE,
ARG_TYPE_CLASS,
ARG_ARRAY_BIT = 1 << 16,
ARG_NUMBER_CLASS_BIT = 1 << 17,
ARG_TYPE_MASK = (1 << 16) - 1
};
RBMap<StringName, Variant> constant_map;
struct MethodInfo {
bool _public = false;
bool _static = false;
bool _constructor = false;
Vector<uint32_t> param_types;
Vector<StringName> param_sigs;
uint32_t return_type = 0;
jmethodID method;
};
_FORCE_INLINE_ static void _convert_to_variant_type(int p_sig, Variant::Type &r_type, float &likelihood) {
likelihood = 1.0;
r_type = Variant::NIL;
switch (p_sig) {
case ARG_TYPE_VOID:
r_type = Variant::NIL;
break;
case ARG_TYPE_BOOLEAN | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_BOOLEAN:
r_type = Variant::BOOL;
break;
case ARG_TYPE_BYTE | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_BYTE:
r_type = Variant::INT;
likelihood = 0.1;
break;
case ARG_TYPE_CHAR | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_CHAR:
r_type = Variant::INT;
likelihood = 0.2;
break;
case ARG_TYPE_SHORT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_SHORT:
r_type = Variant::INT;
likelihood = 0.3;
break;
case ARG_TYPE_INT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_INT:
r_type = Variant::INT;
likelihood = 1.0;
break;
case ARG_TYPE_LONG | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_LONG:
r_type = Variant::INT;
likelihood = 0.5;
break;
case ARG_TYPE_FLOAT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_FLOAT:
r_type = Variant::FLOAT;
likelihood = 1.0;
break;
case ARG_TYPE_DOUBLE | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_DOUBLE:
r_type = Variant::FLOAT;
likelihood = 0.5;
break;
case ARG_TYPE_STRING:
case ARG_TYPE_CHARSEQUENCE:
r_type = Variant::STRING;
break;
case ARG_TYPE_CALLABLE:
r_type = Variant::CALLABLE;
break;
case ARG_TYPE_CLASS:
r_type = Variant::OBJECT;
break;
case ARG_ARRAY_BIT | ARG_TYPE_VOID:
r_type = Variant::NIL;
break;
case ARG_ARRAY_BIT | ARG_TYPE_BOOLEAN:
r_type = Variant::ARRAY;
break;
case ARG_ARRAY_BIT | ARG_TYPE_BYTE:
r_type = Variant::PACKED_BYTE_ARRAY;
likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_CHAR:
r_type = Variant::PACKED_BYTE_ARRAY;
likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_SHORT:
r_type = Variant::PACKED_INT32_ARRAY;
likelihood = 0.3;
break;
case ARG_ARRAY_BIT | ARG_TYPE_INT:
r_type = Variant::PACKED_INT32_ARRAY;
likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_LONG:
r_type = Variant::PACKED_INT32_ARRAY;
likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_FLOAT:
r_type = Variant::PACKED_FLOAT32_ARRAY;
likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_DOUBLE:
r_type = Variant::PACKED_FLOAT32_ARRAY;
likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_STRING:
case ARG_ARRAY_BIT | ARG_TYPE_CHARSEQUENCE:
r_type = Variant::PACKED_STRING_ARRAY;
break;
case ARG_ARRAY_BIT | ARG_TYPE_CLASS:
case ARG_ARRAY_BIT | ARG_TYPE_CALLABLE:
r_type = Variant::ARRAY;
break;
}
}
_FORCE_INLINE_ static bool _convert_object_to_variant(JNIEnv *env, jobject obj, Variant &var, uint32_t p_sig);
bool _call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error, Variant &ret);
friend class JavaClassWrapper;
friend class JavaObject;
String java_class_name;
String java_constructor_name;
HashMap<StringName, List<MethodInfo>> methods;
jclass _class;
bool is_interface;
#endif
protected:
static void _bind_methods();
bool _get(const StringName &p_name, Variant &r_ret) const;
public:
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
String get_java_class_name() const;
TypedArray<Dictionary> get_java_method_list() const;
Ref<JavaClass> get_java_parent_class() const;
bool has_java_method(const StringName &p_method) const;
#ifdef ANDROID_ENABLED
virtual String _to_string() override;
#endif
JavaClass();
~JavaClass();
};
class JavaObject : public RefCounted {
GDCLASS(JavaObject, RefCounted);
#ifdef ANDROID_ENABLED
Ref<JavaClass> base_class;
friend class JavaClass;
jobject instance = nullptr;
#endif
protected:
static void _bind_methods();
public:
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
Ref<JavaClass> get_java_class() const;
bool has_java_method(const StringName &p_method) const;
#ifdef ANDROID_ENABLED
virtual String _to_string() override;
jobject get_instance() { return instance; }
JavaObject();
JavaObject(const Ref<JavaClass> &p_base, jobject p_instance);
~JavaObject();
#endif
};
class JavaClassWrapper : public Object {
GDCLASS(JavaClassWrapper, Object);
#ifdef ANDROID_ENABLED
RBMap<String, Ref<JavaClass>> class_cache;
friend class JavaClass;
jmethodID Class_getConstructors;
jmethodID Class_getDeclaredMethods;
jmethodID Class_getFields;
jmethodID Class_getInterfaces;
jmethodID Class_getName;
jmethodID Class_getSuperclass;
jmethodID Class_isInterface;
jmethodID Constructor_getParameterTypes;
jmethodID Constructor_getModifiers;
jmethodID Method_getParameterTypes;
jmethodID Method_getReturnType;
jmethodID Method_getModifiers;
jmethodID Method_getName;
jmethodID Field_getName;
jmethodID Field_getModifiers;
jmethodID Field_get;
jmethodID Boolean_booleanValue;
jmethodID Byte_byteValue;
jmethodID Character_characterValue;
jmethodID Short_shortValue;
jmethodID Integer_integerValue;
jmethodID Long_longValue;
jmethodID Float_floatValue;
jmethodID Double_doubleValue;
jclass proxy_class;
jmethodID Proxy_isProxyClass;
jclass android_runtime_class;
jmethodID ARP_create_proxy_from_godot_callable;
jmethodID ARP_create_proxy_from_godot_object_id;
bool _is_proxy_class(JNIEnv *env, jclass p_class);
bool _get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig);
bool _wrap_class_components(JNIEnv *p_env, const Ref<JavaClass> &p_java_class, jclass p_class, bool p_allow_non_public_methods_access);
#endif
Ref<JavaObject> exception;
Ref<JavaClass> _wrap(const String &p_class, bool p_allow_non_public_methods_access = false);
static JavaClassWrapper *singleton;
protected:
static void _bind_methods();
public:
static JavaClassWrapper *get_singleton() { return singleton; }
Ref<JavaClass> wrap(const String &p_class) {
return _wrap(p_class, false);
}
Ref<JavaObject> create_sam_callback(const String &p_sam_interface, const Callable &p_callable);
Ref<JavaObject> create_proxy(const Object *p_object, const PackedStringArray &p_interfaces);
Ref<JavaObject> get_exception() {
return exception;
}
#ifdef ANDROID_ENABLED
Ref<JavaClass> wrap_jclass(jclass p_class, bool p_allow_non_public_methods_access = false);
#endif
JavaClassWrapper();
};

View file

@ -0,0 +1,77 @@
/**************************************************************************/
/* jni_singleton.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#include "jni_singleton.h"
#include "core/object/class_db.h"
void JNISingleton::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_java_method", "method"), &JNISingleton::has_java_method);
}
Variant JNISingleton::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
// Godot methods take precedence.
Variant ret = Object::callp(p_method, p_args, p_argcount, r_error);
if (r_error.error == Callable::CallError::CALL_OK) {
return ret;
}
// Check the method we're looking for is in the JNISingleton map.
// This is done because JNISingletons register methods differently than wrapped JavaClass / JavaObject to allow
// for access to private methods annotated with the @UsedByGodot annotation.
// In the future, we should remove access to private methods and require that JNISingletons' methods exposed to
// GDScript be all public, similarly to what we do for wrapped JavaClass / JavaObject methods. Doing so will
// also allow dropping and deprecating the @UsedByGodot annotation.
RBMap<StringName, MethodData>::Element *E = method_map.find(p_method);
if (E) {
if (wrapped_object.is_valid()) {
return wrapped_object->callp(p_method, p_args, p_argcount, r_error);
} else {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
}
}
return Variant();
}
void JNISingleton::add_method(const StringName &p_name, const Vector<Variant::Type> &p_args, Variant::Type p_ret_type) {
MethodData md;
md.argtypes = p_args;
md.ret_type = p_ret_type;
method_map[p_name] = md;
}
void JNISingleton::add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args) {
MethodInfo mi;
mi.name = p_name;
for (int i = 0; i < p_args.size(); i++) {
mi.arguments.push_back(PropertyInfo(p_args[i], "arg" + itos(i + 1)));
}
ADD_SIGNAL(mi);
}

View file

@ -0,0 +1,77 @@
/**************************************************************************/
/* jni_singleton.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/**************************************************************************/
#pragma once
#include "java_class_wrapper.h"
#include "core/templates/rb_map.h"
#include "core/variant/variant.h"
class JNISingleton : public Object {
GDCLASS(JNISingleton, Object);
struct MethodData {
Variant::Type ret_type;
Vector<Variant::Type> argtypes;
};
RBMap<StringName, MethodData> method_map;
Ref<JavaObject> wrapped_object;
protected:
static void _bind_methods();
public:
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
Ref<JavaObject> get_wrapped_object() const {
return wrapped_object;
}
bool has_java_method(const StringName &p_method) const {
return method_map.has(p_method);
}
void add_method(const StringName &p_name, const Vector<Variant::Type> &p_args, Variant::Type p_ret_type);
void add_signal(const StringName &p_name, const Vector<Variant::Type> &p_args);
JNISingleton() {}
JNISingleton(const Ref<JavaObject> &p_wrapped_object) {
wrapped_object = p_wrapped_object;
}
~JNISingleton() {
method_map.clear();
wrapped_object.unref();
}
};