gdscript_functions.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*************************************************************************/
  2. /* gdscript_functions.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GDSCRIPT_FUNCTIONS_H
  31. #define GDSCRIPT_FUNCTIONS_H
  32. #include "core/variant.h"
  33. class GDScriptFunctions {
  34. public:
  35. enum Function {
  36. MATH_SIN,
  37. MATH_COS,
  38. MATH_TAN,
  39. MATH_SINH,
  40. MATH_COSH,
  41. MATH_TANH,
  42. MATH_ASIN,
  43. MATH_ACOS,
  44. MATH_ATAN,
  45. MATH_ATAN2,
  46. MATH_SQRT,
  47. MATH_FMOD,
  48. MATH_FPOSMOD,
  49. MATH_FLOOR,
  50. MATH_CEIL,
  51. MATH_ROUND,
  52. MATH_ABS,
  53. MATH_SIGN,
  54. MATH_POW,
  55. MATH_LOG,
  56. MATH_EXP,
  57. MATH_ISNAN,
  58. MATH_ISINF,
  59. MATH_EASE,
  60. MATH_DECIMALS,
  61. MATH_STEPIFY,
  62. MATH_LERP,
  63. MATH_INVERSE_LERP,
  64. MATH_RANGE_LERP,
  65. MATH_DECTIME,
  66. MATH_RANDOMIZE,
  67. MATH_RAND,
  68. MATH_RANDF,
  69. MATH_RANDOM,
  70. MATH_SEED,
  71. MATH_RANDSEED,
  72. MATH_DEG2RAD,
  73. MATH_RAD2DEG,
  74. MATH_LINEAR2DB,
  75. MATH_DB2LINEAR,
  76. MATH_POLAR2CARTESIAN,
  77. MATH_CARTESIAN2POLAR,
  78. MATH_WRAP,
  79. MATH_WRAPF,
  80. LOGIC_MAX,
  81. LOGIC_MIN,
  82. LOGIC_CLAMP,
  83. LOGIC_NEAREST_PO2,
  84. OBJ_WEAKREF,
  85. FUNC_FUNCREF,
  86. TYPE_CONVERT,
  87. TYPE_OF,
  88. TYPE_EXISTS,
  89. TEXT_CHAR,
  90. TEXT_STR,
  91. TEXT_PRINT,
  92. TEXT_PRINT_TABBED,
  93. TEXT_PRINT_SPACED,
  94. TEXT_PRINTERR,
  95. TEXT_PRINTRAW,
  96. TEXT_PRINT_DEBUG,
  97. PUSH_ERROR,
  98. PUSH_WARNING,
  99. VAR_TO_STR,
  100. STR_TO_VAR,
  101. VAR_TO_BYTES,
  102. BYTES_TO_VAR,
  103. GEN_RANGE,
  104. RESOURCE_LOAD,
  105. INST2DICT,
  106. DICT2INST,
  107. VALIDATE_JSON,
  108. PARSE_JSON,
  109. TO_JSON,
  110. HASH,
  111. COLOR8,
  112. COLORN,
  113. PRINT_STACK,
  114. GET_STACK,
  115. INSTANCE_FROM_ID,
  116. LEN,
  117. IS_INSTANCE_VALID,
  118. FUNC_MAX
  119. };
  120. static const char *get_func_name(Function p_func);
  121. static void call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error);
  122. static bool is_deterministic(Function p_func);
  123. static MethodInfo get_info(Function p_func);
  124. };
  125. #endif // GDSCRIPT_FUNCTIONS_H