gdscript.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /*************************************************************************/
  2. /* gdscript.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GDSCRIPT_H
  31. #define GDSCRIPT_H
  32. #include "core/debugger/engine_debugger.h"
  33. #include "core/debugger/script_debugger.h"
  34. #include "core/doc_data.h"
  35. #include "core/io/resource_loader.h"
  36. #include "core/io/resource_saver.h"
  37. #include "core/object/script_language.h"
  38. #include "core/templates/rb_set.h"
  39. #include "gdscript_function.h"
  40. class GDScriptNativeClass : public RefCounted {
  41. GDCLASS(GDScriptNativeClass, RefCounted);
  42. StringName name;
  43. protected:
  44. bool _get(const StringName &p_name, Variant &r_ret) const;
  45. static void _bind_methods();
  46. public:
  47. _FORCE_INLINE_ const StringName &get_name() const { return name; }
  48. Variant _new();
  49. Object *instantiate();
  50. virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
  51. GDScriptNativeClass(const StringName &p_name);
  52. };
  53. class GDScript : public Script {
  54. GDCLASS(GDScript, Script);
  55. bool tool = false;
  56. bool valid = false;
  57. struct MemberInfo {
  58. int index = 0;
  59. StringName setter;
  60. StringName getter;
  61. GDScriptDataType data_type;
  62. };
  63. friend class GDScriptInstance;
  64. friend class GDScriptFunction;
  65. friend class GDScriptAnalyzer;
  66. friend class GDScriptCompiler;
  67. friend class GDScriptLanguage;
  68. friend struct GDScriptUtilityFunctionsDefinitions;
  69. Ref<GDScriptNativeClass> native;
  70. Ref<GDScript> base;
  71. GDScript *_base = nullptr; //fast pointer access
  72. GDScript *_owner = nullptr; //for subclasses
  73. HashSet<StringName> members; //members are just indices to the instantiated script.
  74. HashMap<StringName, Variant> constants;
  75. HashMap<StringName, GDScriptFunction *> member_functions;
  76. HashMap<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script.
  77. HashMap<StringName, Ref<GDScript>> subclasses;
  78. HashMap<StringName, Vector<StringName>> _signals;
  79. Vector<Multiplayer::RPCConfig> rpc_functions;
  80. #ifdef TOOLS_ENABLED
  81. HashMap<StringName, int> member_lines;
  82. HashMap<StringName, Variant> member_default_values;
  83. List<PropertyInfo> members_cache;
  84. HashMap<StringName, Variant> member_default_values_cache;
  85. Ref<GDScript> base_cache;
  86. HashSet<ObjectID> inheriters_cache;
  87. bool source_changed_cache = false;
  88. bool placeholder_fallback_enabled = false;
  89. void _update_exports_values(HashMap<StringName, Variant> &values, List<PropertyInfo> &propnames);
  90. DocData::ClassDoc doc;
  91. Vector<DocData::ClassDoc> docs;
  92. String doc_brief_description;
  93. String doc_description;
  94. Vector<DocData::TutorialDoc> doc_tutorials;
  95. HashMap<String, String> doc_functions;
  96. HashMap<String, String> doc_variables;
  97. HashMap<String, String> doc_constants;
  98. HashMap<String, String> doc_signals;
  99. HashMap<String, DocData::EnumDoc> doc_enums;
  100. void _clear_doc();
  101. void _update_doc();
  102. void _add_doc(const DocData::ClassDoc &p_inner_class);
  103. #endif
  104. HashMap<StringName, PropertyInfo> member_info;
  105. GDScriptFunction *implicit_initializer = nullptr;
  106. GDScriptFunction *initializer = nullptr; //direct pointer to new , faster to locate
  107. GDScriptFunction *implicit_ready = nullptr;
  108. int subclass_count = 0;
  109. RBSet<Object *> instances;
  110. //exported members
  111. String source;
  112. String path;
  113. String name;
  114. String fully_qualified_name;
  115. SelfList<GDScript> script_list;
  116. SelfList<GDScriptFunctionState>::List pending_func_states;
  117. GDScriptFunction *_super_constructor(GDScript *p_script);
  118. void _super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error);
  119. GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error);
  120. void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
  121. String _get_debug_path() const;
  122. #ifdef TOOLS_ENABLED
  123. HashSet<PlaceHolderScriptInstance *> placeholders;
  124. //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
  125. virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
  126. #endif
  127. #ifdef DEBUG_ENABLED
  128. HashMap<ObjectID, List<Pair<StringName, Variant>>> pending_reload_state;
  129. #endif
  130. bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false, PlaceHolderScriptInstance *p_instance_to_update = nullptr);
  131. void _save_orphaned_subclasses();
  132. void _init_rpc_methods_properties();
  133. void _get_script_property_list(List<PropertyInfo> *r_list, bool p_include_base) const;
  134. void _get_script_method_list(List<MethodInfo> *r_list, bool p_include_base) const;
  135. void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const;
  136. // This method will map the class name from "RefCounted" to "MyClass.InnerClass".
  137. static String _get_gdscript_reference_class_name(const GDScript *p_gdscript);
  138. protected:
  139. bool _get(const StringName &p_name, Variant &r_ret) const;
  140. bool _set(const StringName &p_name, const Variant &p_value);
  141. void _get_property_list(List<PropertyInfo> *p_properties) const;
  142. Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override;
  143. static void _bind_methods();
  144. public:
  145. virtual bool is_valid() const override { return valid; }
  146. bool inherits_script(const Ref<Script> &p_script) const override;
  147. const HashMap<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; }
  148. const HashMap<StringName, Variant> &get_constants() const { return constants; }
  149. const HashSet<StringName> &get_members() const { return members; }
  150. const GDScriptDataType &get_member_type(const StringName &p_member) const {
  151. CRASH_COND(!member_indices.has(p_member));
  152. return member_indices[p_member].data_type;
  153. }
  154. const HashMap<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; }
  155. const Ref<GDScriptNativeClass> &get_native() const { return native; }
  156. const String &get_script_class_name() const { return name; }
  157. virtual bool has_script_signal(const StringName &p_signal) const override;
  158. virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override;
  159. bool is_tool() const override { return tool; }
  160. Ref<GDScript> get_base() const;
  161. const HashMap<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; }
  162. const HashMap<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
  163. StringName debug_get_member_by_index(int p_idx) const;
  164. Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  165. virtual bool can_instantiate() const override;
  166. virtual Ref<Script> get_base_script() const override;
  167. virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so
  168. virtual ScriptInstance *instance_create(Object *p_this) override;
  169. virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override;
  170. virtual bool instance_has(const Object *p_this) const override;
  171. virtual bool has_source_code() const override;
  172. virtual String get_source_code() const override;
  173. virtual void set_source_code(const String &p_code) override;
  174. virtual void update_exports() override;
  175. #ifdef TOOLS_ENABLED
  176. virtual Vector<DocData::ClassDoc> get_documentation() const override {
  177. return docs;
  178. }
  179. #endif // TOOLS_ENABLED
  180. virtual Error reload(bool p_keep_state = false) override;
  181. void set_script_path(const String &p_path) { path = p_path; } //because subclasses need a path too...
  182. Error load_source_code(const String &p_path);
  183. Error load_byte_code(const String &p_path);
  184. Vector<uint8_t> get_as_byte_code() const;
  185. bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
  186. virtual void get_script_method_list(List<MethodInfo> *p_list) const override;
  187. virtual bool has_method(const StringName &p_method) const override;
  188. virtual MethodInfo get_method_info(const StringName &p_method) const override;
  189. virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
  190. virtual ScriptLanguage *get_language() const override;
  191. virtual int get_member_line(const StringName &p_member) const override {
  192. #ifdef TOOLS_ENABLED
  193. if (member_lines.has(p_member)) {
  194. return member_lines[p_member];
  195. }
  196. #endif
  197. return -1;
  198. }
  199. virtual void get_constants(HashMap<StringName, Variant> *p_constants) override;
  200. virtual void get_members(HashSet<StringName> *p_members) override;
  201. virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
  202. #ifdef TOOLS_ENABLED
  203. virtual bool is_placeholder_fallback_enabled() const override { return placeholder_fallback_enabled; }
  204. #endif
  205. GDScript();
  206. ~GDScript();
  207. };
  208. class GDScriptInstance : public ScriptInstance {
  209. friend class GDScript;
  210. friend class GDScriptFunction;
  211. friend class GDScriptLambdaCallable;
  212. friend class GDScriptLambdaSelfCallable;
  213. friend class GDScriptCompiler;
  214. friend struct GDScriptUtilityFunctionsDefinitions;
  215. ObjectID owner_id;
  216. Object *owner = nullptr;
  217. Ref<GDScript> script;
  218. #ifdef DEBUG_ENABLED
  219. HashMap<StringName, int> member_indices_cache; //used only for hot script reloading
  220. #endif
  221. Vector<Variant> members;
  222. bool base_ref_counted;
  223. SelfList<GDScriptFunctionState>::List pending_func_states;
  224. public:
  225. virtual Object *get_owner() { return owner; }
  226. virtual bool set(const StringName &p_name, const Variant &p_value);
  227. virtual bool get(const StringName &p_name, Variant &r_ret) const;
  228. virtual void get_property_list(List<PropertyInfo> *p_properties) const;
  229. virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
  230. virtual void get_method_list(List<MethodInfo> *p_list) const;
  231. virtual bool has_method(const StringName &p_method) const;
  232. virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  233. Variant debug_get_member_by_index(int p_idx) const { return members[p_idx]; }
  234. virtual void notification(int p_notification);
  235. String to_string(bool *r_valid);
  236. virtual Ref<Script> get_script() const;
  237. virtual ScriptLanguage *get_language();
  238. void set_path(const String &p_path);
  239. void reload_members();
  240. virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const;
  241. GDScriptInstance();
  242. ~GDScriptInstance();
  243. };
  244. class GDScriptLanguage : public ScriptLanguage {
  245. friend class GDScriptFunctionState;
  246. static GDScriptLanguage *singleton;
  247. Variant *_global_array = nullptr;
  248. Vector<Variant> global_array;
  249. HashMap<StringName, int> globals;
  250. HashMap<StringName, Variant> named_globals;
  251. struct CallLevel {
  252. Variant *stack = nullptr;
  253. GDScriptFunction *function = nullptr;
  254. GDScriptInstance *instance = nullptr;
  255. int *ip = nullptr;
  256. int *line = nullptr;
  257. };
  258. int _debug_parse_err_line;
  259. String _debug_parse_err_file;
  260. String _debug_error;
  261. int _debug_call_stack_pos;
  262. int _debug_max_call_stack;
  263. CallLevel *_call_stack = nullptr;
  264. void _add_global(const StringName &p_name, const Variant &p_value);
  265. friend class GDScriptInstance;
  266. Mutex lock;
  267. friend class GDScript;
  268. SelfList<GDScript>::List script_list;
  269. friend class GDScriptFunction;
  270. SelfList<GDScriptFunction>::List function_list;
  271. bool profiling;
  272. uint64_t script_frame_time;
  273. HashMap<String, ObjectID> orphan_subclasses;
  274. public:
  275. int calls;
  276. bool debug_break(const String &p_error, bool p_allow_continue = true);
  277. bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
  278. _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
  279. if (Thread::get_main_id() != Thread::get_caller_id()) {
  280. return; //no support for other threads than main for now
  281. }
  282. if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
  283. EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1);
  284. }
  285. if (_debug_call_stack_pos >= _debug_max_call_stack) {
  286. //stack overflow
  287. _debug_error = vformat("Stack overflow (stack size: %s). Check for infinite recursion in your script.", _debug_max_call_stack);
  288. EngineDebugger::get_script_debugger()->debug(this);
  289. return;
  290. }
  291. _call_stack[_debug_call_stack_pos].stack = p_stack;
  292. _call_stack[_debug_call_stack_pos].instance = p_instance;
  293. _call_stack[_debug_call_stack_pos].function = p_function;
  294. _call_stack[_debug_call_stack_pos].ip = p_ip;
  295. _call_stack[_debug_call_stack_pos].line = p_line;
  296. _debug_call_stack_pos++;
  297. }
  298. _FORCE_INLINE_ void exit_function() {
  299. if (Thread::get_main_id() != Thread::get_caller_id()) {
  300. return; //no support for other threads than main for now
  301. }
  302. if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
  303. EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1);
  304. }
  305. if (_debug_call_stack_pos == 0) {
  306. _debug_error = "Stack Underflow (Engine Bug)";
  307. EngineDebugger::get_script_debugger()->debug(this);
  308. return;
  309. }
  310. _debug_call_stack_pos--;
  311. }
  312. virtual Vector<StackInfo> debug_get_current_stack_info() override {
  313. if (Thread::get_main_id() != Thread::get_caller_id()) {
  314. return Vector<StackInfo>();
  315. }
  316. Vector<StackInfo> csi;
  317. csi.resize(_debug_call_stack_pos);
  318. for (int i = 0; i < _debug_call_stack_pos; i++) {
  319. csi.write[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
  320. if (_call_stack[i].function) {
  321. csi.write[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
  322. csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
  323. }
  324. }
  325. return csi;
  326. }
  327. struct {
  328. StringName _init;
  329. StringName _notification;
  330. StringName _set;
  331. StringName _get;
  332. StringName _get_property_list;
  333. StringName _script_source;
  334. } strings;
  335. _FORCE_INLINE_ int get_global_array_size() const { return global_array.size(); }
  336. _FORCE_INLINE_ Variant *get_global_array() { return _global_array; }
  337. _FORCE_INLINE_ const HashMap<StringName, int> &get_global_map() const { return globals; }
  338. _FORCE_INLINE_ const HashMap<StringName, Variant> &get_named_globals_map() const { return named_globals; }
  339. _FORCE_INLINE_ static GDScriptLanguage *get_singleton() { return singleton; }
  340. virtual String get_name() const override;
  341. /* LANGUAGE FUNCTIONS */
  342. virtual void init() override;
  343. virtual String get_type() const override;
  344. virtual String get_extension() const override;
  345. virtual Error execute_file(const String &p_path) override;
  346. virtual void finish() override;
  347. /* EDITOR FUNCTIONS */
  348. virtual void get_reserved_words(List<String> *p_words) const override;
  349. virtual bool is_control_flow_keyword(String p_keywords) const override;
  350. virtual void get_comment_delimiters(List<String> *p_delimiters) const override;
  351. virtual void get_string_delimiters(List<String> *p_delimiters) const override;
  352. virtual bool is_using_templates() override;
  353. virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override;
  354. virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override;
  355. virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override;
  356. virtual Script *create_script() const override;
  357. virtual bool has_named_classes() const override;
  358. virtual bool supports_builtin_mode() const override;
  359. virtual bool supports_documentation() const override;
  360. virtual bool can_inherit_from_file() const override { return true; }
  361. virtual int find_function(const String &p_function, const String &p_code) const override;
  362. virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override;
  363. virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) override;
  364. #ifdef TOOLS_ENABLED
  365. virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override;
  366. #endif
  367. virtual String _get_indentation() const;
  368. virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override;
  369. virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) override;
  370. virtual void add_named_global_constant(const StringName &p_name, const Variant &p_value) override;
  371. virtual void remove_named_global_constant(const StringName &p_name) override;
  372. /* DEBUGGER FUNCTIONS */
  373. virtual String debug_get_error() const override;
  374. virtual int debug_get_stack_level_count() const override;
  375. virtual int debug_get_stack_level_line(int p_level) const override;
  376. virtual String debug_get_stack_level_function(int p_level) const override;
  377. virtual String debug_get_stack_level_source(int p_level) const override;
  378. virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
  379. virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
  380. virtual ScriptInstance *debug_get_stack_level_instance(int p_level) override;
  381. virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
  382. virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) override;
  383. virtual void reload_all_scripts() override;
  384. virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override;
  385. virtual void frame() override;
  386. virtual void get_public_functions(List<MethodInfo> *p_functions) const override;
  387. virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override;
  388. virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override;
  389. virtual void profiling_start() override;
  390. virtual void profiling_stop() override;
  391. virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override;
  392. virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override;
  393. /* LOADER FUNCTIONS */
  394. virtual void get_recognized_extensions(List<String> *p_extensions) const override;
  395. /* GLOBAL CLASSES */
  396. virtual bool handles_global_class_type(const String &p_type) const override;
  397. virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const override;
  398. void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass);
  399. Ref<GDScript> get_orphan_subclass(const String &p_qualified_name);
  400. GDScriptLanguage();
  401. ~GDScriptLanguage();
  402. };
  403. class ResourceFormatLoaderGDScript : public ResourceFormatLoader {
  404. public:
  405. virtual Ref<Resource> load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
  406. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  407. virtual bool handles_type(const String &p_type) const;
  408. virtual String get_resource_type(const String &p_path) const;
  409. virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
  410. };
  411. class ResourceFormatSaverGDScript : public ResourceFormatSaver {
  412. public:
  413. virtual Error save(const String &p_path, const Ref<Resource> &p_resource, uint32_t p_flags = 0);
  414. virtual void get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) const;
  415. virtual bool recognize(const Ref<Resource> &p_resource) const;
  416. };
  417. #endif // GDSCRIPT_H