variant_call.cpp 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  1. /*************************************************************************/
  2. /* variant_call.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #include "variant.h"
  30. #include "object.h"
  31. #include "os/os.h"
  32. #include "core_string_names.h"
  33. #include "script_language.h"
  34. typedef void (*VariantFunc)(Variant& r_ret,Variant& p_self,const Variant** p_args);
  35. typedef void (*VariantConstructFunc)(Variant& r_ret,const Variant** p_args);
  36. VARIANT_ENUM_CAST(Image::CompressMode);
  37. //VARIANT_ENUM_CAST(Image::Format);
  38. struct _VariantCall {
  39. static void Vector3_dot(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  40. r_ret=reinterpret_cast<Vector3*>(p_self._data._mem)->dot(*reinterpret_cast<const Vector3*>(p_args[0]->_data._mem));
  41. }
  42. struct FuncData {
  43. int arg_count;
  44. Vector<Variant> default_args;
  45. Vector<Variant::Type> arg_types;
  46. #ifdef DEBUG_ENABLED
  47. Vector<StringName> arg_names;
  48. Variant::Type return_type;
  49. bool returns;
  50. #endif
  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. 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. int defargcount=def_argcount;
  90. for(int i=p_argcount;i<arg_count;i++)
  91. newargs[i]=&default_args[defargcount-(i-p_argcount)-1]; //default arguments
  92. #ifdef DEBUG_ENABLED
  93. if (!verify_arguments(newargs,r_error))
  94. return;
  95. #endif
  96. func(r_ret,p_self,newargs);
  97. } else {
  98. #ifdef DEBUG_ENABLED
  99. if (!verify_arguments(p_args,r_error))
  100. return;
  101. #endif
  102. func(r_ret,p_self,p_args);
  103. }
  104. }
  105. };
  106. struct TypeFunc {
  107. Map<StringName,FuncData> functions;
  108. };
  109. static TypeFunc* type_funcs;
  110. struct Arg {
  111. StringName name;
  112. Variant::Type type;
  113. Arg() { type=Variant::NIL;}
  114. Arg(Variant::Type p_type,const StringName &p_name) { name=p_name; type=p_type; }
  115. };
  116. // void addfunc(Variant::Type p_type, const StringName& p_name,VariantFunc p_func);
  117. static void addfunc(Variant::Type p_type, Variant::Type p_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()) {
  118. FuncData funcdata;
  119. funcdata.func=p_func;
  120. funcdata.default_args=p_defaultarg;
  121. #ifdef DEBUG_ENABLED
  122. funcdata.return_type=p_return;
  123. funcdata.returns=p_return!=Variant::NIL;
  124. #endif
  125. if (p_argtype1.name) {
  126. funcdata.arg_types.push_back(p_argtype1.type);
  127. #ifdef DEBUG_ENABLED
  128. funcdata.arg_names.push_back(p_argtype1.name);
  129. #endif
  130. } else
  131. goto end;
  132. if (p_argtype2.name) {
  133. funcdata.arg_types.push_back(p_argtype2.type);
  134. #ifdef DEBUG_ENABLED
  135. funcdata.arg_names.push_back(p_argtype2.name);
  136. #endif
  137. } else
  138. goto end;
  139. if (p_argtype3.name) {
  140. funcdata.arg_types.push_back(p_argtype3.type);
  141. #ifdef DEBUG_ENABLED
  142. funcdata.arg_names.push_back(p_argtype3.name);
  143. #endif
  144. } else
  145. goto end;
  146. if (p_argtype4.name) {
  147. funcdata.arg_types.push_back(p_argtype4.type);
  148. #ifdef DEBUG_ENABLED
  149. funcdata.arg_names.push_back(p_argtype4.name);
  150. #endif
  151. } else
  152. goto end;
  153. if (p_argtype5.name) {
  154. funcdata.arg_types.push_back(p_argtype5.type);
  155. #ifdef DEBUG_ENABLED
  156. funcdata.arg_names.push_back(p_argtype5.name);
  157. #endif
  158. } else
  159. goto end;
  160. end:
  161. funcdata.arg_count=funcdata.arg_types.size();
  162. type_funcs[p_type].functions[p_name]=funcdata;
  163. }
  164. #define VCALL_LOCALMEM0(m_type,m_method)\
  165. 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(); }
  166. #define VCALL_LOCALMEM0R(m_type,m_method)\
  167. 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(); }
  168. #define VCALL_LOCALMEM1(m_type,m_method)\
  169. 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]); }
  170. #define VCALL_LOCALMEM1R(m_type,m_method)\
  171. 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]); }
  172. #define VCALL_LOCALMEM2(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(*p_args[0],*p_args[1]); }
  174. #define VCALL_LOCALMEM2R(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(*p_args[0],*p_args[1]); }
  176. #define VCALL_LOCALMEM3(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],*p_args[1],*p_args[2]); }
  178. #define VCALL_LOCALMEM3R(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],*p_args[1],*p_args[2]); }
  180. #define VCALL_LOCALMEM4(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],*p_args[2],*p_args[3]); }
  182. #define VCALL_LOCALMEM4R(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],*p_args[2],*p_args[3]); }
  184. #define VCALL_LOCALMEM5(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],*p_args[3],*p_args[4]); }
  186. #define VCALL_LOCALMEM5R(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],*p_args[3],*p_args[4]); }
  188. // built-in functions of localmem based types
  189. VCALL_LOCALMEM1R(String,casecmp_to);
  190. VCALL_LOCALMEM1R(String,nocasecmp_to);
  191. VCALL_LOCALMEM0R(String,length);
  192. VCALL_LOCALMEM2R(String,substr);
  193. VCALL_LOCALMEM2R(String,find);
  194. VCALL_LOCALMEM1R(String,find_last);
  195. VCALL_LOCALMEM2R(String,findn);
  196. VCALL_LOCALMEM2R(String,rfind);
  197. VCALL_LOCALMEM2R(String,rfindn);
  198. VCALL_LOCALMEM1R(String,match);
  199. VCALL_LOCALMEM1R(String,matchn);
  200. VCALL_LOCALMEM1R(String,begins_with);
  201. VCALL_LOCALMEM2R(String,replace);
  202. VCALL_LOCALMEM2R(String,replacen);
  203. VCALL_LOCALMEM2R(String,insert);
  204. VCALL_LOCALMEM0R(String,capitalize);
  205. VCALL_LOCALMEM2R(String,split);
  206. VCALL_LOCALMEM2R(String,split_floats);
  207. VCALL_LOCALMEM0R(String,to_upper);
  208. VCALL_LOCALMEM0R(String,to_lower);
  209. VCALL_LOCALMEM1R(String,left);
  210. VCALL_LOCALMEM1R(String,right);
  211. VCALL_LOCALMEM0R(String,strip_edges);
  212. VCALL_LOCALMEM0R(String,extension);
  213. VCALL_LOCALMEM0R(String,basename);
  214. VCALL_LOCALMEM1R(String,plus_file);
  215. VCALL_LOCALMEM1R(String,ord_at);
  216. //VCALL_LOCALMEM2R(String,erase);
  217. VCALL_LOCALMEM0R(String,hash);
  218. VCALL_LOCALMEM0R(String,md5_text);
  219. VCALL_LOCALMEM0R(String,md5_buffer);
  220. VCALL_LOCALMEM0R(String,empty);
  221. VCALL_LOCALMEM0R(String,is_abs_path);
  222. VCALL_LOCALMEM0R(String,is_rel_path);
  223. VCALL_LOCALMEM0R(String,get_base_dir);
  224. VCALL_LOCALMEM0R(String,get_file);
  225. VCALL_LOCALMEM0R(String,xml_escape);
  226. VCALL_LOCALMEM0R(String,xml_unescape);
  227. VCALL_LOCALMEM0R(String,c_escape);
  228. VCALL_LOCALMEM0R(String,c_unescape);
  229. VCALL_LOCALMEM0R(String,json_escape);
  230. VCALL_LOCALMEM0R(String,percent_encode);
  231. VCALL_LOCALMEM0R(String,percent_decode);
  232. VCALL_LOCALMEM0R(String,is_valid_identifier);
  233. VCALL_LOCALMEM0R(String,is_valid_integer);
  234. VCALL_LOCALMEM0R(String,is_valid_float);
  235. VCALL_LOCALMEM0R(String,is_valid_html_color);
  236. VCALL_LOCALMEM0R(String,is_valid_ip_address);
  237. VCALL_LOCALMEM0R(String,to_int);
  238. VCALL_LOCALMEM0R(String,to_float);
  239. VCALL_LOCALMEM0R(String,hex_to_int);
  240. VCALL_LOCALMEM1R(String,pad_decimals);
  241. VCALL_LOCALMEM1R(String,pad_zeros);
  242. static void _call_String_to_ascii(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  243. String *s = reinterpret_cast<String*>(p_self._data._mem);
  244. CharString charstr = s->ascii();
  245. ByteArray retval;
  246. size_t len = charstr.length();
  247. retval.resize(len);
  248. ByteArray::Write w = retval.write();
  249. copymem(w.ptr(), charstr.ptr(), len);
  250. w = DVector<uint8_t>::Write();
  251. r_ret = retval;
  252. }
  253. static void _call_String_to_utf8(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  254. String *s = reinterpret_cast<String*>(p_self._data._mem);
  255. CharString charstr = s->utf8();
  256. ByteArray retval;
  257. size_t len = charstr.length();
  258. retval.resize(len);
  259. ByteArray::Write w = retval.write();
  260. copymem(w.ptr(), charstr.ptr(), len);
  261. w = DVector<uint8_t>::Write();
  262. r_ret = retval;
  263. }
  264. VCALL_LOCALMEM0R(Vector2,normalized);
  265. VCALL_LOCALMEM0R(Vector2,length);
  266. VCALL_LOCALMEM0R(Vector2,length_squared);
  267. VCALL_LOCALMEM1R(Vector2,distance_to);
  268. VCALL_LOCALMEM1R(Vector2,distance_squared_to);
  269. VCALL_LOCALMEM1R(Vector2,angle_to);
  270. VCALL_LOCALMEM1R(Vector2,angle_to_point);
  271. VCALL_LOCALMEM2R(Vector2,linear_interpolate);
  272. VCALL_LOCALMEM4R(Vector2,cubic_interpolate);
  273. VCALL_LOCALMEM1R(Vector2,rotated);
  274. VCALL_LOCALMEM0R(Vector2,tangent);
  275. VCALL_LOCALMEM0R(Vector2,floor);
  276. VCALL_LOCALMEM1R(Vector2,snapped);
  277. VCALL_LOCALMEM0R(Vector2,get_aspect);
  278. VCALL_LOCALMEM1R(Vector2,dot);
  279. VCALL_LOCALMEM1R(Vector2,slide);
  280. VCALL_LOCALMEM1R(Vector2,reflect);
  281. VCALL_LOCALMEM0R(Vector2,angle);
  282. // VCALL_LOCALMEM1R(Vector2,cross);
  283. VCALL_LOCALMEM0R(Rect2,get_area);
  284. VCALL_LOCALMEM1R(Rect2,intersects);
  285. VCALL_LOCALMEM1R(Rect2,encloses);
  286. VCALL_LOCALMEM0R(Rect2,has_no_area);
  287. VCALL_LOCALMEM1R(Rect2,clip);
  288. VCALL_LOCALMEM1R(Rect2,merge);
  289. VCALL_LOCALMEM1R(Rect2,has_point);
  290. VCALL_LOCALMEM1R(Rect2,grow);
  291. VCALL_LOCALMEM1R(Rect2,expand);
  292. VCALL_LOCALMEM0R(Vector3, min_axis);
  293. VCALL_LOCALMEM0R(Vector3, max_axis);
  294. VCALL_LOCALMEM0R(Vector3, length);
  295. VCALL_LOCALMEM0R(Vector3, length_squared);
  296. VCALL_LOCALMEM0R(Vector3, normalized);
  297. VCALL_LOCALMEM0R(Vector3, inverse);
  298. VCALL_LOCALMEM1R(Vector3, snapped);
  299. VCALL_LOCALMEM2R(Vector3, rotated);
  300. VCALL_LOCALMEM2R(Vector3, linear_interpolate);
  301. VCALL_LOCALMEM4R(Vector3, cubic_interpolate);
  302. VCALL_LOCALMEM1R(Vector3, dot);
  303. VCALL_LOCALMEM1R(Vector3, cross);
  304. VCALL_LOCALMEM0R(Vector3, abs);
  305. VCALL_LOCALMEM0R(Vector3, floor);
  306. VCALL_LOCALMEM0R(Vector3, ceil);
  307. VCALL_LOCALMEM1R(Vector3, distance_to);
  308. VCALL_LOCALMEM1R(Vector3, distance_squared_to);
  309. VCALL_LOCALMEM1R(Vector3, slide);
  310. VCALL_LOCALMEM1R(Vector3, reflect);
  311. VCALL_LOCALMEM0R(Plane,normalized);
  312. VCALL_LOCALMEM0R(Plane,center);
  313. VCALL_LOCALMEM0R(Plane,get_any_point);
  314. VCALL_LOCALMEM1R(Plane,is_point_over);
  315. VCALL_LOCALMEM1R(Plane,distance_to);
  316. VCALL_LOCALMEM2R(Plane,has_point);
  317. VCALL_LOCALMEM1R(Plane,project);
  318. //return vector3 if intersected, nil if not
  319. static void _call_Plane_intersect_3(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  320. Vector3 result;
  321. if (reinterpret_cast<Plane*>(p_self._data._mem)->intersect_3(*p_args[0],*p_args[1],&result))
  322. r_ret=result;
  323. else
  324. r_ret=Variant();
  325. }
  326. static void _call_Plane_intersects_ray(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  327. Vector3 result;
  328. if (reinterpret_cast<Plane*>(p_self._data._mem)->intersects_ray(*p_args[0],*p_args[1],&result))
  329. r_ret=result;
  330. else
  331. r_ret=Variant();
  332. }
  333. static void _call_Plane_intersects_segment(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  334. Vector3 result;
  335. if (reinterpret_cast<Plane*>(p_self._data._mem)->intersects_segment(*p_args[0],*p_args[1],&result))
  336. r_ret=result;
  337. else
  338. r_ret=Variant();
  339. }
  340. static void _call_Vector2_floorf(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  341. r_ret = reinterpret_cast<Vector2*>(p_self._data._mem)->floor();
  342. };
  343. VCALL_LOCALMEM0R(Quat,length);
  344. VCALL_LOCALMEM0R(Quat,length_squared);
  345. VCALL_LOCALMEM0R(Quat,normalized);
  346. VCALL_LOCALMEM0R(Quat,inverse);
  347. VCALL_LOCALMEM1R(Quat,dot);
  348. VCALL_LOCALMEM1R(Quat,xform);
  349. VCALL_LOCALMEM2R(Quat,slerp);
  350. VCALL_LOCALMEM2R(Quat,slerpni);
  351. VCALL_LOCALMEM4R(Quat,cubic_slerp);
  352. VCALL_LOCALMEM0R(Color,to_32);
  353. VCALL_LOCALMEM0R(Color,to_ARGB32);
  354. VCALL_LOCALMEM0R(Color,gray);
  355. VCALL_LOCALMEM0R(Color,inverted);
  356. VCALL_LOCALMEM0R(Color,contrasted);
  357. VCALL_LOCALMEM2R(Color,linear_interpolate);
  358. VCALL_LOCALMEM1R(Color,blend);
  359. VCALL_LOCALMEM1R(Color,to_html);
  360. VCALL_LOCALMEM0R(RID,get_id);
  361. VCALL_LOCALMEM0R(NodePath,is_absolute);
  362. VCALL_LOCALMEM0R(NodePath,get_name_count);
  363. VCALL_LOCALMEM1R(NodePath,get_name);
  364. VCALL_LOCALMEM0R(NodePath,get_subname_count);
  365. VCALL_LOCALMEM1R(NodePath,get_subname);
  366. VCALL_LOCALMEM0R(NodePath,get_property);
  367. VCALL_LOCALMEM0R(NodePath,is_empty);
  368. VCALL_LOCALMEM0R(Dictionary,size);
  369. VCALL_LOCALMEM0R(Dictionary,empty);
  370. VCALL_LOCALMEM0(Dictionary,clear);
  371. VCALL_LOCALMEM1R(Dictionary,has);
  372. VCALL_LOCALMEM1R(Dictionary,has_all);
  373. VCALL_LOCALMEM1(Dictionary,erase);
  374. VCALL_LOCALMEM0R(Dictionary,hash);
  375. VCALL_LOCALMEM0R(Dictionary,keys);
  376. VCALL_LOCALMEM1R(Dictionary,parse_json);
  377. VCALL_LOCALMEM0R(Dictionary,to_json);
  378. VCALL_LOCALMEM2(Array,set);
  379. VCALL_LOCALMEM1R(Array,get);
  380. VCALL_LOCALMEM0R(Array,size);
  381. VCALL_LOCALMEM0R(Array,empty);
  382. VCALL_LOCALMEM0(Array,clear);
  383. VCALL_LOCALMEM0R(Array,hash);
  384. VCALL_LOCALMEM1(Array,push_back);
  385. VCALL_LOCALMEM1(Array,push_front);
  386. VCALL_LOCALMEM0(Array,pop_back);
  387. VCALL_LOCALMEM0(Array,pop_front);
  388. VCALL_LOCALMEM1(Array,append);
  389. VCALL_LOCALMEM1(Array,resize);
  390. VCALL_LOCALMEM2(Array,insert);
  391. VCALL_LOCALMEM1(Array,remove);
  392. VCALL_LOCALMEM1R(Array,find);
  393. VCALL_LOCALMEM1(Array,erase);
  394. VCALL_LOCALMEM0(Array,sort);
  395. VCALL_LOCALMEM2(Array,sort_custom);
  396. VCALL_LOCALMEM0(Array,invert);
  397. VCALL_LOCALMEM0R(Array,is_shared);
  398. static void _call_ByteArray_get_string_from_ascii(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  399. ByteArray* ba = reinterpret_cast<ByteArray*>(p_self._data._mem);
  400. String s;
  401. if (ba->size()>=0) {
  402. ByteArray::Read r = ba->read();
  403. CharString cs;
  404. cs.resize(ba->size()+1);
  405. copymem(cs.ptr(),r.ptr(),ba->size());
  406. cs[ba->size()]=0;
  407. s = cs.get_data();
  408. }
  409. r_ret=s;
  410. }
  411. static void _call_ByteArray_get_string_from_utf8(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  412. ByteArray* ba = reinterpret_cast<ByteArray*>(p_self._data._mem);
  413. String s;
  414. if (ba->size()>=0) {
  415. ByteArray::Read r = ba->read();
  416. s.parse_utf8((const char*)r.ptr(),ba->size());
  417. }
  418. r_ret=s;
  419. }
  420. VCALL_LOCALMEM0R(ByteArray,size);
  421. VCALL_LOCALMEM2(ByteArray,set);
  422. VCALL_LOCALMEM1R(ByteArray,get);
  423. VCALL_LOCALMEM1(ByteArray,push_back);
  424. VCALL_LOCALMEM1(ByteArray,resize);
  425. VCALL_LOCALMEM1(ByteArray,append);
  426. VCALL_LOCALMEM1(ByteArray,append_array);
  427. VCALL_LOCALMEM0R(IntArray,size);
  428. VCALL_LOCALMEM2(IntArray,set);
  429. VCALL_LOCALMEM1R(IntArray,get);
  430. VCALL_LOCALMEM1(IntArray,push_back);
  431. VCALL_LOCALMEM1(IntArray,resize);
  432. VCALL_LOCALMEM1(IntArray,append);
  433. VCALL_LOCALMEM1(IntArray,append_array);
  434. VCALL_LOCALMEM0R(RealArray,size);
  435. VCALL_LOCALMEM2(RealArray,set);
  436. VCALL_LOCALMEM1R(RealArray,get);
  437. VCALL_LOCALMEM1(RealArray,push_back);
  438. VCALL_LOCALMEM1(RealArray,resize);
  439. VCALL_LOCALMEM1(RealArray,append);
  440. VCALL_LOCALMEM1(RealArray,append_array);
  441. VCALL_LOCALMEM0R(StringArray,size);
  442. VCALL_LOCALMEM2(StringArray,set);
  443. VCALL_LOCALMEM1R(StringArray,get);
  444. VCALL_LOCALMEM1(StringArray,push_back);
  445. VCALL_LOCALMEM1(StringArray,resize);
  446. VCALL_LOCALMEM1(StringArray,append);
  447. VCALL_LOCALMEM1(StringArray,append_array);
  448. VCALL_LOCALMEM0R(Vector2Array,size);
  449. VCALL_LOCALMEM2(Vector2Array,set);
  450. VCALL_LOCALMEM1R(Vector2Array,get);
  451. VCALL_LOCALMEM1(Vector2Array,push_back);
  452. VCALL_LOCALMEM1(Vector2Array,resize);
  453. VCALL_LOCALMEM1(Vector2Array,append);
  454. VCALL_LOCALMEM1(Vector2Array,append_array);
  455. VCALL_LOCALMEM0R(Vector3Array,size);
  456. VCALL_LOCALMEM2(Vector3Array,set);
  457. VCALL_LOCALMEM1R(Vector3Array,get);
  458. VCALL_LOCALMEM1(Vector3Array,push_back);
  459. VCALL_LOCALMEM1(Vector3Array,resize);
  460. VCALL_LOCALMEM1(Vector3Array,append);
  461. VCALL_LOCALMEM1(Vector3Array,append_array);
  462. VCALL_LOCALMEM0R(ColorArray,size);
  463. VCALL_LOCALMEM2(ColorArray,set);
  464. VCALL_LOCALMEM1R(ColorArray,get);
  465. VCALL_LOCALMEM1(ColorArray,push_back);
  466. VCALL_LOCALMEM1(ColorArray,resize);
  467. VCALL_LOCALMEM1(ColorArray,append);
  468. VCALL_LOCALMEM1(ColorArray,append_array);
  469. #define VCALL_PTR0(m_type,m_method)\
  470. 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(); }
  471. #define VCALL_PTR0R(m_type,m_method)\
  472. 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(); }
  473. #define VCALL_PTR1(m_type,m_method)\
  474. 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]); }
  475. #define VCALL_PTR1R(m_type,m_method)\
  476. 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]); }
  477. #define VCALL_PTR2(m_type,m_method)\
  478. 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]); }
  479. #define VCALL_PTR2R(m_type,m_method)\
  480. 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]); }
  481. #define VCALL_PTR3(m_type,m_method)\
  482. 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]); }
  483. #define VCALL_PTR3R(m_type,m_method)\
  484. 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]); }
  485. #define VCALL_PTR4(m_type,m_method)\
  486. 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]); }
  487. #define VCALL_PTR4R(m_type,m_method)\
  488. 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]); }
  489. #define VCALL_PTR5(m_type,m_method)\
  490. 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]); }
  491. #define VCALL_PTR5R(m_type,m_method)\
  492. 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]); }
  493. VCALL_PTR0R(Image,get_format);
  494. VCALL_PTR0R(Image,get_width);
  495. VCALL_PTR0R(Image,get_height);
  496. VCALL_PTR0R(Image,empty);
  497. VCALL_PTR3R(Image,get_pixel);
  498. VCALL_PTR4(Image, put_pixel);
  499. VCALL_PTR0R(Image,get_used_rect);
  500. VCALL_PTR3R(Image,brushed);
  501. VCALL_PTR1R(Image,load);
  502. VCALL_PTR1R(Image,save_png);
  503. VCALL_PTR3(Image,brush_transfer);
  504. VCALL_PTR1R(Image,get_rect);
  505. VCALL_PTR1R(Image,compressed);
  506. VCALL_PTR0R(Image,decompressed);
  507. VCALL_PTR3R(Image, resized);
  508. VCALL_PTR0R(Image, get_data);
  509. VCALL_PTR3(Image, blit_rect);
  510. VCALL_PTR1R(Image, converted);
  511. VCALL_PTR0R( AABB, get_area );
  512. VCALL_PTR0R( AABB, has_no_area );
  513. VCALL_PTR0R( AABB, has_no_surface );
  514. VCALL_PTR1R( AABB, intersects );
  515. VCALL_PTR1R( AABB, encloses );
  516. VCALL_PTR1R( AABB, merge );
  517. VCALL_PTR1R( AABB, intersection );
  518. VCALL_PTR1R( AABB, intersects_plane );
  519. VCALL_PTR2R( AABB, intersects_segment );
  520. VCALL_PTR1R( AABB, has_point );
  521. VCALL_PTR1R( AABB, get_support );
  522. VCALL_PTR0R( AABB, get_longest_axis );
  523. VCALL_PTR0R( AABB, get_longest_axis_index );
  524. VCALL_PTR0R( AABB, get_longest_axis_size );
  525. VCALL_PTR0R( AABB, get_shortest_axis );
  526. VCALL_PTR0R( AABB, get_shortest_axis_index );
  527. VCALL_PTR0R( AABB, get_shortest_axis_size );
  528. VCALL_PTR1R( AABB, expand );
  529. VCALL_PTR1R( AABB, grow );
  530. VCALL_PTR1R( AABB, get_endpoint );
  531. VCALL_PTR0R( Matrix32, inverse );
  532. VCALL_PTR0R( Matrix32, affine_inverse );
  533. VCALL_PTR0R( Matrix32, get_rotation );
  534. VCALL_PTR0R( Matrix32, get_origin );
  535. VCALL_PTR0R( Matrix32, get_scale );
  536. VCALL_PTR0R( Matrix32, orthonormalized );
  537. VCALL_PTR1R( Matrix32, rotated );
  538. VCALL_PTR1R( Matrix32, scaled );
  539. VCALL_PTR1R( Matrix32, translated );
  540. VCALL_PTR2R( Matrix32, interpolate_with );
  541. static void _call_Matrix32_xform(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  542. switch(p_args[0]->type) {
  543. case Variant::VECTOR2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->xform( p_args[0]->operator Vector2()); return;
  544. case Variant::RECT2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->xform( p_args[0]->operator Rect2()); return;
  545. default: r_ret=Variant();
  546. }
  547. }
  548. static void _call_Matrix32_xform_inv(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  549. switch(p_args[0]->type) {
  550. case Variant::VECTOR2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->xform_inv( p_args[0]->operator Vector2()); return;
  551. case Variant::RECT2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->xform_inv( p_args[0]->operator Rect2()); return;
  552. default: r_ret=Variant();
  553. }
  554. }
  555. static void _call_Matrix32_basis_xform(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  556. switch(p_args[0]->type) {
  557. case Variant::VECTOR2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->basis_xform( p_args[0]->operator Vector2()); return;
  558. default: r_ret=Variant();
  559. }
  560. }
  561. static void _call_Matrix32_basis_xform_inv(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  562. switch(p_args[0]->type) {
  563. case Variant::VECTOR2: r_ret=reinterpret_cast<Matrix32*>(p_self._data._ptr)->basis_xform_inv( p_args[0]->operator Vector2()); return;
  564. default: r_ret=Variant();
  565. }
  566. }
  567. VCALL_PTR0R( Matrix3, inverse );
  568. VCALL_PTR0R( Matrix3, transposed );
  569. VCALL_PTR0R( Matrix3, determinant );
  570. VCALL_PTR2R( Matrix3, rotated );
  571. VCALL_PTR1R( Matrix3, scaled );
  572. VCALL_PTR0R( Matrix3, get_scale );
  573. VCALL_PTR0R( Matrix3, get_euler );
  574. VCALL_PTR1R( Matrix3, tdotx );
  575. VCALL_PTR1R( Matrix3, tdoty );
  576. VCALL_PTR1R( Matrix3, tdotz );
  577. VCALL_PTR1R( Matrix3, xform );
  578. VCALL_PTR1R( Matrix3, xform_inv );
  579. VCALL_PTR0R( Matrix3, get_orthogonal_index );
  580. VCALL_PTR0R( Matrix3, orthonormalized );
  581. VCALL_PTR0R( Transform, inverse );
  582. VCALL_PTR0R( Transform, affine_inverse );
  583. VCALL_PTR2R( Transform, rotated );
  584. VCALL_PTR1R( Transform, scaled );
  585. VCALL_PTR1R( Transform, translated );
  586. VCALL_PTR0R( Transform, orthonormalized );
  587. VCALL_PTR2R( Transform, looking_at );
  588. static void _call_Transform_xform(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  589. switch(p_args[0]->type) {
  590. case Variant::VECTOR3: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform( p_args[0]->operator Vector3()); return;
  591. case Variant::PLANE: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform( p_args[0]->operator Plane()); return;
  592. case Variant::_AABB: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform( p_args[0]->operator AABB()); return;
  593. default: r_ret=Variant();
  594. }
  595. }
  596. static void _call_Transform_xform_inv(Variant& r_ret,Variant& p_self,const Variant** p_args) {
  597. switch(p_args[0]->type) {
  598. case Variant::VECTOR3: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform_inv( p_args[0]->operator Vector3()); return;
  599. case Variant::PLANE: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform_inv( p_args[0]->operator Plane()); return;
  600. case Variant::_AABB: r_ret=reinterpret_cast<Transform*>(p_self._data._ptr)->xform_inv( p_args[0]->operator AABB()); return;
  601. default: r_ret=Variant();
  602. }
  603. }
  604. /*
  605. VCALL_PTR0( Transform, invert );
  606. VCALL_PTR0( Transform, affine_invert );
  607. VCALL_PTR2( Transform, rotate );
  608. VCALL_PTR1( Transform, scale );
  609. VCALL_PTR1( Transform, translate );
  610. VCALL_PTR0( Transform, orthonormalize ); */
  611. VCALL_PTR0R( InputEvent, is_pressed );
  612. VCALL_PTR1R( InputEvent, is_action );
  613. VCALL_PTR1R( InputEvent, is_action_pressed );
  614. VCALL_PTR1R( InputEvent, is_action_released );
  615. VCALL_PTR0R( InputEvent, is_echo );
  616. VCALL_PTR2( InputEvent, set_as_action );
  617. struct ConstructData {
  618. int arg_count;
  619. Vector<Variant::Type> arg_types;
  620. Vector<String> arg_names;
  621. VariantConstructFunc func;
  622. };
  623. struct ConstructFunc {
  624. List<ConstructData> constructors;
  625. };
  626. static ConstructFunc* construct_funcs;
  627. static void Vector2_init1(Variant& r_ret,const Variant** p_args) {
  628. r_ret=Vector2(*p_args[0],*p_args[1]);
  629. }
  630. static void Rect2_init1(Variant& r_ret,const Variant** p_args) {
  631. r_ret=Rect2(*p_args[0],*p_args[1]);
  632. }
  633. static void Rect2_init2(Variant& r_ret,const Variant** p_args) {
  634. r_ret=Rect2(*p_args[0],*p_args[1],*p_args[2],*p_args[3]);
  635. }
  636. static void Matrix32_init2(Variant& r_ret,const Variant** p_args) {
  637. Matrix32 m(*p_args[0], *p_args[1]);
  638. r_ret=m;
  639. }
  640. static void Matrix32_init3(Variant& r_ret,const Variant** p_args) {
  641. Matrix32 m;
  642. m[0]=*p_args[0];
  643. m[1]=*p_args[1];
  644. m[2]=*p_args[2];
  645. r_ret=m;
  646. }
  647. static void Vector3_init1(Variant& r_ret,const Variant** p_args) {
  648. r_ret=Vector3(*p_args[0],*p_args[1],*p_args[2]);
  649. }
  650. static void Plane_init1(Variant& r_ret,const Variant** p_args) {
  651. r_ret=Plane(*p_args[0],*p_args[1],*p_args[2],*p_args[3]);
  652. }
  653. static void Plane_init2(Variant& r_ret,const Variant** p_args) {
  654. r_ret=Plane(*p_args[0],*p_args[1],*p_args[2]);
  655. }
  656. static void Plane_init3(Variant& r_ret,const Variant** p_args) {
  657. r_ret=Plane(p_args[0]->operator Vector3(),p_args[1]->operator real_t());
  658. }
  659. static void Plane_init4(Variant& r_ret,const Variant** p_args) {
  660. r_ret=Plane(p_args[0]->operator Vector3(),p_args[1]->operator Vector3());
  661. }
  662. static void Quat_init1(Variant& r_ret,const Variant** p_args) {
  663. r_ret=Quat(*p_args[0],*p_args[1],*p_args[2],*p_args[3]);
  664. }
  665. static void Quat_init2(Variant& r_ret,const Variant** p_args) {
  666. r_ret=Quat(((Vector3)(*p_args[0])),((float)(*p_args[1])));
  667. }
  668. static void Color_init1(Variant& r_ret,const Variant** p_args) {
  669. r_ret=Color(*p_args[0],*p_args[1],*p_args[2],*p_args[3]);
  670. }
  671. static void Color_init2(Variant& r_ret,const Variant** p_args) {
  672. r_ret=Color(*p_args[0],*p_args[1],*p_args[2]);
  673. }
  674. static void Color_init3(Variant& r_ret,const Variant** p_args) {
  675. r_ret=Color::html(*p_args[0]);
  676. }
  677. static void Color_init4(Variant& r_ret,const Variant** p_args) {
  678. r_ret=Color::hex(*p_args[0]);
  679. }
  680. static void AABB_init1(Variant& r_ret,const Variant** p_args) {
  681. r_ret=AABB(*p_args[0],*p_args[1]);
  682. }
  683. static void Matrix3_init1(Variant& r_ret,const Variant** p_args) {
  684. Matrix3 m;
  685. m.set_axis(0,*p_args[0]);
  686. m.set_axis(1,*p_args[1]);
  687. m.set_axis(2,*p_args[2]);
  688. r_ret=m;
  689. }
  690. static void Matrix3_init2(Variant& r_ret,const Variant** p_args) {
  691. r_ret=Matrix3(p_args[0]->operator Vector3(),p_args[1]->operator real_t());
  692. }
  693. static void Transform_init1(Variant& r_ret,const Variant** p_args) {
  694. Transform t;
  695. t.basis.set_axis(0,*p_args[0]);
  696. t.basis.set_axis(1,*p_args[1]);
  697. t.basis.set_axis(2,*p_args[2]);
  698. t.origin=*p_args[3];
  699. r_ret=t;
  700. }
  701. static void Transform_init2(Variant& r_ret,const Variant** p_args) {
  702. r_ret=Transform(p_args[0]->operator Matrix3(),p_args[1]->operator Vector3());
  703. }
  704. static void Image_init1(Variant& r_ret, const Variant** p_args) {
  705. r_ret=Image(*p_args[0],*p_args[1],*p_args[2],Image::Format(p_args[3]->operator int()));
  706. }
  707. static void add_constructor(VariantConstructFunc p_func,const Variant::Type p_type,
  708. const String& p_name1="", const Variant::Type p_type1=Variant::NIL,
  709. const String& p_name2="", const Variant::Type p_type2=Variant::NIL,
  710. const String& p_name3="", const Variant::Type p_type3=Variant::NIL,
  711. const String& p_name4="", const Variant::Type p_type4=Variant::NIL ) {
  712. ConstructData cd;
  713. cd.func=p_func;
  714. cd.arg_count=0;
  715. if (p_name1=="")
  716. goto end;
  717. cd.arg_count++;
  718. cd.arg_names.push_back(p_name1);
  719. cd.arg_types.push_back(p_type1);
  720. if (p_name2=="")
  721. goto end;
  722. cd.arg_count++;
  723. cd.arg_names.push_back(p_name2);
  724. cd.arg_types.push_back(p_type2);
  725. if (p_name3=="")
  726. goto end;
  727. cd.arg_count++;
  728. cd.arg_names.push_back(p_name3);
  729. cd.arg_types.push_back(p_type3);
  730. if (p_name4=="")
  731. goto end;
  732. cd.arg_count++;
  733. cd.arg_names.push_back(p_name4);
  734. cd.arg_types.push_back(p_type4);
  735. end:
  736. construct_funcs[p_type].constructors.push_back(cd);
  737. }
  738. struct ConstantData {
  739. Map<StringName,int> value;
  740. };
  741. static ConstantData* constant_data;
  742. };
  743. _VariantCall::TypeFunc* _VariantCall::type_funcs=NULL;
  744. _VariantCall::ConstructFunc* _VariantCall::construct_funcs=NULL;
  745. _VariantCall::ConstantData* _VariantCall::constant_data=NULL;
  746. Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error) {
  747. Variant ret;
  748. if (type==Variant::OBJECT) {
  749. //call object
  750. Object *obj = _get_obj().obj;
  751. if (!obj) {
  752. r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
  753. return ret;
  754. }
  755. #ifdef DEBUG_ENABLED
  756. if (ScriptDebugger::get_singleton() && _get_obj().ref.is_null()) {
  757. //only if debugging!
  758. if (!ObjectDB::instance_validate(obj)) {
  759. r_error.error=CallError::CALL_ERROR_INSTANCE_IS_NULL;
  760. return ret;
  761. }
  762. }
  763. #endif
  764. return _get_obj().obj->call(p_method,p_args,p_argcount,r_error);
  765. //else if (type==Variant::METHOD) {
  766. } else {
  767. r_error.error=Variant::CallError::CALL_OK;
  768. Map<StringName,_VariantCall::FuncData>::Element *E=_VariantCall::type_funcs[type].functions.find(p_method);
  769. #ifdef DEBUG_ENABLED
  770. if (!E) {
  771. r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
  772. return Variant();
  773. }
  774. #endif
  775. _VariantCall::FuncData& funcdata = E->get();
  776. funcdata.call(ret,*this,p_args,p_argcount,r_error);
  777. }
  778. return ret;
  779. }
  780. #define VCALL(m_type,m_method) _VariantCall::_call_##m_type##_##m_method
  781. Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, int p_argcount, CallError &r_error, bool p_strict) {
  782. r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
  783. ERR_FAIL_INDEX_V(p_type,VARIANT_MAX,Variant());
  784. r_error.error=Variant::CallError::CALL_OK;
  785. if (p_argcount==0) { //generic construct
  786. switch(p_type) {
  787. case NIL: return Variant();
  788. // atomic types
  789. case BOOL: return Variant( false );
  790. case INT: return 0;
  791. case REAL: return 0.0f;
  792. case STRING: return String();
  793. // math types
  794. case VECTOR2: return Vector2(); // 5
  795. case RECT2: return Rect2();
  796. case VECTOR3: return Vector3();
  797. case MATRIX32: return Matrix32();
  798. case PLANE: return Plane();
  799. case QUAT: return Quat();
  800. case _AABB: return AABB(); //sorry naming convention fail :( not like it's used often // 10
  801. case MATRIX3: return Matrix3();
  802. case TRANSFORM: return Transform();
  803. // misc types
  804. case COLOR: return Color();
  805. case IMAGE: return Image();;
  806. case NODE_PATH: return NodePath();; // 15
  807. case _RID: return RID();;
  808. case OBJECT: return (Object*)NULL;
  809. case INPUT_EVENT: return InputEvent();;
  810. case DICTIONARY: return Dictionary();;
  811. case ARRAY: return Array();; // 20
  812. case RAW_ARRAY: return ByteArray();;
  813. case INT_ARRAY: return IntArray();;
  814. case REAL_ARRAY: return RealArray();;
  815. case STRING_ARRAY: return StringArray();;
  816. case VECTOR2_ARRAY: return Vector2Array();; // 25
  817. case VECTOR3_ARRAY: return Vector3Array();; // 25
  818. case COLOR_ARRAY: return ColorArray();;
  819. default: return Variant();
  820. }
  821. } else if (p_argcount>1) {
  822. _VariantCall::ConstructFunc & c = _VariantCall::construct_funcs[p_type];
  823. for(List<_VariantCall::ConstructData>::Element *E=c.constructors.front();E;E=E->next()) {
  824. const _VariantCall::ConstructData &cd = E->get();
  825. if (cd.arg_count!=p_argcount)
  826. continue;
  827. //validate parameters
  828. for(int i=0;i<cd.arg_count;i++) {
  829. if (!Variant::can_convert(p_args[i]->type,cd.arg_types[i])) {
  830. r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor
  831. r_error.argument=i;
  832. r_error.expected=cd.arg_types[i];
  833. return Variant();
  834. }
  835. }
  836. Variant v;
  837. cd.func(v,p_args);
  838. return v;
  839. }
  840. } else if (p_argcount==1 && p_args[0]->type==p_type) {
  841. return *p_args[0]; //copy construct
  842. } else if (p_argcount==1 && (!p_strict || Variant::can_convert(p_args[0]->type,p_type))) {
  843. //near match construct
  844. switch(p_type) {
  845. case NIL: {
  846. return Variant();
  847. } break;
  848. case BOOL: { return Variant(bool(*p_args[0])); }
  849. case INT: { return (int(*p_args[0])); }
  850. case REAL: { return real_t(*p_args[0]); }
  851. case STRING: { return String(*p_args[0]); }
  852. case VECTOR2: { return Vector2(*p_args[0]); }
  853. case RECT2: return (Rect2(*p_args[0]));
  854. case VECTOR3: return (Vector3(*p_args[0]));
  855. case PLANE: return (Plane(*p_args[0]));
  856. case QUAT: return (Quat(*p_args[0]));
  857. case _AABB: return (AABB(*p_args[0])); //sorry naming convention fail :( not like it's used often // 10
  858. case MATRIX3: return (Matrix3(p_args[0]->operator Matrix3()));
  859. case TRANSFORM: return (Transform(p_args[0]->operator Transform()));
  860. // misc types
  861. case COLOR: return p_args[0]->type == Variant::STRING ? Color::html(*p_args[0]) : Color::hex(*p_args[0]);
  862. case IMAGE: return (Image(*p_args[0]));
  863. case NODE_PATH: return (NodePath(p_args[0]->operator NodePath())); // 15
  864. case _RID: return (RID(*p_args[0]));
  865. case OBJECT: return ((Object*)(p_args[0]->operator Object *()));
  866. case INPUT_EVENT: return (InputEvent(*p_args[0]));
  867. case DICTIONARY: return p_args[0]->operator Dictionary();
  868. case ARRAY: return p_args[0]->operator Array();
  869. // arrays
  870. case RAW_ARRAY: return (ByteArray(*p_args[0]));
  871. case INT_ARRAY: return (IntArray(*p_args[0]));
  872. case REAL_ARRAY: return (RealArray(*p_args[0]));
  873. case STRING_ARRAY: return (StringArray(*p_args[0]));
  874. case VECTOR2_ARRAY: return (Vector2Array(*p_args[0])); // 25
  875. case VECTOR3_ARRAY: return (Vector3Array(*p_args[0])); // 25
  876. case COLOR_ARRAY: return (ColorArray(*p_args[0]));
  877. default: return Variant();
  878. }
  879. }
  880. r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor
  881. return Variant();
  882. }
  883. bool Variant::has_method(const StringName& p_method) const {
  884. if (type==OBJECT) {
  885. Object *obj = operator Object*();
  886. if (!obj)
  887. return false;
  888. #ifdef DEBUG_ENABLED
  889. if (ScriptDebugger::get_singleton()) {
  890. if (ObjectDB::instance_validate(obj)) {
  891. #endif
  892. return obj->has_method(p_method);
  893. #ifdef DEBUG_ENABLED
  894. }
  895. }
  896. #endif
  897. }
  898. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[type];
  899. return fd.functions.has(p_method);
  900. }
  901. void Variant::get_method_list(List<MethodInfo> *p_list) const {
  902. const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[type];
  903. for (const Map<StringName,_VariantCall::FuncData>::Element *E=fd.functions.front();E;E=E->next()) {
  904. const _VariantCall::FuncData &fd = E->get();
  905. MethodInfo mi;
  906. mi.name=E->key();
  907. for(int i=0;i<fd.arg_types.size();i++) {
  908. PropertyInfo pi;
  909. pi.type=fd.arg_types[i];
  910. #ifdef DEBUG_ENABLED
  911. pi.name=fd.arg_names[i];
  912. #endif
  913. mi.arguments.push_back(pi);
  914. }
  915. mi.default_arguments=fd.default_args;
  916. PropertyInfo ret;
  917. #ifdef DEBUG_ENABLED
  918. ret.type=fd.return_type;
  919. if (fd.returns)
  920. ret.name="ret";
  921. mi.return_val=ret;
  922. #endif
  923. p_list->push_back(mi);
  924. }
  925. }
  926. void Variant::get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list) {
  927. ERR_FAIL_INDEX(p_type,VARIANT_MAX);
  928. //custom constructors
  929. for(const List<_VariantCall::ConstructData>::Element *E=_VariantCall::construct_funcs[p_type].constructors.front();E;E=E->next()) {
  930. const _VariantCall::ConstructData &cd = E->get();
  931. MethodInfo mi;
  932. mi.name=Variant::get_type_name(p_type);
  933. mi.return_val.type=p_type;
  934. for(int i=0;i<cd.arg_count;i++) {
  935. PropertyInfo pi;
  936. pi.name=cd.arg_names[i];
  937. pi.type=cd.arg_types[i];
  938. mi.arguments.push_back(pi);
  939. }
  940. p_list->push_back(mi);
  941. }
  942. //default constructors
  943. for(int i=0;i<VARIANT_MAX;i++) {
  944. if (i==p_type)
  945. continue;
  946. if (!Variant::can_convert(Variant::Type(i),p_type))
  947. continue;
  948. MethodInfo mi;
  949. mi.name=Variant::get_type_name(p_type);
  950. PropertyInfo pi;
  951. pi.name="from";
  952. pi.type=Variant::Type(i);
  953. mi.arguments.push_back(pi);
  954. mi.return_val.type=p_type;
  955. p_list->push_back(mi);
  956. }
  957. }
  958. void Variant::get_numeric_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) {
  959. ERR_FAIL_INDEX(p_type,Variant::VARIANT_MAX);
  960. _VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
  961. for(Map<StringName,int>::Element *E=cd.value.front();E;E=E->next()) {
  962. p_constants->push_back(E->key());
  963. }
  964. }
  965. bool Variant::has_numeric_constant(Variant::Type p_type, const StringName& p_value) {
  966. ERR_FAIL_INDEX_V(p_type,Variant::VARIANT_MAX,false);
  967. _VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
  968. return cd.value.has(p_value);
  969. }
  970. int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value) {
  971. ERR_FAIL_INDEX_V(p_type,Variant::VARIANT_MAX,0);
  972. _VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
  973. Map<StringName,int>::Element *E = cd.value.find(p_value);
  974. ERR_FAIL_COND_V(!E,0);
  975. return E->get();
  976. }
  977. void register_variant_methods() {
  978. _VariantCall::type_funcs = memnew_arr(_VariantCall::TypeFunc,Variant::VARIANT_MAX );
  979. _VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc,Variant::VARIANT_MAX );
  980. _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
  981. #define ADDFUNC0(m_vtype,m_ret,m_class,m_method,m_defarg)\
  982. _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg);
  983. #define ADDFUNC1(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_defarg)\
  984. _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)) );
  985. #define ADDFUNC2(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_arg2,m_argname2,m_defarg)\
  986. _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)));
  987. #define ADDFUNC3(m_vtype,m_ret,m_class,m_method,m_arg1,m_argname1,m_arg2,m_argname2,m_arg3,m_argname3,m_defarg)\
  988. _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_SCS(m_argname3)));
  989. #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)\
  990. _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_class,m_method),m_defarg,_VariantCall::Arg(Variant::m_arg1,_SCS(m_argname1)),_VariantCall::Arg(Variant::m_arg2,_SCS(m_argname2)),_VariantCall::Arg(Variant::m_arg3,_SCS(m_argname3)),_VariantCall::Arg(Variant::m_arg4,_SCS(m_argname4)));
  991. /* STRING */
  992. ADDFUNC1(STRING,INT,String,casecmp_to,STRING,"to",varray());
  993. ADDFUNC1(STRING,INT,String,nocasecmp_to,STRING,"to",varray());
  994. ADDFUNC0(STRING,INT,String,length,varray());
  995. ADDFUNC2(STRING,STRING,String,substr,INT,"from",INT,"len",varray());
  996. ADDFUNC2(STRING,INT,String,find,STRING,"what",INT,"from",varray(0));
  997. ADDFUNC1(STRING,INT,String,find_last,STRING,"what",varray());
  998. ADDFUNC2(STRING,INT,String,findn,STRING,"what",INT,"from",varray(0));
  999. ADDFUNC2(STRING,INT,String,rfind,STRING,"what",INT,"from",varray(-1));
  1000. ADDFUNC2(STRING,INT,String,rfindn,STRING,"what",INT,"from",varray(-1));
  1001. ADDFUNC1(STRING,BOOL,String,match,STRING,"expr",varray());
  1002. ADDFUNC1(STRING,BOOL,String,matchn,STRING,"expr",varray());
  1003. ADDFUNC1(STRING,BOOL,String,begins_with,STRING,"text",varray());
  1004. ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray());
  1005. ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray());
  1006. ADDFUNC2(STRING,STRING,String,insert,INT,"pos",STRING,"what",varray());
  1007. ADDFUNC0(STRING,STRING,String,capitalize,varray());
  1008. ADDFUNC2(STRING,STRING_ARRAY,String,split,STRING,"divisor",BOOL,"allow_empty",varray(true));
  1009. ADDFUNC2(STRING,REAL_ARRAY,String,split_floats,STRING,"divisor",BOOL,"allow_empty",varray(true));
  1010. ADDFUNC0(STRING,STRING,String,to_upper,varray());
  1011. ADDFUNC0(STRING,STRING,String,to_lower,varray());
  1012. ADDFUNC1(STRING,STRING,String,left,INT,"pos",varray());
  1013. ADDFUNC1(STRING,STRING,String,right,INT,"pos",varray());
  1014. ADDFUNC0(STRING,STRING,String,strip_edges,varray());
  1015. ADDFUNC0(STRING,STRING,String,extension,varray());
  1016. ADDFUNC0(STRING,STRING,String,basename,varray());
  1017. ADDFUNC1(STRING,STRING,String,plus_file,STRING,"file",varray());
  1018. ADDFUNC1(STRING,STRING,String,ord_at,INT,"at",varray());
  1019. // ADDFUNC2(STRING,String,erase,INT,INT,varray());
  1020. ADDFUNC0(STRING,INT,String,hash,varray());
  1021. ADDFUNC0(STRING,STRING,String,md5_text,varray());
  1022. ADDFUNC0(STRING,RAW_ARRAY,String,md5_buffer,varray());
  1023. ADDFUNC0(STRING,BOOL,String,empty,varray());
  1024. ADDFUNC0(STRING,BOOL,String,is_abs_path,varray());
  1025. ADDFUNC0(STRING,BOOL,String,is_rel_path,varray());
  1026. ADDFUNC0(STRING,STRING,String,get_base_dir,varray());
  1027. ADDFUNC0(STRING,STRING,String,get_file,varray());
  1028. ADDFUNC0(STRING,STRING,String,xml_escape,varray());
  1029. ADDFUNC0(STRING,STRING,String,xml_unescape,varray());
  1030. ADDFUNC0(STRING,STRING,String,c_escape,varray());
  1031. ADDFUNC0(STRING,STRING,String,c_unescape,varray());
  1032. ADDFUNC0(STRING,STRING,String,json_escape,varray());
  1033. ADDFUNC0(STRING,STRING,String,percent_encode,varray());
  1034. ADDFUNC0(STRING,STRING,String,percent_decode,varray());
  1035. ADDFUNC0(STRING,BOOL,String,is_valid_identifier,varray());
  1036. ADDFUNC0(STRING,BOOL,String,is_valid_integer,varray());
  1037. ADDFUNC0(STRING,BOOL,String,is_valid_float,varray());
  1038. ADDFUNC0(STRING,BOOL,String,is_valid_html_color,varray());
  1039. ADDFUNC0(STRING,BOOL,String,is_valid_ip_address,varray());
  1040. ADDFUNC0(STRING,INT,String,to_int,varray());
  1041. ADDFUNC0(STRING,REAL,String,to_float,varray());
  1042. ADDFUNC0(STRING,INT,String,hex_to_int,varray());
  1043. ADDFUNC1(STRING,STRING,String,pad_decimals,INT,"digits",varray());
  1044. ADDFUNC1(STRING,STRING,String,pad_zeros,INT,"digits",varray());
  1045. ADDFUNC0(STRING,RAW_ARRAY,String,to_ascii,varray());
  1046. ADDFUNC0(STRING,RAW_ARRAY,String,to_utf8,varray());
  1047. ADDFUNC0(VECTOR2,VECTOR2,Vector2,normalized,varray());
  1048. ADDFUNC0(VECTOR2,REAL,Vector2,length,varray());
  1049. ADDFUNC0(VECTOR2,REAL,Vector2,angle,varray());
  1050. ADDFUNC0(VECTOR2,REAL,Vector2,length_squared,varray());
  1051. ADDFUNC1(VECTOR2,REAL,Vector2,distance_to,VECTOR2,"to",varray());
  1052. ADDFUNC1(VECTOR2,REAL,Vector2,distance_squared_to,VECTOR2,"to",varray());
  1053. ADDFUNC1(VECTOR2,REAL,Vector2,angle_to,VECTOR2,"to",varray());
  1054. ADDFUNC1(VECTOR2,REAL,Vector2,angle_to_point,VECTOR2,"to",varray());
  1055. ADDFUNC2(VECTOR2,VECTOR2,Vector2,linear_interpolate,VECTOR2,"b",REAL,"t",varray());
  1056. ADDFUNC4(VECTOR2,VECTOR2,Vector2,cubic_interpolate,VECTOR2,"b",VECTOR2,"pre_a",VECTOR2,"post_b",REAL,"t",varray());
  1057. ADDFUNC1(VECTOR2,VECTOR2,Vector2,rotated,REAL,"phi",varray());
  1058. ADDFUNC0(VECTOR2,VECTOR2,Vector2,tangent,varray());
  1059. ADDFUNC0(VECTOR2,VECTOR2,Vector2,floor,varray());
  1060. ADDFUNC0(VECTOR2,VECTOR2,Vector2,floorf,varray());
  1061. ADDFUNC1(VECTOR2,VECTOR2,Vector2,snapped,VECTOR2,"by",varray());
  1062. ADDFUNC0(VECTOR2,REAL,Vector2,get_aspect,varray());
  1063. ADDFUNC1(VECTOR2,REAL,Vector2,dot,VECTOR2,"with",varray());
  1064. ADDFUNC1(VECTOR2,VECTOR2,Vector2,slide,VECTOR2,"vec",varray());
  1065. ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray());
  1066. //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
  1067. ADDFUNC0(RECT2,REAL,Rect2,get_area,varray());
  1068. ADDFUNC1(RECT2,BOOL,Rect2,intersects,RECT2,"b",varray());
  1069. ADDFUNC1(RECT2,BOOL,Rect2,encloses,RECT2,"b",varray());
  1070. ADDFUNC0(RECT2,BOOL,Rect2,has_no_area,varray());
  1071. ADDFUNC1(RECT2,RECT2,Rect2,clip,RECT2,"b",varray());
  1072. ADDFUNC1(RECT2,RECT2,Rect2,merge,RECT2,"b",varray());
  1073. ADDFUNC1(RECT2,BOOL,Rect2,has_point,VECTOR2,"point",varray());
  1074. ADDFUNC1(RECT2,RECT2,Rect2,grow,REAL,"by",varray());
  1075. ADDFUNC1(RECT2,RECT2,Rect2,expand,VECTOR2,"to",varray());
  1076. ADDFUNC0(VECTOR3,INT,Vector3,min_axis,varray());
  1077. ADDFUNC0(VECTOR3,INT,Vector3,max_axis,varray());
  1078. ADDFUNC0(VECTOR3,REAL,Vector3,length,varray());
  1079. ADDFUNC0(VECTOR3,REAL,Vector3,length_squared,varray());
  1080. ADDFUNC0(VECTOR3,VECTOR3,Vector3,normalized,varray());
  1081. ADDFUNC0(VECTOR3,VECTOR3,Vector3,inverse,varray());
  1082. ADDFUNC1(VECTOR3,VECTOR3,Vector3,snapped,REAL,"by",varray());
  1083. ADDFUNC2(VECTOR3,VECTOR3,Vector3,rotated,VECTOR3,"axis",REAL,"phi",varray());
  1084. ADDFUNC2(VECTOR3,VECTOR3,Vector3,linear_interpolate,VECTOR3,"b",REAL,"t",varray());
  1085. ADDFUNC4(VECTOR3,VECTOR3,Vector3,cubic_interpolate,VECTOR3,"b",VECTOR3,"pre_a",VECTOR3,"post_b",REAL,"t",varray());
  1086. ADDFUNC1(VECTOR3,REAL,Vector3,dot,VECTOR3,"b",varray());
  1087. ADDFUNC1(VECTOR3,VECTOR3,Vector3,cross,VECTOR3,"b",varray());
  1088. ADDFUNC0(VECTOR3,VECTOR3,Vector3,abs,varray());
  1089. ADDFUNC0(VECTOR3,VECTOR3,Vector3,floor,varray());
  1090. ADDFUNC0(VECTOR3,VECTOR3,Vector3,ceil,varray());
  1091. ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray());
  1092. ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray());
  1093. ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray());
  1094. ADDFUNC1(VECTOR3,VECTOR3,Vector3,reflect,VECTOR3,"by",varray());
  1095. ADDFUNC0(PLANE,PLANE,Plane,normalized,varray());
  1096. ADDFUNC0(PLANE,VECTOR3,Plane,center,varray());
  1097. ADDFUNC0(PLANE,VECTOR3,Plane,get_any_point,varray());
  1098. ADDFUNC1(PLANE,BOOL,Plane,is_point_over,VECTOR3,"point",varray());
  1099. ADDFUNC1(PLANE,REAL,Plane,distance_to,VECTOR3,"point",varray());
  1100. ADDFUNC2(PLANE,BOOL,Plane,has_point,VECTOR3,"point",REAL,"epsilon",varray(CMP_EPSILON));
  1101. ADDFUNC1(PLANE,VECTOR3,Plane,project,VECTOR3,"point",varray());
  1102. ADDFUNC2(PLANE,VECTOR3,Plane,intersect_3,PLANE,"b",PLANE,"c",varray());
  1103. ADDFUNC2(PLANE,VECTOR3,Plane,intersects_ray,VECTOR3,"from",VECTOR3,"dir",varray());
  1104. ADDFUNC2(PLANE,VECTOR3,Plane,intersects_segment,VECTOR3,"begin",VECTOR3,"end",varray());
  1105. ADDFUNC0(QUAT,REAL,Quat,length,varray());
  1106. ADDFUNC0(QUAT,REAL,Quat,length_squared,varray());
  1107. ADDFUNC0(QUAT,QUAT,Quat,normalized,varray());
  1108. ADDFUNC0(QUAT,QUAT,Quat,inverse,varray());
  1109. ADDFUNC1(QUAT,REAL,Quat,dot,QUAT,"b",varray());
  1110. ADDFUNC1(QUAT,VECTOR3,Quat,xform,VECTOR3,"v",varray());
  1111. ADDFUNC2(QUAT,QUAT,Quat,slerp,QUAT,"b",REAL,"t",varray());
  1112. ADDFUNC2(QUAT,QUAT,Quat,slerpni,QUAT,"b",REAL,"t",varray());
  1113. ADDFUNC4(QUAT,QUAT,Quat,cubic_slerp,QUAT,"b",QUAT,"pre_a",QUAT,"post_b",REAL,"t",varray());
  1114. ADDFUNC0(COLOR,INT,Color,to_32,varray());
  1115. ADDFUNC0(COLOR,INT,Color,to_ARGB32,varray());
  1116. ADDFUNC0(COLOR,REAL,Color,gray,varray());
  1117. ADDFUNC0(COLOR,COLOR,Color,inverted,varray());
  1118. ADDFUNC0(COLOR,COLOR,Color,contrasted,varray());
  1119. ADDFUNC2(COLOR,COLOR,Color,linear_interpolate,COLOR,"b",REAL,"t",varray());
  1120. ADDFUNC1(COLOR,COLOR,Color,blend,COLOR,"over",varray());
  1121. ADDFUNC1(COLOR,STRING,Color,to_html,BOOL,"with_alpha",varray(true));
  1122. ADDFUNC0(IMAGE, INT, Image, get_format, varray());
  1123. ADDFUNC0(IMAGE, INT, Image, get_width, varray());
  1124. ADDFUNC0(IMAGE, INT, Image, get_height, varray());
  1125. ADDFUNC0(IMAGE, BOOL, Image, empty, varray());
  1126. ADDFUNC3(IMAGE, COLOR, Image, get_pixel, INT, "x", INT, "y", INT, "mipmap_level", varray(0));
  1127. ADDFUNC4(IMAGE, NIL, Image, put_pixel, INT, "x", INT, "y", COLOR, "color", INT, "mipmap_level", varray(0));
  1128. ADDFUNC3(IMAGE, IMAGE, Image, brushed, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
  1129. ADDFUNC1(IMAGE, INT, Image, load, STRING, "path", varray(0));
  1130. ADDFUNC1(IMAGE, INT, Image, save_png, STRING, "path", varray(0));
  1131. ADDFUNC3(IMAGE, NIL, Image, brush_transfer, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
  1132. ADDFUNC0(IMAGE, RECT2, Image, get_used_rect, varray(0));
  1133. ADDFUNC1(IMAGE, IMAGE, Image, get_rect, RECT2, "area", varray(0));
  1134. ADDFUNC1(IMAGE, IMAGE, Image, compressed, INT, "format", varray(0));
  1135. ADDFUNC0(IMAGE, IMAGE, Image, decompressed, varray(0));
  1136. ADDFUNC3(IMAGE, IMAGE, Image, resized, INT, "x", INT, "y", INT, "interpolation", varray(((int)Image::INTERPOLATE_BILINEAR)));
  1137. ADDFUNC0(IMAGE, RAW_ARRAY, Image, get_data, varray());
  1138. ADDFUNC3(IMAGE, NIL, Image, blit_rect, IMAGE, "src", RECT2, "src_rect", VECTOR2, "dest", varray(0));
  1139. ADDFUNC1(IMAGE, IMAGE, Image, converted, INT, "format", varray(0));
  1140. ADDFUNC0(_RID,INT,RID,get_id,varray());
  1141. ADDFUNC0(NODE_PATH,BOOL,NodePath,is_absolute,varray());
  1142. ADDFUNC0(NODE_PATH,INT,NodePath,get_name_count,varray());
  1143. ADDFUNC1(NODE_PATH,STRING,NodePath,get_name,INT,"idx",varray());
  1144. ADDFUNC0(NODE_PATH,INT,NodePath,get_subname_count,varray());
  1145. ADDFUNC1(NODE_PATH,STRING,NodePath,get_subname,INT,"idx",varray());
  1146. ADDFUNC0(NODE_PATH,STRING,NodePath,get_property,varray());
  1147. ADDFUNC0(NODE_PATH,BOOL,NodePath,is_empty,varray());
  1148. ADDFUNC0(DICTIONARY,INT,Dictionary,size,varray());
  1149. ADDFUNC0(DICTIONARY,BOOL,Dictionary,empty,varray());
  1150. ADDFUNC0(DICTIONARY,NIL,Dictionary,clear,varray());
  1151. ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"value",varray());
  1152. ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"values",varray());
  1153. ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
  1154. ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
  1155. ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
  1156. ADDFUNC1(DICTIONARY,INT,Dictionary,parse_json,STRING,"json",varray());
  1157. ADDFUNC0(DICTIONARY,STRING,Dictionary,to_json,varray());
  1158. ADDFUNC0(ARRAY,INT,Array,size,varray());
  1159. ADDFUNC0(ARRAY,BOOL,Array,empty,varray());
  1160. ADDFUNC0(ARRAY,NIL,Array,clear,varray());
  1161. ADDFUNC0(ARRAY,INT,Array,hash,varray());
  1162. ADDFUNC1(ARRAY,NIL,Array,push_back,NIL,"value",varray());
  1163. ADDFUNC1(ARRAY,NIL,Array,push_front,NIL,"value",varray());
  1164. ADDFUNC1(ARRAY,NIL,Array,append,NIL,"value",varray());
  1165. ADDFUNC1(ARRAY,NIL,Array,resize,INT,"pos",varray());
  1166. ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray());
  1167. ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
  1168. ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray());
  1169. ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray());
  1170. ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
  1171. ADDFUNC0(ARRAY,NIL,Array,pop_front,varray());
  1172. ADDFUNC0(ARRAY,NIL,Array,sort,varray());
  1173. ADDFUNC2(ARRAY,NIL,Array,sort_custom,OBJECT,"obj",STRING,"func",varray());
  1174. ADDFUNC0(ARRAY,NIL,Array,invert,varray());
  1175. ADDFUNC0(ARRAY,BOOL,Array,is_shared,varray());
  1176. ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray());
  1177. ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray());
  1178. //ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray());
  1179. ADDFUNC1(RAW_ARRAY,NIL,ByteArray,push_back,INT,"byte",varray());
  1180. ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray());
  1181. ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray());
  1182. ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_utf8,varray());
  1183. ADDFUNC0(INT_ARRAY,INT,IntArray,size,varray());
  1184. ADDFUNC2(INT_ARRAY,NIL,IntArray,set,INT,"idx",INT,"integer",varray());
  1185. //ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray());
  1186. ADDFUNC1(INT_ARRAY,NIL,IntArray,push_back,INT,"integer",varray());
  1187. ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray());
  1188. ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray());
  1189. ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray());
  1190. //ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray());
  1191. ADDFUNC1(REAL_ARRAY,NIL,RealArray,push_back,REAL,"value",varray());
  1192. ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray());
  1193. ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray());
  1194. ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray());
  1195. //ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray());
  1196. ADDFUNC1(STRING_ARRAY,NIL,StringArray,push_back,STRING,"string",varray());
  1197. ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray());
  1198. ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray());
  1199. ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray());
  1200. //ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray());
  1201. ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,push_back,VECTOR2,"vector2",varray());
  1202. ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray());
  1203. ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray());
  1204. ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray());
  1205. //ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray());
  1206. ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,push_back,VECTOR3,"vector3",varray());
  1207. ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray());
  1208. ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray());
  1209. ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray());
  1210. //ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray());
  1211. ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,push_back,COLOR,"color",varray());
  1212. ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray());
  1213. //pointerbased
  1214. ADDFUNC0(_AABB,REAL,AABB,get_area,varray());
  1215. ADDFUNC0(_AABB,BOOL,AABB,has_no_area,varray());
  1216. ADDFUNC0(_AABB,BOOL,AABB,has_no_surface,varray());
  1217. ADDFUNC1(_AABB,BOOL,AABB,intersects,_AABB,"with",varray());
  1218. ADDFUNC1(_AABB,BOOL,AABB,encloses,_AABB,"with",varray());
  1219. ADDFUNC1(_AABB,_AABB,AABB,merge,_AABB,"with",varray());
  1220. ADDFUNC1(_AABB,_AABB,AABB,intersection,_AABB,"with",varray());
  1221. ADDFUNC1(_AABB,BOOL,AABB,intersects_plane,PLANE,"plane",varray());
  1222. ADDFUNC2(_AABB,BOOL,AABB,intersects_segment,VECTOR3,"from",VECTOR3,"to",varray());
  1223. ADDFUNC1(_AABB,BOOL,AABB,has_point,VECTOR3,"point",varray());
  1224. ADDFUNC1(_AABB,VECTOR3,AABB,get_support,VECTOR3,"dir",varray());
  1225. ADDFUNC0(_AABB,VECTOR3,AABB,get_longest_axis,varray());
  1226. ADDFUNC0(_AABB,INT,AABB,get_longest_axis_index,varray());
  1227. ADDFUNC0(_AABB,REAL,AABB,get_longest_axis_size,varray());
  1228. ADDFUNC0(_AABB,VECTOR3,AABB,get_shortest_axis,varray());
  1229. ADDFUNC0(_AABB,INT,AABB,get_shortest_axis_index,varray());
  1230. ADDFUNC0(_AABB,REAL,AABB,get_shortest_axis_size,varray());
  1231. ADDFUNC1(_AABB,_AABB,AABB,expand,VECTOR3,"to_point",varray());
  1232. ADDFUNC1(_AABB,_AABB,AABB,grow,REAL,"by",varray());
  1233. ADDFUNC1(_AABB,VECTOR3,AABB,get_endpoint,INT,"idx",varray());
  1234. ADDFUNC0(MATRIX32,MATRIX32,Matrix32,inverse,varray());
  1235. ADDFUNC0(MATRIX32,MATRIX32,Matrix32,affine_inverse,varray());
  1236. ADDFUNC0(MATRIX32,REAL,Matrix32,get_rotation,varray());
  1237. ADDFUNC0(MATRIX32,VECTOR2,Matrix32,get_origin,varray());
  1238. ADDFUNC0(MATRIX32,VECTOR2,Matrix32,get_scale,varray());
  1239. ADDFUNC0(MATRIX32,MATRIX32,Matrix32,orthonormalized,varray());
  1240. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,rotated,REAL,"phi",varray());
  1241. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,scaled,VECTOR2,"scale",varray());
  1242. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,translated,VECTOR2,"offset",varray());
  1243. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,xform,NIL,"v",varray());
  1244. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,xform_inv,NIL,"v",varray());
  1245. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,basis_xform,NIL,"v",varray());
  1246. ADDFUNC1(MATRIX32,MATRIX32,Matrix32,basis_xform_inv,NIL,"v",varray());
  1247. ADDFUNC2(MATRIX32,MATRIX32,Matrix32,interpolate_with,MATRIX32,"m",REAL,"c",varray());
  1248. ADDFUNC0(MATRIX3,MATRIX3,Matrix3,inverse,varray());
  1249. ADDFUNC0(MATRIX3,MATRIX3,Matrix3,transposed,varray());
  1250. ADDFUNC0(MATRIX3,MATRIX3,Matrix3,orthonormalized,varray());
  1251. ADDFUNC0(MATRIX3,REAL,Matrix3,determinant,varray());
  1252. ADDFUNC2(MATRIX3,MATRIX3,Matrix3,rotated,VECTOR3,"axis",REAL,"phi",varray());
  1253. ADDFUNC1(MATRIX3,MATRIX3,Matrix3,scaled,VECTOR3,"scale",varray());
  1254. ADDFUNC0(MATRIX3,VECTOR3,Matrix3,get_scale,varray());
  1255. ADDFUNC0(MATRIX3,VECTOR3,Matrix3,get_euler,varray());
  1256. ADDFUNC1(MATRIX3,REAL,Matrix3,tdotx,VECTOR3,"with",varray());
  1257. ADDFUNC1(MATRIX3,REAL,Matrix3,tdoty,VECTOR3,"with",varray());
  1258. ADDFUNC1(MATRIX3,REAL,Matrix3,tdotz,VECTOR3,"with",varray());
  1259. ADDFUNC1(MATRIX3,VECTOR3,Matrix3,xform,VECTOR3,"v",varray());
  1260. ADDFUNC1(MATRIX3,VECTOR3,Matrix3,xform_inv,VECTOR3,"v",varray());
  1261. ADDFUNC0(MATRIX3,INT,Matrix3,get_orthogonal_index,varray());
  1262. ADDFUNC0(TRANSFORM,TRANSFORM,Transform,inverse,varray());
  1263. ADDFUNC0(TRANSFORM,TRANSFORM,Transform,affine_inverse,varray());
  1264. ADDFUNC0(TRANSFORM,TRANSFORM,Transform,orthonormalized,varray());
  1265. ADDFUNC2(TRANSFORM,TRANSFORM,Transform,rotated,VECTOR3,"axis",REAL,"phi",varray());
  1266. ADDFUNC1(TRANSFORM,TRANSFORM,Transform,scaled,VECTOR3,"scale",varray());
  1267. ADDFUNC1(TRANSFORM,TRANSFORM,Transform,translated,VECTOR3,"ofs",varray());
  1268. ADDFUNC2(TRANSFORM,TRANSFORM,Transform,looking_at,VECTOR3,"target",VECTOR3,"up",varray());
  1269. ADDFUNC1(TRANSFORM,NIL,Transform,xform,NIL,"v",varray());
  1270. ADDFUNC1(TRANSFORM,NIL,Transform,xform_inv,NIL,"v",varray());
  1271. #ifdef DEBUG_ENABLED
  1272. _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform"].returns=true;
  1273. _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns=true;
  1274. #endif
  1275. ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray());
  1276. ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray());
  1277. ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"is_action_pressed",varray());
  1278. ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"is_action_released",varray());
  1279. ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray());
  1280. ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray());
  1281. /* REGISTER CONSTRUCTORS */
  1282. _VariantCall::add_constructor(_VariantCall::Vector2_init1,Variant::VECTOR2,"x",Variant::REAL,"y",Variant::REAL);
  1283. _VariantCall::add_constructor(_VariantCall::Rect2_init1,Variant::RECT2,"pos",Variant::VECTOR2,"size",Variant::VECTOR2);
  1284. _VariantCall::add_constructor(_VariantCall::Rect2_init2,Variant::RECT2,"x",Variant::REAL,"y",Variant::REAL,"width",Variant::REAL,"height",Variant::REAL);
  1285. _VariantCall::add_constructor(_VariantCall::Matrix32_init2,Variant::MATRIX32,"rot",Variant::REAL,"pos",Variant::VECTOR2);
  1286. _VariantCall::add_constructor(_VariantCall::Matrix32_init3,Variant::MATRIX32,"x_axis",Variant::VECTOR2,"y_axis",Variant::VECTOR2,"origin",Variant::VECTOR2);
  1287. _VariantCall::add_constructor(_VariantCall::Vector3_init1,Variant::VECTOR3,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL);
  1288. _VariantCall::add_constructor(_VariantCall::Plane_init1,Variant::PLANE,"a",Variant::REAL,"b",Variant::REAL,"c",Variant::REAL,"d",Variant::REAL);
  1289. _VariantCall::add_constructor(_VariantCall::Plane_init2,Variant::PLANE,"v1",Variant::VECTOR3,"v2",Variant::VECTOR3,"v3",Variant::VECTOR3);
  1290. _VariantCall::add_constructor(_VariantCall::Plane_init3,Variant::PLANE,"normal",Variant::VECTOR3,"d",Variant::REAL);
  1291. _VariantCall::add_constructor(_VariantCall::Quat_init1,Variant::QUAT,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL,"w",Variant::REAL);
  1292. _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL);
  1293. _VariantCall::add_constructor(_VariantCall::Color_init1,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL,"a",Variant::REAL);
  1294. _VariantCall::add_constructor(_VariantCall::Color_init2,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL);
  1295. _VariantCall::add_constructor(_VariantCall::AABB_init1,Variant::_AABB,"pos",Variant::VECTOR3,"size",Variant::VECTOR3);
  1296. _VariantCall::add_constructor(_VariantCall::Matrix3_init1,Variant::MATRIX3,"x_axis",Variant::VECTOR3,"y_axis",Variant::VECTOR3,"z_axis",Variant::VECTOR3);
  1297. _VariantCall::add_constructor(_VariantCall::Matrix3_init2,Variant::MATRIX3,"axis",Variant::VECTOR3,"phi",Variant::REAL);
  1298. _VariantCall::add_constructor(_VariantCall::Transform_init1,Variant::TRANSFORM,"x_axis",Variant::VECTOR3,"y_axis",Variant::VECTOR3,"z_axis",Variant::VECTOR3,"origin",Variant::VECTOR3);
  1299. _VariantCall::add_constructor(_VariantCall::Transform_init2,Variant::TRANSFORM,"basis",Variant::MATRIX3,"origin",Variant::VECTOR3);
  1300. _VariantCall::add_constructor(_VariantCall::Image_init1,Variant::IMAGE,"width",Variant::INT,"height",Variant::INT,"mipmaps",Variant::BOOL,"format",Variant::INT);
  1301. /* REGISTER CONSTANTS */
  1302. _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_X"]=Vector3::AXIS_X;
  1303. _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Y"]=Vector3::AXIS_Y;
  1304. _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Z"]=Vector3::AXIS_Z;
  1305. _VariantCall::constant_data[Variant::INPUT_EVENT].value["NONE"]=InputEvent::NONE;
  1306. _VariantCall::constant_data[Variant::INPUT_EVENT].value["KEY"]=InputEvent::KEY;
  1307. _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_MOTION"]=InputEvent::MOUSE_MOTION;
  1308. _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_BUTTON"]=InputEvent::MOUSE_BUTTON;
  1309. _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_MOTION"]=InputEvent::JOYSTICK_MOTION;
  1310. _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_BUTTON"]=InputEvent::JOYSTICK_BUTTON;
  1311. _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_TOUCH"]=InputEvent::SCREEN_TOUCH;
  1312. _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_DRAG"]=InputEvent::SCREEN_DRAG;
  1313. _VariantCall::constant_data[Variant::INPUT_EVENT].value["ACTION"]=InputEvent::ACTION;
  1314. _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_BC"]=Image::COMPRESS_BC;
  1315. _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC2"]=Image::COMPRESS_PVRTC2;
  1316. _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC4"]=Image::COMPRESS_PVRTC4;
  1317. _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_ETC"]=Image::COMPRESS_ETC;
  1318. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE"]=Image::FORMAT_GRAYSCALE;
  1319. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INTENSITY"]=Image::FORMAT_INTENSITY;
  1320. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE_ALPHA"]=Image::FORMAT_GRAYSCALE_ALPHA;
  1321. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGB"]=Image::FORMAT_RGB;
  1322. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGBA"]=Image::FORMAT_RGBA;
  1323. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED"]=Image::FORMAT_INDEXED;
  1324. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED_ALPHA"]=Image::FORMAT_INDEXED_ALPHA;
  1325. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_422"]=Image::FORMAT_YUV_422;
  1326. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_444"]=Image::FORMAT_YUV_444;
  1327. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC1"]=Image::FORMAT_BC1;
  1328. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC2"]=Image::FORMAT_BC2;
  1329. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC3"]=Image::FORMAT_BC3;
  1330. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC4"]=Image::FORMAT_BC4;
  1331. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC5"]=Image::FORMAT_BC5;
  1332. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2"]=Image::FORMAT_PVRTC2;
  1333. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2_ALPHA"]=Image::FORMAT_PVRTC2_ALPHA;
  1334. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4"]=Image::FORMAT_PVRTC4;
  1335. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4_ALPHA"]=Image::FORMAT_PVRTC4_ALPHA;
  1336. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ETC"]=Image::FORMAT_ETC;
  1337. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC"]=Image::FORMAT_ATC;
  1338. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_EXPLICIT"]=Image::FORMAT_ATC_ALPHA_EXPLICIT;
  1339. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_INTERPOLATED"]=Image::FORMAT_ATC_ALPHA_INTERPOLATED;
  1340. _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_CUSTOM"]=Image::FORMAT_CUSTOM;
  1341. }
  1342. void unregister_variant_methods() {
  1343. memdelete_arr(_VariantCall::type_funcs);
  1344. memdelete_arr(_VariantCall::construct_funcs);
  1345. memdelete_arr( _VariantCall::constant_data );
  1346. }