core_bind.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*************************************************************************/
  2. /* core_bind.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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 CORE_BIND_H
  31. #define CORE_BIND_H
  32. #include "core/image.h"
  33. #include "core/io/compression.h"
  34. #include "core/io/resource_loader.h"
  35. #include "core/io/resource_saver.h"
  36. #include "core/os/dir_access.h"
  37. #include "core/os/file_access.h"
  38. #include "core/os/os.h"
  39. #include "core/os/semaphore.h"
  40. #include "core/os/thread.h"
  41. class _ResourceLoader : public Object {
  42. GDCLASS(_ResourceLoader, Object);
  43. protected:
  44. static void _bind_methods();
  45. static _ResourceLoader *singleton;
  46. public:
  47. enum ThreadLoadStatus {
  48. THREAD_LOAD_INVALID_RESOURCE,
  49. THREAD_LOAD_IN_PROGRESS,
  50. THREAD_LOAD_FAILED,
  51. THREAD_LOAD_LOADED
  52. };
  53. static _ResourceLoader *get_singleton() { return singleton; }
  54. Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false);
  55. ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
  56. RES load_threaded_get(const String &p_path);
  57. RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false);
  58. Vector<String> get_recognized_extensions_for_type(const String &p_type);
  59. void set_abort_on_missing_resources(bool p_abort);
  60. PackedStringArray get_dependencies(const String &p_path);
  61. bool has_cached(const String &p_path);
  62. bool exists(const String &p_path, const String &p_type_hint = "");
  63. _ResourceLoader();
  64. };
  65. VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus);
  66. class _ResourceSaver : public Object {
  67. GDCLASS(_ResourceSaver, Object);
  68. protected:
  69. static void _bind_methods();
  70. static _ResourceSaver *singleton;
  71. public:
  72. enum SaverFlags {
  73. FLAG_RELATIVE_PATHS = 1,
  74. FLAG_BUNDLE_RESOURCES = 2,
  75. FLAG_CHANGE_PATH = 4,
  76. FLAG_OMIT_EDITOR_PROPERTIES = 8,
  77. FLAG_SAVE_BIG_ENDIAN = 16,
  78. FLAG_COMPRESS = 32,
  79. FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
  80. };
  81. static _ResourceSaver *get_singleton() { return singleton; }
  82. Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
  83. Vector<String> get_recognized_extensions(const RES &p_resource);
  84. _ResourceSaver();
  85. };
  86. VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
  87. class MainLoop;
  88. class _OS : public Object {
  89. GDCLASS(_OS, Object);
  90. protected:
  91. static void _bind_methods();
  92. static _OS *singleton;
  93. public:
  94. enum VideoDriver {
  95. VIDEO_DRIVER_GLES2,
  96. VIDEO_DRIVER_VULKAN,
  97. };
  98. enum Weekday {
  99. DAY_SUNDAY,
  100. DAY_MONDAY,
  101. DAY_TUESDAY,
  102. DAY_WEDNESDAY,
  103. DAY_THURSDAY,
  104. DAY_FRIDAY,
  105. DAY_SATURDAY
  106. };
  107. enum Month {
  108. // Start at 1 to follow Windows SYSTEMTIME structure
  109. // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
  110. MONTH_JANUARY = 1,
  111. MONTH_FEBRUARY,
  112. MONTH_MARCH,
  113. MONTH_APRIL,
  114. MONTH_MAY,
  115. MONTH_JUNE,
  116. MONTH_JULY,
  117. MONTH_AUGUST,
  118. MONTH_SEPTEMBER,
  119. MONTH_OCTOBER,
  120. MONTH_NOVEMBER,
  121. MONTH_DECEMBER
  122. };
  123. virtual PackedStringArray get_connected_midi_inputs();
  124. virtual void open_midi_inputs();
  125. virtual void close_midi_inputs();
  126. void set_low_processor_usage_mode(bool p_enabled);
  127. bool is_in_low_processor_usage_mode() const;
  128. void set_low_processor_usage_mode_sleep_usec(int p_usec);
  129. int get_low_processor_usage_mode_sleep_usec() const;
  130. String get_executable_path() const;
  131. int execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true, Array p_output = Array(), bool p_read_stderr = false);
  132. Error kill(int p_pid);
  133. Error shell_open(String p_uri);
  134. int get_process_id() const;
  135. bool has_environment(const String &p_var) const;
  136. String get_environment(const String &p_var) const;
  137. String get_name() const;
  138. Vector<String> get_cmdline_args();
  139. String get_locale() const;
  140. String get_model_name() const;
  141. void dump_memory_to_file(const String &p_file);
  142. void dump_resources_to_file(const String &p_file);
  143. void print_resources_in_use(bool p_short = false);
  144. void print_all_resources(const String &p_to_file);
  145. void print_all_textures_by_size();
  146. void print_resources_by_type(const Vector<String> &p_types);
  147. bool is_debug_build() const;
  148. String get_unique_id() const;
  149. String get_keycode_string(uint32_t p_code) const;
  150. bool is_keycode_unicode(uint32_t p_unicode) const;
  151. int find_keycode_from_string(const String &p_code) const;
  152. void set_use_file_access_save_and_swap(bool p_enable);
  153. int get_exit_code() const;
  154. void set_exit_code(int p_code);
  155. Dictionary get_date(bool utc) const;
  156. Dictionary get_time(bool utc) const;
  157. Dictionary get_datetime(bool utc) const;
  158. Dictionary get_datetime_from_unix_time(int64_t unix_time_val) const;
  159. int64_t get_unix_time_from_datetime(Dictionary datetime) const;
  160. Dictionary get_time_zone_info() const;
  161. uint64_t get_unix_time() const;
  162. uint64_t get_system_time_secs() const;
  163. uint64_t get_system_time_msecs() const;
  164. uint64_t get_static_memory_usage() const;
  165. uint64_t get_static_memory_peak_usage() const;
  166. void delay_usec(uint32_t p_usec) const;
  167. void delay_msec(uint32_t p_msec) const;
  168. uint32_t get_ticks_msec() const;
  169. uint64_t get_ticks_usec() const;
  170. uint32_t get_splash_tick_msec() const;
  171. bool can_use_threads() const;
  172. bool is_userfs_persistent() const;
  173. bool is_stdout_verbose() const;
  174. int get_processor_count() const;
  175. enum SystemDir {
  176. SYSTEM_DIR_DESKTOP,
  177. SYSTEM_DIR_DCIM,
  178. SYSTEM_DIR_DOCUMENTS,
  179. SYSTEM_DIR_DOWNLOADS,
  180. SYSTEM_DIR_MOVIES,
  181. SYSTEM_DIR_MUSIC,
  182. SYSTEM_DIR_PICTURES,
  183. SYSTEM_DIR_RINGTONES,
  184. };
  185. String get_system_dir(SystemDir p_dir) const;
  186. String get_user_data_dir() const;
  187. Error set_thread_name(const String &p_name);
  188. bool has_feature(const String &p_feature) const;
  189. bool request_permission(const String &p_name);
  190. bool request_permissions();
  191. Vector<String> get_granted_permissions() const;
  192. static _OS *get_singleton() { return singleton; }
  193. _OS();
  194. };
  195. VARIANT_ENUM_CAST(_OS::VideoDriver);
  196. VARIANT_ENUM_CAST(_OS::Weekday);
  197. VARIANT_ENUM_CAST(_OS::Month);
  198. VARIANT_ENUM_CAST(_OS::SystemDir);
  199. class _Geometry : public Object {
  200. GDCLASS(_Geometry, Object);
  201. static _Geometry *singleton;
  202. protected:
  203. static void _bind_methods();
  204. public:
  205. static _Geometry *get_singleton();
  206. Vector<Plane> build_box_planes(const Vector3 &p_extents);
  207. Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
  208. Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
  209. Variant segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
  210. Variant line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
  211. Vector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
  212. Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
  213. Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  214. Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  215. Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  216. Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  217. Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  218. Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  219. bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
  220. Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
  221. Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
  222. Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
  223. bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
  224. real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
  225. int get_uv84_normal_bit(const Vector3 &p_vector);
  226. bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
  227. bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
  228. Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
  229. Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points);
  230. Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
  231. Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
  232. enum PolyBooleanOperation {
  233. OPERATION_UNION,
  234. OPERATION_DIFFERENCE,
  235. OPERATION_INTERSECTION,
  236. OPERATION_XOR
  237. };
  238. // 2D polygon boolean operations.
  239. Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
  240. Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
  241. Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
  242. Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
  243. // 2D polyline vs polygon operations.
  244. Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
  245. Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
  246. // 2D offset polygons/polylines.
  247. enum PolyJoinType {
  248. JOIN_SQUARE,
  249. JOIN_ROUND,
  250. JOIN_MITER
  251. };
  252. enum PolyEndType {
  253. END_POLYGON,
  254. END_JOINED,
  255. END_BUTT,
  256. END_SQUARE,
  257. END_ROUND
  258. };
  259. Array offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
  260. Array offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
  261. Dictionary make_atlas(const Vector<Size2> &p_rects);
  262. _Geometry();
  263. };
  264. VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation);
  265. VARIANT_ENUM_CAST(_Geometry::PolyJoinType);
  266. VARIANT_ENUM_CAST(_Geometry::PolyEndType);
  267. class _File : public Reference {
  268. GDCLASS(_File, Reference);
  269. FileAccess *f;
  270. bool eswap;
  271. protected:
  272. static void _bind_methods();
  273. public:
  274. enum ModeFlags {
  275. READ = 1,
  276. WRITE = 2,
  277. READ_WRITE = 3,
  278. WRITE_READ = 7,
  279. };
  280. enum CompressionMode {
  281. COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
  282. COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
  283. COMPRESSION_ZSTD = Compression::MODE_ZSTD,
  284. COMPRESSION_GZIP = Compression::MODE_GZIP
  285. };
  286. Error open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key);
  287. Error open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass);
  288. Error open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ);
  289. Error open(const String &p_path, ModeFlags p_mode_flags); // open a file.
  290. void close(); // Close a file.
  291. bool is_open() const; // True when file is open.
  292. String get_path() const; // Returns the path for the current open file.
  293. String get_path_absolute() const; // Returns the absolute path for the current open file.
  294. void seek(int64_t p_position); // Seek to a given position.
  295. void seek_end(int64_t p_position = 0); // Seek from the end of file.
  296. int64_t get_position() const; // Get position in the file.
  297. int64_t get_len() const; // Get size of the file.
  298. bool eof_reached() const; // Reading passed EOF.
  299. uint8_t get_8() const; // Get a byte.
  300. uint16_t get_16() const; // Get 16 bits uint.
  301. uint32_t get_32() const; // Get 32 bits uint.
  302. uint64_t get_64() const; // Get 64 bits uint.
  303. float get_float() const;
  304. double get_double() const;
  305. real_t get_real() const;
  306. Variant get_var(bool p_allow_objects = false) const;
  307. Vector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
  308. String get_line() const;
  309. Vector<String> get_csv_line(const String &p_delim = ",") const;
  310. String get_as_text() const;
  311. String get_md5(const String &p_path) const;
  312. String get_sha256(const String &p_path) const;
  313. /* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac).
  314. * It's not about the current CPU type but file formats.
  315. * This flags get reset to false (little endian) on each open.
  316. */
  317. void set_endian_swap(bool p_swap);
  318. bool get_endian_swap();
  319. Error get_error() const; // Get last error.
  320. void store_8(uint8_t p_dest); // Store a byte.
  321. void store_16(uint16_t p_dest); // Store 16 bits uint.
  322. void store_32(uint32_t p_dest); // Store 32 bits uint.
  323. void store_64(uint64_t p_dest); // Store 64 bits uint.
  324. void store_float(float p_dest);
  325. void store_double(double p_dest);
  326. void store_real(real_t p_real);
  327. void store_string(const String &p_string);
  328. void store_line(const String &p_string);
  329. void store_csv_line(const Vector<String> &p_values, const String &p_delim = ",");
  330. virtual void store_pascal_string(const String &p_string);
  331. virtual String get_pascal_string();
  332. void store_buffer(const Vector<uint8_t> &p_buffer); // Store an array of bytes.
  333. void store_var(const Variant &p_var, bool p_full_objects = false);
  334. bool file_exists(const String &p_name) const; // Return true if a file exists.
  335. uint64_t get_modified_time(const String &p_file) const;
  336. _File();
  337. virtual ~_File();
  338. };
  339. VARIANT_ENUM_CAST(_File::ModeFlags);
  340. VARIANT_ENUM_CAST(_File::CompressionMode);
  341. class _Directory : public Reference {
  342. GDCLASS(_Directory, Reference);
  343. DirAccess *d;
  344. protected:
  345. static void _bind_methods();
  346. public:
  347. Error open(const String &p_path);
  348. Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
  349. String get_next();
  350. bool current_is_dir() const;
  351. void list_dir_end();
  352. int get_drive_count();
  353. String get_drive(int p_drive);
  354. int get_current_drive();
  355. Error change_dir(String p_dir); // Can be relative or absolute, return false on success.
  356. String get_current_dir(); // Return current dir location.
  357. Error make_dir(String p_dir);
  358. Error make_dir_recursive(String p_dir);
  359. bool file_exists(String p_file);
  360. bool dir_exists(String p_dir);
  361. int get_space_left();
  362. Error copy(String p_from, String p_to);
  363. Error rename(String p_from, String p_to);
  364. Error remove(String p_name);
  365. _Directory();
  366. virtual ~_Directory();
  367. private:
  368. bool _list_skip_navigational;
  369. bool _list_skip_hidden;
  370. };
  371. class _Marshalls : public Object {
  372. GDCLASS(_Marshalls, Object);
  373. static _Marshalls *singleton;
  374. protected:
  375. static void _bind_methods();
  376. public:
  377. static _Marshalls *get_singleton();
  378. String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
  379. Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
  380. String raw_to_base64(const Vector<uint8_t> &p_arr);
  381. Vector<uint8_t> base64_to_raw(const String &p_str);
  382. String utf8_to_base64(const String &p_str);
  383. String base64_to_utf8(const String &p_str);
  384. _Marshalls() { singleton = this; }
  385. ~_Marshalls() { singleton = nullptr; }
  386. };
  387. class _Mutex : public Reference {
  388. GDCLASS(_Mutex, Reference);
  389. Mutex mutex;
  390. static void _bind_methods();
  391. public:
  392. void lock();
  393. Error try_lock();
  394. void unlock();
  395. };
  396. class _Semaphore : public Reference {
  397. GDCLASS(_Semaphore, Reference);
  398. Semaphore semaphore;
  399. static void _bind_methods();
  400. public:
  401. void wait();
  402. Error try_wait();
  403. void post();
  404. };
  405. class _Thread : public Reference {
  406. GDCLASS(_Thread, Reference);
  407. protected:
  408. Variant ret;
  409. Variant userdata;
  410. volatile bool active;
  411. Object *target_instance;
  412. StringName target_method;
  413. Thread *thread;
  414. static void _bind_methods();
  415. static void _start_func(void *ud);
  416. public:
  417. enum Priority {
  418. PRIORITY_LOW,
  419. PRIORITY_NORMAL,
  420. PRIORITY_HIGH,
  421. PRIORITY_MAX
  422. };
  423. Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), Priority p_priority = PRIORITY_NORMAL);
  424. String get_id() const;
  425. bool is_active() const;
  426. Variant wait_to_finish();
  427. _Thread();
  428. ~_Thread();
  429. };
  430. VARIANT_ENUM_CAST(_Thread::Priority);
  431. class _ClassDB : public Object {
  432. GDCLASS(_ClassDB, Object);
  433. protected:
  434. static void _bind_methods();
  435. public:
  436. PackedStringArray get_class_list() const;
  437. PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
  438. StringName get_parent_class(const StringName &p_class) const;
  439. bool class_exists(const StringName &p_class) const;
  440. bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
  441. bool can_instance(const StringName &p_class) const;
  442. Variant instance(const StringName &p_class) const;
  443. bool has_signal(StringName p_class, StringName p_signal) const;
  444. Dictionary get_signal(StringName p_class, StringName p_signal) const;
  445. Array get_signal_list(StringName p_class, bool p_no_inheritance = false) const;
  446. Array get_property_list(StringName p_class, bool p_no_inheritance = false) const;
  447. Variant get_property(Object *p_object, const StringName &p_property) const;
  448. Error set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
  449. bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const;
  450. Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
  451. PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
  452. bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
  453. int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
  454. StringName get_category(const StringName &p_node) const;
  455. bool is_class_enabled(StringName p_class) const;
  456. _ClassDB();
  457. ~_ClassDB();
  458. };
  459. class _Engine : public Object {
  460. GDCLASS(_Engine, Object);
  461. protected:
  462. static void _bind_methods();
  463. static _Engine *singleton;
  464. public:
  465. static _Engine *get_singleton() { return singleton; }
  466. void set_iterations_per_second(int p_ips);
  467. int get_iterations_per_second() const;
  468. void set_physics_jitter_fix(float p_threshold);
  469. float get_physics_jitter_fix() const;
  470. float get_physics_interpolation_fraction() const;
  471. void set_target_fps(int p_fps);
  472. int get_target_fps() const;
  473. float get_frames_per_second() const;
  474. uint64_t get_physics_frames() const;
  475. uint64_t get_idle_frames() const;
  476. int get_frames_drawn();
  477. void set_time_scale(float p_scale);
  478. float get_time_scale();
  479. MainLoop *get_main_loop() const;
  480. Dictionary get_version_info() const;
  481. Dictionary get_author_info() const;
  482. Array get_copyright_info() const;
  483. Dictionary get_donor_info() const;
  484. Dictionary get_license_info() const;
  485. String get_license_text() const;
  486. bool is_in_physics_frame() const;
  487. bool has_singleton(const String &p_name) const;
  488. Object *get_singleton_object(const String &p_name) const;
  489. void set_editor_hint(bool p_enabled);
  490. bool is_editor_hint() const;
  491. _Engine();
  492. };
  493. class _JSON;
  494. class JSONParseResult : public Reference {
  495. GDCLASS(JSONParseResult, Reference);
  496. friend class _JSON;
  497. Error error;
  498. String error_string;
  499. int error_line;
  500. Variant result;
  501. protected:
  502. static void _bind_methods();
  503. public:
  504. void set_error(Error p_error);
  505. Error get_error() const;
  506. void set_error_string(const String &p_error_string);
  507. String get_error_string() const;
  508. void set_error_line(int p_error_line);
  509. int get_error_line() const;
  510. void set_result(const Variant &p_result);
  511. Variant get_result() const;
  512. JSONParseResult() :
  513. error_line(-1) {}
  514. };
  515. class _JSON : public Object {
  516. GDCLASS(_JSON, Object);
  517. protected:
  518. static void _bind_methods();
  519. static _JSON *singleton;
  520. public:
  521. static _JSON *get_singleton() { return singleton; }
  522. String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
  523. Ref<JSONParseResult> parse(const String &p_json);
  524. _JSON();
  525. };
  526. #endif // CORE_BIND_H