diff options
Diffstat (limited to 'platform/web')
-rw-r--r-- | platform/web/SCsub | 2 | ||||
-rw-r--r-- | platform/web/api/api.cpp | 52 | ||||
-rw-r--r-- | platform/web/api/javascript_bridge_singleton.h (renamed from platform/web/api/javascript_singleton.h) | 20 | ||||
-rw-r--r-- | platform/web/javascript_bridge_singleton.cpp (renamed from platform/web/javascript_singleton.cpp) | 20 | ||||
-rw-r--r-- | platform/web/os_web.cpp | 6 |
5 files changed, 50 insertions, 50 deletions
diff --git a/platform/web/SCsub b/platform/web/SCsub index ae9d628857..e8d0181ede 100644 --- a/platform/web/SCsub +++ b/platform/web/SCsub @@ -6,7 +6,7 @@ web_files = [ "audio_driver_web.cpp", "display_server_web.cpp", "http_client_web.cpp", - "javascript_singleton.cpp", + "javascript_bridge_singleton.cpp", "web_main.cpp", "os_web.cpp", "api/web_tools_editor_plugin.cpp", diff --git a/platform/web/api/api.cpp b/platform/web/api/api.cpp index a724b0456d..e637f2aef2 100644 --- a/platform/web/api/api.cpp +++ b/platform/web/api/api.cpp @@ -30,66 +30,66 @@ #include "api.h" #include "core/config/engine.h" -#include "javascript_singleton.h" +#include "javascript_bridge_singleton.h" #include "web_tools_editor_plugin.h" -static JavaScript *javascript_singleton; +static JavaScriptBridge *javascript_bridge_singleton; void register_web_api() { WebToolsEditorPlugin::initialize(); GDREGISTER_ABSTRACT_CLASS(JavaScriptObject); - GDREGISTER_ABSTRACT_CLASS(JavaScript); - javascript_singleton = memnew(JavaScript); - Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_singleton)); + GDREGISTER_ABSTRACT_CLASS(JavaScriptBridge); + javascript_bridge_singleton = memnew(JavaScriptBridge); + Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScriptBridge", javascript_bridge_singleton)); } void unregister_web_api() { - memdelete(javascript_singleton); + memdelete(javascript_bridge_singleton); } -JavaScript *JavaScript::singleton = nullptr; +JavaScriptBridge *JavaScriptBridge::singleton = nullptr; -JavaScript *JavaScript::get_singleton() { +JavaScriptBridge *JavaScriptBridge::get_singleton() { return singleton; } -JavaScript::JavaScript() { - ERR_FAIL_COND_MSG(singleton != nullptr, "JavaScript singleton already exist."); +JavaScriptBridge::JavaScriptBridge() { + ERR_FAIL_COND_MSG(singleton != nullptr, "JavaScriptBridge singleton already exist."); singleton = this; } -JavaScript::~JavaScript() {} +JavaScriptBridge::~JavaScriptBridge() {} -void JavaScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_interface", "interface"), &JavaScript::get_interface); - ClassDB::bind_method(D_METHOD("create_callback", "callable"), &JavaScript::create_callback); +void JavaScriptBridge::_bind_methods() { + ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScriptBridge::eval, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("get_interface", "interface"), &JavaScriptBridge::get_interface); + ClassDB::bind_method(D_METHOD("create_callback", "callable"), &JavaScriptBridge::create_callback); { MethodInfo mi; mi.name = "create_object"; mi.arguments.push_back(PropertyInfo(Variant::STRING, "object")); - ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "create_object", &JavaScript::_create_object_bind, mi); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "create_object", &JavaScriptBridge::_create_object_bind, mi); } - ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScript::download_buffer, DEFVAL("application/octet-stream")); - ClassDB::bind_method(D_METHOD("pwa_needs_update"), &JavaScript::pwa_needs_update); - ClassDB::bind_method(D_METHOD("pwa_update"), &JavaScript::pwa_update); + ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScriptBridge::download_buffer, DEFVAL("application/octet-stream")); + ClassDB::bind_method(D_METHOD("pwa_needs_update"), &JavaScriptBridge::pwa_needs_update); + ClassDB::bind_method(D_METHOD("pwa_update"), &JavaScriptBridge::pwa_update); ADD_SIGNAL(MethodInfo("pwa_update_available")); } #if !defined(WEB_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED) -Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { +Variant JavaScriptBridge::eval(const String &p_code, bool p_use_global_exec_context) { return Variant(); } -Ref<JavaScriptObject> JavaScript::get_interface(const String &p_interface) { +Ref<JavaScriptObject> JavaScriptBridge::get_interface(const String &p_interface) { return Ref<JavaScriptObject>(); } -Ref<JavaScriptObject> JavaScript::create_callback(const Callable &p_callable) { +Ref<JavaScriptObject> JavaScriptBridge::create_callback(const Callable &p_callable) { return Ref<JavaScriptObject>(); } -Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { +Variant JavaScriptBridge::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = 0; @@ -105,12 +105,12 @@ Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount, } #endif #if !defined(WEB_ENABLED) -bool JavaScript::pwa_needs_update() const { +bool JavaScriptBridge::pwa_needs_update() const { return false; } -Error JavaScript::pwa_update() { +Error JavaScriptBridge::pwa_update() { return ERR_UNAVAILABLE; } -void JavaScript::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { +void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { } #endif diff --git a/platform/web/api/javascript_singleton.h b/platform/web/api/javascript_bridge_singleton.h index e93b0a18a1..1e7b5a1699 100644 --- a/platform/web/api/javascript_singleton.h +++ b/platform/web/api/javascript_bridge_singleton.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* javascript_singleton.h */ +/* javascript_bridge_singleton.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef JAVASCRIPT_SINGLETON_H -#define JAVASCRIPT_SINGLETON_H +#ifndef JAVASCRIPT_BRIDGE_SINGLETON_H +#define JAVASCRIPT_BRIDGE_SINGLETON_H #include "core/object/class_db.h" #include "core/object/ref_counted.h" @@ -44,11 +44,11 @@ protected: virtual void _get_property_list(List<PropertyInfo> *p_list) const {} }; -class JavaScript : public Object { +class JavaScriptBridge : public Object { private: - GDCLASS(JavaScript, Object); + GDCLASS(JavaScriptBridge, Object); - static JavaScript *singleton; + static JavaScriptBridge *singleton; protected: static void _bind_methods(); @@ -62,9 +62,9 @@ public: bool pwa_needs_update() const; Error pwa_update(); - static JavaScript *get_singleton(); - JavaScript(); - ~JavaScript(); + static JavaScriptBridge *get_singleton(); + JavaScriptBridge(); + ~JavaScriptBridge(); }; -#endif // JAVASCRIPT_SINGLETON_H +#endif // JAVASCRIPT_BRIDGE_SINGLETON_H diff --git a/platform/web/javascript_singleton.cpp b/platform/web/javascript_bridge_singleton.cpp index 36ab4db452..69cd0cece1 100644 --- a/platform/web/javascript_singleton.cpp +++ b/platform/web/javascript_bridge_singleton.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* javascript_singleton.cpp */ +/* javascript_bridge_singleton.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "api/javascript_singleton.h" +#include "api/javascript_bridge_singleton.h" #include "emscripten.h" #include "os_web.h" @@ -62,7 +62,7 @@ extern int godot_js_wrapper_create_object(const char *p_method, void **p_args, i class JavaScriptObjectImpl : public JavaScriptObject { private: - friend class JavaScript; + friend class JavaScriptBridge; int _js_id = 0; Callable _callable; @@ -272,20 +272,20 @@ void JavaScriptObjectImpl::_callback(void *p_ref, int p_args_id, int p_argc) { } } -Ref<JavaScriptObject> JavaScript::create_callback(const Callable &p_callable) { +Ref<JavaScriptObject> JavaScriptBridge::create_callback(const Callable &p_callable) { Ref<JavaScriptObjectImpl> out = memnew(JavaScriptObjectImpl); out->_callable = p_callable; out->_js_id = godot_js_wrapper_create_cb(out.ptr(), JavaScriptObjectImpl::_callback); return out; } -Ref<JavaScriptObject> JavaScript::get_interface(const String &p_interface) { +Ref<JavaScriptObject> JavaScriptBridge::get_interface(const String &p_interface) { int js_id = godot_js_wrapper_interface_get(p_interface.utf8().get_data()); ERR_FAIL_COND_V_MSG(!js_id, Ref<JavaScriptObject>(), "No interface '" + p_interface + "' registered."); return Ref<JavaScriptObject>(memnew(JavaScriptObjectImpl(js_id))); } -Variant JavaScript::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { +Variant JavaScriptBridge::_create_object_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_error.argument = 0; @@ -328,7 +328,7 @@ void *resize_PackedByteArray_and_open_write(void *p_arr, void *r_write, int p_le return arr->ptrw(); } -Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { +Variant JavaScriptBridge::eval(const String &p_code, bool p_use_global_exec_context) { union js_eval_ret js_data; PackedByteArray arr; VectorWriteProxy<uint8_t> arr_write; @@ -354,13 +354,13 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { } #endif // JAVASCRIPT_EVAL_ENABLED -void JavaScript::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { +void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) { godot_js_os_download_buffer(p_arr.ptr(), p_arr.size(), p_name.utf8().get_data(), p_mime.utf8().get_data()); } -bool JavaScript::pwa_needs_update() const { +bool JavaScriptBridge::pwa_needs_update() const { return OS_Web::get_singleton()->pwa_needs_update(); } -Error JavaScript::pwa_update() { +Error JavaScriptBridge::pwa_update() { return OS_Web::get_singleton()->pwa_update(); } diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp index f9714f25e7..ebe56924df 100644 --- a/platform/web/os_web.cpp +++ b/platform/web/os_web.cpp @@ -45,7 +45,7 @@ #include <emscripten.h> #include <stdlib.h> -#include "api/javascript_singleton.h" +#include "api/javascript_bridge_singleton.h" #include "godot_js.h" void OS_Web::alert(const String &p_alert, const String &p_title) { @@ -199,8 +199,8 @@ void OS_Web::update_pwa_state_callback() { if (OS_Web::get_singleton()) { OS_Web::get_singleton()->pwa_is_waiting = true; } - if (JavaScript::get_singleton()) { - JavaScript::get_singleton()->emit_signal("pwa_update_available"); + if (JavaScriptBridge::get_singleton()) { + JavaScriptBridge::get_singleton()->emit_signal("pwa_update_available"); } } |