#ifndef CSCRIPT_H #define CSCRIPT_H /*************************************************************************/ /* gdscript.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. */ /*************************************************************************/ #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #include "core/object/script_language.h" #include "cscript_function.h" class CScriptNativeClass : public Reference { GDCLASS(CScriptNativeClass, Reference); StringName name; protected: bool _get(const StringName &p_name, Variant &r_ret) const; static void _bind_methods(); public: _FORCE_INLINE_ const StringName &get_name() const { return name; } Variant _new(); Object *instance(); CScriptNativeClass(const StringName &p_name); }; class CScript : public Script { GDCLASS(CScript, Script); bool tool; bool valid; struct MemberInfo { int index; StringName setter; StringName getter; CScriptDataType data_type; }; friend class CScriptInstance; friend class CScriptFunction; friend class CScriptCompiler; friend class CScriptFunctions; friend class CScriptLanguage; Ref native; Ref base; CScript *_base; //fast pointer access CScript *_owner; //for subclasses RBSet members; //members are just indices to the instanced script. RBMap constants; RBMap member_functions; RBMap member_indices; //members are just indices to the instanced script. RBMap> subclasses; RBMap> _signals; #ifdef TOOLS_ENABLED RBMap member_lines; RBMap member_default_values; List members_cache; RBMap member_default_values_cache; Ref base_cache; RBSet inheriters_cache; bool source_changed_cache; bool placeholder_fallback_enabled; void _update_exports_values(RBMap &values, List &propnames); #endif RBMap member_info; CScriptFunction *initializer; //direct pointer to _init , faster to locate int subclass_count; RBSet instances; //exported members String source; String path; String name; String fully_qualified_name; SelfList script_list; CScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error); void _set_subclass_path(Ref &p_sc, const String &p_path); String _get_debug_path() const; #ifdef TOOLS_ENABLED RBSet placeholders; //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder); #endif #ifdef DEBUG_ENABLED RBMap>> pending_reload_state; #endif bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false, PlaceHolderScriptInstance *p_instance_to_update = nullptr); void _save_orphaned_subclasses(); protected: bool _get(const StringName &p_name, Variant &r_ret) const; bool _set(const StringName &p_name, const Variant &p_value); void _get_property_list(List *p_properties) const; Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error); //void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount); static void _bind_methods(); public: virtual bool is_valid() const { return valid; } bool inherits_script(const Ref