/*************************************************************************/ /* nativescript.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 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/doc_data.h" #include "core/io/resource.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" #include "core/os/mutex.h" #include "core/os/thread_safe.h" #include "core/templates/oa_hash_map.h" #include "core/templates/ordered_hash_map.h" #include "core/templates/safe_refcount.h" #include "core/templates/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 = 0; uint16_t rpc_method_id = 0; String documentation; }; struct Property { godot_nativescript_property_set_func setter; godot_nativescript_property_get_func getter; PropertyInfo info; Variant default_value; String documentation; }; struct Signal { MethodInfo signal; String documentation; }; Map methods; Vector rpc_methods; OrderedHashMap properties; Map signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; NativeScriptDesc *base_data = nullptr; godot_nativescript_instance_create_func create_func; godot_nativescript_instance_destroy_func destroy_func; String documentation; const void *type_tag = nullptr; bool is_tool = false; inline NativeScriptDesc() { memset(&create_func, 0, sizeof(godot_nativescript_instance_create_func)); memset(&destroy_func, 0, 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) override; #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