visual_script_builtin_funcs.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*************************************************************************/
  2. /* visual_script_builtin_funcs.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef VISUAL_SCRIPT_BUILTIN_FUNCS_H
  30. #define VISUAL_SCRIPT_BUILTIN_FUNCS_H
  31. #include "visual_script.h"
  32. class VisualScriptBuiltinFunc : public VisualScriptNode {
  33. GDCLASS(VisualScriptBuiltinFunc,VisualScriptNode)
  34. public:
  35. enum BuiltinFunc {
  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_DECTIME,
  64. MATH_RANDOMIZE,
  65. MATH_RAND,
  66. MATH_RANDF,
  67. MATH_RANDOM,
  68. MATH_SEED,
  69. MATH_RANDSEED,
  70. MATH_DEG2RAD,
  71. MATH_RAD2DEG,
  72. MATH_LINEAR2DB,
  73. MATH_DB2LINEAR,
  74. LOGIC_MAX,
  75. LOGIC_MIN,
  76. LOGIC_CLAMP,
  77. LOGIC_NEAREST_PO2,
  78. OBJ_WEAKREF,
  79. FUNC_FUNCREF,
  80. TYPE_CONVERT,
  81. TYPE_OF,
  82. TYPE_EXISTS,
  83. TEXT_CHAR,
  84. TEXT_STR,
  85. TEXT_PRINT,
  86. TEXT_PRINTERR,
  87. TEXT_PRINTRAW,
  88. VAR_TO_STR,
  89. STR_TO_VAR,
  90. VAR_TO_BYTES,
  91. BYTES_TO_VAR,
  92. COLORN,
  93. FUNC_MAX
  94. };
  95. static int get_func_argument_count(BuiltinFunc p_func);
  96. static String get_func_name(BuiltinFunc p_func);
  97. static void exec_func(BuiltinFunc p_func, const Variant** p_inputs, Variant* r_return, Variant::CallError& r_error, String& r_error_str);
  98. static BuiltinFunc find_function(const String& p_string);
  99. private:
  100. static const char* func_name[FUNC_MAX];
  101. BuiltinFunc func;
  102. protected:
  103. static void _bind_methods();
  104. public:
  105. virtual int get_output_sequence_port_count() const;
  106. virtual bool has_input_sequence_port() const;
  107. virtual String get_output_sequence_port_text(int p_port) const;
  108. virtual int get_input_value_port_count() const;
  109. virtual int get_output_value_port_count() const;
  110. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  111. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  112. virtual String get_caption() const;
  113. virtual String get_text() const;
  114. virtual String get_category() const { return "functions"; }
  115. void set_func(BuiltinFunc p_which);
  116. BuiltinFunc get_func();
  117. virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
  118. VisualScriptBuiltinFunc();
  119. };
  120. VARIANT_ENUM_CAST(VisualScriptBuiltinFunc::BuiltinFunc)
  121. void register_visual_script_builtin_func_node();
  122. #endif // VISUAL_SCRIPT_BUILTIN_FUNCS_H