Debian Codegraph @

core/core_bind.h

raw symbols SCIP
1 /**************************************************************************/
2 /* core_bind.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 #pragma once
32
33 #include "core/debugger/engine_profiler.h"
34 #include "core/io/resource_loader.h"
35 #include "core/io/resource_saver.h"
36 #include "core/object/script_backtrace.h"
37 #include "core/os/semaphore.h"
38 #include "core/os/thread.h"
39 #include "core/templates/safe_refcount.h"
40 #include "core/variant/typed_array.h"
41
42 class MainLoop;
43
44 namespace CoreBind {
45
46 class ResourceLoader : public Object {
47 GDCLASS(ResourceLoader, Object);
48
49 protected:
50 static void _bind_methods();
51 static inline ResourceLoader *singleton = nullptr;
52
53 public:
54 enum ThreadLoadStatus {
55 THREAD_LOAD_INVALID_RESOURCE,
56 THREAD_LOAD_IN_PROGRESS,
57 THREAD_LOAD_FAILED,
58 THREAD_LOAD_LOADED
59 };
60
61 enum CacheMode {
62 CACHE_MODE_IGNORE,
63 CACHE_MODE_REUSE,
64 CACHE_MODE_REPLACE,
65 CACHE_MODE_IGNORE_DEEP,
66 CACHE_MODE_REPLACE_DEEP,
67 };
68
69 static ResourceLoader *get_singleton() { return singleton; }
70
71 Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, CacheMode p_cache_mode = CACHE_MODE_REUSE);
72 ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = ClassDB::default_array_arg);
73 Ref<Resource> load_threaded_get(const String &p_path);
74
75 Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
76 Vector<String> get_recognized_extensions_for_type(const String &p_type);
77 void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
78 void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
79 void set_abort_on_missing_resources(bool p_abort);
80 PackedStringArray get_dependencies(const String &p_path);
81 bool has_cached(const String &p_path);
82 Ref<Resource> get_cached_ref(const String &p_path);
83 bool exists(const String &p_path, const String &p_type_hint = "");
84 ResourceUID::ID get_resource_uid(const String &p_path);
85
86 Vector<String> list_directory(const String &p_directory);
87
88 ResourceLoader() { singleton = this; }
89 };
90
91 class ResourceSaver : public Object {
92 GDCLASS(ResourceSaver, Object);
93
94 protected:
95 static void _bind_methods();
96 static inline ResourceSaver *singleton = nullptr;
97
98 public:
99 enum SaverFlags {
100 FLAG_NONE = 0,
101 FLAG_RELATIVE_PATHS = 1,
102 FLAG_BUNDLE_RESOURCES = 2,
103 FLAG_CHANGE_PATH = 4,
104 FLAG_OMIT_EDITOR_PROPERTIES = 8,
105 FLAG_SAVE_BIG_ENDIAN = 16,
106 FLAG_COMPRESS = 32,
107 FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
108 };
109
110 static ResourceSaver *get_singleton() { return singleton; }
111
112 Error save(RequiredParam<Resource> p_resource, const String &p_path, BitField<SaverFlags> p_flags);
113 Error set_uid(const String &p_path, ResourceUID::ID p_uid);
114 Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
115 void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
116 void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
117
118 ResourceUID::ID get_resource_id_for_path(const String &p_path, bool p_generate = false);
119
120 ResourceSaver() { singleton = this; }
121 };
122
123 class Logger : public RefCounted {
124 GDCLASS(Logger, RefCounted);
125
126 public:
127 enum ErrorType {
128 ERROR_TYPE_ERROR,
129 ERROR_TYPE_WARNING,
130 ERROR_TYPE_SCRIPT,
131 ERROR_TYPE_SHADER,
132 };
133
134 protected:
135 GDVIRTUAL2(_log_message, String, bool);
136 GDVIRTUAL8(_log_error, String, String, int, String, String, bool, int, TypedArray<ScriptBacktrace>);
137 static void _bind_methods();
138
139 public:
140 virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERROR_TYPE_ERROR, const TypedArray<ScriptBacktrace> &p_script_backtraces = {});
141 virtual void log_message(const String &p_text, bool p_error);
142 };
143
144 class OS : public Object {
145 GDCLASS(OS, Object);
146
147 mutable HashMap<String, bool> feature_cache;
148
149 class LoggerBind : public ::Logger {
150 public:
151 LocalVector<Ref<CoreBind::Logger>> loggers;
152
153 virtual void logv(const char *p_format, va_list p_list, bool p_err) override _PRINTF_FORMAT_ATTRIBUTE_2_0;
154 virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR, const Vector<Ref<ScriptBacktrace>> &p_script_backtraces = {}) override;
155
156 void clear() { loggers.clear(); }
157 };
158
159 LoggerBind *logger_bind = nullptr;
160
161 protected:
162 static void _bind_methods();
163 static inline OS *singleton = nullptr;
164
165 #ifndef DISABLE_DEPRECATED
166 Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments);
167
168 String _read_string_from_stdin_bind_compat_91201();
169 static void _bind_compatibility_methods();
170 #endif
171
172 public:
173 enum RenderingDriver {
174 RENDERING_DRIVER_VULKAN,
175 RENDERING_DRIVER_OPENGL3,
176 RENDERING_DRIVER_D3D12,
177 RENDERING_DRIVER_METAL,
178 };
179
180 PackedByteArray get_entropy(int p_bytes);
181 String get_system_ca_certificates();
182
183 enum StdHandleType {
184 STD_HANDLE_INVALID,
185 STD_HANDLE_CONSOLE,
186 STD_HANDLE_FILE,
187 STD_HANDLE_PIPE,
188 STD_HANDLE_UNKNOWN,
189 };
190
191 virtual PackedStringArray get_connected_midi_inputs();
192 virtual void open_midi_inputs();
193 virtual void close_midi_inputs();
194
195 void set_low_processor_usage_mode(bool p_enabled);
196 bool is_in_low_processor_usage_mode() const;
197
198 void set_low_processor_usage_mode_sleep_usec(int p_usec);
199 int get_low_processor_usage_mode_sleep_usec() const;
200
201 void set_delta_smoothing(bool p_enabled);
202 bool is_delta_smoothing_enabled() const;
203
204 void alert(const String &p_alert, const String &p_title = "ALERT!");
205 void crash(const String &p_message);
206
207 Vector<String> get_system_fonts() const;
208 String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
209 Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
210 String get_executable_path() const;
211
212 String read_string_from_stdin(int64_t p_buffer_size = 1024);
213 PackedByteArray read_buffer_from_stdin(int64_t p_buffer_size = 1024);
214 StdHandleType get_stdin_type() const;
215 StdHandleType get_stdout_type() const;
216 StdHandleType get_stderr_type() const;
217
218 int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = ClassDB::default_array_arg, bool p_read_stderr = false, bool p_open_console = false);
219 Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true);
220 int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
221 int create_instance(const Vector<String> &p_arguments);
222 Error open_with_program(const String &p_program_path, const Vector<String> &p_paths);
223 Error kill(int p_pid);
224 Error shell_open(const String &p_uri);
225 Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
226
227 bool is_process_running(int p_pid) const;
228 int get_process_exit_code(int p_pid) const;
229 int get_process_id() const;
230
231 void set_restart_on_exit(bool p_restart, const Vector<String> &p_restart_arguments = Vector<String>());
232 bool is_restart_on_exit_set() const;
233 Vector<String> get_restart_on_exit_arguments() const;
234
235 bool has_environment(const String &p_var) const;
236 String get_environment(const String &p_var) const;
237 void set_environment(const String &p_var, const String &p_value) const;
238 void unset_environment(const String &p_var) const;
239
240 String get_name() const;
241 String get_distribution_name() const;
242 String get_version() const;
243 String get_version_alias() const;
244 Vector<String> get_cmdline_args();
245 Vector<String> get_cmdline_user_args();
246
247 Vector<String> get_video_adapter_driver_info() const;
248
249 String get_locale() const;
250 String get_locale_language() const;
251
252 String get_model_name() const;
253
254 bool is_debug_build() const;
255
256 String get_unique_id() const;
257
258 String get_keycode_string(Key p_code) const;
259 bool is_keycode_unicode(char32_t p_unicode) const;
260 Key find_keycode_from_string(const String &p_code) const;
261
262 void set_use_file_access_save_and_swap(bool p_enable);
263
264 uint64_t get_static_memory_usage() const;
265 uint64_t get_static_memory_peak_usage() const;
266 Dictionary get_memory_info() const;
267
268 void delay_usec(int p_usec) const;
269 void delay_msec(int p_msec) const;
270 uint64_t get_ticks_msec() const;
271 uint64_t get_ticks_usec() const;
272
273 bool is_userfs_persistent() const;
274
275 bool is_stdout_verbose() const;
276
277 int get_processor_count() const;
278 String get_processor_name() const;
279
280 enum SystemDir {
281 SYSTEM_DIR_DESKTOP,
282 SYSTEM_DIR_DCIM,
283 SYSTEM_DIR_DOCUMENTS,
284 SYSTEM_DIR_DOWNLOADS,
285 SYSTEM_DIR_MOVIES,
286 SYSTEM_DIR_MUSIC,
287 SYSTEM_DIR_PICTURES,
288 SYSTEM_DIR_RINGTONES,
289 };
290
291 String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
292
293 Error move_to_trash(const String &p_path) const;
294 String get_user_data_dir() const;
295 String get_config_dir() const;
296 String get_data_dir() const;
297 String get_cache_dir() const;
298 String get_temp_dir() const;
299
300 Error set_thread_name(const String &p_name);
301 ::Thread::ID get_thread_caller_id() const;
302 ::Thread::ID get_main_thread_id() const;
303
304 bool has_feature(const String &p_feature) const;
305 bool is_sandboxed() const;
306
307 bool request_permission(const String &p_name);
308 bool request_permissions();
309 Vector<String> get_granted_permissions() const;
310 void revoke_granted_permissions();
311
312 void add_logger(const Ref<Logger> &p_logger);
313 void remove_logger(const Ref<Logger> &p_logger);
314 void remove_script_loggers(const ScriptLanguage *p_script);
315
316 static OS *get_singleton() { return singleton; }
317
318 OS();
319 ~OS();
320 };
321
322 class Geometry2D : public Object {
323 GDCLASS(Geometry2D, Object);
324
325 static inline Geometry2D *singleton = nullptr;
326
327 protected:
328 static void _bind_methods();
329
330 public:
331 static Geometry2D *get_singleton();
332 Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
333 Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
334 Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
335 Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
336 Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
337 bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
338
339 bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
340 real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
341
342 bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
343 bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
344 Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
345 Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
346 Vector<Point2> convex_hull(const Vector<Point2> &p_points);
347 TypedArray<PackedVector2Array> decompose_polygon_in_convex(const Vector<Vector2> &p_polygon);
348
349 enum PolyBooleanOperation {
350 OPERATION_UNION,
351 OPERATION_DIFFERENCE,
352 OPERATION_INTERSECTION,
353 OPERATION_XOR
354 };
355 // 2D polygon boolean operations.
356 TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
357 TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
358 TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
359 TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
360
361 // 2D polyline vs polygon operations.
362 TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
363 TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
364
365 // 2D offset polygons/polylines.
366 enum PolyJoinType {
367 JOIN_SQUARE,
368 JOIN_ROUND,
369 JOIN_MITER
370 };
371 enum PolyEndType {
372 END_POLYGON,
373 END_JOINED,
374 END_BUTT,
375 END_SQUARE,
376 END_ROUND
377 };
378 TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
379 TypedArray<PackedVector2Array> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
380
381 Dictionary make_atlas(const Vector<Size2> &p_rects);
382
383 TypedArray<Point2i> bresenham_line(const Point2i &p_from, const Point2i &p_to);
384
385 Geometry2D() { singleton = this; }
386 };
387
388 class Geometry3D : public Object {
389 GDCLASS(Geometry3D, Object);
390
391 static inline Geometry3D *singleton = nullptr;
392
393 protected:
394 static void _bind_methods();
395
396 public:
397 static Geometry3D *get_singleton();
398 Vector<Vector3> compute_convex_mesh_points(const TypedArray<Plane> &p_planes);
399 TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
400 TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
401 TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
402 Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
403 Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
404 Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
405 Vector3 get_triangle_barycentric_coords(const Vector3 &p_point, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
406 Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
407 Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
408
409 Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
410 Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
411 Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const TypedArray<Plane> &p_planes);
412
413 Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
414 Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points);
415
416 Geometry3D() { singleton = this; }
417 };
418
419 class Marshalls : public Object {
420 GDCLASS(Marshalls, Object);
421
422 static inline Marshalls *singleton = nullptr;
423
424 protected:
425 static void _bind_methods();
426
427 public:
428 static Marshalls *get_singleton();
429
430 String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
431 Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
432
433 String raw_to_base64(const Vector<uint8_t> &p_arr);
434 Vector<uint8_t> base64_to_raw(const String &p_str);
435
436 String utf8_to_base64(const String &p_str);
437 String base64_to_utf8(const String &p_str);
438
439 Marshalls() { singleton = this; }
440 ~Marshalls() { singleton = nullptr; }
441 };
442
443 class Mutex : public RefCounted {
444 GDCLASS(Mutex, RefCounted);
445 ::Mutex mutex;
446
447 static void _bind_methods();
448
449 public:
450 void lock();
451 bool try_lock();
452 void unlock();
453 };
454
455 class Semaphore : public RefCounted {
456 GDCLASS(Semaphore, RefCounted);
457 ::Semaphore semaphore;
458
459 protected:
460 static void _bind_methods();
461 #ifndef DISABLE_DEPRECATED
462 void _post_bind_compat_93605();
463 static void _bind_compatibility_methods();
464 #endif // DISABLE_DEPRECATED
465
466 public:
467 void wait();
468 bool try_wait();
469 void post(int p_count = 1);
470 };
471
472 class Thread : public RefCounted {
473 GDCLASS(Thread, RefCounted);
474
475 protected:
476 Variant ret;
477 SafeFlag running;
478 Callable target_callable;
479 ::Thread thread;
480 static void _bind_methods();
481 static void _start_func(void *ud);
482
483 public:
484 enum Priority {
485 PRIORITY_LOW,
486 PRIORITY_NORMAL,
487 PRIORITY_HIGH,
488 PRIORITY_MAX
489 };
490
491 Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL);
492 String get_id() const;
493 bool is_started() const;
494 bool is_alive() const;
495 Variant wait_to_finish();
496
497 static void set_thread_safety_checks_enabled(bool p_enabled);
498 static bool is_main_thread();
499 };
500
501 namespace Special {
502
503 class ClassDB : public Object {
504 GDCLASS(ClassDB, Object);
505
506 protected:
507 static void _bind_methods();
508
509 public:
510 enum APIType {
511 API_CORE,
512 API_EDITOR,
513 API_EXTENSION,
514 API_EDITOR_EXTENSION,
515 API_NONE,
516 };
517
518 PackedStringArray get_class_list() const;
519 PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
520 StringName get_parent_class(const StringName &p_class) const;
521 bool class_exists(const StringName &p_class) const;
522 bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
523 bool can_instantiate(const StringName &p_class) const;
524 Variant instantiate(const StringName &p_class) const;
525
526 APIType class_get_api_type(const StringName &p_class) const;
527 bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
528 Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
529 TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
530
531 TypedArray<Dictionary> class_get_property_list(const StringName &p_class, bool p_no_inheritance = false) const;
532 StringName class_get_property_getter(const StringName &p_class, const StringName &p_property);
533 StringName class_get_property_setter(const StringName &p_class, const StringName &p_property);
534 Variant class_get_property(Object *p_object, const StringName &p_property) const;
535 Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
536
537 Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
538
539 bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
540
541 int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
542
543 TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
544 Variant class_call_static(const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error);
545
546 PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
547 bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
548 int64_t class_get_integer_constant(const StringName &p_class, const StringName &p_name) const;
549
550 bool class_has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
551 PackedStringArray class_get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
552 PackedStringArray class_get_enum_constants(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
553 StringName class_get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
554
555 bool is_class_enum_bitfield(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
556
557 bool is_class_enabled(const StringName &p_class) const;
558
559 #ifdef TOOLS_ENABLED
560 virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
561 #endif
562 };
563
564 } // namespace Special
565
566 class Engine : public Object {
567 GDCLASS(Engine, Object);
568
569 protected:
570 static void _bind_methods();
571 static inline Engine *singleton = nullptr;
572
573 public:
574 static Engine *get_singleton() { return singleton; }
575 void set_physics_ticks_per_second(int p_ips);
576 int get_physics_ticks_per_second() const;
577
578 void set_max_physics_steps_per_frame(int p_max_physics_steps);
579 int get_max_physics_steps_per_frame() const;
580
581 void set_physics_jitter_fix(double p_threshold);
582 double get_physics_jitter_fix() const;
583 double get_physics_interpolation_fraction() const;
584
585 void set_max_fps(int p_fps);
586 int get_max_fps() const;
587
588 double get_frames_per_second() const;
589 uint64_t get_physics_frames() const;
590 uint64_t get_process_frames() const;
591
592 int get_frames_drawn();
593
594 void set_time_scale(double p_scale);
595 double get_time_scale();
596
597 MainLoop *get_main_loop() const;
598
599 Dictionary get_version_info() const;
600 Dictionary get_author_info() const;
601 TypedArray<Dictionary> get_copyright_info() const;
602 Dictionary get_donor_info() const;
603 Dictionary get_license_info() const;
604 String get_license_text() const;
605
606 String get_architecture_name() const;
607
608 bool is_in_physics_frame() const;
609
610 bool has_singleton(const StringName &p_name) const;
611 Object *get_singleton_object(const StringName &p_name) const;
612 void register_singleton(const StringName &p_name, Object *p_object);
613 void unregister_singleton(const StringName &p_name);
614 Vector<String> get_singleton_list() const;
615
616 Error register_script_language(ScriptLanguage *p_language);
617 Error unregister_script_language(const ScriptLanguage *p_language);
618 int get_script_language_count();
619 ScriptLanguage *get_script_language(int p_index) const;
620 TypedArray<ScriptBacktrace> capture_script_backtraces(bool p_include_variables = false) const;
621
622 void set_editor_hint(bool p_enabled);
623 bool is_editor_hint() const;
624
625 bool is_embedded_in_editor() const;
626
627 // `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
628 String get_write_movie_path() const;
629
630 void set_print_to_stdout(bool p_enabled);
631 bool is_printing_to_stdout() const;
632
633 void set_print_error_messages(bool p_enabled);
634 bool is_printing_error_messages() const;
635
636 #ifdef TOOLS_ENABLED
637 virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
638 #endif
639
640 Engine() { singleton = this; }
641 };
642
643 class EngineDebugger : public Object {
644 GDCLASS(EngineDebugger, Object);
645
646 HashMap<StringName, Callable> captures;
647 HashMap<StringName, Ref<EngineProfiler>> profilers;
648
649 protected:
650 static void _bind_methods();
651 static inline EngineDebugger *singleton = nullptr;
652
653 public:
654 static EngineDebugger *get_singleton() { return singleton; }
655
656 bool is_active();
657
658 void register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler);
659 void unregister_profiler(const StringName &p_name);
660 bool is_profiling(const StringName &p_name);
661 bool has_profiler(const StringName &p_name);
662 void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
663 void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
664
665 void register_message_capture(const StringName &p_name, const Callable &p_callable);
666 void unregister_message_capture(const StringName &p_name);
667 bool has_capture(const StringName &p_name);
668
669 void send_message(const String &p_msg, const Array &p_data);
670 void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
671 void script_debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
672
673 static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
674
675 void line_poll();
676
677 void set_lines_left(int p_lines);
678 int get_lines_left() const;
679
680 void set_depth(int p_depth);
681 int get_depth() const;
682
683 bool is_breakpoint(int p_line, const StringName &p_source) const;
684 bool is_skipping_breakpoints() const;
685 void insert_breakpoint(int p_line, const StringName &p_source);
686 void remove_breakpoint(int p_line, const StringName &p_source);
687 void clear_breakpoints();
688
689 EngineDebugger() { singleton = this; }
690 ~EngineDebugger();
691 };
692
693 } // namespace CoreBind
694
695 VARIANT_ENUM_CAST(CoreBind::Logger::ErrorType);
696 VARIANT_ENUM_CAST(CoreBind::ResourceLoader::ThreadLoadStatus);
697 VARIANT_ENUM_CAST(CoreBind::ResourceLoader::CacheMode);
698
699 VARIANT_BITFIELD_CAST(CoreBind::ResourceSaver::SaverFlags);
700
701 VARIANT_ENUM_CAST(CoreBind::OS::RenderingDriver);
702 VARIANT_ENUM_CAST(CoreBind::OS::SystemDir);
703 VARIANT_ENUM_CAST(CoreBind::OS::StdHandleType);
704
705 VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyBooleanOperation);
706 VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyJoinType);
707 VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyEndType);
708
709 VARIANT_ENUM_CAST(CoreBind::Thread::Priority);
710
711 VARIANT_ENUM_CAST(CoreBind::Special::ClassDB::APIType);