/*************************************************************************/ /* nativescript.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2021 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/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 #ifndef NO_THREADS #include "core/os/mutex.h" #endif struct NativeScriptDesc { struct Method { godot_instance_method method; MethodInfo info; int rpc_mode; String documentation; }; struct Property { godot_property_set_func setter; godot_property_get_func getter; PropertyInfo info; Variant default_value; int rset_mode; String documentation; }; struct Signal { MethodInfo signal; String documentation; }; Map methods; OrderedHashMap properties; Map signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; NativeScriptDesc *base_data; godot_instance_create_func create_func; godot_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(NULL) { zeromem(&create_func, sizeof(godot_instance_create_func)); zeromem(&destroy_func, sizeof(godot_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; #ifndef NO_THREADS Mutex *owners_lock; #endif Set instance_owners; protected: static void _bind_methods(); public: inline NativeScriptDesc *get_script_desc() const; void set_class_name(String p_class_name); String get_class_name() const; void set_library(Ref p_library); Ref get_library() const; void set_script_class_name(String p_type); String get_script_class_name() const; void set_script_class_icon_path(String p_icon_path); String get_script_class_icon_path() const; virtual bool can_instance() const; virtual Ref