variant_call.cpp 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944
  1. /*************************************************************************/
  2. /* variant_call.cpp */
  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. #include "variant.h"
  31. #include "core/color_names.inc"
  32. #include "core/core_string_names.h"
  33. #include "core/io/compression.h"
  34. #include "core/object.h"
  35. #include "core/os/os.h"
  36. #include "core/script_language.h"
  37. typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args);
  38. typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args);
  39. struct _VariantCall {
  40. static void Vector3_dot(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  41. r_ret = reinterpret_cast<Vector3 *>(p_self._data._mem)->dot(*reinterpret_cast<const Vector3 *>(p_args[0]->_data._mem));
  42. }
  43. struct FuncData {
  44. int arg_count;
  45. Vector<Variant> default_args;
  46. Vector<Variant::Type> arg_types;
  47. Vector<StringName> arg_names;
  48. Variant::Type return_type;
  49. bool _const;
  50. bool returns;
  51. VariantFunc func;
  52. _FORCE_INLINE_ bool verify_arguments(const Variant **p_args, Variant::CallError &r_error) {
  53. if (arg_count == 0)
  54. return true;
  55. const Variant::Type *tptr = &arg_types[0];
  56. for (int i = 0; i < arg_count; i++) {
  57. if (!tptr[i] || tptr[i] == p_args[i]->type)
  58. continue; // all good
  59. if (!Variant::can_convert(p_args[i]->type, tptr[i])) {
  60. r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
  61. r_error.argument = i;
  62. r_error.expected = tptr[i];
  63. return false;
  64. }
  65. }
  66. return true;
  67. }
  68. _FORCE_INLINE_ void call(Variant &r_ret, Variant &p_self, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
  69. #ifdef DEBUG_ENABLED
  70. if (p_argcount > arg_count) {
  71. r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
  72. r_error.argument = arg_count;
  73. return;
  74. } else
  75. #endif
  76. if (p_argcount < arg_count) {
  77. int def_argcount = default_args.size();
  78. #ifdef DEBUG_ENABLED
  79. if (p_argcount < (arg_count - def_argcount)) {
  80. r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
  81. r_error.argument = arg_count - def_argcount;
  82. return;
  83. }
  84. #endif
  85. ERR_FAIL_COND(p_argcount > VARIANT_ARG_MAX);
  86. const Variant *newargs[VARIANT_ARG_MAX];
  87. for (int i = 0; i < p_argcount; i++)
  88. newargs[i] = p_args[i];
  89. // fill in any remaining parameters with defaults
  90. int first_default_arg = arg_count - def_argcount;
  91. for (int i = p_argcount; i < arg_count; i++)
  92. newargs[i] = &default_args[i - first_default_arg];
  93. #ifdef DEBUG_ENABLED
  94. if (!verify_arguments(newargs, r_error))
  95. return;
  96. #endif
  97. func(r_ret, p_self, newargs);
  98. } else {
  99. #ifdef DEBUG_ENABLED
  100. if (!verify_arguments(p_args, r_error))
  101. return;
  102. #endif
  103. func(r_ret, p_self, p_args);
  104. }
  105. }
  106. };
  107. struct TypeFunc {
  108. Map<StringName, FuncData> functions;
  109. };
  110. static TypeFunc *type_funcs;
  111. struct Arg {
  112. StringName name;
  113. Variant::Type type;
  114. Arg() { type = Variant::NIL; }
  115. Arg(Variant::Type p_type, const StringName &p_name) :
  116. name(p_name),
  117. type(p_type) {
  118. }
  119. };
  120. //void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func);
  121. static void make_func_return_variant(Variant::Type p_type, const StringName &p_name) {
  122. #ifdef DEBUG_ENABLED
  123. type_funcs[p_type].functions[p_name].returns = true;
  124. #endif
  125. }
  126. static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, bool p_has_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) {
  127. FuncData funcdata;
  128. funcdata.func = p_func;
  129. funcdata.default_args = p_defaultarg;
  130. funcdata._const = p_const;
  131. funcdata.returns = p_has_return;
  132. funcdata.return_type = p_return;
  133. if (p_argtype1.name) {
  134. funcdata.arg_types.push_back(p_argtype1.type);
  135. #ifdef DEBUG_ENABLED
  136. funcdata.arg_names.push_back(p_argtype1.name);
  137. #endif
  138. } else
  139. goto end;
  140. if (p_argtype2.name) {
  141. funcdata.arg_types.push_back(p_argtype2.type);
  142. #ifdef DEBUG_ENABLED
  143. funcdata.arg_names.push_back(p_argtype2.name);
  144. #endif
  145. } else
  146. goto end;
  147. if (p_argtype3.name) {
  148. funcdata.arg_types.push_back(p_argtype3.type);
  149. #ifdef DEBUG_ENABLED
  150. funcdata.arg_names.push_back(p_argtype3.name);
  151. #endif
  152. } else
  153. goto end;
  154. if (p_argtype4.name) {
  155. funcdata.arg_types.push_back(p_argtype4.type);
  156. #ifdef DEBUG_ENABLED
  157. funcdata.arg_names.push_back(p_argtype4.name);
  158. #endif
  159. } else
  160. goto end;
  161. if (p_argtype5.name) {
  162. funcdata.arg_types.push_back(p_argtype5.type);
  163. #ifdef DEBUG_ENABLED
  164. funcdata.arg_names.push_back(p_argtype5.name);
  165. #endif
  166. } else
  167. goto end;
  168. end:
  169. funcdata.arg_count = funcdata.arg_types.size();
  170. type_funcs[p_type].functions[p_name] = funcdata;
  171. }
  172. #define VCALL_LOCALMEM0(m_type, m_method) \
  173. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(); }
  174. #define VCALL_LOCALMEM0R(m_type, m_method) \
  175. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(); }
  176. #define VCALL_LOCALMEM1(m_type, m_method) \
  177. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0]); }
  178. #define VCALL_LOCALMEM1R(m_type, m_method) \
  179. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0]); }
  180. #define VCALL_LOCALMEM2(m_type, m_method) \
  181. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1]); }
  182. #define VCALL_LOCALMEM2R(m_type, m_method) \
  183. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1]); }
  184. #define VCALL_LOCALMEM3(m_type, m_method) \
  185. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
  186. #define VCALL_LOCALMEM3R(m_type, m_method) \
  187. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
  188. #define VCALL_LOCALMEM4(m_type, m_method) \
  189. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
  190. #define VCALL_LOCALMEM4R(m_type, m_method) \
  191. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
  192. #define VCALL_LOCALMEM5(m_type, m_method) \
  193. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
  194. #define VCALL_LOCALMEM5R(m_type, m_method) \
  195. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._mem)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
  196. // built-in functions of localmem based types
  197. VCALL_LOCALMEM1R(String, casecmp_to);
  198. VCALL_LOCALMEM1R(String, nocasecmp_to);
  199. VCALL_LOCALMEM0R(String, length);
  200. VCALL_LOCALMEM2R(String, substr);
  201. VCALL_LOCALMEM2R(String, find);
  202. VCALL_LOCALMEM1R(String, find_last);
  203. VCALL_LOCALMEM2R(String, findn);
  204. VCALL_LOCALMEM2R(String, rfind);
  205. VCALL_LOCALMEM2R(String, rfindn);
  206. VCALL_LOCALMEM1R(String, match);
  207. VCALL_LOCALMEM1R(String, matchn);
  208. VCALL_LOCALMEM1R(String, begins_with);
  209. VCALL_LOCALMEM1R(String, ends_with);
  210. VCALL_LOCALMEM1R(String, is_subsequence_of);
  211. VCALL_LOCALMEM1R(String, is_subsequence_ofi);
  212. VCALL_LOCALMEM0R(String, bigrams);
  213. VCALL_LOCALMEM1R(String, similarity);
  214. VCALL_LOCALMEM2R(String, format);
  215. VCALL_LOCALMEM2R(String, replace);
  216. VCALL_LOCALMEM2R(String, replacen);
  217. VCALL_LOCALMEM2R(String, insert);
  218. VCALL_LOCALMEM0R(String, capitalize);
  219. VCALL_LOCALMEM3R(String, split);
  220. VCALL_LOCALMEM3R(String, rsplit);
  221. VCALL_LOCALMEM2R(String, split_floats);
  222. VCALL_LOCALMEM0R(String, to_upper);
  223. VCALL_LOCALMEM0R(String, to_lower);
  224. VCALL_LOCALMEM1R(String, left);
  225. VCALL_LOCALMEM1R(String, right);
  226. VCALL_LOCALMEM0R(String, dedent);
  227. VCALL_LOCALMEM2R(String, strip_edges);
  228. VCALL_LOCALMEM1R(String, lstrip);
  229. VCALL_LOCALMEM1R(String, rstrip);
  230. VCALL_LOCALMEM0R(String, get_extension);
  231. VCALL_LOCALMEM0R(String, get_basename);
  232. VCALL_LOCALMEM1R(String, plus_file);
  233. VCALL_LOCALMEM1R(String, ord_at);
  234. VCALL_LOCALMEM2(String, erase);
  235. VCALL_LOCALMEM0R(String, hash);
  236. VCALL_LOCALMEM0R(String, md5_text);
  237. VCALL_LOCALMEM0R(String, sha256_text);
  238. VCALL_LOCALMEM0R(String, md5_buffer);
  239. VCALL_LOCALMEM0R(String, sha256_buffer);
  240. VCALL_LOCALMEM0R(String, empty);
  241. VCALL_LOCALMEM0R(String, is_abs_path);
  242. VCALL_LOCALMEM0R(String, is_rel_path);
  243. VCALL_LOCALMEM0R(String, get_base_dir);
  244. VCALL_LOCALMEM0R(String, get_file);
  245. VCALL_LOCALMEM0R(String, xml_escape);
  246. VCALL_LOCALMEM0R(String, xml_unescape);
  247. VCALL_LOCALMEM0R(String, c_escape);
  248. VCALL_LOCALMEM0R(String, c_unescape);
  249. VCALL_LOCALMEM0R(String, json_escape);
  250. VCALL_LOCALMEM0R(String, percent_encode);
  251. VCALL_LOCALMEM0R(String, percent_decode);
  252. VCALL_LOCALMEM0R(String, is_valid_identifier);
  253. VCALL_LOCALMEM0R(String, is_valid_integer);
  254. VCALL_LOCALMEM0R(String, is_valid_float);
  255. VCALL_LOCALMEM1R(String, is_valid_hex_number);
  256. VCALL_LOCALMEM0R(String, is_valid_html_color);
  257. VCALL_LOCALMEM0R(String, is_valid_ip_address);
  258. VCALL_LOCALMEM0R(String, to_int);
  259. VCALL_LOCALMEM0R(String, to_float);
  260. VCALL_LOCALMEM0R(String, hex_to_int);
  261. VCALL_LOCALMEM1R(String, pad_decimals);
  262. VCALL_LOCALMEM1R(String, pad_zeros);
  263. VCALL_LOCALMEM1R(String, trim_prefix);
  264. VCALL_LOCALMEM1R(String, trim_suffix);
  265. static void _call_String_to_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  266. String *s = reinterpret_cast<String *>(p_self._data._mem);
  267. CharString charstr = s->ascii();
  268. PoolByteArray retval;
  269. size_t len = charstr.length();
  270. retval.resize(len);
  271. PoolByteArray::Write w = retval.write();
  272. copymem(w.ptr(), charstr.ptr(), len);
  273. w = PoolVector<uint8_t>::Write();
  274. r_ret = retval;
  275. }
  276. static void _call_String_to_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  277. String *s = reinterpret_cast<String *>(p_self._data._mem);
  278. CharString charstr = s->utf8();
  279. PoolByteArray retval;
  280. size_t len = charstr.length();
  281. retval.resize(len);
  282. PoolByteArray::Write w = retval.write();
  283. copymem(w.ptr(), charstr.ptr(), len);
  284. w = PoolVector<uint8_t>::Write();
  285. r_ret = retval;
  286. }
  287. VCALL_LOCALMEM0R(Vector2, normalized);
  288. VCALL_LOCALMEM0R(Vector2, length);
  289. VCALL_LOCALMEM0R(Vector2, length_squared);
  290. VCALL_LOCALMEM0R(Vector2, is_normalized);
  291. VCALL_LOCALMEM1R(Vector2, distance_to);
  292. VCALL_LOCALMEM1R(Vector2, distance_squared_to);
  293. VCALL_LOCALMEM1R(Vector2, project);
  294. VCALL_LOCALMEM1R(Vector2, angle_to);
  295. VCALL_LOCALMEM1R(Vector2, angle_to_point);
  296. VCALL_LOCALMEM2R(Vector2, linear_interpolate);
  297. VCALL_LOCALMEM2R(Vector2, slerp);
  298. VCALL_LOCALMEM4R(Vector2, cubic_interpolate);
  299. VCALL_LOCALMEM1R(Vector2, rotated);
  300. VCALL_LOCALMEM0R(Vector2, tangent);
  301. VCALL_LOCALMEM0R(Vector2, floor);
  302. VCALL_LOCALMEM0R(Vector2, ceil);
  303. VCALL_LOCALMEM0R(Vector2, round);
  304. VCALL_LOCALMEM1R(Vector2, snapped);
  305. VCALL_LOCALMEM0R(Vector2, aspect);
  306. VCALL_LOCALMEM1R(Vector2, dot);
  307. VCALL_LOCALMEM1R(Vector2, slide);
  308. VCALL_LOCALMEM1R(Vector2, bounce);
  309. VCALL_LOCALMEM1R(Vector2, reflect);
  310. VCALL_LOCALMEM0R(Vector2, angle);
  311. VCALL_LOCALMEM1R(Vector2, cross);
  312. VCALL_LOCALMEM0R(Vector2, abs);
  313. VCALL_LOCALMEM1R(Vector2, clamped);
  314. VCALL_LOCALMEM0R(Rect2, get_area);
  315. VCALL_LOCALMEM1R(Rect2, intersects);
  316. VCALL_LOCALMEM1R(Rect2, encloses);
  317. VCALL_LOCALMEM0R(Rect2, has_no_area);
  318. VCALL_LOCALMEM1R(Rect2, clip);
  319. VCALL_LOCALMEM1R(Rect2, merge);
  320. VCALL_LOCALMEM1R(Rect2, has_point);
  321. VCALL_LOCALMEM1R(Rect2, grow);
  322. VCALL_LOCALMEM2R(Rect2, grow_margin);
  323. VCALL_LOCALMEM4R(Rect2, grow_individual);
  324. VCALL_LOCALMEM1R(Rect2, expand);
  325. VCALL_LOCALMEM0R(Rect2, abs);
  326. VCALL_LOCALMEM0R(Vector3, min_axis);
  327. VCALL_LOCALMEM0R(Vector3, max_axis);
  328. VCALL_LOCALMEM0R(Vector3, length);
  329. VCALL_LOCALMEM0R(Vector3, length_squared);
  330. VCALL_LOCALMEM0R(Vector3, is_normalized);
  331. VCALL_LOCALMEM0R(Vector3, normalized);
  332. VCALL_LOCALMEM0R(Vector3, inverse);
  333. VCALL_LOCALMEM1R(Vector3, snapped);
  334. VCALL_LOCALMEM2R(Vector3, rotated);
  335. VCALL_LOCALMEM2R(Vector3, linear_interpolate);
  336. VCALL_LOCALMEM2R(Vector3, slerp);
  337. VCALL_LOCALMEM4R(Vector3, cubic_interpolate);
  338. VCALL_LOCALMEM1R(Vector3, dot);
  339. VCALL_LOCALMEM1R(Vector3, cross);
  340. VCALL_LOCALMEM1R(Vector3, outer);
  341. VCALL_LOCALMEM0R(Vector3, to_diagonal_matrix);
  342. VCALL_LOCALMEM0R(Vector3, abs);
  343. VCALL_LOCALMEM0R(Vector3, floor);
  344. VCALL_LOCALMEM0R(Vector3, ceil);
  345. VCALL_LOCALMEM0R(Vector3, round);
  346. VCALL_LOCALMEM1R(Vector3, distance_to);
  347. VCALL_LOCALMEM1R(Vector3, distance_squared_to);
  348. VCALL_LOCALMEM1R(Vector3, project);
  349. VCALL_LOCALMEM1R(Vector3, angle_to);
  350. VCALL_LOCALMEM1R(Vector3, slide);
  351. VCALL_LOCALMEM1R(Vector3, bounce);
  352. VCALL_LOCALMEM1R(Vector3, reflect);
  353. VCALL_LOCALMEM0R(Plane, normalized);
  354. VCALL_LOCALMEM0R(Plane, center);
  355. VCALL_LOCALMEM0R(Plane, get_any_point);
  356. VCALL_LOCALMEM1R(Plane, is_point_over);
  357. VCALL_LOCALMEM1R(Plane, distance_to);
  358. VCALL_LOCALMEM2R(Plane, has_point);
  359. VCALL_LOCALMEM1R(Plane, project);
  360. //return vector3 if intersected, nil if not
  361. static void _call_Plane_intersect_3(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  362. Vector3 result;
  363. if (reinterpret_cast<Plane *>(p_self._data._mem)->intersect_3(*p_args[0], *p_args[1], &result))
  364. r_ret = result;
  365. else
  366. r_ret = Variant();
  367. }
  368. static void _call_Plane_intersects_ray(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  369. Vector3 result;
  370. if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_ray(*p_args[0], *p_args[1], &result))
  371. r_ret = result;
  372. else
  373. r_ret = Variant();
  374. }
  375. static void _call_Plane_intersects_segment(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  376. Vector3 result;
  377. if (reinterpret_cast<Plane *>(p_self._data._mem)->intersects_segment(*p_args[0], *p_args[1], &result))
  378. r_ret = result;
  379. else
  380. r_ret = Variant();
  381. }
  382. VCALL_LOCALMEM0R(Quat, length);
  383. VCALL_LOCALMEM0R(Quat, length_squared);
  384. VCALL_LOCALMEM0R(Quat, normalized);
  385. VCALL_LOCALMEM0R(Quat, is_normalized);
  386. VCALL_LOCALMEM0R(Quat, inverse);
  387. VCALL_LOCALMEM1R(Quat, dot);
  388. VCALL_LOCALMEM1R(Quat, xform);
  389. VCALL_LOCALMEM2R(Quat, slerp);
  390. VCALL_LOCALMEM2R(Quat, slerpni);
  391. VCALL_LOCALMEM4R(Quat, cubic_slerp);
  392. VCALL_LOCALMEM0R(Quat, get_euler);
  393. VCALL_LOCALMEM1(Quat, set_euler);
  394. VCALL_LOCALMEM2(Quat, set_axis_angle);
  395. VCALL_LOCALMEM0R(Color, to_argb32);
  396. VCALL_LOCALMEM0R(Color, to_abgr32);
  397. VCALL_LOCALMEM0R(Color, to_rgba32);
  398. VCALL_LOCALMEM0R(Color, to_argb64);
  399. VCALL_LOCALMEM0R(Color, to_abgr64);
  400. VCALL_LOCALMEM0R(Color, to_rgba64);
  401. VCALL_LOCALMEM0R(Color, gray);
  402. VCALL_LOCALMEM0R(Color, inverted);
  403. VCALL_LOCALMEM0R(Color, contrasted);
  404. VCALL_LOCALMEM2R(Color, linear_interpolate);
  405. VCALL_LOCALMEM1R(Color, blend);
  406. VCALL_LOCALMEM1R(Color, lightened);
  407. VCALL_LOCALMEM1R(Color, darkened);
  408. VCALL_LOCALMEM1R(Color, to_html);
  409. VCALL_LOCALMEM4R(Color, from_hsv);
  410. VCALL_LOCALMEM0R(RID, get_id);
  411. VCALL_LOCALMEM0R(NodePath, is_absolute);
  412. VCALL_LOCALMEM0R(NodePath, get_name_count);
  413. VCALL_LOCALMEM1R(NodePath, get_name);
  414. VCALL_LOCALMEM0R(NodePath, get_subname_count);
  415. VCALL_LOCALMEM1R(NodePath, get_subname);
  416. VCALL_LOCALMEM0R(NodePath, get_concatenated_subnames);
  417. VCALL_LOCALMEM0R(NodePath, get_as_property_path);
  418. VCALL_LOCALMEM0R(NodePath, is_empty);
  419. VCALL_LOCALMEM0R(Dictionary, size);
  420. VCALL_LOCALMEM0R(Dictionary, empty);
  421. VCALL_LOCALMEM0(Dictionary, clear);
  422. VCALL_LOCALMEM1R(Dictionary, has);
  423. VCALL_LOCALMEM1R(Dictionary, has_all);
  424. VCALL_LOCALMEM1(Dictionary, erase);
  425. VCALL_LOCALMEM0R(Dictionary, hash);
  426. VCALL_LOCALMEM0R(Dictionary, keys);
  427. VCALL_LOCALMEM0R(Dictionary, values);
  428. VCALL_LOCALMEM1R(Dictionary, duplicate);
  429. VCALL_LOCALMEM2R(Dictionary, get);
  430. VCALL_LOCALMEM2(Array, set);
  431. VCALL_LOCALMEM1R(Array, get);
  432. VCALL_LOCALMEM0R(Array, size);
  433. VCALL_LOCALMEM0R(Array, empty);
  434. VCALL_LOCALMEM0(Array, clear);
  435. VCALL_LOCALMEM0R(Array, hash);
  436. VCALL_LOCALMEM1(Array, push_back);
  437. VCALL_LOCALMEM1(Array, push_front);
  438. VCALL_LOCALMEM0R(Array, pop_back);
  439. VCALL_LOCALMEM0R(Array, pop_front);
  440. VCALL_LOCALMEM1(Array, append);
  441. VCALL_LOCALMEM1(Array, resize);
  442. VCALL_LOCALMEM2(Array, insert);
  443. VCALL_LOCALMEM1(Array, remove);
  444. VCALL_LOCALMEM0R(Array, front);
  445. VCALL_LOCALMEM0R(Array, back);
  446. VCALL_LOCALMEM2R(Array, find);
  447. VCALL_LOCALMEM2R(Array, rfind);
  448. VCALL_LOCALMEM1R(Array, find_last);
  449. VCALL_LOCALMEM1R(Array, count);
  450. VCALL_LOCALMEM1R(Array, has);
  451. VCALL_LOCALMEM1(Array, erase);
  452. VCALL_LOCALMEM0(Array, sort);
  453. VCALL_LOCALMEM2(Array, sort_custom);
  454. VCALL_LOCALMEM0(Array, shuffle);
  455. VCALL_LOCALMEM2R(Array, bsearch);
  456. VCALL_LOCALMEM4R(Array, bsearch_custom);
  457. VCALL_LOCALMEM1R(Array, duplicate);
  458. VCALL_LOCALMEM0(Array, invert);
  459. VCALL_LOCALMEM0R(Array, max);
  460. VCALL_LOCALMEM0R(Array, min);
  461. static void _call_PoolByteArray_get_string_from_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  462. PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
  463. String s;
  464. if (ba->size() >= 0) {
  465. PoolByteArray::Read r = ba->read();
  466. CharString cs;
  467. cs.resize(ba->size() + 1);
  468. copymem(cs.ptrw(), r.ptr(), ba->size());
  469. cs[ba->size()] = 0;
  470. s = cs.get_data();
  471. }
  472. r_ret = s;
  473. }
  474. static void _call_PoolByteArray_get_string_from_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  475. PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
  476. String s;
  477. if (ba->size() >= 0) {
  478. PoolByteArray::Read r = ba->read();
  479. s.parse_utf8((const char *)r.ptr(), ba->size());
  480. }
  481. r_ret = s;
  482. }
  483. static void _call_PoolByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  484. PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
  485. PoolByteArray compressed;
  486. Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]);
  487. compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode));
  488. int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode);
  489. result = result >= 0 ? result : 0;
  490. compressed.resize(result);
  491. r_ret = compressed;
  492. }
  493. static void _call_PoolByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  494. PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
  495. PoolByteArray decompressed;
  496. Compression::Mode mode = (Compression::Mode)(int)(*p_args[1]);
  497. int buffer_size = (int)(*p_args[0]);
  498. if (buffer_size < 0) {
  499. r_ret = decompressed;
  500. ERR_EXPLAIN("Decompression buffer size is less than zero");
  501. ERR_FAIL();
  502. }
  503. decompressed.resize(buffer_size);
  504. int result = Compression::decompress(decompressed.write().ptr(), buffer_size, ba->read().ptr(), ba->size(), mode);
  505. result = result >= 0 ? result : 0;
  506. decompressed.resize(result);
  507. r_ret = decompressed;
  508. }
  509. VCALL_LOCALMEM0R(PoolByteArray, size);
  510. VCALL_LOCALMEM2(PoolByteArray, set);
  511. VCALL_LOCALMEM1R(PoolByteArray, get);
  512. VCALL_LOCALMEM1(PoolByteArray, push_back);
  513. VCALL_LOCALMEM1(PoolByteArray, resize);
  514. VCALL_LOCALMEM2R(PoolByteArray, insert);
  515. VCALL_LOCALMEM1(PoolByteArray, remove);
  516. VCALL_LOCALMEM1(PoolByteArray, append);
  517. VCALL_LOCALMEM1(PoolByteArray, append_array);
  518. VCALL_LOCALMEM0(PoolByteArray, invert);
  519. VCALL_LOCALMEM2R(PoolByteArray, subarray);
  520. VCALL_LOCALMEM0R(PoolIntArray, size);
  521. VCALL_LOCALMEM2(PoolIntArray, set);
  522. VCALL_LOCALMEM1R(PoolIntArray, get);
  523. VCALL_LOCALMEM1(PoolIntArray, push_back);
  524. VCALL_LOCALMEM1(PoolIntArray, resize);
  525. VCALL_LOCALMEM2R(PoolIntArray, insert);
  526. VCALL_LOCALMEM1(PoolIntArray, remove);
  527. VCALL_LOCALMEM1(PoolIntArray, append);
  528. VCALL_LOCALMEM1(PoolIntArray, append_array);
  529. VCALL_LOCALMEM0(PoolIntArray, invert);
  530. VCALL_LOCALMEM0R(PoolRealArray, size);
  531. VCALL_LOCALMEM2(PoolRealArray, set);
  532. VCALL_LOCALMEM1R(PoolRealArray, get);
  533. VCALL_LOCALMEM1(PoolRealArray, push_back);
  534. VCALL_LOCALMEM1(PoolRealArray, resize);
  535. VCALL_LOCALMEM2R(PoolRealArray, insert);
  536. VCALL_LOCALMEM1(PoolRealArray, remove);
  537. VCALL_LOCALMEM1(PoolRealArray, append);
  538. VCALL_LOCALMEM1(PoolRealArray, append_array);
  539. VCALL_LOCALMEM0(PoolRealArray, invert);
  540. VCALL_LOCALMEM0R(PoolStringArray, size);
  541. VCALL_LOCALMEM2(PoolStringArray, set);
  542. VCALL_LOCALMEM1R(PoolStringArray, get);
  543. VCALL_LOCALMEM1(PoolStringArray, push_back);
  544. VCALL_LOCALMEM1(PoolStringArray, resize);
  545. VCALL_LOCALMEM2R(PoolStringArray, insert);
  546. VCALL_LOCALMEM1(PoolStringArray, remove);
  547. VCALL_LOCALMEM1(PoolStringArray, append);
  548. VCALL_LOCALMEM1(PoolStringArray, append_array);
  549. VCALL_LOCALMEM0(PoolStringArray, invert);
  550. VCALL_LOCALMEM1R(PoolStringArray, join);
  551. VCALL_LOCALMEM0R(PoolVector2Array, size);
  552. VCALL_LOCALMEM2(PoolVector2Array, set);
  553. VCALL_LOCALMEM1R(PoolVector2Array, get);
  554. VCALL_LOCALMEM1(PoolVector2Array, push_back);
  555. VCALL_LOCALMEM1(PoolVector2Array, resize);
  556. VCALL_LOCALMEM2R(PoolVector2Array, insert);
  557. VCALL_LOCALMEM1(PoolVector2Array, remove);
  558. VCALL_LOCALMEM1(PoolVector2Array, append);
  559. VCALL_LOCALMEM1(PoolVector2Array, append_array);
  560. VCALL_LOCALMEM0(PoolVector2Array, invert);
  561. VCALL_LOCALMEM0R(PoolVector3Array, size);
  562. VCALL_LOCALMEM2(PoolVector3Array, set);
  563. VCALL_LOCALMEM1R(PoolVector3Array, get);
  564. VCALL_LOCALMEM1(PoolVector3Array, push_back);
  565. VCALL_LOCALMEM1(PoolVector3Array, resize);
  566. VCALL_LOCALMEM2R(PoolVector3Array, insert);
  567. VCALL_LOCALMEM1(PoolVector3Array, remove);
  568. VCALL_LOCALMEM1(PoolVector3Array, append);
  569. VCALL_LOCALMEM1(PoolVector3Array, append_array);
  570. VCALL_LOCALMEM0(PoolVector3Array, invert);
  571. VCALL_LOCALMEM0R(PoolColorArray, size);
  572. VCALL_LOCALMEM2(PoolColorArray, set);
  573. VCALL_LOCALMEM1R(PoolColorArray, get);
  574. VCALL_LOCALMEM1(PoolColorArray, push_back);
  575. VCALL_LOCALMEM1(PoolColorArray, resize);
  576. VCALL_LOCALMEM2R(PoolColorArray, insert);
  577. VCALL_LOCALMEM1(PoolColorArray, remove);
  578. VCALL_LOCALMEM1(PoolColorArray, append);
  579. VCALL_LOCALMEM1(PoolColorArray, append_array);
  580. VCALL_LOCALMEM0(PoolColorArray, invert);
  581. #define VCALL_PTR0(m_type, m_method) \
  582. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(); }
  583. #define VCALL_PTR0R(m_type, m_method) \
  584. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(); }
  585. #define VCALL_PTR1(m_type, m_method) \
  586. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0]); }
  587. #define VCALL_PTR1R(m_type, m_method) \
  588. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0]); }
  589. #define VCALL_PTR2(m_type, m_method) \
  590. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1]); }
  591. #define VCALL_PTR2R(m_type, m_method) \
  592. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1]); }
  593. #define VCALL_PTR3(m_type, m_method) \
  594. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
  595. #define VCALL_PTR3R(m_type, m_method) \
  596. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2]); }
  597. #define VCALL_PTR4(m_type, m_method) \
  598. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
  599. #define VCALL_PTR4R(m_type, m_method) \
  600. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3]); }
  601. #define VCALL_PTR5(m_type, m_method) \
  602. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
  603. #define VCALL_PTR5R(m_type, m_method) \
  604. static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
  605. VCALL_PTR0R(AABB, get_area);
  606. VCALL_PTR0R(AABB, has_no_area);
  607. VCALL_PTR0R(AABB, has_no_surface);
  608. VCALL_PTR1R(AABB, intersects);
  609. VCALL_PTR1R(AABB, encloses);
  610. VCALL_PTR1R(AABB, merge);
  611. VCALL_PTR1R(AABB, intersection);
  612. VCALL_PTR1R(AABB, intersects_plane);
  613. VCALL_PTR2R(AABB, intersects_segment);
  614. VCALL_PTR1R(AABB, has_point);
  615. VCALL_PTR1R(AABB, get_support);
  616. VCALL_PTR0R(AABB, get_longest_axis);
  617. VCALL_PTR0R(AABB, get_longest_axis_index);
  618. VCALL_PTR0R(AABB, get_longest_axis_size);
  619. VCALL_PTR0R(AABB, get_shortest_axis);
  620. VCALL_PTR0R(AABB, get_shortest_axis_index);
  621. VCALL_PTR0R(AABB, get_shortest_axis_size);
  622. VCALL_PTR1R(AABB, expand);
  623. VCALL_PTR1R(AABB, grow);
  624. VCALL_PTR1R(AABB, get_endpoint);
  625. VCALL_PTR0R(Transform2D, inverse);
  626. VCALL_PTR0R(Transform2D, affine_inverse);
  627. VCALL_PTR0R(Transform2D, get_rotation);
  628. VCALL_PTR0R(Transform2D, get_origin);
  629. VCALL_PTR0R(Transform2D, get_scale);
  630. VCALL_PTR0R(Transform2D, orthonormalized);
  631. VCALL_PTR1R(Transform2D, rotated);
  632. VCALL_PTR1R(Transform2D, scaled);
  633. VCALL_PTR1R(Transform2D, translated);
  634. VCALL_PTR2R(Transform2D, interpolate_with);
  635. static void _call_Transform2D_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  636. switch (p_args[0]->type) {
  637. case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Vector2()); return;
  638. case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Rect2()); return;
  639. default: r_ret = Variant();
  640. }
  641. }
  642. static void _call_Transform2D_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  643. switch (p_args[0]->type) {
  644. case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector2()); return;
  645. case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect2()); return;
  646. default: r_ret = Variant();
  647. }
  648. }
  649. static void _call_Transform2D_basis_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  650. switch (p_args[0]->type) {
  651. case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->basis_xform(p_args[0]->operator Vector2()); return;
  652. default: r_ret = Variant();
  653. }
  654. }
  655. static void _call_Transform2D_basis_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  656. switch (p_args[0]->type) {
  657. case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->basis_xform_inv(p_args[0]->operator Vector2()); return;
  658. default: r_ret = Variant();
  659. }
  660. }
  661. VCALL_PTR0R(Basis, inverse);
  662. VCALL_PTR0R(Basis, transposed);
  663. VCALL_PTR0R(Basis, determinant);
  664. VCALL_PTR2R(Basis, rotated);
  665. VCALL_PTR1R(Basis, scaled);
  666. VCALL_PTR0R(Basis, get_scale);
  667. VCALL_PTR0R(Basis, get_euler);
  668. VCALL_PTR1R(Basis, tdotx);
  669. VCALL_PTR1R(Basis, tdoty);
  670. VCALL_PTR1R(Basis, tdotz);
  671. VCALL_PTR1R(Basis, xform);
  672. VCALL_PTR1R(Basis, xform_inv);
  673. VCALL_PTR0R(Basis, get_orthogonal_index);
  674. VCALL_PTR0R(Basis, orthonormalized);
  675. VCALL_PTR2R(Basis, slerp);
  676. VCALL_PTR0R(Transform, inverse);
  677. VCALL_PTR0R(Transform, affine_inverse);
  678. VCALL_PTR2R(Transform, rotated);
  679. VCALL_PTR1R(Transform, scaled);
  680. VCALL_PTR1R(Transform, translated);
  681. VCALL_PTR0R(Transform, orthonormalized);
  682. VCALL_PTR2R(Transform, looking_at);
  683. VCALL_PTR2R(Transform, interpolate_with);
  684. static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  685. switch (p_args[0]->type) {
  686. case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return;
  687. case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return;
  688. case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return;
  689. default: r_ret = Variant();
  690. }
  691. }
  692. static void _call_Transform_xform_inv(Variant &r_ret, Variant &p_self, const Variant **p_args) {
  693. switch (p_args[0]->type) {
  694. case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return;
  695. case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return;
  696. case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return;
  697. default: r_ret = Variant();
  698. }
  699. }
  700. /*
  701. VCALL_PTR0( Transform, invert );
  702. VCALL_PTR0( Transform, affine_invert );
  703. VCALL_PTR2( Transform, rotate );
  704. VCALL_PTR1( Transform, scale );
  705. VCALL_PTR1( Transform, translate );
  706. VCALL_PTR0( Transform, orthonormalize ); */
  707. struct ConstructData {
  708. int arg_count;
  709. Vector<Variant::Type> arg_types;
  710. Vector<String> arg_names;
  711. VariantConstructFunc func;
  712. };
  713. struct ConstructFunc {
  714. List<ConstructData> constructors;
  715. };
  716. static ConstructFunc *construct_funcs;
  717. static void Vector2_init1(Variant &r_ret, const Variant **p_args) {
  718. r_ret = Vector2(*p_args[0], *p_args[1]);
  719. }
  720. static void Rect2_init1(Variant &r_ret, const Variant **p_args) {
  721. r_ret = Rect2(*p_args[0], *p_args[1]);
  722. }
  723. static void Rect2_init2(Variant &r_ret, const Variant **p_args) {
  724. r_ret = Rect2(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
  725. }
  726. static void Transform2D_init2(Variant &r_ret, const Variant **p_args) {
  727. Transform2D m(*p_args[0], *p_args[1]);
  728. r_ret = m;
  729. }
  730. static void Transform2D_init3(Variant &r_ret, const Variant **p_args) {
  731. Transform2D m;
  732. m[0] = *p_args[0];
  733. m[1] = *p_args[1];
  734. m[2] = *p_args[2];
  735. r_ret = m;
  736. }
  737. static void Vector3_init1(Variant &r_ret, const Variant **p_args) {
  738. r_ret = Vector3(*p_args[0], *p_args[1], *p_args[2]);
  739. }
  740. static void Plane_init1(Variant &r_ret, const Variant **p_args) {
  741. r_ret = Plane(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
  742. }
  743. static void Plane_init2(Variant &r_ret, const Variant **p_args) {
  744. r_ret = Plane(*p_args[0], *p_args[1], *p_args[2]);
  745. }
  746. static void Plane_init3(Variant &r_ret, const Variant **p_args) {
  747. r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
  748. }
  749. static void Plane_init4(Variant &r_ret, const Variant **p_args) {
  750. r_ret = Plane(p_args[0]->operator Vector3(), p_args[1]->operator Vector3());
  751. }
  752. static void Quat_init1(Variant &r_ret, const Variant **p_args) {
  753. r_ret = Quat(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
  754. }
  755. static void Quat_init2(Variant &r_ret, const Variant **p_args) {
  756. r_ret = Quat(((Vector3)(*p_args[0])), ((float)(*p_args[1])));
  757. }
  758. static void Quat_init3(Variant &r_ret, const Variant **p_args) {
  759. r_ret = Quat(((Vector3)(*p_args[0])));
  760. }
  761. static void Color_init1(Variant &r_ret, const Variant **p_args) {
  762. r_ret = Color(*p_args[0], *p_args[1], *p_args[2], *p_args[3]);
  763. }
  764. static void Color_init2(Variant &r_ret, const Variant **p_args) {
  765. r_ret = Color(*p_args[0], *p_args[1], *p_args[2]);
  766. }
  767. static void Color_init3(Variant &r_ret, const Variant **p_args) {
  768. r_ret = Color::html(*p_args[0]);
  769. }
  770. static void Color_init4(Variant &r_ret, const Variant **p_args) {
  771. r_ret = Color::hex(*p_args[0]);
  772. }
  773. static void AABB_init1(Variant &r_ret, const Variant **p_args) {
  774. r_ret = ::AABB(*p_args[0], *p_args[1]);
  775. }
  776. static void Basis_init1(Variant &r_ret, const Variant **p_args) {
  777. Basis m;
  778. m.set_axis(0, *p_args[0]);
  779. m.set_axis(1, *p_args[1]);
  780. m.set_axis(2, *p_args[2]);
  781. r_ret = m;
  782. }
  783. static void Basis_init2(Variant &r_ret, const Variant **p_args) {
  784. r_ret = Basis(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
  785. }
  786. static void Transform_init1(Variant &r_ret, const Variant **p_args) {
  787. Transform t;
  788. t.basis.set_axis(0, *p_args[0]);
  789. t.basis.set_axis(1, *p_args[1]);
  790. t.basis.set_axis(2, *p_args[2]);
  791. t.origin = *p_args[3];
  792. r_ret = t;
  793. }
  794. static void Transform_init2(Variant &r_ret, const Variant **p_args) {
  795. r_ret = Transform(p_args[0]->operator Basis(), p_args[1]->operator Vector3());
  796. }
  797. static void add_constructor(VariantConstructFunc p_func, const Variant::Type p_type,
  798. const String &p_name1 = "", const Variant::Type p_type1 = Variant::NIL,
  799. const String &p_name2 = "", const Variant::Type p_type2 = Variant::NIL,
  800. const String &p_name3 = "", const Variant::Type p_type3 = Variant::NIL,
  801. const String &p_name4 = "", const Variant::Type p_type4 = Variant::NIL) {
  802. ConstructData cd;
  803. cd.func = p_func;
  804. cd.arg_count = 0;
  805. if (p_name1 == "")
  806. goto end;
  807. cd.arg_count++;
  808. cd.arg_names.push_back(p_name1);
  809. cd.arg_types.push_back(p_type1);
  810. if (p_name2 == "")
  811. goto end;
  812. cd.arg_count++;
  813. cd.arg_names.push_back(p_name2);
  814. cd.arg_types.push_back(p_type2);
  815. if (p_name3 == "")
  816. goto end;
  817. cd.arg_count++;
  818. cd.arg_names.push_back(p_name3);
  819. cd.arg_types.push_back(p_type3);
  820. if (p_name4 == "")
  821. goto end;
  822. cd.arg_count++;
  823. cd.arg_names.push_back(p_name4);
  824. cd.arg_types.push_back(p_type4);
  825. end:
  826. construct_funcs[p_type].constructors.push_back(cd);
  827. }
  828. struct ConstantData {
  829. Map<StringName, int> value;
  830. #ifdef DEBUG_ENABLED
  831. List<StringName> value_ordered;
  832. #endif
  833. Map<StringName, Variant> variant_value;
  834. };
  835. static ConstantData *constant_data;
  836. static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) {
  837. constant_data[p_type].value[p_constant_name] = p_constant_value;
  838. #ifdef DEBUG_ENABLED
  839. constant_data[p_type].value_ordered.push_back(p_constant_name);
  840. #endif
  841. }
  842. static void add_variant_constant(int p_type, StringName p_constant_name, const Variant &p_constant_value) {
  843. constant_data[p_type].variant_value[p_constant_name] = p_constant_value;
  844. }
  845. };
  846. _VariantCall::TypeFunc *_VariantCall::type_funcs = NULL;
  847. _VariantCall::ConstructFunc *_VariantCall::construct_funcs = NULL;
  848. _VariantCall::ConstantData *_VariantCall::constant_data = NULL;
  849. Variant Variant::call(const StringName &p_method, const Variant **p_args, int p_argcount, CallError &r_error) {
  850. Variant ret;
  851. call_ptr(p_method, p_args, p_argcount, &ret, r_error);
  852. return ret;
  853. }
  854. void Variant::call_ptr(const StringName &p_method, const Variant **p_args, int p_argcount, Variant *r_ret, CallError &r_error) {
  855. Variant ret;
  856. if (type == Variant::OBJECT) {
  857. //call object
  858. Object *obj = _get_obj().obj;
  859. if (!obj) {
  860. r_error.error = CallError::CALL_ERROR_INSTANCE_IS_NULL;
  861. return;
  862. }
  863. #ifdef DEBUG_ENABLED
  864. if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) {
  865. //only if debugging!
  866. if (!ObjectDB::instance_validate(obj)) {
  867. r_error.error = CallError::CALL_ERROR_INSTANCE_IS_NULL;
  868. return;
  869. }
  870. }
  871. #endif
  872. ret = _get_obj().obj->call(p_method, p_args, p_argcount, r_error);
  873. //else if (type==Variant::METHOD) {
  874. } else {
  875. r_error.error = Variant::CallError::CALL_OK;
  876. Map<StringName, _VariantCall::FuncData>::Element *E = _VariantCall::type_funcs[type].functions.find(p_method);
  877. #ifdef DEBUG_ENABLED
  878. if (!E) {
  879. r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
  880. return;
  881. }
  882. #endif
  883. _VariantCall::FuncData &funcdata = E->get();
  884. funcdata.call(ret, *this, p_args, p_argcount, r_error);
  885. }
  886. if (r_error.error == Variant::CallError::CALL_OK && r_ret)
  887. *r_ret = ret;
  888. }
  889. #define VCALL(m_type, m_method) _VariantCall::_call_##m_type##_##m_method
  890. Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, int p_argcount, CallError &r_error, bool p_strict) {
  891. r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
  892. ERR_FAIL_INDEX_V(p_type, VARIANT_MAX, Variant());
  893. r_error.error = Variant::CallError::CALL_OK;
  894. if (p_argcount == 0) { //generic construct
  895. switch (p_type) {
  896. case NIL:
  897. return Variant();
  898. // atomic types
  899. case BOOL: return Variant(false);
  900. case INT: return 0;
  901. case REAL: return 0.0f;
  902. case STRING:
  903. return String();
  904. // math types
  905. case VECTOR2:
  906. return Vector2(); // 5
  907. case RECT2: return Rect2();
  908. case VECTOR3: return Vector3();
  909. case TRANSFORM2D: return Transform2D();
  910. case PLANE: return Plane();
  911. case QUAT: return Quat();
  912. case AABB:
  913. return ::AABB(); // 10
  914. case BASIS: return Basis();
  915. case TRANSFORM:
  916. return Transform();
  917. // misc types
  918. case COLOR: return Color();
  919. case NODE_PATH:
  920. return NodePath(); // 15
  921. case _RID: return RID();
  922. case OBJECT: return (Object *)NULL;
  923. case DICTIONARY: return Dictionary();
  924. case ARRAY:
  925. return Array(); // 20
  926. case POOL_BYTE_ARRAY: return PoolByteArray();
  927. case POOL_INT_ARRAY: return PoolIntArray();
  928. case POOL_REAL_ARRAY: return PoolRealArray();
  929. case POOL_STRING_ARRAY: return PoolStringArray();
  930. case POOL_VECTOR2_ARRAY:
  931. return PoolVector2Array(); // 25
  932. case POOL_VECTOR3_ARRAY: return PoolVector3Array();
  933. case POOL_COLOR_ARRAY: return PoolColorArray();
  934. default: return Variant();
  935. }
  936. } else if (p_argcount > 1) {
  937. _VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type];
  938. for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) {
  939. const _VariantCall::ConstructData &cd = E->get();
  940. if (cd.arg_count != p_argcount)
  941. continue;
  942. //validate parameters
  943. for (int i = 0; i < cd.arg_count; i++) {
  944. if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) {
  945. r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor
  946. r_error.argument = i;
  947. r_error.expected = cd.arg_types[i];
  948. return Variant();
  949. }
  950. }
  951. Variant v;
  952. cd.func(v, p_args);
  953. return v;
  954. }
  955. } else if (p_argcount == 1 && p_args[0]->type == p_type) {
  956. return *p_args[0]; //copy construct
  957. } else if (p_argcount == 1 && (!p_strict || Variant::can_convert(p_args[0]->type, p_type))) {
  958. //near match construct
  959. switch (p_type) {
  960. case NIL: {
  961. return Variant();
  962. } break;
  963. case BOOL: {
  964. return Variant(bool(*p_args[0]));
  965. }
  966. case INT: {
  967. return (int64_t(*p_args[0]));
  968. }
  969. case REAL: {
  970. return real_t(*p_args[0]);
  971. }
  972. case STRING: {
  973. return String(*p_args[0]);
  974. }
  975. case VECTOR2: {
  976. return Vector2(*p_args[0]);
  977. }
  978. case RECT2: return (Rect2(*p_args[0]));
  979. case VECTOR3: return (Vector3(*p_args[0]));
  980. case PLANE: return (Plane(*p_args[0]));
  981. case QUAT: return (p_args[0]->operator Quat());
  982. case AABB:
  983. return (::AABB(*p_args[0])); // 10
  984. case BASIS: return (Basis(p_args[0]->operator Basis()));
  985. case TRANSFORM:
  986. return (Transform(p_args[0]->operator Transform()));
  987. // misc types
  988. case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]);
  989. case NODE_PATH:
  990. return (NodePath(p_args[0]->operator NodePath())); // 15
  991. case _RID: return (RID(*p_args[0]));
  992. case OBJECT: return ((Object *)(p_args[0]->operator Object *()));
  993. case DICTIONARY: return p_args[0]->operator Dictionary();
  994. case ARRAY:
  995. return p_args[0]->operator Array(); // 20
  996. // arrays
  997. case POOL_BYTE_ARRAY: return (PoolByteArray(*p_args[0]));
  998. case POOL_INT_ARRAY: return (PoolIntArray(*p_args[0]));
  999. case POOL_REAL_ARRAY: return (PoolRealArray(*p_args[0]));
  1000. case POOL_STRING_ARRAY: return (PoolStringArray(*p_args[0]));
  1001. case POOL_VECTOR2_ARRAY:
  1002. return (PoolVector2Array(*p_args[0])); // 25
  1003. case POOL_VECTOR3_ARRAY: return (PoolVector3Array(*p_args[0]));
  1004. case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0]));
  1005. default: return Variant();
  1006. }
  1007. }
  1008. r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor
  1009. return Variant();
  1010. }
  1011. bool Variant::has_method(const StringName &p_method) const {
  1012. if (type == OBJECT) {
  1013. Object *obj = operator Object *();
  1014. if (!obj)
  1015. return false;
  1016. #ifdef DEBUG_ENABLED
  1017. if (ScriptDebugger::get_singleton()) {
  1018. if (ObjectDB::instance_validate(obj)) {
  1019. #endif
  1020. return obj->has_method(p_method);
  1021. #ifdef DEBUG_ENABLED
  1022. }
  1023. }
  1024. #endif
  1025. }
  1026. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[type];
  1027. return fd.functions.has(p_method);
  1028. }
  1029. Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type, const StringName &p_method) {
  1030. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
  1031. const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
  1032. if (!E)
  1033. return Vector<Variant::Type>();
  1034. return E->get().arg_types;
  1035. }
  1036. bool Variant::is_method_const(Variant::Type p_type, const StringName &p_method) {
  1037. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
  1038. const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
  1039. if (!E)
  1040. return false;
  1041. return E->get()._const;
  1042. }
  1043. Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type, const StringName &p_method) {
  1044. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
  1045. const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
  1046. if (!E)
  1047. return Vector<StringName>();
  1048. return E->get().arg_names;
  1049. }
  1050. Variant::Type Variant::get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return) {
  1051. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
  1052. const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
  1053. if (!E)
  1054. return Variant::NIL;
  1055. if (r_has_return)
  1056. *r_has_return = E->get().returns;
  1057. return E->get().return_type;
  1058. }
  1059. Vector<Variant> Variant::get_method_default_arguments(Variant::Type p_type, const StringName &p_method) {
  1060. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
  1061. const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
  1062. if (!E)
  1063. return Vector<Variant>();
  1064. return E->get().default_args;
  1065. }
  1066. void Variant::get_method_list(List<MethodInfo> *p_list) const {
  1067. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[type];
  1068. for (const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.front(); E; E = E->next()) {
  1069. const _VariantCall::FuncData &fd = E->get();
  1070. MethodInfo mi;
  1071. mi.name = E->key();
  1072. if (fd._const) {
  1073. mi.flags |= METHOD_FLAG_CONST;
  1074. }
  1075. for (int i = 0; i < fd.arg_types.size(); i++) {
  1076. PropertyInfo pi;
  1077. pi.type = fd.arg_types[i];
  1078. #ifdef DEBUG_ENABLED
  1079. pi.name = fd.arg_names[i];
  1080. #endif
  1081. mi.arguments.push_back(pi);
  1082. }
  1083. mi.default_arguments = fd.default_args;
  1084. PropertyInfo ret;
  1085. #ifdef DEBUG_ENABLED
  1086. ret.type = fd.return_type;
  1087. if (fd.returns)
  1088. ret.name = "ret";
  1089. mi.return_val = ret;
  1090. #endif
  1091. p_list->push_back(mi);
  1092. }
  1093. }
  1094. void Variant::get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list) {
  1095. ERR_FAIL_INDEX(p_type, VARIANT_MAX);
  1096. //custom constructors
  1097. for (const List<_VariantCall::ConstructData>::Element *E = _VariantCall::construct_funcs[p_type].constructors.front(); E; E = E->next()) {
  1098. const _VariantCall::ConstructData &cd = E->get();
  1099. MethodInfo mi;
  1100. mi.name = Variant::get_type_name(p_type);
  1101. mi.return_val.type = p_type;
  1102. for (int i = 0; i < cd.arg_count; i++) {
  1103. PropertyInfo pi;
  1104. pi.name = cd.arg_names[i];
  1105. pi.type = cd.arg_types[i];
  1106. mi.arguments.push_back(pi);
  1107. }
  1108. p_list->push_back(mi);
  1109. }
  1110. //default constructors
  1111. for (int i = 0; i < VARIANT_MAX; i++) {
  1112. if (i == p_type)
  1113. continue;
  1114. if (!Variant::can_convert(Variant::Type(i), p_type))
  1115. continue;
  1116. MethodInfo mi;
  1117. mi.name = Variant::get_type_name(p_type);
  1118. PropertyInfo pi;
  1119. pi.name = "from";
  1120. pi.type = Variant::Type(i);
  1121. mi.arguments.push_back(pi);
  1122. mi.return_val.type = p_type;
  1123. p_list->push_back(mi);
  1124. }
  1125. }
  1126. void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) {
  1127. ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
  1128. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1129. #ifdef DEBUG_ENABLED
  1130. for (List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) {
  1131. p_constants->push_back(E->get());
  1132. #else
  1133. for (Map<StringName, int>::Element *E = cd.value.front(); E; E = E->next()) {
  1134. p_constants->push_back(E->key());
  1135. #endif
  1136. }
  1137. for (Map<StringName, Variant>::Element *E = cd.variant_value.front(); E; E = E->next()) {
  1138. p_constants->push_back(E->key());
  1139. }
  1140. }
  1141. bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) {
  1142. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1143. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1144. return cd.value.has(p_value) || cd.variant_value.has(p_value);
  1145. }
  1146. Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid) {
  1147. if (r_valid)
  1148. *r_valid = false;
  1149. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
  1150. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1151. Map<StringName, int>::Element *E = cd.value.find(p_value);
  1152. if (!E) {
  1153. Map<StringName, Variant>::Element *E = cd.variant_value.find(p_value);
  1154. if (E) {
  1155. if (r_valid)
  1156. *r_valid = true;
  1157. return E->get();
  1158. } else {
  1159. return -1;
  1160. }
  1161. }
  1162. if (r_valid)
  1163. *r_valid = true;
  1164. return E->get();
  1165. }
  1166. void register_variant_methods() {
  1167. _VariantCall::type_funcs = memnew_arr(_VariantCall::TypeFunc, Variant::VARIANT_MAX);
  1168. _VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc, Variant::VARIANT_MAX);
  1169. _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
  1170. #define ADDFUNC0R(m_vtype, m_ret, m_class, m_method, m_defarg) \
  1171. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
  1172. #define ADDFUNC1R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
  1173. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
  1174. #define ADDFUNC2R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
  1175. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
  1176. #define ADDFUNC3R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
  1177. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
  1178. #define ADDFUNC4R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
  1179. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
  1180. #define ADDFUNC0RNC(m_vtype, m_ret, m_class, m_method, m_defarg) \
  1181. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
  1182. #define ADDFUNC1RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
  1183. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
  1184. #define ADDFUNC2RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
  1185. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
  1186. #define ADDFUNC3RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
  1187. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
  1188. #define ADDFUNC4RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
  1189. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
  1190. #define ADDFUNC0(m_vtype, m_ret, m_class, m_method, m_defarg) \
  1191. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
  1192. #define ADDFUNC1(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
  1193. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
  1194. #define ADDFUNC2(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
  1195. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
  1196. #define ADDFUNC3(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
  1197. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
  1198. #define ADDFUNC4(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
  1199. _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
  1200. #define ADDFUNC0NC(m_vtype, m_ret, m_class, m_method, m_defarg) \
  1201. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
  1202. #define ADDFUNC1NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
  1203. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
  1204. #define ADDFUNC2NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
  1205. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
  1206. #define ADDFUNC3NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
  1207. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
  1208. #define ADDFUNC4NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
  1209. _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
  1210. /* STRING */
  1211. ADDFUNC1R(STRING, INT, String, casecmp_to, STRING, "to", varray());
  1212. ADDFUNC1R(STRING, INT, String, nocasecmp_to, STRING, "to", varray());
  1213. ADDFUNC0R(STRING, INT, String, length, varray());
  1214. ADDFUNC2R(STRING, STRING, String, substr, INT, "from", INT, "len", varray());
  1215. ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0));
  1216. ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray());
  1217. ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
  1218. ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));
  1219. ADDFUNC2R(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1));
  1220. ADDFUNC1R(STRING, BOOL, String, match, STRING, "expr", varray());
  1221. ADDFUNC1R(STRING, BOOL, String, matchn, STRING, "expr", varray());
  1222. ADDFUNC1R(STRING, BOOL, String, begins_with, STRING, "text", varray());
  1223. ADDFUNC1R(STRING, BOOL, String, ends_with, STRING, "text", varray());
  1224. ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray());
  1225. ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray());
  1226. ADDFUNC0R(STRING, POOL_STRING_ARRAY, String, bigrams, varray());
  1227. ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray());
  1228. ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));
  1229. ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray());
  1230. ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray());
  1231. ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray());
  1232. ADDFUNC0R(STRING, STRING, String, capitalize, varray());
  1233. ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, split, STRING, "divisor", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
  1234. ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, rsplit, STRING, "divisor", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0));
  1235. ADDFUNC2R(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "divisor", BOOL, "allow_empty", varray(true));
  1236. ADDFUNC0R(STRING, STRING, String, to_upper, varray());
  1237. ADDFUNC0R(STRING, STRING, String, to_lower, varray());
  1238. ADDFUNC1R(STRING, STRING, String, left, INT, "position", varray());
  1239. ADDFUNC1R(STRING, STRING, String, right, INT, "position", varray());
  1240. ADDFUNC2R(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true));
  1241. ADDFUNC1R(STRING, STRING, String, lstrip, STRING, "chars", varray());
  1242. ADDFUNC1R(STRING, STRING, String, rstrip, STRING, "chars", varray());
  1243. ADDFUNC0R(STRING, STRING, String, get_extension, varray());
  1244. ADDFUNC0R(STRING, STRING, String, get_basename, varray());
  1245. ADDFUNC1R(STRING, STRING, String, plus_file, STRING, "file", varray());
  1246. ADDFUNC1R(STRING, INT, String, ord_at, INT, "at", varray());
  1247. ADDFUNC0R(STRING, STRING, String, dedent, varray());
  1248. ADDFUNC2(STRING, NIL, String, erase, INT, "position", INT, "chars", varray());
  1249. ADDFUNC0R(STRING, INT, String, hash, varray());
  1250. ADDFUNC0R(STRING, STRING, String, md5_text, varray());
  1251. ADDFUNC0R(STRING, STRING, String, sha256_text, varray());
  1252. ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray());
  1253. ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray());
  1254. ADDFUNC0R(STRING, BOOL, String, empty, varray());
  1255. ADDFUNC0R(STRING, BOOL, String, is_abs_path, varray());
  1256. ADDFUNC0R(STRING, BOOL, String, is_rel_path, varray());
  1257. ADDFUNC0R(STRING, STRING, String, get_base_dir, varray());
  1258. ADDFUNC0R(STRING, STRING, String, get_file, varray());
  1259. ADDFUNC0R(STRING, STRING, String, xml_escape, varray());
  1260. ADDFUNC0R(STRING, STRING, String, xml_unescape, varray());
  1261. ADDFUNC0R(STRING, STRING, String, c_escape, varray());
  1262. ADDFUNC0R(STRING, STRING, String, c_unescape, varray());
  1263. ADDFUNC0R(STRING, STRING, String, json_escape, varray());
  1264. ADDFUNC0R(STRING, STRING, String, percent_encode, varray());
  1265. ADDFUNC0R(STRING, STRING, String, percent_decode, varray());
  1266. ADDFUNC0R(STRING, BOOL, String, is_valid_identifier, varray());
  1267. ADDFUNC0R(STRING, BOOL, String, is_valid_integer, varray());
  1268. ADDFUNC0R(STRING, BOOL, String, is_valid_float, varray());
  1269. ADDFUNC1R(STRING, BOOL, String, is_valid_hex_number, BOOL, "with_prefix", varray(false));
  1270. ADDFUNC0R(STRING, BOOL, String, is_valid_html_color, varray());
  1271. ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray());
  1272. ADDFUNC0R(STRING, INT, String, to_int, varray());
  1273. ADDFUNC0R(STRING, REAL, String, to_float, varray());
  1274. ADDFUNC0R(STRING, INT, String, hex_to_int, varray());
  1275. ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray());
  1276. ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray());
  1277. ADDFUNC1R(STRING, STRING, String, trim_prefix, STRING, "prefix", varray());
  1278. ADDFUNC1R(STRING, STRING, String, trim_suffix, STRING, "suffix", varray());
  1279. ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray());
  1280. ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray());
  1281. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray());
  1282. ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray());
  1283. ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray());
  1284. ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray());
  1285. ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray());
  1286. ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
  1287. ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
  1288. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", varray());
  1289. ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
  1290. ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray());
  1291. ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray());
  1292. ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", REAL, "t", varray());
  1293. ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
  1294. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
  1295. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray());
  1296. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray());
  1297. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, ceil, varray());
  1298. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, round, varray());
  1299. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray());
  1300. ADDFUNC0R(VECTOR2, REAL, Vector2, aspect, varray());
  1301. ADDFUNC1R(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray());
  1302. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray());
  1303. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray());
  1304. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray());
  1305. ADDFUNC1R(VECTOR2, REAL, Vector2, cross, VECTOR2, "with", varray());
  1306. ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray());
  1307. ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray());
  1308. ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray());
  1309. ADDFUNC1R(RECT2, BOOL, Rect2, intersects, RECT2, "b", varray());
  1310. ADDFUNC1R(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray());
  1311. ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray());
  1312. ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray());
  1313. ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray());
  1314. ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
  1315. ADDFUNC1R(RECT2, RECT2, Rect2, grow, REAL, "by", varray());
  1316. ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray());
  1317. ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
  1318. ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray());
  1319. ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray());
  1320. ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
  1321. ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());
  1322. ADDFUNC0R(VECTOR3, REAL, Vector3, length, varray());
  1323. ADDFUNC0R(VECTOR3, REAL, Vector3, length_squared, varray());
  1324. ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray());
  1325. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray());
  1326. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
  1327. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
  1328. ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
  1329. ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
  1330. ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", REAL, "t", varray());
  1331. ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
  1332. ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
  1333. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
  1334. ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray());
  1335. ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray());
  1336. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, abs, varray());
  1337. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray());
  1338. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray());
  1339. ADDFUNC0R(VECTOR3, VECTOR3, Vector3, round, varray());
  1340. ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
  1341. ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray());
  1342. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, project, VECTOR3, "b", varray());
  1343. ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
  1344. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray());
  1345. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray());
  1346. ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray());
  1347. ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray());
  1348. ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray());
  1349. ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray());
  1350. ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray());
  1351. ADDFUNC1R(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray());
  1352. ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON));
  1353. ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray());
  1354. ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray());
  1355. ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray());
  1356. ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray());
  1357. ADDFUNC0R(QUAT, REAL, Quat, length, varray());
  1358. ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray());
  1359. ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray());
  1360. ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray());
  1361. ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
  1362. ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
  1363. ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
  1364. ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray());
  1365. ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray());
  1366. ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray());
  1367. ADDFUNC0R(QUAT, VECTOR3, Quat, get_euler, varray());
  1368. ADDFUNC1(QUAT, NIL, Quat, set_euler, VECTOR3, "euler", varray());
  1369. ADDFUNC2(QUAT, NIL, Quat, set_axis_angle, VECTOR3, "axis", REAL, "angle", varray());
  1370. ADDFUNC0R(COLOR, INT, Color, to_argb32, varray());
  1371. ADDFUNC0R(COLOR, INT, Color, to_abgr32, varray());
  1372. ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray());
  1373. ADDFUNC0R(COLOR, INT, Color, to_argb64, varray());
  1374. ADDFUNC0R(COLOR, INT, Color, to_abgr64, varray());
  1375. ADDFUNC0R(COLOR, INT, Color, to_rgba64, varray());
  1376. ADDFUNC0R(COLOR, REAL, Color, gray, varray());
  1377. ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
  1378. ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
  1379. ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
  1380. ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
  1381. ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray());
  1382. ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
  1383. ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
  1384. ADDFUNC4R(COLOR, COLOR, Color, from_hsv, REAL, "h", REAL, "s", REAL, "v", REAL, "a", varray(1.0));
  1385. ADDFUNC0R(_RID, INT, RID, get_id, varray());
  1386. ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_absolute, varray());
  1387. ADDFUNC0R(NODE_PATH, INT, NodePath, get_name_count, varray());
  1388. ADDFUNC1R(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray());
  1389. ADDFUNC0R(NODE_PATH, INT, NodePath, get_subname_count, varray());
  1390. ADDFUNC1R(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray());
  1391. ADDFUNC0R(NODE_PATH, STRING, NodePath, get_concatenated_subnames, varray());
  1392. ADDFUNC0R(NODE_PATH, NODE_PATH, NodePath, get_as_property_path, varray());
  1393. ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_empty, varray());
  1394. ADDFUNC0R(DICTIONARY, INT, Dictionary, size, varray());
  1395. ADDFUNC0R(DICTIONARY, BOOL, Dictionary, empty, varray());
  1396. ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray());
  1397. ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray());
  1398. ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray());
  1399. ADDFUNC1R(DICTIONARY, BOOL, Dictionary, erase, NIL, "key", varray());
  1400. ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray());
  1401. ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray());
  1402. ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray());
  1403. ADDFUNC1R(DICTIONARY, DICTIONARY, Dictionary, duplicate, BOOL, "deep", varray(false));
  1404. ADDFUNC2R(DICTIONARY, NIL, Dictionary, get, NIL, "key", NIL, "default", varray(Variant()));
  1405. ADDFUNC0R(ARRAY, INT, Array, size, varray());
  1406. ADDFUNC0R(ARRAY, BOOL, Array, empty, varray());
  1407. ADDFUNC0NC(ARRAY, NIL, Array, clear, varray());
  1408. ADDFUNC0R(ARRAY, INT, Array, hash, varray());
  1409. ADDFUNC1NC(ARRAY, NIL, Array, push_back, NIL, "value", varray());
  1410. ADDFUNC1NC(ARRAY, NIL, Array, push_front, NIL, "value", varray());
  1411. ADDFUNC1NC(ARRAY, NIL, Array, append, NIL, "value", varray());
  1412. ADDFUNC1NC(ARRAY, NIL, Array, resize, INT, "size", varray());
  1413. ADDFUNC2NC(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray());
  1414. ADDFUNC1NC(ARRAY, NIL, Array, remove, INT, "position", varray());
  1415. ADDFUNC1NC(ARRAY, NIL, Array, erase, NIL, "value", varray());
  1416. ADDFUNC0R(ARRAY, NIL, Array, front, varray());
  1417. ADDFUNC0R(ARRAY, NIL, Array, back, varray());
  1418. ADDFUNC2R(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0));
  1419. ADDFUNC2R(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1));
  1420. ADDFUNC1R(ARRAY, INT, Array, find_last, NIL, "value", varray());
  1421. ADDFUNC1R(ARRAY, INT, Array, count, NIL, "value", varray());
  1422. ADDFUNC1R(ARRAY, BOOL, Array, has, NIL, "value", varray());
  1423. ADDFUNC0RNC(ARRAY, NIL, Array, pop_back, varray());
  1424. ADDFUNC0RNC(ARRAY, NIL, Array, pop_front, varray());
  1425. ADDFUNC0NC(ARRAY, NIL, Array, sort, varray());
  1426. ADDFUNC2NC(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray());
  1427. ADDFUNC0NC(ARRAY, NIL, Array, shuffle, varray());
  1428. ADDFUNC2R(ARRAY, INT, Array, bsearch, NIL, "value", BOOL, "before", varray(true));
  1429. ADDFUNC4R(ARRAY, INT, Array, bsearch_custom, NIL, "value", OBJECT, "obj", STRING, "func", BOOL, "before", varray(true));
  1430. ADDFUNC0NC(ARRAY, NIL, Array, invert, varray());
  1431. ADDFUNC1R(ARRAY, ARRAY, Array, duplicate, BOOL, "deep", varray(false));
  1432. ADDFUNC0R(ARRAY, NIL, Array, max, varray());
  1433. ADDFUNC0R(ARRAY, NIL, Array, min, varray());
  1434. ADDFUNC0R(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
  1435. ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray());
  1436. ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, push_back, INT, "byte", varray());
  1437. ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append, INT, "byte", varray());
  1438. ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append_array, POOL_BYTE_ARRAY, "array", varray());
  1439. ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, remove, INT, "idx", varray());
  1440. ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray());
  1441. ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, resize, INT, "idx", varray());
  1442. ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray());
  1443. ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
  1444. ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
  1445. ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray());
  1446. ADDFUNC1R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0));
  1447. ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
  1448. ADDFUNC0R(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
  1449. ADDFUNC2(POOL_INT_ARRAY, NIL, PoolIntArray, set, INT, "idx", INT, "integer", varray());
  1450. ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, push_back, INT, "integer", varray());
  1451. ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append, INT, "integer", varray());
  1452. ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append_array, POOL_INT_ARRAY, "array", varray());
  1453. ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, remove, INT, "idx", varray());
  1454. ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray());
  1455. ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray());
  1456. ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
  1457. ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
  1458. ADDFUNC2(POOL_REAL_ARRAY, NIL, PoolRealArray, set, INT, "idx", REAL, "value", varray());
  1459. ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, push_back, REAL, "value", varray());
  1460. ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append, REAL, "value", varray());
  1461. ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append_array, POOL_REAL_ARRAY, "array", varray());
  1462. ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, remove, INT, "idx", varray());
  1463. ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray());
  1464. ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray());
  1465. ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
  1466. ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
  1467. ADDFUNC2(POOL_STRING_ARRAY, NIL, PoolStringArray, set, INT, "idx", STRING, "string", varray());
  1468. ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, push_back, STRING, "string", varray());
  1469. ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append, STRING, "string", varray());
  1470. ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append_array, POOL_STRING_ARRAY, "array", varray());
  1471. ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, remove, INT, "idx", varray());
  1472. ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray());
  1473. ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, resize, INT, "idx", varray());
  1474. ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray());
  1475. ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
  1476. ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
  1477. ADDFUNC2(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, set, INT, "idx", VECTOR2, "vector2", varray());
  1478. ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, push_back, VECTOR2, "vector2", varray());
  1479. ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append, VECTOR2, "vector2", varray());
  1480. ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append_array, POOL_VECTOR2_ARRAY, "array", varray());
  1481. ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, remove, INT, "idx", varray());
  1482. ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
  1483. ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray());
  1484. ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
  1485. ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
  1486. ADDFUNC2(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, set, INT, "idx", VECTOR3, "vector3", varray());
  1487. ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, push_back, VECTOR3, "vector3", varray());
  1488. ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append, VECTOR3, "vector3", varray());
  1489. ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append_array, POOL_VECTOR3_ARRAY, "array", varray());
  1490. ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, remove, INT, "idx", varray());
  1491. ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
  1492. ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray());
  1493. ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
  1494. ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
  1495. ADDFUNC2(POOL_COLOR_ARRAY, NIL, PoolColorArray, set, INT, "idx", COLOR, "color", varray());
  1496. ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, push_back, COLOR, "color", varray());
  1497. ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append, COLOR, "color", varray());
  1498. ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append_array, POOL_COLOR_ARRAY, "array", varray());
  1499. ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, remove, INT, "idx", varray());
  1500. ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray());
  1501. ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray());
  1502. ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray());
  1503. //pointerbased
  1504. ADDFUNC0R(AABB, REAL, AABB, get_area, varray());
  1505. ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray());
  1506. ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray());
  1507. ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray());
  1508. ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray());
  1509. ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray());
  1510. ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray());
  1511. ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray());
  1512. ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray());
  1513. ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray());
  1514. ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray());
  1515. ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray());
  1516. ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray());
  1517. ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray());
  1518. ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray());
  1519. ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray());
  1520. ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray());
  1521. ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray());
  1522. ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray());
  1523. ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray());
  1524. ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray());
  1525. ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray());
  1526. ADDFUNC0R(TRANSFORM2D, REAL, Transform2D, get_rotation, varray());
  1527. ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray());
  1528. ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray());
  1529. ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray());
  1530. ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray());
  1531. ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray());
  1532. ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray());
  1533. ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform, NIL, "v", varray());
  1534. ADDFUNC1R(TRANSFORM2D, NIL, Transform2D, xform_inv, NIL, "v", varray());
  1535. ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform, VECTOR2, "v", varray());
  1536. ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform_inv, VECTOR2, "v", varray());
  1537. ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray());
  1538. ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray());
  1539. ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray());
  1540. ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray());
  1541. ADDFUNC0R(BASIS, REAL, Basis, determinant, varray());
  1542. ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray());
  1543. ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray());
  1544. ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray());
  1545. ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray());
  1546. ADDFUNC1R(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray());
  1547. ADDFUNC1R(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray());
  1548. ADDFUNC1R(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray());
  1549. ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
  1550. ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
  1551. ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
  1552. ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", REAL, "t", varray());
  1553. ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
  1554. ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
  1555. ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
  1556. ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
  1557. ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
  1558. ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray());
  1559. ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
  1560. ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
  1561. ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
  1562. ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
  1563. /* REGISTER CONSTRUCTORS */
  1564. _VariantCall::add_constructor(_VariantCall::Vector2_init1, Variant::VECTOR2, "x", Variant::REAL, "y", Variant::REAL);
  1565. _VariantCall::add_constructor(_VariantCall::Rect2_init1, Variant::RECT2, "position", Variant::VECTOR2, "size", Variant::VECTOR2);
  1566. _VariantCall::add_constructor(_VariantCall::Rect2_init2, Variant::RECT2, "x", Variant::REAL, "y", Variant::REAL, "width", Variant::REAL, "height", Variant::REAL);
  1567. _VariantCall::add_constructor(_VariantCall::Transform2D_init2, Variant::TRANSFORM2D, "rotation", Variant::REAL, "position", Variant::VECTOR2);
  1568. _VariantCall::add_constructor(_VariantCall::Transform2D_init3, Variant::TRANSFORM2D, "x_axis", Variant::VECTOR2, "y_axis", Variant::VECTOR2, "origin", Variant::VECTOR2);
  1569. _VariantCall::add_constructor(_VariantCall::Vector3_init1, Variant::VECTOR3, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL);
  1570. _VariantCall::add_constructor(_VariantCall::Plane_init1, Variant::PLANE, "a", Variant::REAL, "b", Variant::REAL, "c", Variant::REAL, "d", Variant::REAL);
  1571. _VariantCall::add_constructor(_VariantCall::Plane_init2, Variant::PLANE, "v1", Variant::VECTOR3, "v2", Variant::VECTOR3, "v3", Variant::VECTOR3);
  1572. _VariantCall::add_constructor(_VariantCall::Plane_init3, Variant::PLANE, "normal", Variant::VECTOR3, "d", Variant::REAL);
  1573. _VariantCall::add_constructor(_VariantCall::Quat_init1, Variant::QUAT, "x", Variant::REAL, "y", Variant::REAL, "z", Variant::REAL, "w", Variant::REAL);
  1574. _VariantCall::add_constructor(_VariantCall::Quat_init2, Variant::QUAT, "axis", Variant::VECTOR3, "angle", Variant::REAL);
  1575. _VariantCall::add_constructor(_VariantCall::Quat_init3, Variant::QUAT, "euler", Variant::VECTOR3);
  1576. _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
  1577. _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
  1578. _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
  1579. _VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
  1580. _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
  1581. _VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3);
  1582. _VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3);
  1583. /* REGISTER CONSTANTS */
  1584. _populate_named_colors();
  1585. for (Map<String, Color>::Element *color = _named_colors.front(); color; color = color->next()) {
  1586. _VariantCall::add_variant_constant(Variant::COLOR, color->key(), color->value());
  1587. }
  1588. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_X", Vector3::AXIS_X);
  1589. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Y", Vector3::AXIS_Y);
  1590. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z);
  1591. _VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0));
  1592. _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1));
  1593. _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(Math_INF, Math_INF, Math_INF));
  1594. _VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0));
  1595. _VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0));
  1596. _VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3(0, 1, 0));
  1597. _VariantCall::add_variant_constant(Variant::VECTOR3, "DOWN", Vector3(0, -1, 0));
  1598. _VariantCall::add_variant_constant(Variant::VECTOR3, "FORWARD", Vector3(0, 0, -1));
  1599. _VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1));
  1600. _VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
  1601. _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
  1602. _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(Math_INF, Math_INF));
  1603. _VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0));
  1604. _VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0));
  1605. _VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1));
  1606. _VariantCall::add_variant_constant(Variant::VECTOR2, "DOWN", Vector2(0, 1));
  1607. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D(1, 0, 0, 1, 0, 0));
  1608. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0));
  1609. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0));
  1610. Transform identity_transform, transform_x, transform_y, transform_z;
  1611. identity_transform.set(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
  1612. _VariantCall::add_variant_constant(Variant::TRANSFORM, "IDENTITY", identity_transform);
  1613. transform_x.set(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
  1614. _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_X", transform_x);
  1615. transform_x.set(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
  1616. _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Y", transform_y);
  1617. transform_x.set(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
  1618. _VariantCall::add_variant_constant(Variant::TRANSFORM, "FLIP_Z", transform_z);
  1619. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_YZ", Plane(Vector3(1, 0, 0), 0));
  1620. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane(Vector3(0, 1, 0), 0));
  1621. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane(Vector3(0, 0, 1), 0));
  1622. _VariantCall::add_variant_constant(Variant::QUAT, "IDENTITY", Quat(0, 0, 0, 1));
  1623. }
  1624. void unregister_variant_methods() {
  1625. memdelete_arr(_VariantCall::type_funcs);
  1626. memdelete_arr(_VariantCall::construct_funcs);
  1627. memdelete_arr(_VariantCall::constant_data);
  1628. }