/**************************************************************************/ /* nativescript.h */ /**************************************************************************/ /* This file is part of: */ /* PANDEMONIUM ENGINE */ /* https://pandemoniumengine.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. */ /**************************************************************************/ #ifndef NATIVESCRIPT_H #define NATIVESCRIPT_H #include "core/containers/oa_hash_map.h" #include "core/containers/ordered_hash_map.h" #include "core/containers/self_list.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/resource.h" #include "core/object/script_language.h" #include "core/os/safe_refcount.h" #include "core/os/thread_safe.h" #include "scene/main/node.h" #include "../gdnative.h" #include #ifndef NO_THREADS #include "core/os/mutex.h" #endif struct NativeScriptDesc { struct Method { pandemonium_instance_method method; MethodInfo info; int rpc_mode; String documentation; }; struct Property { pandemonium_property_set_func setter; pandemonium_property_get_func getter; PropertyInfo info; Variant default_value; int rset_mode; String documentation; }; struct Signal { MethodInfo signal; String documentation; }; RBMap methods; OrderedHashMap properties; RBMap signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; NativeScriptDesc *base_data; pandemonium_instance_create_func create_func; pandemonium_instance_destroy_func destroy_func; String documentation; const void *type_tag; bool is_tool; inline NativeScriptDesc() : methods(), properties(), signals_(), base(), base_native_type(), documentation(), type_tag(nullptr) { memset(&create_func, 0, sizeof(pandemonium_instance_create_func)); memset(&destroy_func, 0, sizeof(pandemonium_instance_destroy_func)); } }; class NativeScript : public Script { GDCLASS(NativeScript, Script); #ifdef TOOLS_ENABLED RBSet placeholders; void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); #endif friend class NativeScriptInstance; friend class NativeScriptLanguage; friend class NativeReloadNode; friend class GDNativeLibrary; Ref library; String lib_path; String class_name; String script_class_name; String script_class_icon_path; Mutex owners_lock; RBSet instance_owners; protected: static void _bind_methods(); public: inline NativeScriptDesc *get_script_desc() const; bool inherits_script(const Ref