/*************************************************************************/ /* nativescript.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2020 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. */ /*************************************************************************/ #ifndef NATIVE_SCRIPT_H #define NATIVE_SCRIPT_H #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/oa_hash_map.h" #include "core/ordered_hash_map.h" #include "core/os/mutex.h" #include "core/os/thread_safe.h" #include "core/resource.h" #include "core/script_language.h" #include "core/self_list.h" #include "scene/main/node.h" #include "modules/gdnative/gdnative.h" #include struct NativeScriptDesc { struct Method { godot_nativescript_instance_method method; MethodInfo info; int rpc_mode; uint16_t rpc_method_id; String documentation; }; struct Property { godot_nativescript_property_set_func setter; godot_nativescript_property_get_func getter; PropertyInfo info; Variant default_value; int rset_mode; uint16_t rset_property_id; String documentation; }; struct Signal { MethodInfo signal; String documentation; }; uint16_t rpc_count = 0; Map methods; uint16_t rset_count = 0; OrderedHashMap properties; Map signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; NativeScriptDesc *base_data; godot_nativescript_instance_create_func create_func; godot_nativescript_instance_destroy_func destroy_func; String documentation; const void *type_tag = nullptr; bool is_tool; inline NativeScriptDesc() { zeromem(&create_func, sizeof(godot_nativescript_instance_create_func)); zeromem(&destroy_func, sizeof(godot_nativescript_instance_destroy_func)); } }; class NativeScript : public Script { GDCLASS(NativeScript, Script); #ifdef TOOLS_ENABLED Set 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; Set instance_owners; protected: static void _bind_methods(); public: inline NativeScriptDesc *get_script_desc() const; bool inherits_script(const Ref