diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 4 | ||||
-rw-r--r-- | core/dictionary.cpp | 21 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 4 | ||||
-rw-r--r-- | core/io/tcp_server.cpp | 2 | ||||
-rw-r--r-- | core/method_ptrcall.h | 56 | ||||
-rw-r--r-- | core/object.cpp | 11 | ||||
-rw-r--r-- | core/object.h | 2 | ||||
-rw-r--r-- | core/resource.cpp | 3 | ||||
-rw-r--r-- | core/safe_refcount.cpp | 6 | ||||
-rw-r--r-- | core/script_language.cpp | 7 | ||||
-rw-r--r-- | core/script_language.h | 1 |
11 files changed, 79 insertions, 38 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 69d0ba7851..ce08b3f754 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -149,7 +149,7 @@ _ResourceSaver *_ResourceSaver::singleton = NULL; void _ResourceSaver::_bind_methods() { ClassDB::bind_method(D_METHOD("save", "path", "resource:Resource", "flags"), &_ResourceSaver::save, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions); + ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type:Resource"), &_ResourceSaver::get_recognized_extensions); BIND_CONSTANT(FLAG_RELATIVE_PATHS); BIND_CONSTANT(FLAG_BUNDLE_RESOURCES); @@ -998,7 +998,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window); ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window); - ClassDB::bind_method(D_METHOD("set_ime_position"), &_OS::set_ime_position); + ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position); ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation); ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index e6d549b83d..1fe45aff94 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -200,6 +200,7 @@ uint32_t Dictionary::hash() const { Array Dictionary::keys() const { +#if 0 Array karr; karr.resize(size()); const Variant *K = NULL; @@ -208,6 +209,26 @@ Array Dictionary::keys() const { karr[idx++] = (*K); } return karr; +#else + + Array varr; + varr.resize(size()); + if (_p->variant_map.empty()) + return varr; + + int count = _p->variant_map.size(); + const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *)); + _p->variant_map.get_key_value_ptr_array(pairs); + + SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort; + sort.sort(pairs, count); + + for (int i = 0; i < count; i++) { + varr[i] = pairs[i]->key; + } + + return varr; +#endif } Array Dictionary::values() const { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 57acb6c754..285cc6e3c2 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_loader.h" -#include "project_settings.h" #include "io/resource_import.h" #include "os/file_access.h" #include "os/os.h" #include "path_remap.h" #include "print_string.h" +#include "project_settings.h" #include "translation.h" ResourceFormatLoader *ResourceLoader::loader[MAX_LOADERS]; @@ -84,7 +84,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li void ResourceInteractiveLoader::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_resource"), &ResourceInteractiveLoader::get_resource); + ClassDB::bind_method(D_METHOD("get_resource:Resource"), &ResourceInteractiveLoader::get_resource); ClassDB::bind_method(D_METHOD("poll"), &ResourceInteractiveLoader::poll); ClassDB::bind_method(D_METHOD("wait"), &ResourceInteractiveLoader::wait); ClassDB::bind_method(D_METHOD("get_stage"), &ResourceInteractiveLoader::get_stage); diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 29a80ecc19..4c891188ee 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -49,7 +49,7 @@ void TCP_Server::_bind_methods() { ClassDB::bind_method(D_METHOD("listen", "port", "bind_address"), &TCP_Server::listen, DEFVAL("*")); ClassDB::bind_method(D_METHOD("is_connection_available"), &TCP_Server::is_connection_available); - ClassDB::bind_method(D_METHOD("take_connection"), &TCP_Server::take_connection); + ClassDB::bind_method(D_METHOD("take_connection:StreamPeerTCP"), &TCP_Server::take_connection); ClassDB::bind_method(D_METHOD("stop"), &TCP_Server::stop); } diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index c6dbfc2a7a..ead58c23c8 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -60,37 +60,37 @@ struct PtrToArg { } \ } -#define MAKE_PTRARGR(m_type, m_ret) \ - template <> \ - struct PtrToArg<m_type> { \ - _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ - return *reinterpret_cast<const m_type *>(p_ptr); \ - } \ - _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_ret *)p_ptr) = p_val; \ - } \ - }; \ - template <> \ - struct PtrToArg<const m_type &> { \ - _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ - return *reinterpret_cast<const m_type *>(p_ptr); \ - } \ - _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ - *((m_ret *)p_ptr) = p_val; \ - } \ +#define MAKE_PTRARGCONV(m_type, m_conv) \ + template <> \ + struct PtrToArg<m_type> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \ + } \ + _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ + *((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \ + } \ + }; \ + template <> \ + struct PtrToArg<const m_type &> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + return static_cast<m_type>(*reinterpret_cast<const m_conv *>(p_ptr)); \ + } \ + _FORCE_INLINE_ static void encode(m_type p_val, void *p_ptr) { \ + *((m_conv *)p_ptr) = static_cast<m_conv>(p_val); \ + } \ } MAKE_PTRARG(bool); -MAKE_PTRARGR(uint8_t, int); -MAKE_PTRARGR(int8_t, int); -MAKE_PTRARGR(uint16_t, int); -MAKE_PTRARGR(int16_t, int); -MAKE_PTRARGR(uint32_t, int); -MAKE_PTRARGR(int32_t, int); -MAKE_PTRARGR(int64_t, int); -MAKE_PTRARGR(uint64_t, int); -MAKE_PTRARG(float); -MAKE_PTRARGR(double, float); +MAKE_PTRARGCONV(uint8_t, int64_t); +MAKE_PTRARGCONV(int8_t, int64_t); +MAKE_PTRARGCONV(uint16_t, int64_t); +MAKE_PTRARGCONV(int16_t, int64_t); +MAKE_PTRARGCONV(uint32_t, int64_t); +MAKE_PTRARGCONV(int32_t, int64_t); +MAKE_PTRARG(int64_t); +MAKE_PTRARG(uint64_t); +MAKE_PTRARGCONV(float, double); +MAKE_PTRARG(double); MAKE_PTRARG(String); MAKE_PTRARG(Vector2); diff --git a/core/object.cpp b/core/object.cpp index 000cefcac7..316c624268 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -993,6 +993,17 @@ void Object::cancel_delete() { _predelete_ok = true; } +void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance) { + + //this function is not meant to be used in any of these ways + ERR_FAIL_COND(p_script.is_null()); + ERR_FAIL_COND(!p_instance); + ERR_FAIL_COND(script_instance != NULL || !script.is_null()); + + script = p_script; + script_instance = p_instance; +} + void Object::set_script(const RefPtr &p_script) { if (script == p_script) diff --git a/core/object.h b/core/object.h index 556f3f1586..148a73fbc4 100644 --- a/core/object.h +++ b/core/object.h @@ -651,6 +651,8 @@ public: void set_script_instance(ScriptInstance *p_instance); _FORCE_INLINE_ ScriptInstance *get_script_instance() const { return script_instance; } + void set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process + void add_user_signal(const MethodInfo &p_signal); void emit_signal(const StringName &p_name, VARIANT_ARG_LIST); void emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); diff --git a/core/resource.cpp b/core/resource.cpp index a7a5498ef6..5625784396 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -31,7 +31,6 @@ #include "core_string_names.h" #include "io/resource_loader.h" -#include "io/resource_loader.h" #include "os/file_access.h" #include "script_language.h" #include <stdio.h> @@ -340,7 +339,7 @@ void Resource::_bind_methods() { ClassDB::bind_method(D_METHOD("get_local_scene:Node"), &Resource::get_local_scene); ClassDB::bind_method(D_METHOD("setup_local_to_scene"), &Resource::setup_local_to_scene); - ClassDB::bind_method(D_METHOD("duplicate", "subresources"), &Resource::duplicate, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("duplicate:Resource", "subresources"), &Resource::duplicate, DEFVAL(false)); ADD_SIGNAL(MethodInfo("changed")); ADD_GROUP("Resource", "resource_"); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene"); diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index 1bd16f9e4f..d7e5297321 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -55,7 +55,7 @@ static _ALWAYS_INLINE_ T _atomic_decrement_impl(register T *pw) { } template <class T> -static _ALWAYS_INLINE_T _atomic_increment_impl(register T *pw) { +static _ALWAYS_INLINE_ T _atomic_increment_impl(register T *pw) { (*pw)++; @@ -71,7 +71,7 @@ static _ALWAYS_INLINE_ T _atomic_sub_impl(register T *pw, register T val) { } template <class T> -static _ALWAYS_INLINE_T _atomic_add_impl(register T *pw, register T val) { +static _ALWAYS_INLINE_ T _atomic_add_impl(register T *pw, register T val) { (*pw) += val; @@ -185,7 +185,7 @@ static _ALWAYS_INLINE_ uint64_t _atomic_increment_impl(register uint64_t *pw) { static _ALWAYS_INLINE_ uint64_t _atomic_sub_impl(register uint64_t *pw, register uint64_t val) { -#if _WIN32_WINNT >= 0x0601 // Windows 7+ +#if _WIN32_WINNT >= 0x0601 && !defined(UWP_ENABLED) // Windows 7+ except UWP return InterlockedExchangeSubtract64(pw, val) - val; #else return InterlockedExchangeAdd64((LONGLONG volatile *)pw, -(int64_t)val) - val; diff --git a/core/script_language.cpp b/core/script_language.cpp index 4a7fdc9d64..aeb1573840 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -99,6 +99,13 @@ void ScriptServer::init_languages() { } } +void ScriptServer::finish_languages() { + + for (int i = 0; i < _language_count; i++) { + _languages[i]->finish(); + } +} + void ScriptServer::set_reload_scripts_on_save(bool p_enable) { reload_scripts_on_save = p_enable; diff --git a/core/script_language.h b/core/script_language.h index a81300233f..7aba3ec0f1 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -69,6 +69,7 @@ public: static void thread_exit(); static void init_languages(); + static void finish_languages(); }; class ScriptInstance; |