1 | /**************************************************************************/ |
2 | /* gdscript.h */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
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 | |
31 | #ifndef GDSCRIPT_H |
32 | #define GDSCRIPT_H |
33 | |
34 | #include "gdscript_function.h" |
35 | |
36 | #include "core/debugger/engine_debugger.h" |
37 | #include "core/debugger/script_debugger.h" |
38 | #include "core/doc_data.h" |
39 | #include "core/io/resource_loader.h" |
40 | #include "core/io/resource_saver.h" |
41 | #include "core/object/script_language.h" |
42 | #include "core/templates/rb_set.h" |
43 | |
44 | class GDScriptNativeClass : public RefCounted { |
45 | GDCLASS(GDScriptNativeClass, RefCounted); |
46 | |
47 | StringName name; |
48 | |
49 | protected: |
50 | bool _get(const StringName &p_name, Variant &r_ret) const; |
51 | static void _bind_methods(); |
52 | |
53 | public: |
54 | _FORCE_INLINE_ const StringName &get_name() const { return name; } |
55 | Variant _new(); |
56 | Object *instantiate(); |
57 | virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override; |
58 | GDScriptNativeClass(const StringName &p_name); |
59 | }; |
60 | |
61 | class GDScript : public Script { |
62 | GDCLASS(GDScript, Script); |
63 | bool tool = false; |
64 | bool valid = false; |
65 | bool reloading = false; |
66 | |
67 | struct MemberInfo { |
68 | int index = 0; |
69 | StringName setter; |
70 | StringName getter; |
71 | GDScriptDataType data_type; |
72 | PropertyInfo property_info; |
73 | }; |
74 | |
75 | struct ClearData { |
76 | RBSet<GDScriptFunction *> functions; |
77 | RBSet<Ref<Script>> scripts; |
78 | void clear() { |
79 | functions.clear(); |
80 | scripts.clear(); |
81 | } |
82 | }; |
83 | |
84 | friend class GDScriptInstance; |
85 | friend class GDScriptFunction; |
86 | friend class GDScriptAnalyzer; |
87 | friend class GDScriptCompiler; |
88 | friend class GDScriptDocGen; |
89 | friend class GDScriptLanguage; |
90 | friend struct GDScriptUtilityFunctionsDefinitions; |
91 | |
92 | Ref<GDScriptNativeClass> native; |
93 | Ref<GDScript> base; |
94 | GDScript *_base = nullptr; //fast pointer access |
95 | GDScript *_owner = nullptr; //for subclasses |
96 | |
97 | HashSet<StringName> members; //members are just indices to the instantiated script. |
98 | HashMap<StringName, Variant> constants; |
99 | HashMap<StringName, MemberInfo> static_variables_indices; |
100 | Vector<Variant> static_variables; |
101 | HashMap<StringName, GDScriptFunction *> member_functions; |
102 | HashMap<StringName, MemberInfo> member_indices; //members are just indices to the instantiated script. |
103 | HashMap<StringName, Ref<GDScript>> subclasses; |
104 | HashMap<StringName, MethodInfo> _signals; |
105 | Dictionary rpc_config; |
106 | |
107 | #ifdef TOOLS_ENABLED |
108 | // For static data storage during hot-reloading. |
109 | HashMap<StringName, MemberInfo> old_static_variables_indices; |
110 | Vector<Variant> old_static_variables; |
111 | void _save_old_static_data(); |
112 | void _restore_old_static_data(); |
113 | |
114 | HashMap<StringName, int> member_lines; |
115 | HashMap<StringName, Variant> member_default_values; |
116 | List<PropertyInfo> members_cache; |
117 | HashMap<StringName, Variant> member_default_values_cache; |
118 | Ref<GDScript> base_cache; |
119 | HashSet<ObjectID> inheriters_cache; |
120 | bool source_changed_cache = false; |
121 | bool placeholder_fallback_enabled = false; |
122 | void _update_exports_values(HashMap<StringName, Variant> &values, List<PropertyInfo> &propnames); |
123 | |
124 | DocData::ClassDoc doc; |
125 | Vector<DocData::ClassDoc> docs; |
126 | void _clear_doc(); |
127 | void _add_doc(const DocData::ClassDoc &p_inner_class); |
128 | #endif |
129 | |
130 | GDScriptFunction *implicit_initializer = nullptr; |
131 | GDScriptFunction *initializer = nullptr; //direct pointer to new , faster to locate |
132 | GDScriptFunction *implicit_ready = nullptr; |
133 | GDScriptFunction *static_initializer = nullptr; |
134 | |
135 | Error _static_init(); |
136 | |
137 | int subclass_count = 0; |
138 | RBSet<Object *> instances; |
139 | bool destructing = false; |
140 | bool clearing = false; |
141 | //exported members |
142 | String source; |
143 | String path; |
144 | StringName local_name; // Inner class identifier or `class_name`. |
145 | StringName global_name; // `class_name`. |
146 | String fully_qualified_name; |
147 | String simplified_icon_path; |
148 | SelfList<GDScript> script_list; |
149 | |
150 | SelfList<GDScriptFunctionState>::List pending_func_states; |
151 | |
152 | GDScriptFunction *_super_constructor(GDScript *p_script); |
153 | void _super_implicit_constructor(GDScript *p_script, GDScriptInstance *p_instance, Callable::CallError &r_error); |
154 | GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_is_ref_counted, Callable::CallError &r_error); |
155 | |
156 | String _get_debug_path() const; |
157 | |
158 | #ifdef TOOLS_ENABLED |
159 | HashSet<PlaceHolderScriptInstance *> placeholders; |
160 | //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); |
161 | virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override; |
162 | #endif |
163 | |
164 | #ifdef DEBUG_ENABLED |
165 | HashMap<ObjectID, List<Pair<StringName, Variant>>> pending_reload_state; |
166 | #endif |
167 | |
168 | bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false, PlaceHolderScriptInstance *p_instance_to_update = nullptr); |
169 | |
170 | void _save_orphaned_subclasses(GDScript::ClearData *p_clear_data); |
171 | |
172 | void _get_script_property_list(List<PropertyInfo> *r_list, bool p_include_base) const; |
173 | void _get_script_method_list(List<MethodInfo> *r_list, bool p_include_base) const; |
174 | void _get_script_signal_list(List<MethodInfo> *r_list, bool p_include_base) const; |
175 | |
176 | GDScript *_get_gdscript_from_variant(const Variant &p_variant); |
177 | void _get_dependencies(RBSet<GDScript *> &p_dependencies, const GDScript *p_except); |
178 | |
179 | protected: |
180 | bool _get(const StringName &p_name, Variant &r_ret) const; |
181 | bool _set(const StringName &p_name, const Variant &p_value); |
182 | void _get_property_list(List<PropertyInfo> *p_properties) const; |
183 | |
184 | Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) override; |
185 | |
186 | static void _bind_methods(); |
187 | |
188 | public: |
189 | #ifdef DEBUG_ENABLED |
190 | static String debug_get_script_name(const Ref<Script> &p_script); |
191 | #endif |
192 | |
193 | _FORCE_INLINE_ StringName get_local_name() const { return local_name; } |
194 | |
195 | void clear(GDScript::ClearData *p_clear_data = nullptr); |
196 | |
197 | virtual bool is_valid() const override { return valid; } |
198 | |
199 | bool inherits_script(const Ref<Script> &p_script) const override; |
200 | |
201 | GDScript *find_class(const String &p_qualified_name); |
202 | bool has_class(const GDScript *p_script); |
203 | GDScript *get_root_script(); |
204 | bool is_root_script() const { return _owner == nullptr; } |
205 | String get_fully_qualified_name() const { return fully_qualified_name; } |
206 | const HashMap<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; } |
207 | const HashMap<StringName, Variant> &get_constants() const { return constants; } |
208 | const HashSet<StringName> &get_members() const { return members; } |
209 | const GDScriptDataType &get_member_type(const StringName &p_member) const { |
210 | CRASH_COND(!member_indices.has(p_member)); |
211 | return member_indices[p_member].data_type; |
212 | } |
213 | const HashMap<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; } |
214 | const Ref<GDScriptNativeClass> &get_native() const { return native; } |
215 | |
216 | RBSet<GDScript *> get_dependencies(); |
217 | RBSet<GDScript *> get_inverted_dependencies(); |
218 | RBSet<GDScript *> get_must_clear_dependencies(); |
219 | |
220 | virtual bool has_script_signal(const StringName &p_signal) const override; |
221 | virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override; |
222 | |
223 | bool is_tool() const override { return tool; } |
224 | Ref<GDScript> get_base() const; |
225 | |
226 | const HashMap<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; } |
227 | const HashMap<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only |
228 | StringName debug_get_member_by_index(int p_idx) const; |
229 | StringName debug_get_static_var_by_index(int p_idx) const; |
230 | |
231 | Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error); |
232 | virtual bool can_instantiate() const override; |
233 | |
234 | virtual Ref<Script> get_base_script() const override; |
235 | virtual StringName get_global_name() const override; |
236 | |
237 | virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so |
238 | virtual ScriptInstance *instance_create(Object *p_this) override; |
239 | virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override; |
240 | virtual bool instance_has(const Object *p_this) const override; |
241 | |
242 | virtual bool has_source_code() const override; |
243 | virtual String get_source_code() const override; |
244 | virtual void set_source_code(const String &p_code) override; |
245 | virtual void update_exports() override; |
246 | |
247 | #ifdef TOOLS_ENABLED |
248 | virtual Vector<DocData::ClassDoc> get_documentation() const override { |
249 | return docs; |
250 | } |
251 | virtual String get_class_icon_path() const override; |
252 | #endif // TOOLS_ENABLED |
253 | |
254 | virtual Error reload(bool p_keep_state = false) override; |
255 | |
256 | virtual void set_path(const String &p_path, bool p_take_over = false) override; |
257 | String get_script_path() const; |
258 | Error load_source_code(const String &p_path); |
259 | |
260 | bool get_property_default_value(const StringName &p_property, Variant &r_value) const override; |
261 | |
262 | virtual void get_script_method_list(List<MethodInfo> *p_list) const override; |
263 | virtual bool has_method(const StringName &p_method) const override; |
264 | virtual MethodInfo get_method_info(const StringName &p_method) const override; |
265 | |
266 | virtual void get_script_property_list(List<PropertyInfo> *p_list) const override; |
267 | |
268 | virtual ScriptLanguage *get_language() const override; |
269 | |
270 | virtual int get_member_line(const StringName &p_member) const override { |
271 | #ifdef TOOLS_ENABLED |
272 | if (member_lines.has(p_member)) { |
273 | return member_lines[p_member]; |
274 | } |
275 | #endif |
276 | return -1; |
277 | } |
278 | |
279 | virtual void get_constants(HashMap<StringName, Variant> *p_constants) override; |
280 | virtual void get_members(HashSet<StringName> *p_members) override; |
281 | |
282 | virtual const Variant get_rpc_config() const override; |
283 | |
284 | void unload_static() const; |
285 | |
286 | #ifdef TOOLS_ENABLED |
287 | virtual bool is_placeholder_fallback_enabled() const override { return placeholder_fallback_enabled; } |
288 | #endif |
289 | |
290 | GDScript(); |
291 | ~GDScript(); |
292 | }; |
293 | |
294 | class GDScriptInstance : public ScriptInstance { |
295 | friend class GDScript; |
296 | friend class GDScriptFunction; |
297 | friend class GDScriptLambdaCallable; |
298 | friend class GDScriptLambdaSelfCallable; |
299 | friend class GDScriptCompiler; |
300 | friend class GDScriptCache; |
301 | friend struct GDScriptUtilityFunctionsDefinitions; |
302 | |
303 | ObjectID owner_id; |
304 | Object *owner = nullptr; |
305 | Ref<GDScript> script; |
306 | #ifdef DEBUG_ENABLED |
307 | HashMap<StringName, int> member_indices_cache; //used only for hot script reloading |
308 | #endif |
309 | Vector<Variant> members; |
310 | bool base_ref_counted; |
311 | |
312 | SelfList<GDScriptFunctionState>::List pending_func_states; |
313 | |
314 | public: |
315 | virtual Object *get_owner() { return owner; } |
316 | |
317 | virtual bool set(const StringName &p_name, const Variant &p_value); |
318 | virtual bool get(const StringName &p_name, Variant &r_ret) const; |
319 | virtual void get_property_list(List<PropertyInfo> *p_properties) const; |
320 | virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; |
321 | virtual void validate_property(PropertyInfo &p_property) const; |
322 | |
323 | virtual bool property_can_revert(const StringName &p_name) const; |
324 | virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const; |
325 | |
326 | virtual void get_method_list(List<MethodInfo> *p_list) const; |
327 | virtual bool has_method(const StringName &p_method) const; |
328 | virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error); |
329 | |
330 | Variant debug_get_member_by_index(int p_idx) const { return members[p_idx]; } |
331 | |
332 | virtual void notification(int p_notification, bool p_reversed = false); |
333 | String to_string(bool *r_valid); |
334 | |
335 | virtual Ref<Script> get_script() const; |
336 | |
337 | virtual ScriptLanguage *get_language(); |
338 | |
339 | void set_path(const String &p_path); |
340 | |
341 | void reload_members(); |
342 | |
343 | virtual const Variant get_rpc_config() const; |
344 | |
345 | GDScriptInstance(); |
346 | ~GDScriptInstance(); |
347 | }; |
348 | |
349 | class GDScriptLanguage : public ScriptLanguage { |
350 | friend class GDScriptFunctionState; |
351 | |
352 | static GDScriptLanguage *singleton; |
353 | |
354 | Variant *_global_array = nullptr; |
355 | Vector<Variant> global_array; |
356 | HashMap<StringName, int> globals; |
357 | HashMap<StringName, Variant> named_globals; |
358 | |
359 | struct CallLevel { |
360 | Variant *stack = nullptr; |
361 | GDScriptFunction *function = nullptr; |
362 | GDScriptInstance *instance = nullptr; |
363 | int *ip = nullptr; |
364 | int *line = nullptr; |
365 | }; |
366 | |
367 | static thread_local int _debug_parse_err_line; |
368 | static thread_local String _debug_parse_err_file; |
369 | static thread_local String _debug_error; |
370 | struct CallStack { |
371 | CallLevel *levels = nullptr; |
372 | int stack_pos = 0; |
373 | |
374 | void free() { |
375 | if (levels) { |
376 | memdelete(levels); |
377 | levels = nullptr; |
378 | } |
379 | } |
380 | ~CallStack() { |
381 | free(); |
382 | } |
383 | }; |
384 | |
385 | static thread_local CallStack _call_stack; |
386 | int _debug_max_call_stack = 0; |
387 | |
388 | void _add_global(const StringName &p_name, const Variant &p_value); |
389 | |
390 | friend class GDScriptInstance; |
391 | |
392 | Mutex mutex; |
393 | |
394 | friend class GDScript; |
395 | |
396 | SelfList<GDScript>::List script_list; |
397 | friend class GDScriptFunction; |
398 | |
399 | SelfList<GDScriptFunction>::List function_list; |
400 | bool profiling; |
401 | uint64_t script_frame_time; |
402 | |
403 | HashMap<String, ObjectID> orphan_subclasses; |
404 | |
405 | public: |
406 | int calls; |
407 | |
408 | bool debug_break(const String &p_error, bool p_allow_continue = true); |
409 | bool debug_break_parse(const String &p_file, int p_line, const String &p_error); |
410 | |
411 | _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) { |
412 | if (unlikely(_call_stack.levels == nullptr)) { |
413 | _call_stack.levels = memnew_arr(CallLevel, _debug_max_call_stack + 1); |
414 | } |
415 | |
416 | if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) { |
417 | EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1); |
418 | } |
419 | |
420 | if (_call_stack.stack_pos >= _debug_max_call_stack) { |
421 | //stack overflow |
422 | _debug_error = vformat("Stack overflow (stack size: %s). Check for infinite recursion in your script." , _debug_max_call_stack); |
423 | EngineDebugger::get_script_debugger()->debug(this); |
424 | return; |
425 | } |
426 | |
427 | _call_stack.levels[_call_stack.stack_pos].stack = p_stack; |
428 | _call_stack.levels[_call_stack.stack_pos].instance = p_instance; |
429 | _call_stack.levels[_call_stack.stack_pos].function = p_function; |
430 | _call_stack.levels[_call_stack.stack_pos].ip = p_ip; |
431 | _call_stack.levels[_call_stack.stack_pos].line = p_line; |
432 | _call_stack.stack_pos++; |
433 | } |
434 | |
435 | _FORCE_INLINE_ void exit_function() { |
436 | if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) { |
437 | EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1); |
438 | } |
439 | |
440 | if (_call_stack.stack_pos == 0) { |
441 | _debug_error = "Stack Underflow (Engine Bug)" ; |
442 | EngineDebugger::get_script_debugger()->debug(this); |
443 | return; |
444 | } |
445 | |
446 | _call_stack.stack_pos--; |
447 | } |
448 | |
449 | virtual Vector<StackInfo> debug_get_current_stack_info() override { |
450 | Vector<StackInfo> csi; |
451 | csi.resize(_call_stack.stack_pos); |
452 | for (int i = 0; i < _call_stack.stack_pos; i++) { |
453 | csi.write[_call_stack.stack_pos - i - 1].line = _call_stack.levels[i].line ? *_call_stack.levels[i].line : 0; |
454 | if (_call_stack.levels[i].function) { |
455 | csi.write[_call_stack.stack_pos - i - 1].func = _call_stack.levels[i].function->get_name(); |
456 | csi.write[_call_stack.stack_pos - i - 1].file = _call_stack.levels[i].function->get_script()->get_script_path(); |
457 | } |
458 | } |
459 | return csi; |
460 | } |
461 | |
462 | struct { |
463 | StringName _init; |
464 | StringName _static_init; |
465 | StringName _notification; |
466 | StringName _set; |
467 | StringName _get; |
468 | StringName _get_property_list; |
469 | StringName _validate_property; |
470 | StringName _property_can_revert; |
471 | StringName _property_get_revert; |
472 | StringName _script_source; |
473 | |
474 | } strings; |
475 | |
476 | _FORCE_INLINE_ int get_global_array_size() const { return global_array.size(); } |
477 | _FORCE_INLINE_ Variant *get_global_array() { return _global_array; } |
478 | _FORCE_INLINE_ const HashMap<StringName, int> &get_global_map() const { return globals; } |
479 | _FORCE_INLINE_ const HashMap<StringName, Variant> &get_named_globals_map() const { return named_globals; } |
480 | // These two functions should be used when behavior needs to be consistent between in-editor and running the scene |
481 | bool has_any_global_constant(const StringName &p_name) { return named_globals.has(p_name) || globals.has(p_name); } |
482 | Variant get_any_global_constant(const StringName &p_name); |
483 | |
484 | _FORCE_INLINE_ static GDScriptLanguage *get_singleton() { return singleton; } |
485 | |
486 | virtual String get_name() const override; |
487 | |
488 | /* LANGUAGE FUNCTIONS */ |
489 | virtual void init() override; |
490 | virtual String get_type() const override; |
491 | virtual String get_extension() const override; |
492 | virtual void finish() override; |
493 | |
494 | /* EDITOR FUNCTIONS */ |
495 | virtual void get_reserved_words(List<String> *p_words) const override; |
496 | virtual bool is_control_flow_keyword(String p_keywords) const override; |
497 | virtual void (List<String> *p_delimiters) const override; |
498 | virtual void get_string_delimiters(List<String> *p_delimiters) const override; |
499 | virtual bool is_using_templates() override; |
500 | virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override; |
501 | virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override; |
502 | 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; |
503 | virtual Script *create_script() const override; |
504 | virtual bool has_named_classes() const override; |
505 | virtual bool supports_builtin_mode() const override; |
506 | virtual bool supports_documentation() const override; |
507 | virtual bool can_inherit_from_file() const override { return true; } |
508 | virtual int find_function(const String &p_function, const String &p_code) const override; |
509 | virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override; |
510 | 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; |
511 | #ifdef TOOLS_ENABLED |
512 | virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override; |
513 | #endif |
514 | virtual String _get_indentation() const; |
515 | virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override; |
516 | virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) override; |
517 | virtual void add_named_global_constant(const StringName &p_name, const Variant &p_value) override; |
518 | virtual void remove_named_global_constant(const StringName &p_name) override; |
519 | |
520 | /* DEBUGGER FUNCTIONS */ |
521 | |
522 | virtual String debug_get_error() const override; |
523 | virtual int debug_get_stack_level_count() const override; |
524 | virtual int debug_get_stack_level_line(int p_level) const override; |
525 | virtual String debug_get_stack_level_function(int p_level) const override; |
526 | virtual String debug_get_stack_level_source(int p_level) const override; |
527 | 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; |
528 | 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; |
529 | virtual ScriptInstance *debug_get_stack_level_instance(int p_level) override; |
530 | virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override; |
531 | 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; |
532 | |
533 | virtual void reload_all_scripts() override; |
534 | virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override; |
535 | |
536 | virtual void frame() override; |
537 | |
538 | virtual void get_public_functions(List<MethodInfo> *p_functions) const override; |
539 | virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override; |
540 | virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override; |
541 | |
542 | virtual void profiling_start() override; |
543 | virtual void profiling_stop() override; |
544 | |
545 | virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override; |
546 | virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override; |
547 | |
548 | /* LOADER FUNCTIONS */ |
549 | |
550 | virtual void get_recognized_extensions(List<String> *p_extensions) const override; |
551 | |
552 | /* GLOBAL CLASSES */ |
553 | |
554 | virtual bool handles_global_class_type(const String &p_type) const override; |
555 | virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const override; |
556 | |
557 | void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass); |
558 | Ref<GDScript> get_orphan_subclass(const String &p_qualified_name); |
559 | |
560 | Ref<GDScript> get_script_by_fully_qualified_name(const String &p_name); |
561 | |
562 | GDScriptLanguage(); |
563 | ~GDScriptLanguage(); |
564 | }; |
565 | |
566 | class ResourceFormatLoaderGDScript : public ResourceFormatLoader { |
567 | public: |
568 | 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); |
569 | virtual void get_recognized_extensions(List<String> *p_extensions) const; |
570 | virtual bool handles_type(const String &p_type) const; |
571 | virtual String get_resource_type(const String &p_path) const; |
572 | virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); |
573 | }; |
574 | |
575 | class ResourceFormatSaverGDScript : public ResourceFormatSaver { |
576 | public: |
577 | virtual Error save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags = 0); |
578 | virtual void get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions) const; |
579 | virtual bool recognize(const Ref<Resource> &p_resource) const; |
580 | }; |
581 | |
582 | #endif // GDSCRIPT_H |
583 | |