Merge pull request #12961 from eska014/platform-doc
Facilitate documenting platform-exclusive classes
This commit is contained in:
commit
992a40a50d
12 changed files with 211 additions and 35 deletions
73
platform/javascript/api/api.cpp
Normal file
73
platform/javascript/api/api.cpp
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*************************************************************************/
|
||||
/* api.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2017 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. */
|
||||
/*************************************************************************/
|
||||
#include "api.h"
|
||||
#include "engine.h"
|
||||
#include "javascript_eval.h"
|
||||
|
||||
static JavaScript *javascript_eval;
|
||||
|
||||
void register_javascript_api() {
|
||||
|
||||
ClassDB::register_virtual_class<JavaScript>();
|
||||
javascript_eval = memnew(JavaScript);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval));
|
||||
}
|
||||
|
||||
void unregister_javascript_api() {
|
||||
|
||||
memdelete(javascript_eval);
|
||||
}
|
||||
|
||||
JavaScript *JavaScript::singleton = NULL;
|
||||
|
||||
JavaScript *JavaScript::get_singleton() {
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
JavaScript::JavaScript() {
|
||||
|
||||
ERR_FAIL_COND(singleton != NULL);
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
JavaScript::~JavaScript() {}
|
||||
|
||||
void JavaScript::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, DEFVAL(false));
|
||||
}
|
||||
|
||||
#if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED)
|
||||
Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
|
||||
|
||||
return Variant();
|
||||
}
|
||||
#endif
|
||||
31
platform/javascript/api/api.h
Normal file
31
platform/javascript/api/api.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*************************************************************************/
|
||||
/* api.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2017 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_javascript_api();
|
||||
void unregister_javascript_api();
|
||||
|
|
@ -27,8 +27,6 @@
|
|||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifdef JAVASCRIPT_EVAL_ENABLED
|
||||
|
||||
#ifndef JAVASCRIPT_EVAL_H
|
||||
#define JAVASCRIPT_EVAL_H
|
||||
|
||||
|
|
@ -52,4 +50,3 @@ public:
|
|||
};
|
||||
|
||||
#endif // JAVASCRIPT_EVAL_H
|
||||
#endif // JAVASCRIPT_EVAL_ENABLED
|
||||
|
|
@ -29,16 +29,9 @@
|
|||
/*************************************************************************/
|
||||
#ifdef JAVASCRIPT_EVAL_ENABLED
|
||||
|
||||
#include "javascript_eval.h"
|
||||
#include "api/javascript_eval.h"
|
||||
#include "emscripten.h"
|
||||
|
||||
JavaScript *JavaScript::singleton = NULL;
|
||||
|
||||
JavaScript *JavaScript::get_singleton() {
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_poolbytearray_and_open_write(PoolByteArray *p_arr, PoolByteArray::Write *r_write, int p_len) {
|
||||
|
||||
p_arr->resize(p_len);
|
||||
|
|
@ -182,18 +175,4 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
|
|||
return Variant();
|
||||
}
|
||||
|
||||
void JavaScript::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false);
|
||||
}
|
||||
|
||||
JavaScript::JavaScript() {
|
||||
|
||||
ERR_FAIL_COND(singleton != NULL);
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
JavaScript::~JavaScript() {
|
||||
}
|
||||
|
||||
#endif // JAVASCRIPT_EVAL_ENABLED
|
||||
|
|
|
|||
|
|
@ -512,11 +512,6 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i
|
|||
#undef SET_EM_CALLBACK
|
||||
#undef EM_CHECK
|
||||
|
||||
#ifdef JAVASCRIPT_EVAL_ENABLED
|
||||
javascript_eval = memnew(JavaScript);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval));
|
||||
#endif
|
||||
|
||||
visual_server->init();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "audio_driver_javascript.h"
|
||||
#include "drivers/unix/os_unix.h"
|
||||
#include "javascript_eval.h"
|
||||
#include "main/input_default.h"
|
||||
#include "os/input.h"
|
||||
#include "os/main_loop.h"
|
||||
|
|
@ -67,10 +66,6 @@ class OS_JavaScript : public OS_Unix {
|
|||
|
||||
PowerJavascript *power_manager;
|
||||
|
||||
#ifdef JAVASCRIPT_EVAL_ENABLED
|
||||
JavaScript *javascript_eval;
|
||||
#endif
|
||||
|
||||
static void _close_notification_funcs(const String &p_file, int p_flags);
|
||||
|
||||
void process_joypads();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue