core_bind.h 25 KB

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