variant_call.cpp 162 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762
  1. /**************************************************************************/
  2. /* variant_call.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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/crypto/crypto_core.h"
  32. #include "core/debugger/engine_debugger.h"
  33. #include "core/io/compression.h"
  34. #include "core/io/marshalls.h"
  35. #include "core/object/class_db.h"
  36. #include "core/os/os.h"
  37. #include "core/templates/local_vector.h"
  38. #include "core/templates/oa_hash_map.h"
  39. typedef void (*VariantFunc)(Variant &r_ret, Variant &p_self, const Variant **p_args);
  40. typedef void (*VariantConstructFunc)(Variant &r_ret, const Variant **p_args);
  41. template <typename R, typename... P>
  42. static _FORCE_INLINE_ void vc_static_method_call(R (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  43. call_with_variant_args_static_ret_dv(method, p_args, p_argcount, r_ret, r_error, p_defvals);
  44. }
  45. template <typename... P>
  46. static _FORCE_INLINE_ void vc_static_method_call(void (*method)(P...), const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  47. call_with_variant_args_static_dv(method, p_args, p_argcount, r_error, p_defvals);
  48. }
  49. template <typename R, typename T, typename... P>
  50. static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  51. call_with_variant_args_ret_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals);
  52. }
  53. template <typename R, typename T, typename... P>
  54. static _FORCE_INLINE_ void vc_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  55. call_with_variant_args_retc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, r_error, p_defvals);
  56. }
  57. template <typename T, typename... P>
  58. static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  59. VariantInternal::clear(&r_ret);
  60. call_with_variant_args_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
  61. }
  62. template <typename T, typename... P>
  63. static _FORCE_INLINE_ void vc_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  64. VariantInternal::clear(&r_ret);
  65. call_with_variant_argsc_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_error, p_defvals);
  66. }
  67. template <typename From, typename R, typename T, typename... P>
  68. static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  69. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  70. call_with_variant_args_ret_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals);
  71. }
  72. template <typename From, typename R, typename T, typename... P>
  73. static _FORCE_INLINE_ void vc_convert_method_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  74. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  75. call_with_variant_args_retc_dv(&converted, method, p_args, p_argcount, r_ret, r_error, p_defvals);
  76. }
  77. template <typename From, typename T, typename... P>
  78. static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  79. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  80. call_with_variant_args_dv(&converted, method, p_args, p_argcount, r_error, p_defvals);
  81. }
  82. template <typename From, typename T, typename... P>
  83. static _FORCE_INLINE_ void vc_convert_method_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  84. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  85. call_with_variant_argsc_dv(&converted, method, p_args, p_argcount, r_error, p_defvals);
  86. }
  87. template <typename R, typename T, typename... P>
  88. static _FORCE_INLINE_ void vc_method_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  89. call_with_variant_args_retc_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, r_ret, p_defvals, r_error);
  90. }
  91. template <typename T, typename... P>
  92. static _FORCE_INLINE_ void vc_method_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) {
  93. call_with_variant_args_static_helper_dv(VariantGetInternalPtr<T>::get_ptr(base), method, p_args, p_argcount, p_defvals, r_error);
  94. }
  95. template <typename R, typename T, typename... P>
  96. static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  97. call_with_validated_variant_args_ret(base, method, p_args, r_ret);
  98. }
  99. template <typename R, typename T, typename... P>
  100. static _FORCE_INLINE_ void vc_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
  101. call_with_validated_variant_args_retc(base, method, p_args, r_ret);
  102. }
  103. template <typename T, typename... P>
  104. static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  105. call_with_validated_variant_args(base, method, p_args);
  106. }
  107. template <typename T, typename... P>
  108. static _FORCE_INLINE_ void vc_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
  109. call_with_validated_variant_argsc(base, method, p_args);
  110. }
  111. template <typename From, typename R, typename T, typename... P>
  112. static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  113. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  114. call_with_validated_variant_args_ret_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
  115. }
  116. template <typename From, typename R, typename T, typename... P>
  117. static _FORCE_INLINE_ void vc_convert_validated_call(R (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
  118. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  119. call_with_validated_variant_args_retc_helper<T, R, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
  120. }
  121. template <typename From, typename T, typename... P>
  122. static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  123. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  124. call_with_validated_variant_args_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
  125. }
  126. template <typename From, typename T, typename... P>
  127. static _FORCE_INLINE_ void vc_convert_validated_call(void (T::*method)(P...) const, Variant *base, const Variant **p_args, Variant *r_ret) {
  128. T converted(static_cast<T>(*VariantGetInternalPtr<From>::get_ptr(base)));
  129. call_with_validated_variant_argsc_helper<T, P...>(&converted, method, p_args, r_ret, BuildIndexSequence<sizeof...(P)>{});
  130. }
  131. template <typename R, typename T, typename... P>
  132. static _FORCE_INLINE_ void vc_validated_call_static(R (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  133. call_with_validated_variant_args_static_retc(base, method, p_args, r_ret);
  134. }
  135. template <typename T, typename... P>
  136. static _FORCE_INLINE_ void vc_validated_call_static(void (*method)(T *, P...), Variant *base, const Variant **p_args, Variant *r_ret) {
  137. call_with_validated_variant_args_static(base, method, p_args);
  138. }
  139. template <typename R, typename... P>
  140. static _FORCE_INLINE_ void vc_validated_static_call(R (*method)(P...), const Variant **p_args, Variant *r_ret) {
  141. call_with_validated_variant_args_static_method_ret(method, p_args, r_ret);
  142. }
  143. template <typename... P>
  144. static _FORCE_INLINE_ void vc_validated_static_call(void (*method)(P...), const Variant **p_args, Variant *r_ret) {
  145. call_with_validated_variant_args_static_method(method, p_args);
  146. }
  147. template <typename R, typename T, typename... P>
  148. static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
  149. call_with_ptr_args_ret(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
  150. }
  151. template <typename R, typename T, typename... P>
  152. static _FORCE_INLINE_ void vc_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
  153. call_with_ptr_args_retc(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
  154. }
  155. template <typename T, typename... P>
  156. static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
  157. call_with_ptr_args(reinterpret_cast<T *>(p_base), method, p_args);
  158. }
  159. template <typename T, typename... P>
  160. static _FORCE_INLINE_ void vc_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
  161. call_with_ptr_argsc(reinterpret_cast<T *>(p_base), method, p_args);
  162. }
  163. template <typename From, typename R, typename T, typename... P>
  164. static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
  165. T converted(*reinterpret_cast<From *>(p_base));
  166. call_with_ptr_args_ret(&converted, method, p_args, r_ret);
  167. }
  168. template <typename From, typename R, typename T, typename... P>
  169. static _FORCE_INLINE_ void vc_convert_ptrcall(R (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
  170. T converted(*reinterpret_cast<From *>(p_base));
  171. call_with_ptr_args_retc(&converted, method, p_args, r_ret);
  172. }
  173. template <typename From, typename T, typename... P>
  174. static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...), void *p_base, const void **p_args, void *r_ret) {
  175. T converted(*reinterpret_cast<From *>(p_base));
  176. call_with_ptr_args(&converted, method, p_args);
  177. }
  178. template <typename From, typename T, typename... P>
  179. static _FORCE_INLINE_ void vc_convert_ptrcall(void (T::*method)(P...) const, void *p_base, const void **p_args, void *r_ret) {
  180. T converted(*reinterpret_cast<From *>(p_base));
  181. call_with_ptr_argsc(&converted, method, p_args);
  182. }
  183. template <typename R, typename T, typename... P>
  184. static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...)) {
  185. return sizeof...(P);
  186. }
  187. template <typename R, typename T, typename... P>
  188. static _FORCE_INLINE_ int vc_get_argument_count(R (T::*method)(P...) const) {
  189. return sizeof...(P);
  190. }
  191. template <typename T, typename... P>
  192. static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...)) {
  193. return sizeof...(P);
  194. }
  195. template <typename T, typename... P>
  196. static _FORCE_INLINE_ int vc_get_argument_count(void (T::*method)(P...) const) {
  197. return sizeof...(P);
  198. }
  199. template <typename R, typename T, typename... P>
  200. static _FORCE_INLINE_ int vc_get_argument_count(R (*method)(T *, P...)) {
  201. return sizeof...(P);
  202. }
  203. template <typename R, typename... P>
  204. static _FORCE_INLINE_ int vc_get_argument_count_static(R (*method)(P...)) {
  205. return sizeof...(P);
  206. }
  207. template <typename R, typename T, typename... P>
  208. static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...), int p_arg) {
  209. return call_get_argument_type<P...>(p_arg);
  210. }
  211. template <typename R, typename T, typename... P>
  212. static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (T::*method)(P...) const, int p_arg) {
  213. return call_get_argument_type<P...>(p_arg);
  214. }
  215. template <typename T, typename... P>
  216. static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...), int p_arg) {
  217. return call_get_argument_type<P...>(p_arg);
  218. }
  219. template <typename T, typename... P>
  220. static _FORCE_INLINE_ Variant::Type vc_get_argument_type(void (T::*method)(P...) const, int p_arg) {
  221. return call_get_argument_type<P...>(p_arg);
  222. }
  223. template <typename R, typename T, typename... P>
  224. static _FORCE_INLINE_ Variant::Type vc_get_argument_type(R (*method)(T *, P...), int p_arg) {
  225. return call_get_argument_type<P...>(p_arg);
  226. }
  227. template <typename R, typename... P>
  228. static _FORCE_INLINE_ Variant::Type vc_get_argument_type_static(R (*method)(P...), int p_arg) {
  229. return call_get_argument_type<P...>(p_arg);
  230. }
  231. template <typename R, typename T, typename... P>
  232. static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...)) {
  233. return GetTypeInfo<R>::VARIANT_TYPE;
  234. }
  235. template <typename R, typename T, typename... P>
  236. static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (T::*method)(P...) const) {
  237. return GetTypeInfo<R>::VARIANT_TYPE;
  238. }
  239. template <typename T, typename... P>
  240. static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...)) {
  241. return Variant::NIL;
  242. }
  243. template <typename T, typename... P>
  244. static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (T::*method)(P...) const) {
  245. return Variant::NIL;
  246. }
  247. template <typename R, typename... P>
  248. static _FORCE_INLINE_ Variant::Type vc_get_return_type(R (*method)(P...)) {
  249. return GetTypeInfo<R>::VARIANT_TYPE;
  250. }
  251. template <typename... P>
  252. static _FORCE_INLINE_ Variant::Type vc_get_return_type(void (*method)(P...)) {
  253. return Variant::NIL;
  254. }
  255. template <typename R, typename T, typename... P>
  256. static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...)) {
  257. return true;
  258. }
  259. template <typename R, typename T, typename... P>
  260. static _FORCE_INLINE_ bool vc_has_return_type(R (T::*method)(P...) const) {
  261. return true;
  262. }
  263. template <typename T, typename... P>
  264. static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...)) {
  265. return false;
  266. }
  267. template <typename T, typename... P>
  268. static _FORCE_INLINE_ bool vc_has_return_type(void (T::*method)(P...) const) {
  269. return false;
  270. }
  271. template <typename... P>
  272. static _FORCE_INLINE_ bool vc_has_return_type_static(void (*method)(P...)) {
  273. return false;
  274. }
  275. template <typename R, typename... P>
  276. static _FORCE_INLINE_ bool vc_has_return_type_static(R (*method)(P...)) {
  277. return true;
  278. }
  279. template <typename R, typename T, typename... P>
  280. static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...)) {
  281. return false;
  282. }
  283. template <typename R, typename T, typename... P>
  284. static _FORCE_INLINE_ bool vc_is_const(R (T::*method)(P...) const) {
  285. return true;
  286. }
  287. template <typename T, typename... P>
  288. static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...)) {
  289. return false;
  290. }
  291. template <typename T, typename... P>
  292. static _FORCE_INLINE_ bool vc_is_const(void (T::*method)(P...) const) {
  293. return true;
  294. }
  295. template <typename R, typename T, typename... P>
  296. static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...)) {
  297. return GetTypeInfo<T>::VARIANT_TYPE;
  298. }
  299. template <typename R, typename T, typename... P>
  300. static _FORCE_INLINE_ Variant::Type vc_get_base_type(R (T::*method)(P...) const) {
  301. return GetTypeInfo<T>::VARIANT_TYPE;
  302. }
  303. template <typename T, typename... P>
  304. static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...)) {
  305. return GetTypeInfo<T>::VARIANT_TYPE;
  306. }
  307. template <typename T, typename... P>
  308. static _FORCE_INLINE_ Variant::Type vc_get_base_type(void (T::*method)(P...) const) {
  309. return GetTypeInfo<T>::VARIANT_TYPE;
  310. }
  311. #define METHOD_CLASS(m_class, m_method_name, m_method_ptr) \
  312. struct Method_##m_class##_##m_method_name { \
  313. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  314. vc_method_call(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \
  315. } \
  316. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  317. vc_validated_call(m_method_ptr, base, p_args, r_ret); \
  318. } \
  319. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  320. vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \
  321. } \
  322. static int get_argument_count() { \
  323. return vc_get_argument_count(m_method_ptr); \
  324. } \
  325. static Variant::Type get_argument_type(int p_arg) { \
  326. return vc_get_argument_type(m_method_ptr, p_arg); \
  327. } \
  328. static Variant::Type get_return_type() { \
  329. return vc_get_return_type(m_method_ptr); \
  330. } \
  331. static bool has_return_type() { \
  332. return vc_has_return_type(m_method_ptr); \
  333. } \
  334. static bool is_const() { \
  335. return vc_is_const(m_method_ptr); \
  336. } \
  337. static bool is_static() { \
  338. return false; \
  339. } \
  340. static bool is_vararg() { \
  341. return false; \
  342. } \
  343. static Variant::Type get_base_type() { \
  344. return vc_get_base_type(m_method_ptr); \
  345. } \
  346. static StringName get_name() { \
  347. return #m_method_name; \
  348. } \
  349. };
  350. #define CONVERT_METHOD_CLASS(m_class, m_method_name, m_method_ptr) \
  351. struct Method_##m_class##_##m_method_name { \
  352. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  353. vc_convert_method_call<m_class>(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \
  354. } \
  355. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  356. vc_convert_validated_call<m_class>(m_method_ptr, base, p_args, r_ret); \
  357. } \
  358. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  359. vc_convert_ptrcall<m_class>(m_method_ptr, p_base, p_args, r_ret); \
  360. } \
  361. static int get_argument_count() { \
  362. return vc_get_argument_count(m_method_ptr); \
  363. } \
  364. static Variant::Type get_argument_type(int p_arg) { \
  365. return vc_get_argument_type(m_method_ptr, p_arg); \
  366. } \
  367. static Variant::Type get_return_type() { \
  368. return vc_get_return_type(m_method_ptr); \
  369. } \
  370. static bool has_return_type() { \
  371. return vc_has_return_type(m_method_ptr); \
  372. } \
  373. static bool is_const() { \
  374. return vc_is_const(m_method_ptr); \
  375. } \
  376. static bool is_static() { \
  377. return false; \
  378. } \
  379. static bool is_vararg() { \
  380. return false; \
  381. } \
  382. static Variant::Type get_base_type() { \
  383. return GetTypeInfo<m_class>::VARIANT_TYPE; \
  384. } \
  385. static StringName get_name() { \
  386. return #m_method_name; \
  387. } \
  388. };
  389. template <typename R, typename... P>
  390. static _FORCE_INLINE_ void vc_static_ptrcall(R (*method)(P...), const void **p_args, void *r_ret) {
  391. call_with_ptr_args_static_method_ret<R, P...>(method, p_args, r_ret);
  392. }
  393. template <typename... P>
  394. static _FORCE_INLINE_ void vc_static_ptrcall(void (*method)(P...), const void **p_args, void *r_ret) {
  395. call_with_ptr_args_static_method<P...>(method, p_args);
  396. }
  397. #define STATIC_METHOD_CLASS(m_class, m_method_name, m_method_ptr) \
  398. struct Method_##m_class##_##m_method_name { \
  399. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  400. vc_static_method_call(m_method_ptr, p_args, p_argcount, r_ret, p_defvals, r_error); \
  401. } \
  402. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  403. vc_validated_static_call(m_method_ptr, p_args, r_ret); \
  404. } \
  405. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  406. vc_static_ptrcall(m_method_ptr, p_args, r_ret); \
  407. } \
  408. static int get_argument_count() { \
  409. return vc_get_argument_count_static(m_method_ptr); \
  410. } \
  411. static Variant::Type get_argument_type(int p_arg) { \
  412. return vc_get_argument_type_static(m_method_ptr, p_arg); \
  413. } \
  414. static Variant::Type get_return_type() { \
  415. return vc_get_return_type(m_method_ptr); \
  416. } \
  417. static bool has_return_type() { \
  418. return vc_has_return_type_static(m_method_ptr); \
  419. } \
  420. static bool is_const() { \
  421. return false; \
  422. } \
  423. static bool is_static() { \
  424. return true; \
  425. } \
  426. static bool is_vararg() { \
  427. return false; \
  428. } \
  429. static Variant::Type get_base_type() { \
  430. return GetTypeInfo<m_class>::VARIANT_TYPE; \
  431. } \
  432. static StringName get_name() { \
  433. return #m_method_name; \
  434. } \
  435. };
  436. template <typename R, typename T, typename... P>
  437. static _FORCE_INLINE_ void vc_ptrcall(R (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) {
  438. call_with_ptr_args_static_retc<T, R, P...>(reinterpret_cast<T *>(p_base), method, p_args, r_ret);
  439. }
  440. template <typename T, typename... P>
  441. static _FORCE_INLINE_ void vc_ptrcall(void (*method)(T *, P...), void *p_base, const void **p_args, void *r_ret) {
  442. call_with_ptr_args_static<T, P...>(reinterpret_cast<T *>(p_base), method, p_args);
  443. }
  444. #define FUNCTION_CLASS(m_class, m_method_name, m_method_ptr, m_const) \
  445. struct Method_##m_class##_##m_method_name { \
  446. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  447. vc_method_call_static(m_method_ptr, base, p_args, p_argcount, r_ret, p_defvals, r_error); \
  448. } \
  449. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  450. vc_validated_call_static(m_method_ptr, base, p_args, r_ret); \
  451. } \
  452. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  453. vc_ptrcall(m_method_ptr, p_base, p_args, r_ret); \
  454. } \
  455. static int get_argument_count() { \
  456. return vc_get_argument_count(m_method_ptr); \
  457. } \
  458. static Variant::Type get_argument_type(int p_arg) { \
  459. return vc_get_argument_type(m_method_ptr, p_arg); \
  460. } \
  461. static Variant::Type get_return_type() { \
  462. return vc_get_return_type(m_method_ptr); \
  463. } \
  464. static bool has_return_type() { \
  465. return vc_has_return_type_static(m_method_ptr); \
  466. } \
  467. static bool is_const() { \
  468. return m_const; \
  469. } \
  470. static bool is_static() { \
  471. return false; \
  472. } \
  473. static bool is_vararg() { \
  474. return false; \
  475. } \
  476. static Variant::Type get_base_type() { \
  477. return GetTypeInfo<m_class>::VARIANT_TYPE; \
  478. } \
  479. static StringName get_name() { \
  480. return #m_method_name; \
  481. } \
  482. };
  483. #define VARARG_CLASS(m_class, m_method_name, m_method_ptr, m_has_return, m_return_type) \
  484. struct Method_##m_class##_##m_method_name { \
  485. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  486. m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \
  487. } \
  488. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  489. Callable::CallError ce; \
  490. m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \
  491. } \
  492. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  493. LocalVector<Variant> vars; \
  494. LocalVector<const Variant *> vars_ptrs; \
  495. vars.resize(p_argcount); \
  496. vars_ptrs.resize(p_argcount); \
  497. for (int i = 0; i < p_argcount; i++) { \
  498. vars[i] = PtrToArg<Variant>::convert(p_args[i]); \
  499. vars_ptrs[i] = &vars[i]; \
  500. } \
  501. Variant base = PtrToArg<m_class>::convert(p_base); \
  502. Variant ret; \
  503. Callable::CallError ce; \
  504. m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \
  505. if (m_has_return) { \
  506. m_return_type r = ret; \
  507. PtrToArg<m_return_type>::encode(ret, r_ret); \
  508. } \
  509. } \
  510. static int get_argument_count() { \
  511. return 0; \
  512. } \
  513. static Variant::Type get_argument_type(int p_arg) { \
  514. return Variant::NIL; \
  515. } \
  516. static Variant::Type get_return_type() { \
  517. return GetTypeInfo<m_return_type>::VARIANT_TYPE; \
  518. } \
  519. static bool has_return_type() { \
  520. return m_has_return; \
  521. } \
  522. static bool is_const() { \
  523. return true; \
  524. } \
  525. static bool is_static() { \
  526. return false; \
  527. } \
  528. static bool is_vararg() { \
  529. return true; \
  530. } \
  531. static Variant::Type get_base_type() { \
  532. return GetTypeInfo<m_class>::VARIANT_TYPE; \
  533. } \
  534. static StringName get_name() { \
  535. return #m_method_name; \
  536. } \
  537. };
  538. #define VARARG_CLASS1(m_class, m_method_name, m_method_ptr, m_arg_type) \
  539. struct Method_##m_class##_##m_method_name { \
  540. static void call(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) { \
  541. m_method_ptr(base, p_args, p_argcount, r_ret, r_error); \
  542. } \
  543. static void validated_call(Variant *base, const Variant **p_args, int p_argcount, Variant *r_ret) { \
  544. Callable::CallError ce; \
  545. m_method_ptr(base, p_args, p_argcount, *r_ret, ce); \
  546. } \
  547. static void ptrcall(void *p_base, const void **p_args, void *r_ret, int p_argcount) { \
  548. LocalVector<Variant> vars; \
  549. LocalVector<const Variant *> vars_ptrs; \
  550. vars.resize(p_argcount); \
  551. vars_ptrs.resize(p_argcount); \
  552. for (int i = 0; i < p_argcount; i++) { \
  553. vars[i] = PtrToArg<Variant>::convert(p_args[i]); \
  554. vars_ptrs[i] = &vars[i]; \
  555. } \
  556. Variant base = PtrToArg<m_class>::convert(p_base); \
  557. Variant ret; \
  558. Callable::CallError ce; \
  559. m_method_ptr(&base, vars_ptrs.ptr(), p_argcount, ret, ce); \
  560. } \
  561. static int get_argument_count() { \
  562. return 1; \
  563. } \
  564. static Variant::Type get_argument_type(int p_arg) { \
  565. return m_arg_type; \
  566. } \
  567. static Variant::Type get_return_type() { \
  568. return Variant::NIL; \
  569. } \
  570. static bool has_return_type() { \
  571. return false; \
  572. } \
  573. static bool is_const() { \
  574. return true; \
  575. } \
  576. static bool is_static() { \
  577. return false; \
  578. } \
  579. static bool is_vararg() { \
  580. return true; \
  581. } \
  582. static Variant::Type get_base_type() { \
  583. return GetTypeInfo<m_class>::VARIANT_TYPE; \
  584. } \
  585. static StringName get_name() { \
  586. return #m_method_name; \
  587. } \
  588. };
  589. struct _VariantCall {
  590. static String func_PackedByteArray_get_string_from_ascii(PackedByteArray *p_instance) {
  591. String s;
  592. if (p_instance->size() > 0) {
  593. const uint8_t *r = p_instance->ptr();
  594. CharString cs;
  595. cs.resize(p_instance->size() + 1);
  596. memcpy(cs.ptrw(), r, p_instance->size());
  597. cs[(int)p_instance->size()] = 0;
  598. s = cs.get_data();
  599. }
  600. return s;
  601. }
  602. static String func_PackedByteArray_get_string_from_utf8(PackedByteArray *p_instance) {
  603. String s;
  604. if (p_instance->size() > 0) {
  605. const uint8_t *r = p_instance->ptr();
  606. s.parse_utf8((const char *)r, p_instance->size());
  607. }
  608. return s;
  609. }
  610. static String func_PackedByteArray_get_string_from_utf16(PackedByteArray *p_instance) {
  611. String s;
  612. if (p_instance->size() > 0) {
  613. const uint8_t *r = p_instance->ptr();
  614. s.parse_utf16((const char16_t *)r, floor((double)p_instance->size() / (double)sizeof(char16_t)));
  615. }
  616. return s;
  617. }
  618. static String func_PackedByteArray_get_string_from_utf32(PackedByteArray *p_instance) {
  619. String s;
  620. if (p_instance->size() > 0) {
  621. const uint8_t *r = p_instance->ptr();
  622. s = String((const char32_t *)r, floor((double)p_instance->size() / (double)sizeof(char32_t)));
  623. }
  624. return s;
  625. }
  626. static String func_PackedByteArray_get_string_from_wchar(PackedByteArray *p_instance) {
  627. String s;
  628. if (p_instance->size() > 0) {
  629. const uint8_t *r = p_instance->ptr();
  630. #ifdef WINDOWS_ENABLED
  631. s.parse_utf16((const char16_t *)r, floor((double)p_instance->size() / (double)sizeof(char16_t)));
  632. #else
  633. s = String((const char32_t *)r, floor((double)p_instance->size() / (double)sizeof(char32_t)));
  634. #endif
  635. }
  636. return s;
  637. }
  638. static PackedByteArray func_PackedByteArray_compress(PackedByteArray *p_instance, int p_mode) {
  639. PackedByteArray compressed;
  640. if (p_instance->size() > 0) {
  641. Compression::Mode mode = (Compression::Mode)(p_mode);
  642. compressed.resize(Compression::get_max_compressed_buffer_size(p_instance->size(), mode));
  643. int result = Compression::compress(compressed.ptrw(), p_instance->ptr(), p_instance->size(), mode);
  644. result = result >= 0 ? result : 0;
  645. compressed.resize(result);
  646. }
  647. return compressed;
  648. }
  649. static PackedByteArray func_PackedByteArray_decompress(PackedByteArray *p_instance, int64_t p_buffer_size, int p_mode) {
  650. PackedByteArray decompressed;
  651. Compression::Mode mode = (Compression::Mode)(p_mode);
  652. int64_t buffer_size = p_buffer_size;
  653. if (buffer_size <= 0) {
  654. ERR_FAIL_V_MSG(decompressed, "Decompression buffer size must be greater than zero.");
  655. }
  656. if (p_instance->size() == 0) {
  657. ERR_FAIL_V_MSG(decompressed, "Compressed buffer size must be greater than zero.");
  658. }
  659. decompressed.resize(buffer_size);
  660. int result = Compression::decompress(decompressed.ptrw(), buffer_size, p_instance->ptr(), p_instance->size(), mode);
  661. result = result >= 0 ? result : 0;
  662. decompressed.resize(result);
  663. return decompressed;
  664. }
  665. static PackedByteArray func_PackedByteArray_decompress_dynamic(PackedByteArray *p_instance, int64_t p_buffer_size, int p_mode) {
  666. PackedByteArray decompressed;
  667. int64_t max_output_size = p_buffer_size;
  668. Compression::Mode mode = (Compression::Mode)(p_mode);
  669. int result = Compression::decompress_dynamic(&decompressed, max_output_size, p_instance->ptr(), p_instance->size(), mode);
  670. if (result == OK) {
  671. return decompressed;
  672. } else {
  673. decompressed.clear();
  674. ERR_FAIL_V_MSG(decompressed, "Decompression failed.");
  675. }
  676. }
  677. static String func_PackedByteArray_hex_encode(PackedByteArray *p_instance) {
  678. if (p_instance->size() == 0) {
  679. return String();
  680. }
  681. const uint8_t *r = p_instance->ptr();
  682. String s = String::hex_encode_buffer(&r[0], p_instance->size());
  683. return s;
  684. }
  685. static int64_t func_PackedByteArray_decode_u8(PackedByteArray *p_instance, int64_t p_offset) {
  686. uint64_t size = p_instance->size();
  687. ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0);
  688. const uint8_t *r = p_instance->ptr();
  689. return r[p_offset];
  690. }
  691. static int64_t func_PackedByteArray_decode_s8(PackedByteArray *p_instance, int64_t p_offset) {
  692. uint64_t size = p_instance->size();
  693. ERR_FAIL_COND_V(p_offset < 0 || p_offset > int64_t(size) - 1, 0);
  694. const uint8_t *r = p_instance->ptr();
  695. return *((const int8_t *)&r[p_offset]);
  696. }
  697. static int64_t func_PackedByteArray_decode_u16(PackedByteArray *p_instance, int64_t p_offset) {
  698. uint64_t size = p_instance->size();
  699. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0);
  700. const uint8_t *r = p_instance->ptr();
  701. return decode_uint16(&r[p_offset]);
  702. }
  703. static int64_t func_PackedByteArray_decode_s16(PackedByteArray *p_instance, int64_t p_offset) {
  704. uint64_t size = p_instance->size();
  705. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0);
  706. const uint8_t *r = p_instance->ptr();
  707. return (int16_t)decode_uint16(&r[p_offset]);
  708. }
  709. static int64_t func_PackedByteArray_decode_u32(PackedByteArray *p_instance, int64_t p_offset) {
  710. uint64_t size = p_instance->size();
  711. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0);
  712. const uint8_t *r = p_instance->ptr();
  713. return decode_uint32(&r[p_offset]);
  714. }
  715. static int64_t func_PackedByteArray_decode_s32(PackedByteArray *p_instance, int64_t p_offset) {
  716. uint64_t size = p_instance->size();
  717. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0);
  718. const uint8_t *r = p_instance->ptr();
  719. return (int32_t)decode_uint32(&r[p_offset]);
  720. }
  721. static int64_t func_PackedByteArray_decode_u64(PackedByteArray *p_instance, int64_t p_offset) {
  722. uint64_t size = p_instance->size();
  723. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0);
  724. const uint8_t *r = p_instance->ptr();
  725. return (int64_t)decode_uint64(&r[p_offset]);
  726. }
  727. static int64_t func_PackedByteArray_decode_s64(PackedByteArray *p_instance, int64_t p_offset) {
  728. uint64_t size = p_instance->size();
  729. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0);
  730. const uint8_t *r = p_instance->ptr();
  731. return (int64_t)decode_uint64(&r[p_offset]);
  732. }
  733. static double func_PackedByteArray_decode_half(PackedByteArray *p_instance, int64_t p_offset) {
  734. uint64_t size = p_instance->size();
  735. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 2), 0);
  736. const uint8_t *r = p_instance->ptr();
  737. return Math::half_to_float(decode_uint16(&r[p_offset]));
  738. }
  739. static double func_PackedByteArray_decode_float(PackedByteArray *p_instance, int64_t p_offset) {
  740. uint64_t size = p_instance->size();
  741. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 4), 0);
  742. const uint8_t *r = p_instance->ptr();
  743. return decode_float(&r[p_offset]);
  744. }
  745. static double func_PackedByteArray_decode_double(PackedByteArray *p_instance, int64_t p_offset) {
  746. uint64_t size = p_instance->size();
  747. ERR_FAIL_COND_V(p_offset < 0 || p_offset > (int64_t(size) - 8), 0);
  748. const uint8_t *r = p_instance->ptr();
  749. return decode_double(&r[p_offset]);
  750. }
  751. static bool func_PackedByteArray_has_encoded_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) {
  752. uint64_t size = p_instance->size();
  753. ERR_FAIL_COND_V(p_offset < 0, false);
  754. const uint8_t *r = p_instance->ptr();
  755. Variant ret;
  756. Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects);
  757. return err == OK;
  758. }
  759. static Variant func_PackedByteArray_decode_var(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) {
  760. uint64_t size = p_instance->size();
  761. ERR_FAIL_COND_V(p_offset < 0, Variant());
  762. const uint8_t *r = p_instance->ptr();
  763. Variant ret;
  764. Error err = decode_variant(ret, r + p_offset, size - p_offset, nullptr, p_allow_objects);
  765. if (err != OK) {
  766. ret = Variant();
  767. }
  768. return ret;
  769. }
  770. static int64_t func_PackedByteArray_decode_var_size(PackedByteArray *p_instance, int64_t p_offset, bool p_allow_objects) {
  771. uint64_t size = p_instance->size();
  772. ERR_FAIL_COND_V(p_offset < 0, 0);
  773. const uint8_t *r = p_instance->ptr();
  774. Variant ret;
  775. int r_size;
  776. Error err = decode_variant(ret, r + p_offset, size - p_offset, &r_size, p_allow_objects);
  777. if (err == OK) {
  778. return r_size;
  779. }
  780. return 0;
  781. }
  782. static PackedInt32Array func_PackedByteArray_decode_s32_array(PackedByteArray *p_instance) {
  783. uint64_t size = p_instance->size();
  784. PackedInt32Array dest;
  785. if (size == 0) {
  786. return dest;
  787. }
  788. ERR_FAIL_COND_V_MSG(size % sizeof(int32_t), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit integer) to convert to PackedInt32Array.");
  789. const uint8_t *r = p_instance->ptr();
  790. dest.resize(size / sizeof(int32_t));
  791. ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed.
  792. memcpy(dest.ptrw(), r, dest.size() * sizeof(int32_t));
  793. return dest;
  794. }
  795. static PackedInt64Array func_PackedByteArray_decode_s64_array(PackedByteArray *p_instance) {
  796. uint64_t size = p_instance->size();
  797. PackedInt64Array dest;
  798. if (size == 0) {
  799. return dest;
  800. }
  801. ERR_FAIL_COND_V_MSG(size % sizeof(int64_t), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit integer) to convert to PackedInt64Array.");
  802. const uint8_t *r = p_instance->ptr();
  803. dest.resize(size / sizeof(int64_t));
  804. ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed.
  805. memcpy(dest.ptrw(), r, dest.size() * sizeof(int64_t));
  806. return dest;
  807. }
  808. static PackedFloat32Array func_PackedByteArray_decode_float_array(PackedByteArray *p_instance) {
  809. uint64_t size = p_instance->size();
  810. PackedFloat32Array dest;
  811. if (size == 0) {
  812. return dest;
  813. }
  814. ERR_FAIL_COND_V_MSG(size % sizeof(float), dest, "PackedByteArray size must be a multiple of 4 (size of 32-bit float) to convert to PackedFloat32Array.");
  815. const uint8_t *r = p_instance->ptr();
  816. dest.resize(size / sizeof(float));
  817. ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed.
  818. memcpy(dest.ptrw(), r, dest.size() * sizeof(float));
  819. return dest;
  820. }
  821. static PackedFloat64Array func_PackedByteArray_decode_double_array(PackedByteArray *p_instance) {
  822. uint64_t size = p_instance->size();
  823. PackedFloat64Array dest;
  824. if (size == 0) {
  825. return dest;
  826. }
  827. ERR_FAIL_COND_V_MSG(size % sizeof(double), dest, "PackedByteArray size must be a multiple of 8 (size of 64-bit double) to convert to PackedFloat64Array.");
  828. const uint8_t *r = p_instance->ptr();
  829. dest.resize(size / sizeof(double));
  830. ERR_FAIL_COND_V(dest.is_empty(), dest); // Avoid UB in case resize failed.
  831. memcpy(dest.ptrw(), r, dest.size() * sizeof(double));
  832. return dest;
  833. }
  834. static void func_PackedByteArray_encode_u8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  835. uint64_t size = p_instance->size();
  836. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1);
  837. uint8_t *w = p_instance->ptrw();
  838. *((uint8_t *)&w[p_offset]) = p_value;
  839. }
  840. static void func_PackedByteArray_encode_s8(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  841. uint64_t size = p_instance->size();
  842. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 1);
  843. uint8_t *w = p_instance->ptrw();
  844. *((int8_t *)&w[p_offset]) = p_value;
  845. }
  846. static void func_PackedByteArray_encode_u16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  847. uint64_t size = p_instance->size();
  848. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2);
  849. uint8_t *w = p_instance->ptrw();
  850. encode_uint16((uint16_t)p_value, &w[p_offset]);
  851. }
  852. static void func_PackedByteArray_encode_s16(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  853. uint64_t size = p_instance->size();
  854. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2);
  855. uint8_t *w = p_instance->ptrw();
  856. encode_uint16((int16_t)p_value, &w[p_offset]);
  857. }
  858. static void func_PackedByteArray_encode_u32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  859. uint64_t size = p_instance->size();
  860. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4);
  861. uint8_t *w = p_instance->ptrw();
  862. encode_uint32((uint32_t)p_value, &w[p_offset]);
  863. }
  864. static void func_PackedByteArray_encode_s32(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  865. uint64_t size = p_instance->size();
  866. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4);
  867. uint8_t *w = p_instance->ptrw();
  868. encode_uint32((int32_t)p_value, &w[p_offset]);
  869. }
  870. static void func_PackedByteArray_encode_u64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  871. uint64_t size = p_instance->size();
  872. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8);
  873. uint8_t *w = p_instance->ptrw();
  874. encode_uint64((uint64_t)p_value, &w[p_offset]);
  875. }
  876. static void func_PackedByteArray_encode_s64(PackedByteArray *p_instance, int64_t p_offset, int64_t p_value) {
  877. uint64_t size = p_instance->size();
  878. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8);
  879. uint8_t *w = p_instance->ptrw();
  880. encode_uint64((int64_t)p_value, &w[p_offset]);
  881. }
  882. static void func_PackedByteArray_encode_half(PackedByteArray *p_instance, int64_t p_offset, double p_value) {
  883. uint64_t size = p_instance->size();
  884. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 2);
  885. uint8_t *w = p_instance->ptrw();
  886. encode_uint16(Math::make_half_float(p_value), &w[p_offset]);
  887. }
  888. static void func_PackedByteArray_encode_float(PackedByteArray *p_instance, int64_t p_offset, double p_value) {
  889. uint64_t size = p_instance->size();
  890. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 4);
  891. uint8_t *w = p_instance->ptrw();
  892. encode_float(p_value, &w[p_offset]);
  893. }
  894. static void func_PackedByteArray_encode_double(PackedByteArray *p_instance, int64_t p_offset, double p_value) {
  895. uint64_t size = p_instance->size();
  896. ERR_FAIL_COND(p_offset < 0 || p_offset > int64_t(size) - 8);
  897. uint8_t *w = p_instance->ptrw();
  898. encode_double(p_value, &w[p_offset]);
  899. }
  900. static int64_t func_PackedByteArray_encode_var(PackedByteArray *p_instance, int64_t p_offset, const Variant &p_value, bool p_allow_objects) {
  901. uint64_t size = p_instance->size();
  902. ERR_FAIL_COND_V(p_offset < 0, -1);
  903. uint8_t *w = p_instance->ptrw();
  904. int len;
  905. Error err = encode_variant(p_value, nullptr, len, p_allow_objects);
  906. if (err != OK) {
  907. return -1;
  908. }
  909. if (uint64_t(p_offset + len) > size) {
  910. return -1; // did not fit
  911. }
  912. encode_variant(p_value, w + p_offset, len, p_allow_objects);
  913. return len;
  914. }
  915. static void func_Callable_call(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  916. Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
  917. callable->callp(p_args, p_argcount, r_ret, r_error);
  918. }
  919. static void func_Callable_call_deferred(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  920. Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
  921. callable->call_deferredp(p_args, p_argcount);
  922. }
  923. static void func_Callable_rpc(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  924. Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
  925. callable->rpcp(0, p_args, p_argcount, r_error);
  926. }
  927. static void func_Callable_rpc_id(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  928. if (p_argcount == 0) {
  929. r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
  930. r_error.expected = 1;
  931. } else if (p_args[0]->get_type() != Variant::INT) {
  932. r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
  933. r_error.argument = 0;
  934. r_error.expected = Variant::INT;
  935. } else {
  936. Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
  937. callable->rpcp(*p_args[0], &p_args[1], p_argcount - 1, r_error);
  938. }
  939. }
  940. static void func_Callable_bind(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  941. Callable *callable = VariantGetInternalPtr<Callable>::get_ptr(v);
  942. r_ret = callable->bindp(p_args, p_argcount);
  943. }
  944. static int func_Callable_get_argument_count(Callable *p_callable) {
  945. return p_callable->get_argument_count();
  946. }
  947. static void func_Signal_emit(Variant *v, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  948. Signal *signal = VariantGetInternalPtr<Signal>::get_ptr(v);
  949. signal->emit(p_args, p_argcount);
  950. }
  951. struct ConstantData {
  952. HashMap<StringName, int64_t> value;
  953. #ifdef DEBUG_ENABLED
  954. List<StringName> value_ordered;
  955. #endif
  956. HashMap<StringName, Variant> variant_value;
  957. #ifdef DEBUG_ENABLED
  958. List<StringName> variant_value_ordered;
  959. #endif
  960. };
  961. static ConstantData *constant_data;
  962. static void add_constant(int p_type, const StringName &p_constant_name, int64_t p_constant_value) {
  963. constant_data[p_type].value[p_constant_name] = p_constant_value;
  964. #ifdef DEBUG_ENABLED
  965. constant_data[p_type].value_ordered.push_back(p_constant_name);
  966. #endif
  967. }
  968. static void add_variant_constant(int p_type, const StringName &p_constant_name, const Variant &p_constant_value) {
  969. constant_data[p_type].variant_value[p_constant_name] = p_constant_value;
  970. #ifdef DEBUG_ENABLED
  971. constant_data[p_type].variant_value_ordered.push_back(p_constant_name);
  972. #endif
  973. }
  974. struct EnumData {
  975. HashMap<StringName, HashMap<StringName, int>> value;
  976. };
  977. static EnumData *enum_data;
  978. static void add_enum_constant(int p_type, const StringName &p_enum_type_name, const StringName &p_enumeration_name, int p_enum_value) {
  979. enum_data[p_type].value[p_enum_type_name][p_enumeration_name] = p_enum_value;
  980. }
  981. };
  982. _VariantCall::ConstantData *_VariantCall::constant_data = nullptr;
  983. _VariantCall::EnumData *_VariantCall::enum_data = nullptr;
  984. struct VariantBuiltInMethodInfo {
  985. void (*call)(Variant *base, const Variant **p_args, int p_argcount, Variant &r_ret, const Vector<Variant> &p_defvals, Callable::CallError &r_error) = nullptr;
  986. Variant::ValidatedBuiltInMethod validated_call = nullptr;
  987. Variant::PTRBuiltInMethod ptrcall = nullptr;
  988. Vector<Variant> default_arguments;
  989. Vector<String> argument_names;
  990. bool is_const = false;
  991. bool is_static = false;
  992. bool has_return_type = false;
  993. bool is_vararg = false;
  994. Variant::Type return_type;
  995. int argument_count = 0;
  996. Variant::Type (*get_argument_type)(int p_arg) = nullptr;
  997. MethodInfo get_method_info(const StringName &p_name) const {
  998. MethodInfo mi;
  999. mi.name = p_name;
  1000. if (has_return_type) {
  1001. mi.return_val.type = return_type;
  1002. if (mi.return_val.type == Variant::NIL) {
  1003. mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
  1004. }
  1005. }
  1006. if (is_const) {
  1007. mi.flags |= METHOD_FLAG_CONST;
  1008. }
  1009. if (is_vararg) {
  1010. mi.flags |= METHOD_FLAG_VARARG;
  1011. }
  1012. if (is_static) {
  1013. mi.flags |= METHOD_FLAG_STATIC;
  1014. }
  1015. for (int i = 0; i < argument_count; i++) {
  1016. PropertyInfo pi;
  1017. #ifdef DEBUG_METHODS_ENABLED
  1018. pi.name = argument_names[i];
  1019. #else
  1020. pi.name = "arg" + itos(i + 1);
  1021. #endif
  1022. pi.type = (*get_argument_type)(i);
  1023. if (pi.type == Variant::NIL) {
  1024. pi.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
  1025. }
  1026. mi.arguments.push_back(pi);
  1027. }
  1028. mi.default_arguments = default_arguments;
  1029. return mi;
  1030. }
  1031. };
  1032. typedef OAHashMap<StringName, VariantBuiltInMethodInfo> BuiltinMethodMap;
  1033. static BuiltinMethodMap *builtin_method_info;
  1034. static List<StringName> *builtin_method_names;
  1035. template <typename T>
  1036. static void register_builtin_method(const Vector<String> &p_argnames, const Vector<Variant> &p_def_args) {
  1037. StringName name = T::get_name();
  1038. ERR_FAIL_COND(builtin_method_info[T::get_base_type()].has(name));
  1039. VariantBuiltInMethodInfo imi;
  1040. imi.call = T::call;
  1041. imi.validated_call = T::validated_call;
  1042. imi.ptrcall = T::ptrcall;
  1043. imi.default_arguments = p_def_args;
  1044. imi.argument_names = p_argnames;
  1045. imi.is_const = T::is_const();
  1046. imi.is_static = T::is_static();
  1047. imi.is_vararg = T::is_vararg();
  1048. imi.has_return_type = T::has_return_type();
  1049. imi.return_type = T::get_return_type();
  1050. imi.argument_count = T::get_argument_count();
  1051. imi.get_argument_type = T::get_argument_type;
  1052. #ifdef DEBUG_METHODS_ENABLED
  1053. ERR_FAIL_COND(!imi.is_vararg && imi.argument_count != imi.argument_names.size());
  1054. #endif
  1055. builtin_method_info[T::get_base_type()].insert(name, imi);
  1056. builtin_method_names[T::get_base_type()].push_back(name);
  1057. }
  1058. void Variant::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  1059. if (type == Variant::OBJECT) {
  1060. //call object
  1061. Object *obj = _get_obj().obj;
  1062. if (!obj) {
  1063. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
  1064. return;
  1065. }
  1066. #ifdef DEBUG_ENABLED
  1067. if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
  1068. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
  1069. return;
  1070. }
  1071. #endif
  1072. r_ret = _get_obj().obj->callp(p_method, p_args, p_argcount, r_error);
  1073. } else {
  1074. r_error.error = Callable::CallError::CALL_OK;
  1075. const VariantBuiltInMethodInfo *imf = builtin_method_info[type].lookup_ptr(p_method);
  1076. if (!imf) {
  1077. r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
  1078. return;
  1079. }
  1080. imf->call(this, p_args, p_argcount, r_ret, imf->default_arguments, r_error);
  1081. }
  1082. }
  1083. void Variant::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  1084. if (type == Variant::OBJECT) {
  1085. //call object
  1086. Object *obj = _get_obj().obj;
  1087. if (!obj) {
  1088. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
  1089. return;
  1090. }
  1091. #ifdef DEBUG_ENABLED
  1092. if (EngineDebugger::is_active() && !_get_obj().id.is_ref_counted() && ObjectDB::get_instance(_get_obj().id) == nullptr) {
  1093. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
  1094. return;
  1095. }
  1096. #endif
  1097. r_ret = _get_obj().obj->call_const(p_method, p_args, p_argcount, r_error);
  1098. //else if (type==Variant::METHOD) {
  1099. } else {
  1100. r_error.error = Callable::CallError::CALL_OK;
  1101. const VariantBuiltInMethodInfo *imf = builtin_method_info[type].lookup_ptr(p_method);
  1102. if (!imf) {
  1103. r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
  1104. return;
  1105. }
  1106. if (!imf->is_const) {
  1107. r_error.error = Callable::CallError::CALL_ERROR_METHOD_NOT_CONST;
  1108. return;
  1109. }
  1110. imf->call(this, p_args, p_argcount, r_ret, imf->default_arguments, r_error);
  1111. }
  1112. }
  1113. void Variant::call_static(Variant::Type p_type, const StringName &p_method, const Variant **p_args, int p_argcount, Variant &r_ret, Callable::CallError &r_error) {
  1114. r_error.error = Callable::CallError::CALL_OK;
  1115. const VariantBuiltInMethodInfo *imf = builtin_method_info[p_type].lookup_ptr(p_method);
  1116. if (!imf) {
  1117. r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
  1118. return;
  1119. }
  1120. if (!imf->is_static) {
  1121. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
  1122. return;
  1123. }
  1124. imf->call(nullptr, p_args, p_argcount, r_ret, imf->default_arguments, r_error);
  1125. }
  1126. bool Variant::has_method(const StringName &p_method) const {
  1127. if (type == OBJECT) {
  1128. Object *obj = get_validated_object();
  1129. if (!obj) {
  1130. return false;
  1131. }
  1132. return obj->has_method(p_method);
  1133. }
  1134. return builtin_method_info[type].has(p_method);
  1135. }
  1136. bool Variant::has_builtin_method(Variant::Type p_type, const StringName &p_method) {
  1137. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1138. return builtin_method_info[p_type].has(p_method);
  1139. }
  1140. Variant::ValidatedBuiltInMethod Variant::get_validated_builtin_method(Variant::Type p_type, const StringName &p_method) {
  1141. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr);
  1142. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1143. ERR_FAIL_NULL_V(method, nullptr);
  1144. return method->validated_call;
  1145. }
  1146. Variant::PTRBuiltInMethod Variant::get_ptr_builtin_method(Variant::Type p_type, const StringName &p_method) {
  1147. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, nullptr);
  1148. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1149. ERR_FAIL_NULL_V(method, nullptr);
  1150. return method->ptrcall;
  1151. }
  1152. MethodInfo Variant::get_builtin_method_info(Variant::Type p_type, const StringName &p_method) {
  1153. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, MethodInfo());
  1154. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1155. ERR_FAIL_NULL_V(method, MethodInfo());
  1156. return method->get_method_info(p_method);
  1157. }
  1158. int Variant::get_builtin_method_argument_count(Variant::Type p_type, const StringName &p_method) {
  1159. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
  1160. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1161. ERR_FAIL_NULL_V(method, 0);
  1162. return method->argument_count;
  1163. }
  1164. Variant::Type Variant::get_builtin_method_argument_type(Variant::Type p_type, const StringName &p_method, int p_argument) {
  1165. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL);
  1166. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1167. ERR_FAIL_NULL_V(method, Variant::NIL);
  1168. ERR_FAIL_INDEX_V(p_argument, method->argument_count, Variant::NIL);
  1169. return method->get_argument_type(p_argument);
  1170. }
  1171. String Variant::get_builtin_method_argument_name(Variant::Type p_type, const StringName &p_method, int p_argument) {
  1172. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, String());
  1173. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1174. ERR_FAIL_NULL_V(method, String());
  1175. #ifdef DEBUG_METHODS_ENABLED
  1176. ERR_FAIL_INDEX_V(p_argument, method->argument_count, String());
  1177. return method->argument_names[p_argument];
  1178. #else
  1179. return "arg" + itos(p_argument + 1);
  1180. #endif
  1181. }
  1182. Vector<Variant> Variant::get_builtin_method_default_arguments(Variant::Type p_type, const StringName &p_method) {
  1183. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Vector<Variant>());
  1184. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1185. ERR_FAIL_NULL_V(method, Vector<Variant>());
  1186. return method->default_arguments;
  1187. }
  1188. bool Variant::has_builtin_method_return_value(Variant::Type p_type, const StringName &p_method) {
  1189. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1190. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1191. ERR_FAIL_NULL_V(method, false);
  1192. return method->has_return_type;
  1193. }
  1194. void Variant::get_builtin_method_list(Variant::Type p_type, List<StringName> *p_list) {
  1195. ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
  1196. for (const StringName &E : builtin_method_names[p_type]) {
  1197. p_list->push_back(E);
  1198. }
  1199. }
  1200. int Variant::get_builtin_method_count(Variant::Type p_type) {
  1201. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1);
  1202. return builtin_method_names[p_type].size();
  1203. }
  1204. Variant::Type Variant::get_builtin_method_return_type(Variant::Type p_type, const StringName &p_method) {
  1205. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, Variant::NIL);
  1206. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1207. ERR_FAIL_NULL_V(method, Variant::NIL);
  1208. return method->return_type;
  1209. }
  1210. bool Variant::is_builtin_method_const(Variant::Type p_type, const StringName &p_method) {
  1211. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1212. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1213. ERR_FAIL_NULL_V(method, false);
  1214. return method->is_const;
  1215. }
  1216. bool Variant::is_builtin_method_static(Variant::Type p_type, const StringName &p_method) {
  1217. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1218. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1219. ERR_FAIL_NULL_V(method, false);
  1220. return method->is_static;
  1221. }
  1222. bool Variant::is_builtin_method_vararg(Variant::Type p_type, const StringName &p_method) {
  1223. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1224. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1225. ERR_FAIL_NULL_V(method, false);
  1226. return method->is_vararg;
  1227. }
  1228. uint32_t Variant::get_builtin_method_hash(Variant::Type p_type, const StringName &p_method) {
  1229. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
  1230. const VariantBuiltInMethodInfo *method = builtin_method_info[p_type].lookup_ptr(p_method);
  1231. ERR_FAIL_NULL_V(method, 0);
  1232. uint32_t hash = hash_murmur3_one_32(method->is_const);
  1233. hash = hash_murmur3_one_32(method->is_static, hash);
  1234. hash = hash_murmur3_one_32(method->is_vararg, hash);
  1235. hash = hash_murmur3_one_32(method->has_return_type, hash);
  1236. if (method->has_return_type) {
  1237. hash = hash_murmur3_one_32(method->return_type, hash);
  1238. }
  1239. hash = hash_murmur3_one_32(method->argument_count, hash);
  1240. for (int i = 0; i < method->argument_count; i++) {
  1241. hash = hash_murmur3_one_32(method->get_argument_type(i), hash);
  1242. }
  1243. return hash_fmix32(hash);
  1244. }
  1245. void Variant::get_method_list(List<MethodInfo> *p_list) const {
  1246. if (type == OBJECT) {
  1247. Object *obj = get_validated_object();
  1248. if (obj) {
  1249. obj->get_method_list(p_list);
  1250. }
  1251. } else {
  1252. for (const StringName &E : builtin_method_names[type]) {
  1253. const VariantBuiltInMethodInfo *method = builtin_method_info[type].lookup_ptr(E);
  1254. ERR_CONTINUE(!method);
  1255. p_list->push_back(method->get_method_info(E));
  1256. }
  1257. }
  1258. }
  1259. void Variant::get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants) {
  1260. ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
  1261. const _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1262. #ifdef DEBUG_ENABLED
  1263. for (const List<StringName>::Element *E = cd.value_ordered.front(); E; E = E->next()) {
  1264. p_constants->push_back(E->get());
  1265. #else
  1266. for (const KeyValue<StringName, int64_t> &E : cd.value) {
  1267. p_constants->push_back(E.key);
  1268. #endif
  1269. }
  1270. #ifdef DEBUG_ENABLED
  1271. for (const List<StringName>::Element *E = cd.variant_value_ordered.front(); E; E = E->next()) {
  1272. p_constants->push_back(E->get());
  1273. #else
  1274. for (const KeyValue<StringName, Variant> &E : cd.variant_value) {
  1275. p_constants->push_back(E.key);
  1276. #endif
  1277. }
  1278. }
  1279. int Variant::get_constants_count_for_type(Variant::Type p_type) {
  1280. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1);
  1281. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1282. return cd.value.size() + cd.variant_value.size();
  1283. }
  1284. bool Variant::has_constant(Variant::Type p_type, const StringName &p_value) {
  1285. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, false);
  1286. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1287. return cd.value.has(p_value) || cd.variant_value.has(p_value);
  1288. }
  1289. Variant Variant::get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid) {
  1290. if (r_valid) {
  1291. *r_valid = false;
  1292. }
  1293. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, 0);
  1294. _VariantCall::ConstantData &cd = _VariantCall::constant_data[p_type];
  1295. HashMap<StringName, int64_t>::Iterator E = cd.value.find(p_value);
  1296. if (!E) {
  1297. HashMap<StringName, Variant>::Iterator F = cd.variant_value.find(p_value);
  1298. if (F) {
  1299. if (r_valid) {
  1300. *r_valid = true;
  1301. }
  1302. return F->value;
  1303. } else {
  1304. return -1;
  1305. }
  1306. }
  1307. if (r_valid) {
  1308. *r_valid = true;
  1309. }
  1310. return E->value;
  1311. }
  1312. void Variant::get_enums_for_type(Variant::Type p_type, List<StringName> *p_enums) {
  1313. ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
  1314. _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type];
  1315. for (const KeyValue<StringName, HashMap<StringName, int>> &E : enum_data.value) {
  1316. p_enums->push_back(E.key);
  1317. }
  1318. }
  1319. void Variant::get_enumerations_for_enum(Variant::Type p_type, const StringName &p_enum_name, List<StringName> *p_enumerations) {
  1320. ERR_FAIL_INDEX(p_type, Variant::VARIANT_MAX);
  1321. _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type];
  1322. for (const KeyValue<StringName, HashMap<StringName, int>> &E : enum_data.value) {
  1323. for (const KeyValue<StringName, int> &V : E.value) {
  1324. p_enumerations->push_back(V.key);
  1325. }
  1326. }
  1327. }
  1328. int Variant::get_enum_value(Variant::Type p_type, const StringName &p_enum_name, const StringName &p_enumeration, bool *r_valid) {
  1329. if (r_valid) {
  1330. *r_valid = false;
  1331. }
  1332. ERR_FAIL_INDEX_V(p_type, Variant::VARIANT_MAX, -1);
  1333. _VariantCall::EnumData &enum_data = _VariantCall::enum_data[p_type];
  1334. HashMap<StringName, HashMap<StringName, int>>::Iterator E = enum_data.value.find(p_enum_name);
  1335. if (!E) {
  1336. return -1;
  1337. }
  1338. HashMap<StringName, int>::Iterator V = E->value.find(p_enumeration);
  1339. if (!V) {
  1340. return -1;
  1341. }
  1342. if (r_valid) {
  1343. *r_valid = true;
  1344. }
  1345. return V->value;
  1346. }
  1347. #ifdef DEBUG_METHODS_ENABLED
  1348. #define bind_method(m_type, m_method, m_arg_names, m_default_args) \
  1349. METHOD_CLASS(m_type, m_method, &m_type::m_method); \
  1350. register_builtin_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args);
  1351. #else
  1352. #define bind_method(m_type, m_method, m_arg_names, m_default_args) \
  1353. METHOD_CLASS(m_type, m_method, &m_type ::m_method); \
  1354. register_builtin_method<Method_##m_type##_##m_method>(sarray(), m_default_args);
  1355. #endif
  1356. #ifdef DEBUG_METHODS_ENABLED
  1357. #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \
  1358. CONVERT_METHOD_CLASS(m_type_from, m_method, &m_type_to::m_method); \
  1359. register_builtin_method<Method_##m_type_from##_##m_method>(m_arg_names, m_default_args);
  1360. #else
  1361. #define bind_convert_method(m_type_from, m_type_to, m_method, m_arg_names, m_default_args) \
  1362. CONVERT_METHOD_CLASS(m_type_from, m_method, &m_type_to ::m_method); \
  1363. register_builtin_method<Method_##m_type_from##_##m_method>(sarray(), m_default_args);
  1364. #endif
  1365. #ifdef DEBUG_METHODS_ENABLED
  1366. #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \
  1367. STATIC_METHOD_CLASS(m_type, m_method, m_type::m_method); \
  1368. register_builtin_method<Method_##m_type##_##m_method>(m_arg_names, m_default_args);
  1369. #else
  1370. #define bind_static_method(m_type, m_method, m_arg_names, m_default_args) \
  1371. STATIC_METHOD_CLASS(m_type, m_method, m_type ::m_method); \
  1372. register_builtin_method<Method_##m_type##_##m_method>(sarray(), m_default_args);
  1373. #endif
  1374. #ifdef DEBUG_METHODS_ENABLED
  1375. #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1376. METHOD_CLASS(m_type, m_name, m_method); \
  1377. register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args);
  1378. #else
  1379. #define bind_methodv(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1380. METHOD_CLASS(m_type, m_name, m_method); \
  1381. register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args);
  1382. #endif
  1383. #ifdef DEBUG_METHODS_ENABLED
  1384. #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \
  1385. CONVERT_METHOD_CLASS(m_type_from, m_name, m_method); \
  1386. register_builtin_method<Method_##m_type_from##_##m_name>(m_arg_names, m_default_args);
  1387. #else
  1388. #define bind_convert_methodv(m_type_from, m_type_to, m_name, m_method, m_arg_names, m_default_args) \
  1389. CONVERT_METHOD_CLASS(m_type_from, m_name, m_method); \
  1390. register_builtin_method<Method_##m_type_from##_##m_name>(sarray(), m_default_args);
  1391. #endif
  1392. #ifdef DEBUG_METHODS_ENABLED
  1393. #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1394. FUNCTION_CLASS(m_type, m_name, m_method, true); \
  1395. register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args);
  1396. #else
  1397. #define bind_function(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1398. FUNCTION_CLASS(m_type, m_name, m_method, true); \
  1399. register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args);
  1400. #endif
  1401. #ifdef DEBUG_METHODS_ENABLED
  1402. #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1403. FUNCTION_CLASS(m_type, m_name, m_method, false); \
  1404. register_builtin_method<Method_##m_type##_##m_name>(m_arg_names, m_default_args);
  1405. #else
  1406. #define bind_functionnc(m_type, m_name, m_method, m_arg_names, m_default_args) \
  1407. FUNCTION_CLASS(m_type, m_name, m_method, false); \
  1408. register_builtin_method<Method_##m_type##_##m_name>(sarray(), m_default_args);
  1409. #endif
  1410. #define bind_string_method(m_method, m_arg_names, m_default_args) \
  1411. bind_method(String, m_method, m_arg_names, m_default_args); \
  1412. bind_convert_method(StringName, String, m_method, m_arg_names, m_default_args);
  1413. #define bind_string_methodv(m_name, m_method, m_arg_names, m_default_args) \
  1414. bind_methodv(String, m_name, m_method, m_arg_names, m_default_args); \
  1415. bind_convert_methodv(StringName, String, m_name, m_method, m_arg_names, m_default_args);
  1416. #define bind_custom(m_type, m_name, m_method, m_has_return, m_ret_type) \
  1417. VARARG_CLASS(m_type, m_name, m_method, m_has_return, m_ret_type) \
  1418. register_builtin_method<Method_##m_type##_##m_name>(sarray(), Vector<Variant>());
  1419. #define bind_custom1(m_type, m_name, m_method, m_arg_type, m_arg_name) \
  1420. VARARG_CLASS1(m_type, m_name, m_method, m_arg_type) \
  1421. register_builtin_method<Method_##m_type##_##m_name>(sarray(m_arg_name), Vector<Variant>());
  1422. static void _register_variant_builtin_methods() {
  1423. _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
  1424. _VariantCall::enum_data = memnew_arr(_VariantCall::EnumData, Variant::VARIANT_MAX);
  1425. builtin_method_info = memnew_arr(BuiltinMethodMap, Variant::VARIANT_MAX);
  1426. builtin_method_names = memnew_arr(List<StringName>, Variant::VARIANT_MAX);
  1427. /* String */
  1428. bind_string_method(casecmp_to, sarray("to"), varray());
  1429. bind_string_method(nocasecmp_to, sarray("to"), varray());
  1430. bind_string_method(naturalcasecmp_to, sarray("to"), varray());
  1431. bind_string_method(naturalnocasecmp_to, sarray("to"), varray());
  1432. bind_string_method(filecasecmp_to, sarray("to"), varray());
  1433. bind_string_method(filenocasecmp_to, sarray("to"), varray());
  1434. bind_string_method(length, sarray(), varray());
  1435. bind_string_method(substr, sarray("from", "len"), varray(-1));
  1436. bind_string_methodv(get_slice, static_cast<String (String::*)(const String &, int) const>(&String::get_slice), sarray("delimiter", "slice"), varray());
  1437. bind_string_method(get_slicec, sarray("delimiter", "slice"), varray());
  1438. bind_string_methodv(get_slice_count, static_cast<int (String::*)(const String &) const>(&String::get_slice_count), sarray("delimiter"), varray());
  1439. bind_string_methodv(find, static_cast<int (String::*)(const String &, int) const>(&String::find), sarray("what", "from"), varray(0));
  1440. bind_string_methodv(findn, static_cast<int (String::*)(const String &, int) const>(&String::findn), sarray("what", "from"), varray(0));
  1441. bind_string_methodv(count, static_cast<int (String::*)(const String &, int, int) const>(&String::count), sarray("what", "from", "to"), varray(0, 0));
  1442. bind_string_methodv(countn, static_cast<int (String::*)(const String &, int, int) const>(&String::countn), sarray("what", "from", "to"), varray(0, 0));
  1443. bind_string_methodv(rfind, static_cast<int (String::*)(const String &, int) const>(&String::rfind), sarray("what", "from"), varray(-1));
  1444. bind_string_methodv(rfindn, static_cast<int (String::*)(const String &, int) const>(&String::rfindn), sarray("what", "from"), varray(-1));
  1445. bind_string_method(match, sarray("expr"), varray());
  1446. bind_string_method(matchn, sarray("expr"), varray());
  1447. bind_string_methodv(begins_with, static_cast<bool (String::*)(const String &) const>(&String::begins_with), sarray("text"), varray());
  1448. bind_string_methodv(ends_with, static_cast<bool (String::*)(const String &) const>(&String::ends_with), sarray("text"), varray());
  1449. bind_string_method(is_subsequence_of, sarray("text"), varray());
  1450. bind_string_method(is_subsequence_ofn, sarray("text"), varray());
  1451. bind_string_method(bigrams, sarray(), varray());
  1452. bind_string_method(similarity, sarray("text"), varray());
  1453. bind_string_method(format, sarray("values", "placeholder"), varray("{_}"));
  1454. bind_string_methodv(replace, static_cast<String (String::*)(const String &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray());
  1455. bind_string_methodv(replacen, static_cast<String (String::*)(const String &, const String &) const>(&String::replacen), sarray("what", "forwhat"), varray());
  1456. bind_string_method(repeat, sarray("count"), varray());
  1457. bind_string_method(reverse, sarray(), varray());
  1458. bind_string_method(insert, sarray("position", "what"), varray());
  1459. bind_string_method(erase, sarray("position", "chars"), varray(1));
  1460. bind_string_method(capitalize, sarray(), varray());
  1461. bind_string_method(to_camel_case, sarray(), varray());
  1462. bind_string_method(to_pascal_case, sarray(), varray());
  1463. bind_string_method(to_snake_case, sarray(), varray());
  1464. bind_string_methodv(split, static_cast<Vector<String> (String::*)(const String &, bool, int) const>(&String::split), sarray("delimiter", "allow_empty", "maxsplit"), varray("", true, 0));
  1465. bind_string_methodv(rsplit, static_cast<Vector<String> (String::*)(const String &, bool, int) const>(&String::rsplit), sarray("delimiter", "allow_empty", "maxsplit"), varray("", true, 0));
  1466. bind_string_method(split_floats, sarray("delimiter", "allow_empty"), varray(true));
  1467. bind_string_method(join, sarray("parts"), varray());
  1468. bind_string_method(to_upper, sarray(), varray());
  1469. bind_string_method(to_lower, sarray(), varray());
  1470. bind_string_method(left, sarray("length"), varray());
  1471. bind_string_method(right, sarray("length"), varray());
  1472. bind_string_method(strip_edges, sarray("left", "right"), varray(true, true));
  1473. bind_string_method(strip_escapes, sarray(), varray());
  1474. bind_string_method(lstrip, sarray("chars"), varray());
  1475. bind_string_method(rstrip, sarray("chars"), varray());
  1476. bind_string_method(get_extension, sarray(), varray());
  1477. bind_string_method(get_basename, sarray(), varray());
  1478. bind_string_method(path_join, sarray("file"), varray());
  1479. bind_string_method(unicode_at, sarray("at"), varray());
  1480. bind_string_method(indent, sarray("prefix"), varray());
  1481. bind_string_method(dedent, sarray(), varray());
  1482. bind_method(String, hash, sarray(), varray());
  1483. bind_string_method(md5_text, sarray(), varray());
  1484. bind_string_method(sha1_text, sarray(), varray());
  1485. bind_string_method(sha256_text, sarray(), varray());
  1486. bind_string_method(md5_buffer, sarray(), varray());
  1487. bind_string_method(sha1_buffer, sarray(), varray());
  1488. bind_string_method(sha256_buffer, sarray(), varray());
  1489. bind_string_method(is_empty, sarray(), varray());
  1490. bind_string_methodv(contains, static_cast<bool (String::*)(const String &) const>(&String::contains), sarray("what"), varray());
  1491. bind_string_methodv(containsn, static_cast<bool (String::*)(const String &) const>(&String::containsn), sarray("what"), varray());
  1492. bind_string_method(is_absolute_path, sarray(), varray());
  1493. bind_string_method(is_relative_path, sarray(), varray());
  1494. bind_string_method(simplify_path, sarray(), varray());
  1495. bind_string_method(get_base_dir, sarray(), varray());
  1496. bind_string_method(get_file, sarray(), varray());
  1497. bind_string_method(xml_escape, sarray("escape_quotes"), varray(false));
  1498. bind_string_method(xml_unescape, sarray(), varray());
  1499. bind_string_method(uri_encode, sarray(), varray());
  1500. bind_string_method(uri_decode, sarray(), varray());
  1501. bind_string_method(c_escape, sarray(), varray());
  1502. bind_string_method(c_unescape, sarray(), varray());
  1503. bind_string_method(json_escape, sarray(), varray());
  1504. bind_string_method(validate_node_name, sarray(), varray());
  1505. bind_string_method(validate_filename, sarray(), varray());
  1506. bind_string_method(is_valid_identifier, sarray(), varray());
  1507. bind_string_method(is_valid_int, sarray(), varray());
  1508. bind_string_method(is_valid_float, sarray(), varray());
  1509. bind_string_method(is_valid_hex_number, sarray("with_prefix"), varray(false));
  1510. bind_string_method(is_valid_html_color, sarray(), varray());
  1511. bind_string_method(is_valid_ip_address, sarray(), varray());
  1512. bind_string_method(is_valid_filename, sarray(), varray());
  1513. bind_string_method(to_int, sarray(), varray());
  1514. bind_string_method(to_float, sarray(), varray());
  1515. bind_string_method(hex_to_int, sarray(), varray());
  1516. bind_string_method(bin_to_int, sarray(), varray());
  1517. bind_string_method(lpad, sarray("min_length", "character"), varray(" "));
  1518. bind_string_method(rpad, sarray("min_length", "character"), varray(" "));
  1519. bind_string_method(pad_decimals, sarray("digits"), varray());
  1520. bind_string_method(pad_zeros, sarray("digits"), varray());
  1521. bind_string_methodv(trim_prefix, static_cast<String (String::*)(const String &) const>(&String::trim_prefix), sarray("prefix"), varray());
  1522. bind_string_methodv(trim_suffix, static_cast<String (String::*)(const String &) const>(&String::trim_suffix), sarray("suffix"), varray());
  1523. bind_string_method(to_ascii_buffer, sarray(), varray());
  1524. bind_string_method(to_utf8_buffer, sarray(), varray());
  1525. bind_string_method(to_utf16_buffer, sarray(), varray());
  1526. bind_string_method(to_utf32_buffer, sarray(), varray());
  1527. bind_string_method(hex_decode, sarray(), varray());
  1528. bind_string_method(to_wchar_buffer, sarray(), varray());
  1529. bind_static_method(String, num_scientific, sarray("number"), varray());
  1530. bind_static_method(String, num, sarray("number", "decimals"), varray(-1));
  1531. bind_static_method(String, num_int64, sarray("number", "base", "capitalize_hex"), varray(10, false));
  1532. bind_static_method(String, num_uint64, sarray("number", "base", "capitalize_hex"), varray(10, false));
  1533. bind_static_method(String, chr, sarray("char"), varray());
  1534. bind_static_method(String, humanize_size, sarray("size"), varray());
  1535. /* StringName */
  1536. bind_method(StringName, hash, sarray(), varray());
  1537. /* Vector2 */
  1538. bind_method(Vector2, angle, sarray(), varray());
  1539. bind_method(Vector2, angle_to, sarray("to"), varray());
  1540. bind_method(Vector2, angle_to_point, sarray("to"), varray());
  1541. bind_method(Vector2, direction_to, sarray("to"), varray());
  1542. bind_method(Vector2, distance_to, sarray("to"), varray());
  1543. bind_method(Vector2, distance_squared_to, sarray("to"), varray());
  1544. bind_method(Vector2, length, sarray(), varray());
  1545. bind_method(Vector2, length_squared, sarray(), varray());
  1546. bind_method(Vector2, limit_length, sarray("length"), varray(1.0));
  1547. bind_method(Vector2, normalized, sarray(), varray());
  1548. bind_method(Vector2, is_normalized, sarray(), varray());
  1549. bind_method(Vector2, is_equal_approx, sarray("to"), varray());
  1550. bind_method(Vector2, is_zero_approx, sarray(), varray());
  1551. bind_method(Vector2, is_finite, sarray(), varray());
  1552. bind_method(Vector2, posmod, sarray("mod"), varray());
  1553. bind_method(Vector2, posmodv, sarray("modv"), varray());
  1554. bind_method(Vector2, project, sarray("b"), varray());
  1555. bind_method(Vector2, lerp, sarray("to", "weight"), varray());
  1556. bind_method(Vector2, slerp, sarray("to", "weight"), varray());
  1557. bind_method(Vector2, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
  1558. bind_method(Vector2, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray());
  1559. bind_method(Vector2, bezier_interpolate, sarray("control_1", "control_2", "end", "t"), varray());
  1560. bind_method(Vector2, bezier_derivative, sarray("control_1", "control_2", "end", "t"), varray());
  1561. bind_method(Vector2, max_axis_index, sarray(), varray());
  1562. bind_method(Vector2, min_axis_index, sarray(), varray());
  1563. bind_method(Vector2, move_toward, sarray("to", "delta"), varray());
  1564. bind_method(Vector2, rotated, sarray("angle"), varray());
  1565. bind_method(Vector2, orthogonal, sarray(), varray());
  1566. bind_method(Vector2, floor, sarray(), varray());
  1567. bind_method(Vector2, ceil, sarray(), varray());
  1568. bind_method(Vector2, round, sarray(), varray());
  1569. bind_method(Vector2, aspect, sarray(), varray());
  1570. bind_method(Vector2, dot, sarray("with"), varray());
  1571. bind_method(Vector2, slide, sarray("n"), varray());
  1572. bind_method(Vector2, bounce, sarray("n"), varray());
  1573. bind_method(Vector2, reflect, sarray("line"), varray());
  1574. bind_method(Vector2, cross, sarray("with"), varray());
  1575. bind_method(Vector2, abs, sarray(), varray());
  1576. bind_method(Vector2, sign, sarray(), varray());
  1577. bind_method(Vector2, clamp, sarray("min", "max"), varray());
  1578. bind_method(Vector2, clampf, sarray("min", "max"), varray());
  1579. bind_method(Vector2, snapped, sarray("step"), varray());
  1580. bind_method(Vector2, snappedf, sarray("step"), varray());
  1581. bind_method(Vector2, min, sarray("with"), varray());
  1582. bind_method(Vector2, minf, sarray("with"), varray());
  1583. bind_method(Vector2, max, sarray("with"), varray());
  1584. bind_method(Vector2, maxf, sarray("with"), varray());
  1585. bind_static_method(Vector2, from_angle, sarray("angle"), varray());
  1586. /* Vector2i */
  1587. bind_method(Vector2i, aspect, sarray(), varray());
  1588. bind_method(Vector2i, max_axis_index, sarray(), varray());
  1589. bind_method(Vector2i, min_axis_index, sarray(), varray());
  1590. bind_method(Vector2i, distance_to, sarray("to"), varray());
  1591. bind_method(Vector2i, distance_squared_to, sarray("to"), varray());
  1592. bind_method(Vector2i, length, sarray(), varray());
  1593. bind_method(Vector2i, length_squared, sarray(), varray());
  1594. bind_method(Vector2i, sign, sarray(), varray());
  1595. bind_method(Vector2i, abs, sarray(), varray());
  1596. bind_method(Vector2i, clamp, sarray("min", "max"), varray());
  1597. bind_method(Vector2i, clampi, sarray("min", "max"), varray());
  1598. bind_method(Vector2i, snapped, sarray("step"), varray());
  1599. bind_method(Vector2i, snappedi, sarray("step"), varray());
  1600. bind_method(Vector2i, min, sarray("with"), varray());
  1601. bind_method(Vector2i, mini, sarray("with"), varray());
  1602. bind_method(Vector2i, max, sarray("with"), varray());
  1603. bind_method(Vector2i, maxi, sarray("with"), varray());
  1604. /* Rect2 */
  1605. bind_method(Rect2, get_center, sarray(), varray());
  1606. bind_method(Rect2, get_area, sarray(), varray());
  1607. bind_method(Rect2, has_area, sarray(), varray());
  1608. bind_method(Rect2, has_point, sarray("point"), varray());
  1609. bind_method(Rect2, is_equal_approx, sarray("rect"), varray());
  1610. bind_method(Rect2, is_finite, sarray(), varray());
  1611. bind_method(Rect2, intersects, sarray("b", "include_borders"), varray(false));
  1612. bind_method(Rect2, encloses, sarray("b"), varray());
  1613. bind_method(Rect2, intersection, sarray("b"), varray());
  1614. bind_method(Rect2, merge, sarray("b"), varray());
  1615. bind_method(Rect2, expand, sarray("to"), varray());
  1616. bind_method(Rect2, grow, sarray("amount"), varray());
  1617. bind_methodv(Rect2, grow_side, &Rect2::grow_side_bind, sarray("side", "amount"), varray());
  1618. bind_method(Rect2, grow_individual, sarray("left", "top", "right", "bottom"), varray());
  1619. bind_method(Rect2, abs, sarray(), varray());
  1620. /* Rect2i */
  1621. bind_method(Rect2i, get_center, sarray(), varray());
  1622. bind_method(Rect2i, get_area, sarray(), varray());
  1623. bind_method(Rect2i, has_area, sarray(), varray());
  1624. bind_method(Rect2i, has_point, sarray("point"), varray());
  1625. bind_method(Rect2i, intersects, sarray("b"), varray());
  1626. bind_method(Rect2i, encloses, sarray("b"), varray());
  1627. bind_method(Rect2i, intersection, sarray("b"), varray());
  1628. bind_method(Rect2i, merge, sarray("b"), varray());
  1629. bind_method(Rect2i, expand, sarray("to"), varray());
  1630. bind_method(Rect2i, grow, sarray("amount"), varray());
  1631. bind_methodv(Rect2i, grow_side, &Rect2i::grow_side_bind, sarray("side", "amount"), varray());
  1632. bind_method(Rect2i, grow_individual, sarray("left", "top", "right", "bottom"), varray());
  1633. bind_method(Rect2i, abs, sarray(), varray());
  1634. /* Vector3 */
  1635. bind_method(Vector3, min_axis_index, sarray(), varray());
  1636. bind_method(Vector3, max_axis_index, sarray(), varray());
  1637. bind_method(Vector3, angle_to, sarray("to"), varray());
  1638. bind_method(Vector3, signed_angle_to, sarray("to", "axis"), varray());
  1639. bind_method(Vector3, direction_to, sarray("to"), varray());
  1640. bind_method(Vector3, distance_to, sarray("to"), varray());
  1641. bind_method(Vector3, distance_squared_to, sarray("to"), varray());
  1642. bind_method(Vector3, length, sarray(), varray());
  1643. bind_method(Vector3, length_squared, sarray(), varray());
  1644. bind_method(Vector3, limit_length, sarray("length"), varray(1.0));
  1645. bind_method(Vector3, normalized, sarray(), varray());
  1646. bind_method(Vector3, is_normalized, sarray(), varray());
  1647. bind_method(Vector3, is_equal_approx, sarray("to"), varray());
  1648. bind_method(Vector3, is_zero_approx, sarray(), varray());
  1649. bind_method(Vector3, is_finite, sarray(), varray());
  1650. bind_method(Vector3, inverse, sarray(), varray());
  1651. bind_method(Vector3, clamp, sarray("min", "max"), varray());
  1652. bind_method(Vector3, clampf, sarray("min", "max"), varray());
  1653. bind_method(Vector3, snapped, sarray("step"), varray());
  1654. bind_method(Vector3, snappedf, sarray("step"), varray());
  1655. bind_method(Vector3, rotated, sarray("axis", "angle"), varray());
  1656. bind_method(Vector3, lerp, sarray("to", "weight"), varray());
  1657. bind_method(Vector3, slerp, sarray("to", "weight"), varray());
  1658. bind_method(Vector3, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
  1659. bind_method(Vector3, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray());
  1660. bind_method(Vector3, bezier_interpolate, sarray("control_1", "control_2", "end", "t"), varray());
  1661. bind_method(Vector3, bezier_derivative, sarray("control_1", "control_2", "end", "t"), varray());
  1662. bind_method(Vector3, move_toward, sarray("to", "delta"), varray());
  1663. bind_method(Vector3, dot, sarray("with"), varray());
  1664. bind_method(Vector3, cross, sarray("with"), varray());
  1665. bind_method(Vector3, outer, sarray("with"), varray());
  1666. bind_method(Vector3, abs, sarray(), varray());
  1667. bind_method(Vector3, floor, sarray(), varray());
  1668. bind_method(Vector3, ceil, sarray(), varray());
  1669. bind_method(Vector3, round, sarray(), varray());
  1670. bind_method(Vector3, posmod, sarray("mod"), varray());
  1671. bind_method(Vector3, posmodv, sarray("modv"), varray());
  1672. bind_method(Vector3, project, sarray("b"), varray());
  1673. bind_method(Vector3, slide, sarray("n"), varray());
  1674. bind_method(Vector3, bounce, sarray("n"), varray());
  1675. bind_method(Vector3, reflect, sarray("n"), varray());
  1676. bind_method(Vector3, sign, sarray(), varray());
  1677. bind_method(Vector3, octahedron_encode, sarray(), varray());
  1678. bind_method(Vector3, min, sarray("with"), varray());
  1679. bind_method(Vector3, minf, sarray("with"), varray());
  1680. bind_method(Vector3, max, sarray("with"), varray());
  1681. bind_method(Vector3, maxf, sarray("with"), varray());
  1682. bind_static_method(Vector3, octahedron_decode, sarray("uv"), varray());
  1683. /* Vector3i */
  1684. bind_method(Vector3i, min_axis_index, sarray(), varray());
  1685. bind_method(Vector3i, max_axis_index, sarray(), varray());
  1686. bind_method(Vector3i, distance_to, sarray("to"), varray());
  1687. bind_method(Vector3i, distance_squared_to, sarray("to"), varray());
  1688. bind_method(Vector3i, length, sarray(), varray());
  1689. bind_method(Vector3i, length_squared, sarray(), varray());
  1690. bind_method(Vector3i, sign, sarray(), varray());
  1691. bind_method(Vector3i, abs, sarray(), varray());
  1692. bind_method(Vector3i, clamp, sarray("min", "max"), varray());
  1693. bind_method(Vector3i, clampi, sarray("min", "max"), varray());
  1694. bind_method(Vector3i, snapped, sarray("step"), varray());
  1695. bind_method(Vector3i, snappedi, sarray("step"), varray());
  1696. bind_method(Vector3i, min, sarray("with"), varray());
  1697. bind_method(Vector3i, mini, sarray("with"), varray());
  1698. bind_method(Vector3i, max, sarray("with"), varray());
  1699. bind_method(Vector3i, maxi, sarray("with"), varray());
  1700. /* Vector4 */
  1701. bind_method(Vector4, min_axis_index, sarray(), varray());
  1702. bind_method(Vector4, max_axis_index, sarray(), varray());
  1703. bind_method(Vector4, length, sarray(), varray());
  1704. bind_method(Vector4, length_squared, sarray(), varray());
  1705. bind_method(Vector4, abs, sarray(), varray());
  1706. bind_method(Vector4, sign, sarray(), varray());
  1707. bind_method(Vector4, floor, sarray(), varray());
  1708. bind_method(Vector4, ceil, sarray(), varray());
  1709. bind_method(Vector4, round, sarray(), varray());
  1710. bind_method(Vector4, lerp, sarray("to", "weight"), varray());
  1711. bind_method(Vector4, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
  1712. bind_method(Vector4, cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray());
  1713. bind_method(Vector4, posmod, sarray("mod"), varray());
  1714. bind_method(Vector4, posmodv, sarray("modv"), varray());
  1715. bind_method(Vector4, snapped, sarray("step"), varray());
  1716. bind_method(Vector4, snappedf, sarray("step"), varray());
  1717. bind_method(Vector4, clamp, sarray("min", "max"), varray());
  1718. bind_method(Vector4, clampf, sarray("min", "max"), varray());
  1719. bind_method(Vector4, normalized, sarray(), varray());
  1720. bind_method(Vector4, is_normalized, sarray(), varray());
  1721. bind_method(Vector4, direction_to, sarray("to"), varray());
  1722. bind_method(Vector4, distance_to, sarray("to"), varray());
  1723. bind_method(Vector4, distance_squared_to, sarray("to"), varray());
  1724. bind_method(Vector4, dot, sarray("with"), varray());
  1725. bind_method(Vector4, inverse, sarray(), varray());
  1726. bind_method(Vector4, is_equal_approx, sarray("to"), varray());
  1727. bind_method(Vector4, is_zero_approx, sarray(), varray());
  1728. bind_method(Vector4, is_finite, sarray(), varray());
  1729. bind_method(Vector4, min, sarray("with"), varray());
  1730. bind_method(Vector4, minf, sarray("with"), varray());
  1731. bind_method(Vector4, max, sarray("with"), varray());
  1732. bind_method(Vector4, maxf, sarray("with"), varray());
  1733. /* Vector4i */
  1734. bind_method(Vector4i, min_axis_index, sarray(), varray());
  1735. bind_method(Vector4i, max_axis_index, sarray(), varray());
  1736. bind_method(Vector4i, length, sarray(), varray());
  1737. bind_method(Vector4i, length_squared, sarray(), varray());
  1738. bind_method(Vector4i, sign, sarray(), varray());
  1739. bind_method(Vector4i, abs, sarray(), varray());
  1740. bind_method(Vector4i, clamp, sarray("min", "max"), varray());
  1741. bind_method(Vector4i, clampi, sarray("min", "max"), varray());
  1742. bind_method(Vector4i, snapped, sarray("step"), varray());
  1743. bind_method(Vector4i, snappedi, sarray("step"), varray());
  1744. bind_method(Vector4i, min, sarray("with"), varray());
  1745. bind_method(Vector4i, mini, sarray("with"), varray());
  1746. bind_method(Vector4i, max, sarray("with"), varray());
  1747. bind_method(Vector4i, maxi, sarray("with"), varray());
  1748. bind_method(Vector4i, distance_to, sarray("to"), varray());
  1749. bind_method(Vector4i, distance_squared_to, sarray("to"), varray());
  1750. /* Plane */
  1751. bind_method(Plane, normalized, sarray(), varray());
  1752. bind_method(Plane, get_center, sarray(), varray());
  1753. bind_method(Plane, is_equal_approx, sarray("to_plane"), varray());
  1754. bind_method(Plane, is_finite, sarray(), varray());
  1755. bind_method(Plane, is_point_over, sarray("point"), varray());
  1756. bind_method(Plane, distance_to, sarray("point"), varray());
  1757. bind_method(Plane, has_point, sarray("point", "tolerance"), varray(CMP_EPSILON));
  1758. bind_method(Plane, project, sarray("point"), varray());
  1759. bind_methodv(Plane, intersect_3, &Plane::intersect_3_bind, sarray("b", "c"), varray());
  1760. bind_methodv(Plane, intersects_ray, &Plane::intersects_ray_bind, sarray("from", "dir"), varray());
  1761. bind_methodv(Plane, intersects_segment, &Plane::intersects_segment_bind, sarray("from", "to"), varray());
  1762. /* Quaternion */
  1763. bind_method(Quaternion, length, sarray(), varray());
  1764. bind_method(Quaternion, length_squared, sarray(), varray());
  1765. bind_method(Quaternion, normalized, sarray(), varray());
  1766. bind_method(Quaternion, is_normalized, sarray(), varray());
  1767. bind_method(Quaternion, is_equal_approx, sarray("to"), varray());
  1768. bind_method(Quaternion, is_finite, sarray(), varray());
  1769. bind_method(Quaternion, inverse, sarray(), varray());
  1770. bind_method(Quaternion, log, sarray(), varray());
  1771. bind_method(Quaternion, exp, sarray(), varray());
  1772. bind_method(Quaternion, angle_to, sarray("to"), varray());
  1773. bind_method(Quaternion, dot, sarray("with"), varray());
  1774. bind_method(Quaternion, slerp, sarray("to", "weight"), varray());
  1775. bind_method(Quaternion, slerpni, sarray("to", "weight"), varray());
  1776. bind_method(Quaternion, spherical_cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
  1777. bind_method(Quaternion, spherical_cubic_interpolate_in_time, sarray("b", "pre_a", "post_b", "weight", "b_t", "pre_a_t", "post_b_t"), varray());
  1778. bind_method(Quaternion, get_euler, sarray("order"), varray((int64_t)EulerOrder::YXZ));
  1779. bind_static_method(Quaternion, from_euler, sarray("euler"), varray());
  1780. bind_method(Quaternion, get_axis, sarray(), varray());
  1781. bind_method(Quaternion, get_angle, sarray(), varray());
  1782. /* Color */
  1783. bind_method(Color, to_argb32, sarray(), varray());
  1784. bind_method(Color, to_abgr32, sarray(), varray());
  1785. bind_method(Color, to_rgba32, sarray(), varray());
  1786. bind_method(Color, to_argb64, sarray(), varray());
  1787. bind_method(Color, to_abgr64, sarray(), varray());
  1788. bind_method(Color, to_rgba64, sarray(), varray());
  1789. bind_method(Color, to_html, sarray("with_alpha"), varray(true));
  1790. bind_method(Color, clamp, sarray("min", "max"), varray(Color(0, 0, 0, 0), Color(1, 1, 1, 1)));
  1791. bind_method(Color, inverted, sarray(), varray());
  1792. bind_method(Color, lerp, sarray("to", "weight"), varray());
  1793. bind_method(Color, lightened, sarray("amount"), varray());
  1794. bind_method(Color, darkened, sarray("amount"), varray());
  1795. bind_method(Color, blend, sarray("over"), varray());
  1796. bind_method(Color, get_luminance, sarray(), varray());
  1797. bind_method(Color, srgb_to_linear, sarray(), varray());
  1798. bind_method(Color, linear_to_srgb, sarray(), varray());
  1799. bind_method(Color, is_equal_approx, sarray("to"), varray());
  1800. bind_static_method(Color, hex, sarray("hex"), varray());
  1801. bind_static_method(Color, hex64, sarray("hex"), varray());
  1802. bind_static_method(Color, html, sarray("rgba"), varray());
  1803. bind_static_method(Color, html_is_valid, sarray("color"), varray());
  1804. bind_static_method(Color, from_string, sarray("str", "default"), varray());
  1805. bind_static_method(Color, from_hsv, sarray("h", "s", "v", "alpha"), varray(1.0));
  1806. bind_static_method(Color, from_ok_hsl, sarray("h", "s", "l", "alpha"), varray(1.0));
  1807. bind_static_method(Color, from_rgbe9995, sarray("rgbe"), varray());
  1808. /* RID */
  1809. bind_method(RID, is_valid, sarray(), varray());
  1810. bind_method(RID, get_id, sarray(), varray());
  1811. /* NodePath */
  1812. bind_method(NodePath, is_absolute, sarray(), varray());
  1813. bind_method(NodePath, get_name_count, sarray(), varray());
  1814. bind_method(NodePath, get_name, sarray("idx"), varray());
  1815. bind_method(NodePath, get_subname_count, sarray(), varray());
  1816. bind_method(NodePath, hash, sarray(), varray());
  1817. bind_method(NodePath, get_subname, sarray("idx"), varray());
  1818. bind_method(NodePath, get_concatenated_names, sarray(), varray());
  1819. bind_method(NodePath, get_concatenated_subnames, sarray(), varray());
  1820. bind_method(NodePath, slice, sarray("begin", "end"), varray(INT_MAX));
  1821. bind_method(NodePath, get_as_property_path, sarray(), varray());
  1822. bind_method(NodePath, is_empty, sarray(), varray());
  1823. /* Callable */
  1824. bind_static_method(Callable, create, sarray("variant", "method"), varray());
  1825. bind_method(Callable, callv, sarray("arguments"), varray());
  1826. bind_method(Callable, is_null, sarray(), varray());
  1827. bind_method(Callable, is_custom, sarray(), varray());
  1828. bind_method(Callable, is_standard, sarray(), varray());
  1829. bind_method(Callable, is_valid, sarray(), varray());
  1830. bind_method(Callable, get_object, sarray(), varray());
  1831. bind_method(Callable, get_object_id, sarray(), varray());
  1832. bind_method(Callable, get_method, sarray(), varray());
  1833. bind_function(Callable, get_argument_count, _VariantCall::func_Callable_get_argument_count, sarray(), varray());
  1834. bind_method(Callable, get_bound_arguments_count, sarray(), varray());
  1835. bind_method(Callable, get_bound_arguments, sarray(), varray());
  1836. bind_method(Callable, hash, sarray(), varray());
  1837. bind_method(Callable, bindv, sarray("arguments"), varray());
  1838. bind_method(Callable, unbind, sarray("argcount"), varray());
  1839. bind_custom(Callable, call, _VariantCall::func_Callable_call, true, Variant);
  1840. bind_custom(Callable, call_deferred, _VariantCall::func_Callable_call_deferred, false, Variant);
  1841. bind_custom(Callable, rpc, _VariantCall::func_Callable_rpc, false, Variant);
  1842. bind_custom1(Callable, rpc_id, _VariantCall::func_Callable_rpc_id, Variant::INT, "peer_id");
  1843. bind_custom(Callable, bind, _VariantCall::func_Callable_bind, true, Callable);
  1844. /* Signal */
  1845. bind_method(Signal, is_null, sarray(), varray());
  1846. bind_method(Signal, get_object, sarray(), varray());
  1847. bind_method(Signal, get_object_id, sarray(), varray());
  1848. bind_method(Signal, get_name, sarray(), varray());
  1849. bind_method(Signal, connect, sarray("callable", "flags"), varray(0));
  1850. bind_method(Signal, disconnect, sarray("callable"), varray());
  1851. bind_method(Signal, is_connected, sarray("callable"), varray());
  1852. bind_method(Signal, get_connections, sarray(), varray());
  1853. bind_custom(Signal, emit, _VariantCall::func_Signal_emit, false, Variant);
  1854. /* Transform2D */
  1855. bind_method(Transform2D, inverse, sarray(), varray());
  1856. bind_method(Transform2D, affine_inverse, sarray(), varray());
  1857. bind_method(Transform2D, get_rotation, sarray(), varray());
  1858. bind_method(Transform2D, get_origin, sarray(), varray());
  1859. bind_method(Transform2D, get_scale, sarray(), varray());
  1860. bind_method(Transform2D, get_skew, sarray(), varray());
  1861. bind_method(Transform2D, orthonormalized, sarray(), varray());
  1862. bind_method(Transform2D, rotated, sarray("angle"), varray());
  1863. bind_method(Transform2D, rotated_local, sarray("angle"), varray());
  1864. bind_method(Transform2D, scaled, sarray("scale"), varray());
  1865. bind_method(Transform2D, scaled_local, sarray("scale"), varray());
  1866. bind_method(Transform2D, translated, sarray("offset"), varray());
  1867. bind_method(Transform2D, translated_local, sarray("offset"), varray());
  1868. bind_method(Transform2D, determinant, sarray(), varray());
  1869. bind_method(Transform2D, basis_xform, sarray("v"), varray());
  1870. bind_method(Transform2D, basis_xform_inv, sarray("v"), varray());
  1871. bind_method(Transform2D, interpolate_with, sarray("xform", "weight"), varray());
  1872. bind_method(Transform2D, is_conformal, sarray(), varray());
  1873. bind_method(Transform2D, is_equal_approx, sarray("xform"), varray());
  1874. bind_method(Transform2D, is_finite, sarray(), varray());
  1875. // Do not bind functions like set_rotation, set_scale, set_skew, etc because this type is immutable and can't be modified.
  1876. bind_method(Transform2D, looking_at, sarray("target"), varray(Vector2()));
  1877. /* Basis */
  1878. bind_method(Basis, inverse, sarray(), varray());
  1879. bind_method(Basis, transposed, sarray(), varray());
  1880. bind_method(Basis, orthonormalized, sarray(), varray());
  1881. bind_method(Basis, determinant, sarray(), varray());
  1882. bind_methodv(Basis, rotated, static_cast<Basis (Basis::*)(const Vector3 &, real_t) const>(&Basis::rotated), sarray("axis", "angle"), varray());
  1883. bind_method(Basis, scaled, sarray("scale"), varray());
  1884. bind_method(Basis, get_scale, sarray(), varray());
  1885. bind_method(Basis, get_euler, sarray("order"), varray((int64_t)EulerOrder::YXZ));
  1886. bind_method(Basis, tdotx, sarray("with"), varray());
  1887. bind_method(Basis, tdoty, sarray("with"), varray());
  1888. bind_method(Basis, tdotz, sarray("with"), varray());
  1889. bind_method(Basis, slerp, sarray("to", "weight"), varray());
  1890. bind_method(Basis, is_conformal, sarray(), varray());
  1891. bind_method(Basis, is_equal_approx, sarray("b"), varray());
  1892. bind_method(Basis, is_finite, sarray(), varray());
  1893. bind_method(Basis, get_rotation_quaternion, sarray(), varray());
  1894. bind_static_method(Basis, looking_at, sarray("target", "up", "use_model_front"), varray(Vector3(0, 1, 0), false));
  1895. bind_static_method(Basis, from_scale, sarray("scale"), varray());
  1896. bind_static_method(Basis, from_euler, sarray("euler", "order"), varray((int64_t)EulerOrder::YXZ));
  1897. /* AABB */
  1898. bind_method(AABB, abs, sarray(), varray());
  1899. bind_method(AABB, get_center, sarray(), varray());
  1900. bind_method(AABB, get_volume, sarray(), varray());
  1901. bind_method(AABB, has_volume, sarray(), varray());
  1902. bind_method(AABB, has_surface, sarray(), varray());
  1903. bind_method(AABB, has_point, sarray("point"), varray());
  1904. bind_method(AABB, is_equal_approx, sarray("aabb"), varray());
  1905. bind_method(AABB, is_finite, sarray(), varray());
  1906. bind_method(AABB, intersects, sarray("with"), varray());
  1907. bind_method(AABB, encloses, sarray("with"), varray());
  1908. bind_method(AABB, intersects_plane, sarray("plane"), varray());
  1909. bind_method(AABB, intersection, sarray("with"), varray());
  1910. bind_method(AABB, merge, sarray("with"), varray());
  1911. bind_method(AABB, expand, sarray("to_point"), varray());
  1912. bind_method(AABB, grow, sarray("by"), varray());
  1913. bind_method(AABB, get_support, sarray("dir"), varray());
  1914. bind_method(AABB, get_longest_axis, sarray(), varray());
  1915. bind_method(AABB, get_longest_axis_index, sarray(), varray());
  1916. bind_method(AABB, get_longest_axis_size, sarray(), varray());
  1917. bind_method(AABB, get_shortest_axis, sarray(), varray());
  1918. bind_method(AABB, get_shortest_axis_index, sarray(), varray());
  1919. bind_method(AABB, get_shortest_axis_size, sarray(), varray());
  1920. bind_method(AABB, get_endpoint, sarray("idx"), varray());
  1921. bind_methodv(AABB, intersects_segment, &AABB::intersects_segment_bind, sarray("from", "to"), varray());
  1922. bind_methodv(AABB, intersects_ray, &AABB::intersects_ray_bind, sarray("from", "dir"), varray());
  1923. /* Transform3D */
  1924. bind_method(Transform3D, inverse, sarray(), varray());
  1925. bind_method(Transform3D, affine_inverse, sarray(), varray());
  1926. bind_method(Transform3D, orthonormalized, sarray(), varray());
  1927. bind_method(Transform3D, rotated, sarray("axis", "angle"), varray());
  1928. bind_method(Transform3D, rotated_local, sarray("axis", "angle"), varray());
  1929. bind_method(Transform3D, scaled, sarray("scale"), varray());
  1930. bind_method(Transform3D, scaled_local, sarray("scale"), varray());
  1931. bind_method(Transform3D, translated, sarray("offset"), varray());
  1932. bind_method(Transform3D, translated_local, sarray("offset"), varray());
  1933. bind_method(Transform3D, looking_at, sarray("target", "up", "use_model_front"), varray(Vector3(0, 1, 0), false));
  1934. bind_method(Transform3D, interpolate_with, sarray("xform", "weight"), varray());
  1935. bind_method(Transform3D, is_equal_approx, sarray("xform"), varray());
  1936. bind_method(Transform3D, is_finite, sarray(), varray());
  1937. /* Projection */
  1938. bind_static_method(Projection, create_depth_correction, sarray("flip_y"), varray());
  1939. bind_static_method(Projection, create_light_atlas_rect, sarray("rect"), varray());
  1940. bind_static_method(Projection, create_perspective, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov"), varray(false));
  1941. bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", "convergence_dist"), varray());
  1942. bind_static_method(Projection, create_for_hmd, sarray("eye", "aspect", "intraocular_dist", "display_width", "display_to_lens", "oversample", "z_near", "z_far"), varray());
  1943. bind_static_method(Projection, create_orthogonal, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray());
  1944. bind_static_method(Projection, create_orthogonal_aspect, sarray("size", "aspect", "z_near", "z_far", "flip_fov"), varray(false));
  1945. bind_static_method(Projection, create_frustum, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray());
  1946. bind_static_method(Projection, create_frustum_aspect, sarray("size", "aspect", "offset", "z_near", "z_far", "flip_fov"), varray(false));
  1947. bind_static_method(Projection, create_fit_aabb, sarray("aabb"), varray());
  1948. bind_method(Projection, determinant, sarray(), varray());
  1949. bind_method(Projection, perspective_znear_adjusted, sarray("new_znear"), varray());
  1950. bind_method(Projection, get_projection_plane, sarray("plane"), varray());
  1951. bind_method(Projection, flipped_y, sarray(), varray());
  1952. bind_method(Projection, jitter_offseted, sarray("offset"), varray());
  1953. bind_static_method(Projection, get_fovy, sarray("fovx", "aspect"), varray());
  1954. bind_method(Projection, get_z_far, sarray(), varray());
  1955. bind_method(Projection, get_z_near, sarray(), varray());
  1956. bind_method(Projection, get_aspect, sarray(), varray());
  1957. bind_method(Projection, get_fov, sarray(), varray());
  1958. bind_method(Projection, is_orthogonal, sarray(), varray());
  1959. bind_method(Projection, get_viewport_half_extents, sarray(), varray());
  1960. bind_method(Projection, get_far_plane_half_extents, sarray(), varray());
  1961. bind_method(Projection, inverse, sarray(), varray());
  1962. bind_method(Projection, get_pixels_per_meter, sarray("for_pixel_width"), varray());
  1963. bind_method(Projection, get_lod_multiplier, sarray(), varray());
  1964. /* Dictionary */
  1965. bind_method(Dictionary, size, sarray(), varray());
  1966. bind_method(Dictionary, is_empty, sarray(), varray());
  1967. bind_method(Dictionary, clear, sarray(), varray());
  1968. bind_method(Dictionary, merge, sarray("dictionary", "overwrite"), varray(false));
  1969. bind_method(Dictionary, merged, sarray("dictionary", "overwrite"), varray(false));
  1970. bind_method(Dictionary, has, sarray("key"), varray());
  1971. bind_method(Dictionary, has_all, sarray("keys"), varray());
  1972. bind_method(Dictionary, find_key, sarray("value"), varray());
  1973. bind_method(Dictionary, erase, sarray("key"), varray());
  1974. bind_method(Dictionary, hash, sarray(), varray());
  1975. bind_method(Dictionary, keys, sarray(), varray());
  1976. bind_method(Dictionary, values, sarray(), varray());
  1977. bind_method(Dictionary, duplicate, sarray("deep"), varray(false));
  1978. bind_method(Dictionary, get, sarray("key", "default"), varray(Variant()));
  1979. bind_method(Dictionary, get_or_add, sarray("key", "default"), varray(Variant()));
  1980. bind_method(Dictionary, make_read_only, sarray(), varray());
  1981. bind_method(Dictionary, is_read_only, sarray(), varray());
  1982. /* Array */
  1983. bind_method(Array, size, sarray(), varray());
  1984. bind_method(Array, is_empty, sarray(), varray());
  1985. bind_method(Array, clear, sarray(), varray());
  1986. bind_method(Array, hash, sarray(), varray());
  1987. bind_method(Array, assign, sarray("array"), varray());
  1988. bind_method(Array, push_back, sarray("value"), varray());
  1989. bind_method(Array, push_front, sarray("value"), varray());
  1990. bind_method(Array, append, sarray("value"), varray());
  1991. bind_method(Array, append_array, sarray("array"), varray());
  1992. bind_method(Array, resize, sarray("size"), varray());
  1993. bind_method(Array, insert, sarray("position", "value"), varray());
  1994. bind_method(Array, remove_at, sarray("position"), varray());
  1995. bind_method(Array, fill, sarray("value"), varray());
  1996. bind_method(Array, erase, sarray("value"), varray());
  1997. bind_method(Array, front, sarray(), varray());
  1998. bind_method(Array, back, sarray(), varray());
  1999. bind_method(Array, pick_random, sarray(), varray());
  2000. bind_method(Array, find, sarray("what", "from"), varray(0));
  2001. bind_method(Array, rfind, sarray("what", "from"), varray(-1));
  2002. bind_method(Array, count, sarray("value"), varray());
  2003. bind_method(Array, has, sarray("value"), varray());
  2004. bind_method(Array, pop_back, sarray(), varray());
  2005. bind_method(Array, pop_front, sarray(), varray());
  2006. bind_method(Array, pop_at, sarray("position"), varray());
  2007. bind_method(Array, sort, sarray(), varray());
  2008. bind_method(Array, sort_custom, sarray("func"), varray());
  2009. bind_method(Array, shuffle, sarray(), varray());
  2010. bind_method(Array, bsearch, sarray("value", "before"), varray(true));
  2011. bind_method(Array, bsearch_custom, sarray("value", "func", "before"), varray(true));
  2012. bind_method(Array, reverse, sarray(), varray());
  2013. bind_method(Array, duplicate, sarray("deep"), varray(false));
  2014. bind_method(Array, slice, sarray("begin", "end", "step", "deep"), varray(INT_MAX, 1, false));
  2015. bind_method(Array, filter, sarray("method"), varray());
  2016. bind_method(Array, map, sarray("method"), varray());
  2017. bind_method(Array, reduce, sarray("method", "accum"), varray(Variant()));
  2018. bind_method(Array, any, sarray("method"), varray());
  2019. bind_method(Array, all, sarray("method"), varray());
  2020. bind_method(Array, max, sarray(), varray());
  2021. bind_method(Array, min, sarray(), varray());
  2022. bind_method(Array, is_typed, sarray(), varray());
  2023. bind_method(Array, is_same_typed, sarray("array"), varray());
  2024. bind_method(Array, get_typed_builtin, sarray(), varray());
  2025. bind_method(Array, get_typed_class_name, sarray(), varray());
  2026. bind_method(Array, get_typed_script, sarray(), varray());
  2027. bind_method(Array, make_read_only, sarray(), varray());
  2028. bind_method(Array, is_read_only, sarray(), varray());
  2029. /* Byte Array */
  2030. bind_method(PackedByteArray, size, sarray(), varray());
  2031. bind_method(PackedByteArray, is_empty, sarray(), varray());
  2032. bind_method(PackedByteArray, set, sarray("index", "value"), varray());
  2033. bind_method(PackedByteArray, push_back, sarray("value"), varray());
  2034. bind_method(PackedByteArray, append, sarray("value"), varray());
  2035. bind_method(PackedByteArray, append_array, sarray("array"), varray());
  2036. bind_method(PackedByteArray, remove_at, sarray("index"), varray());
  2037. bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray());
  2038. bind_method(PackedByteArray, fill, sarray("value"), varray());
  2039. bind_methodv(PackedByteArray, resize, &PackedByteArray::resize_zeroed, sarray("new_size"), varray());
  2040. bind_method(PackedByteArray, clear, sarray(), varray());
  2041. bind_method(PackedByteArray, has, sarray("value"), varray());
  2042. bind_method(PackedByteArray, reverse, sarray(), varray());
  2043. bind_method(PackedByteArray, slice, sarray("begin", "end"), varray(INT_MAX));
  2044. bind_method(PackedByteArray, sort, sarray(), varray());
  2045. bind_method(PackedByteArray, bsearch, sarray("value", "before"), varray(true));
  2046. bind_method(PackedByteArray, duplicate, sarray(), varray());
  2047. bind_method(PackedByteArray, find, sarray("value", "from"), varray(0));
  2048. bind_method(PackedByteArray, rfind, sarray("value", "from"), varray(-1));
  2049. bind_method(PackedByteArray, count, sarray("value"), varray());
  2050. bind_function(PackedByteArray, get_string_from_ascii, _VariantCall::func_PackedByteArray_get_string_from_ascii, sarray(), varray());
  2051. bind_function(PackedByteArray, get_string_from_utf8, _VariantCall::func_PackedByteArray_get_string_from_utf8, sarray(), varray());
  2052. bind_function(PackedByteArray, get_string_from_utf16, _VariantCall::func_PackedByteArray_get_string_from_utf16, sarray(), varray());
  2053. bind_function(PackedByteArray, get_string_from_utf32, _VariantCall::func_PackedByteArray_get_string_from_utf32, sarray(), varray());
  2054. bind_function(PackedByteArray, get_string_from_wchar, _VariantCall::func_PackedByteArray_get_string_from_wchar, sarray(), varray());
  2055. bind_function(PackedByteArray, hex_encode, _VariantCall::func_PackedByteArray_hex_encode, sarray(), varray());
  2056. bind_function(PackedByteArray, compress, _VariantCall::func_PackedByteArray_compress, sarray("compression_mode"), varray(0));
  2057. bind_function(PackedByteArray, decompress, _VariantCall::func_PackedByteArray_decompress, sarray("buffer_size", "compression_mode"), varray(0));
  2058. bind_function(PackedByteArray, decompress_dynamic, _VariantCall::func_PackedByteArray_decompress_dynamic, sarray("max_output_size", "compression_mode"), varray(0));
  2059. bind_function(PackedByteArray, decode_u8, _VariantCall::func_PackedByteArray_decode_u8, sarray("byte_offset"), varray());
  2060. bind_function(PackedByteArray, decode_s8, _VariantCall::func_PackedByteArray_decode_s8, sarray("byte_offset"), varray());
  2061. bind_function(PackedByteArray, decode_u16, _VariantCall::func_PackedByteArray_decode_u16, sarray("byte_offset"), varray());
  2062. bind_function(PackedByteArray, decode_s16, _VariantCall::func_PackedByteArray_decode_s16, sarray("byte_offset"), varray());
  2063. bind_function(PackedByteArray, decode_u32, _VariantCall::func_PackedByteArray_decode_u32, sarray("byte_offset"), varray());
  2064. bind_function(PackedByteArray, decode_s32, _VariantCall::func_PackedByteArray_decode_s32, sarray("byte_offset"), varray());
  2065. bind_function(PackedByteArray, decode_u64, _VariantCall::func_PackedByteArray_decode_u64, sarray("byte_offset"), varray());
  2066. bind_function(PackedByteArray, decode_s64, _VariantCall::func_PackedByteArray_decode_s64, sarray("byte_offset"), varray());
  2067. bind_function(PackedByteArray, decode_half, _VariantCall::func_PackedByteArray_decode_half, sarray("byte_offset"), varray());
  2068. bind_function(PackedByteArray, decode_float, _VariantCall::func_PackedByteArray_decode_float, sarray("byte_offset"), varray());
  2069. bind_function(PackedByteArray, decode_double, _VariantCall::func_PackedByteArray_decode_double, sarray("byte_offset"), varray());
  2070. bind_function(PackedByteArray, has_encoded_var, _VariantCall::func_PackedByteArray_has_encoded_var, sarray("byte_offset", "allow_objects"), varray(false));
  2071. bind_function(PackedByteArray, decode_var, _VariantCall::func_PackedByteArray_decode_var, sarray("byte_offset", "allow_objects"), varray(false));
  2072. bind_function(PackedByteArray, decode_var_size, _VariantCall::func_PackedByteArray_decode_var_size, sarray("byte_offset", "allow_objects"), varray(false));
  2073. bind_function(PackedByteArray, to_int32_array, _VariantCall::func_PackedByteArray_decode_s32_array, sarray(), varray());
  2074. bind_function(PackedByteArray, to_int64_array, _VariantCall::func_PackedByteArray_decode_s64_array, sarray(), varray());
  2075. bind_function(PackedByteArray, to_float32_array, _VariantCall::func_PackedByteArray_decode_float_array, sarray(), varray());
  2076. bind_function(PackedByteArray, to_float64_array, _VariantCall::func_PackedByteArray_decode_double_array, sarray(), varray());
  2077. bind_functionnc(PackedByteArray, encode_u8, _VariantCall::func_PackedByteArray_encode_u8, sarray("byte_offset", "value"), varray());
  2078. bind_functionnc(PackedByteArray, encode_s8, _VariantCall::func_PackedByteArray_encode_s8, sarray("byte_offset", "value"), varray());
  2079. bind_functionnc(PackedByteArray, encode_u16, _VariantCall::func_PackedByteArray_encode_u16, sarray("byte_offset", "value"), varray());
  2080. bind_functionnc(PackedByteArray, encode_s16, _VariantCall::func_PackedByteArray_encode_s16, sarray("byte_offset", "value"), varray());
  2081. bind_functionnc(PackedByteArray, encode_u32, _VariantCall::func_PackedByteArray_encode_u32, sarray("byte_offset", "value"), varray());
  2082. bind_functionnc(PackedByteArray, encode_s32, _VariantCall::func_PackedByteArray_encode_s32, sarray("byte_offset", "value"), varray());
  2083. bind_functionnc(PackedByteArray, encode_u64, _VariantCall::func_PackedByteArray_encode_u64, sarray("byte_offset", "value"), varray());
  2084. bind_functionnc(PackedByteArray, encode_s64, _VariantCall::func_PackedByteArray_encode_s64, sarray("byte_offset", "value"), varray());
  2085. bind_functionnc(PackedByteArray, encode_half, _VariantCall::func_PackedByteArray_encode_half, sarray("byte_offset", "value"), varray());
  2086. bind_functionnc(PackedByteArray, encode_float, _VariantCall::func_PackedByteArray_encode_float, sarray("byte_offset", "value"), varray());
  2087. bind_functionnc(PackedByteArray, encode_double, _VariantCall::func_PackedByteArray_encode_double, sarray("byte_offset", "value"), varray());
  2088. bind_functionnc(PackedByteArray, encode_var, _VariantCall::func_PackedByteArray_encode_var, sarray("byte_offset", "value", "allow_objects"), varray(false));
  2089. /* Int32 Array */
  2090. bind_method(PackedInt32Array, size, sarray(), varray());
  2091. bind_method(PackedInt32Array, is_empty, sarray(), varray());
  2092. bind_method(PackedInt32Array, set, sarray("index", "value"), varray());
  2093. bind_method(PackedInt32Array, push_back, sarray("value"), varray());
  2094. bind_method(PackedInt32Array, append, sarray("value"), varray());
  2095. bind_method(PackedInt32Array, append_array, sarray("array"), varray());
  2096. bind_method(PackedInt32Array, remove_at, sarray("index"), varray());
  2097. bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray());
  2098. bind_method(PackedInt32Array, fill, sarray("value"), varray());
  2099. bind_methodv(PackedInt32Array, resize, &PackedInt32Array::resize_zeroed, sarray("new_size"), varray());
  2100. bind_method(PackedInt32Array, clear, sarray(), varray());
  2101. bind_method(PackedInt32Array, has, sarray("value"), varray());
  2102. bind_method(PackedInt32Array, reverse, sarray(), varray());
  2103. bind_method(PackedInt32Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2104. bind_method(PackedInt32Array, to_byte_array, sarray(), varray());
  2105. bind_method(PackedInt32Array, sort, sarray(), varray());
  2106. bind_method(PackedInt32Array, bsearch, sarray("value", "before"), varray(true));
  2107. bind_method(PackedInt32Array, duplicate, sarray(), varray());
  2108. bind_method(PackedInt32Array, find, sarray("value", "from"), varray(0));
  2109. bind_method(PackedInt32Array, rfind, sarray("value", "from"), varray(-1));
  2110. bind_method(PackedInt32Array, count, sarray("value"), varray());
  2111. /* Int64 Array */
  2112. bind_method(PackedInt64Array, size, sarray(), varray());
  2113. bind_method(PackedInt64Array, is_empty, sarray(), varray());
  2114. bind_method(PackedInt64Array, set, sarray("index", "value"), varray());
  2115. bind_method(PackedInt64Array, push_back, sarray("value"), varray());
  2116. bind_method(PackedInt64Array, append, sarray("value"), varray());
  2117. bind_method(PackedInt64Array, append_array, sarray("array"), varray());
  2118. bind_method(PackedInt64Array, remove_at, sarray("index"), varray());
  2119. bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray());
  2120. bind_method(PackedInt64Array, fill, sarray("value"), varray());
  2121. bind_methodv(PackedInt64Array, resize, &PackedInt64Array::resize_zeroed, sarray("new_size"), varray());
  2122. bind_method(PackedInt64Array, clear, sarray(), varray());
  2123. bind_method(PackedInt64Array, has, sarray("value"), varray());
  2124. bind_method(PackedInt64Array, reverse, sarray(), varray());
  2125. bind_method(PackedInt64Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2126. bind_method(PackedInt64Array, to_byte_array, sarray(), varray());
  2127. bind_method(PackedInt64Array, sort, sarray(), varray());
  2128. bind_method(PackedInt64Array, bsearch, sarray("value", "before"), varray(true));
  2129. bind_method(PackedInt64Array, duplicate, sarray(), varray());
  2130. bind_method(PackedInt64Array, find, sarray("value", "from"), varray(0));
  2131. bind_method(PackedInt64Array, rfind, sarray("value", "from"), varray(-1));
  2132. bind_method(PackedInt64Array, count, sarray("value"), varray());
  2133. /* Float32 Array */
  2134. bind_method(PackedFloat32Array, size, sarray(), varray());
  2135. bind_method(PackedFloat32Array, is_empty, sarray(), varray());
  2136. bind_method(PackedFloat32Array, set, sarray("index", "value"), varray());
  2137. bind_method(PackedFloat32Array, push_back, sarray("value"), varray());
  2138. bind_method(PackedFloat32Array, append, sarray("value"), varray());
  2139. bind_method(PackedFloat32Array, append_array, sarray("array"), varray());
  2140. bind_method(PackedFloat32Array, remove_at, sarray("index"), varray());
  2141. bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray());
  2142. bind_method(PackedFloat32Array, fill, sarray("value"), varray());
  2143. bind_methodv(PackedFloat32Array, resize, &PackedFloat32Array::resize_zeroed, sarray("new_size"), varray());
  2144. bind_method(PackedFloat32Array, clear, sarray(), varray());
  2145. bind_method(PackedFloat32Array, has, sarray("value"), varray());
  2146. bind_method(PackedFloat32Array, reverse, sarray(), varray());
  2147. bind_method(PackedFloat32Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2148. bind_method(PackedFloat32Array, to_byte_array, sarray(), varray());
  2149. bind_method(PackedFloat32Array, sort, sarray(), varray());
  2150. bind_method(PackedFloat32Array, bsearch, sarray("value", "before"), varray(true));
  2151. bind_method(PackedFloat32Array, duplicate, sarray(), varray());
  2152. bind_method(PackedFloat32Array, find, sarray("value", "from"), varray(0));
  2153. bind_method(PackedFloat32Array, rfind, sarray("value", "from"), varray(-1));
  2154. bind_method(PackedFloat32Array, count, sarray("value"), varray());
  2155. /* Float64 Array */
  2156. bind_method(PackedFloat64Array, size, sarray(), varray());
  2157. bind_method(PackedFloat64Array, is_empty, sarray(), varray());
  2158. bind_method(PackedFloat64Array, set, sarray("index", "value"), varray());
  2159. bind_method(PackedFloat64Array, push_back, sarray("value"), varray());
  2160. bind_method(PackedFloat64Array, append, sarray("value"), varray());
  2161. bind_method(PackedFloat64Array, append_array, sarray("array"), varray());
  2162. bind_method(PackedFloat64Array, remove_at, sarray("index"), varray());
  2163. bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray());
  2164. bind_method(PackedFloat64Array, fill, sarray("value"), varray());
  2165. bind_methodv(PackedFloat64Array, resize, &PackedFloat64Array::resize_zeroed, sarray("new_size"), varray());
  2166. bind_method(PackedFloat64Array, clear, sarray(), varray());
  2167. bind_method(PackedFloat64Array, has, sarray("value"), varray());
  2168. bind_method(PackedFloat64Array, reverse, sarray(), varray());
  2169. bind_method(PackedFloat64Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2170. bind_method(PackedFloat64Array, to_byte_array, sarray(), varray());
  2171. bind_method(PackedFloat64Array, sort, sarray(), varray());
  2172. bind_method(PackedFloat64Array, bsearch, sarray("value", "before"), varray(true));
  2173. bind_method(PackedFloat64Array, duplicate, sarray(), varray());
  2174. bind_method(PackedFloat64Array, find, sarray("value", "from"), varray(0));
  2175. bind_method(PackedFloat64Array, rfind, sarray("value", "from"), varray(-1));
  2176. bind_method(PackedFloat64Array, count, sarray("value"), varray());
  2177. /* String Array */
  2178. bind_method(PackedStringArray, size, sarray(), varray());
  2179. bind_method(PackedStringArray, is_empty, sarray(), varray());
  2180. bind_method(PackedStringArray, set, sarray("index", "value"), varray());
  2181. bind_method(PackedStringArray, push_back, sarray("value"), varray());
  2182. bind_method(PackedStringArray, append, sarray("value"), varray());
  2183. bind_method(PackedStringArray, append_array, sarray("array"), varray());
  2184. bind_method(PackedStringArray, remove_at, sarray("index"), varray());
  2185. bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray());
  2186. bind_method(PackedStringArray, fill, sarray("value"), varray());
  2187. bind_methodv(PackedStringArray, resize, &PackedStringArray::resize_zeroed, sarray("new_size"), varray());
  2188. bind_method(PackedStringArray, clear, sarray(), varray());
  2189. bind_method(PackedStringArray, has, sarray("value"), varray());
  2190. bind_method(PackedStringArray, reverse, sarray(), varray());
  2191. bind_method(PackedStringArray, slice, sarray("begin", "end"), varray(INT_MAX));
  2192. bind_method(PackedStringArray, to_byte_array, sarray(), varray());
  2193. bind_method(PackedStringArray, sort, sarray(), varray());
  2194. bind_method(PackedStringArray, bsearch, sarray("value", "before"), varray(true));
  2195. bind_method(PackedStringArray, duplicate, sarray(), varray());
  2196. bind_method(PackedStringArray, find, sarray("value", "from"), varray(0));
  2197. bind_method(PackedStringArray, rfind, sarray("value", "from"), varray(-1));
  2198. bind_method(PackedStringArray, count, sarray("value"), varray());
  2199. /* Vector2 Array */
  2200. bind_method(PackedVector2Array, size, sarray(), varray());
  2201. bind_method(PackedVector2Array, is_empty, sarray(), varray());
  2202. bind_method(PackedVector2Array, set, sarray("index", "value"), varray());
  2203. bind_method(PackedVector2Array, push_back, sarray("value"), varray());
  2204. bind_method(PackedVector2Array, append, sarray("value"), varray());
  2205. bind_method(PackedVector2Array, append_array, sarray("array"), varray());
  2206. bind_method(PackedVector2Array, remove_at, sarray("index"), varray());
  2207. bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray());
  2208. bind_method(PackedVector2Array, fill, sarray("value"), varray());
  2209. bind_methodv(PackedVector2Array, resize, &PackedVector2Array::resize_zeroed, sarray("new_size"), varray());
  2210. bind_method(PackedVector2Array, clear, sarray(), varray());
  2211. bind_method(PackedVector2Array, has, sarray("value"), varray());
  2212. bind_method(PackedVector2Array, reverse, sarray(), varray());
  2213. bind_method(PackedVector2Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2214. bind_method(PackedVector2Array, to_byte_array, sarray(), varray());
  2215. bind_method(PackedVector2Array, sort, sarray(), varray());
  2216. bind_method(PackedVector2Array, bsearch, sarray("value", "before"), varray(true));
  2217. bind_method(PackedVector2Array, duplicate, sarray(), varray());
  2218. bind_method(PackedVector2Array, find, sarray("value", "from"), varray(0));
  2219. bind_method(PackedVector2Array, rfind, sarray("value", "from"), varray(-1));
  2220. bind_method(PackedVector2Array, count, sarray("value"), varray());
  2221. /* Vector3 Array */
  2222. bind_method(PackedVector3Array, size, sarray(), varray());
  2223. bind_method(PackedVector3Array, is_empty, sarray(), varray());
  2224. bind_method(PackedVector3Array, set, sarray("index", "value"), varray());
  2225. bind_method(PackedVector3Array, push_back, sarray("value"), varray());
  2226. bind_method(PackedVector3Array, append, sarray("value"), varray());
  2227. bind_method(PackedVector3Array, append_array, sarray("array"), varray());
  2228. bind_method(PackedVector3Array, remove_at, sarray("index"), varray());
  2229. bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray());
  2230. bind_method(PackedVector3Array, fill, sarray("value"), varray());
  2231. bind_methodv(PackedVector3Array, resize, &PackedVector3Array::resize_zeroed, sarray("new_size"), varray());
  2232. bind_method(PackedVector3Array, clear, sarray(), varray());
  2233. bind_method(PackedVector3Array, has, sarray("value"), varray());
  2234. bind_method(PackedVector3Array, reverse, sarray(), varray());
  2235. bind_method(PackedVector3Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2236. bind_method(PackedVector3Array, to_byte_array, sarray(), varray());
  2237. bind_method(PackedVector3Array, sort, sarray(), varray());
  2238. bind_method(PackedVector3Array, bsearch, sarray("value", "before"), varray(true));
  2239. bind_method(PackedVector3Array, duplicate, sarray(), varray());
  2240. bind_method(PackedVector3Array, find, sarray("value", "from"), varray(0));
  2241. bind_method(PackedVector3Array, rfind, sarray("value", "from"), varray(-1));
  2242. bind_method(PackedVector3Array, count, sarray("value"), varray());
  2243. /* Color Array */
  2244. bind_method(PackedColorArray, size, sarray(), varray());
  2245. bind_method(PackedColorArray, is_empty, sarray(), varray());
  2246. bind_method(PackedColorArray, set, sarray("index", "value"), varray());
  2247. bind_method(PackedColorArray, push_back, sarray("value"), varray());
  2248. bind_method(PackedColorArray, append, sarray("value"), varray());
  2249. bind_method(PackedColorArray, append_array, sarray("array"), varray());
  2250. bind_method(PackedColorArray, remove_at, sarray("index"), varray());
  2251. bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray());
  2252. bind_method(PackedColorArray, fill, sarray("value"), varray());
  2253. bind_methodv(PackedColorArray, resize, &PackedColorArray::resize_zeroed, sarray("new_size"), varray());
  2254. bind_method(PackedColorArray, clear, sarray(), varray());
  2255. bind_method(PackedColorArray, has, sarray("value"), varray());
  2256. bind_method(PackedColorArray, reverse, sarray(), varray());
  2257. bind_method(PackedColorArray, slice, sarray("begin", "end"), varray(INT_MAX));
  2258. bind_method(PackedColorArray, to_byte_array, sarray(), varray());
  2259. bind_method(PackedColorArray, sort, sarray(), varray());
  2260. bind_method(PackedColorArray, bsearch, sarray("value", "before"), varray(true));
  2261. bind_method(PackedColorArray, duplicate, sarray(), varray());
  2262. bind_method(PackedColorArray, find, sarray("value", "from"), varray(0));
  2263. bind_method(PackedColorArray, rfind, sarray("value", "from"), varray(-1));
  2264. bind_method(PackedColorArray, count, sarray("value"), varray());
  2265. /* Vector4 Array */
  2266. bind_method(PackedVector4Array, size, sarray(), varray());
  2267. bind_method(PackedVector4Array, is_empty, sarray(), varray());
  2268. bind_method(PackedVector4Array, set, sarray("index", "value"), varray());
  2269. bind_method(PackedVector4Array, push_back, sarray("value"), varray());
  2270. bind_method(PackedVector4Array, append, sarray("value"), varray());
  2271. bind_method(PackedVector4Array, append_array, sarray("array"), varray());
  2272. bind_method(PackedVector4Array, remove_at, sarray("index"), varray());
  2273. bind_method(PackedVector4Array, insert, sarray("at_index", "value"), varray());
  2274. bind_method(PackedVector4Array, fill, sarray("value"), varray());
  2275. bind_methodv(PackedVector4Array, resize, &PackedVector4Array::resize_zeroed, sarray("new_size"), varray());
  2276. bind_method(PackedVector4Array, clear, sarray(), varray());
  2277. bind_method(PackedVector4Array, has, sarray("value"), varray());
  2278. bind_method(PackedVector4Array, reverse, sarray(), varray());
  2279. bind_method(PackedVector4Array, slice, sarray("begin", "end"), varray(INT_MAX));
  2280. bind_method(PackedVector4Array, to_byte_array, sarray(), varray());
  2281. bind_method(PackedVector4Array, sort, sarray(), varray());
  2282. bind_method(PackedVector4Array, bsearch, sarray("value", "before"), varray(true));
  2283. bind_method(PackedVector4Array, duplicate, sarray(), varray());
  2284. bind_method(PackedVector4Array, find, sarray("value", "from"), varray(0));
  2285. bind_method(PackedVector4Array, rfind, sarray("value", "from"), varray(-1));
  2286. bind_method(PackedVector4Array, count, sarray("value"), varray());
  2287. /* Register constants */
  2288. int ncc = Color::get_named_color_count();
  2289. for (int i = 0; i < ncc; i++) {
  2290. _VariantCall::add_variant_constant(Variant::COLOR, Color::get_named_color_name(i), Color::get_named_color(i));
  2291. }
  2292. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_X", Vector3::AXIS_X);
  2293. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Y", Vector3::AXIS_Y);
  2294. _VariantCall::add_constant(Variant::VECTOR3, "AXIS_Z", Vector3::AXIS_Z);
  2295. _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_X", Vector3::AXIS_X);
  2296. _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_Y", Vector3::AXIS_Y);
  2297. _VariantCall::add_enum_constant(Variant::VECTOR3, "Axis", "AXIS_Z", Vector3::AXIS_Z);
  2298. _VariantCall::add_variant_constant(Variant::VECTOR3, "ZERO", Vector3(0, 0, 0));
  2299. _VariantCall::add_variant_constant(Variant::VECTOR3, "ONE", Vector3(1, 1, 1));
  2300. _VariantCall::add_variant_constant(Variant::VECTOR3, "INF", Vector3(INFINITY, INFINITY, INFINITY));
  2301. _VariantCall::add_variant_constant(Variant::VECTOR3, "LEFT", Vector3(-1, 0, 0));
  2302. _VariantCall::add_variant_constant(Variant::VECTOR3, "RIGHT", Vector3(1, 0, 0));
  2303. _VariantCall::add_variant_constant(Variant::VECTOR3, "UP", Vector3(0, 1, 0));
  2304. _VariantCall::add_variant_constant(Variant::VECTOR3, "DOWN", Vector3(0, -1, 0));
  2305. _VariantCall::add_variant_constant(Variant::VECTOR3, "FORWARD", Vector3(0, 0, -1));
  2306. _VariantCall::add_variant_constant(Variant::VECTOR3, "BACK", Vector3(0, 0, 1));
  2307. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_LEFT", Vector3(1, 0, 0));
  2308. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_RIGHT", Vector3(-1, 0, 0));
  2309. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_TOP", Vector3(0, 1, 0));
  2310. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_BOTTOM", Vector3(0, -1, 0));
  2311. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_FRONT", Vector3(0, 0, 1));
  2312. _VariantCall::add_variant_constant(Variant::VECTOR3, "MODEL_REAR", Vector3(0, 0, -1));
  2313. _VariantCall::add_constant(Variant::VECTOR4, "AXIS_X", Vector4::AXIS_X);
  2314. _VariantCall::add_constant(Variant::VECTOR4, "AXIS_Y", Vector4::AXIS_Y);
  2315. _VariantCall::add_constant(Variant::VECTOR4, "AXIS_Z", Vector4::AXIS_Z);
  2316. _VariantCall::add_constant(Variant::VECTOR4, "AXIS_W", Vector4::AXIS_W);
  2317. _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_X", Vector4::AXIS_X);
  2318. _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_Y", Vector4::AXIS_Y);
  2319. _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_Z", Vector4::AXIS_Z);
  2320. _VariantCall::add_enum_constant(Variant::VECTOR4, "Axis", "AXIS_W", Vector4::AXIS_W);
  2321. _VariantCall::add_variant_constant(Variant::VECTOR4, "ZERO", Vector4(0, 0, 0, 0));
  2322. _VariantCall::add_variant_constant(Variant::VECTOR4, "ONE", Vector4(1, 1, 1, 1));
  2323. _VariantCall::add_variant_constant(Variant::VECTOR4, "INF", Vector4(INFINITY, INFINITY, INFINITY, INFINITY));
  2324. _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_X", Vector3i::AXIS_X);
  2325. _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Y", Vector3i::AXIS_Y);
  2326. _VariantCall::add_constant(Variant::VECTOR3I, "AXIS_Z", Vector3i::AXIS_Z);
  2327. _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_X", Vector3i::AXIS_X);
  2328. _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_Y", Vector3i::AXIS_Y);
  2329. _VariantCall::add_enum_constant(Variant::VECTOR3I, "Axis", "AXIS_Z", Vector3i::AXIS_Z);
  2330. _VariantCall::add_constant(Variant::VECTOR4I, "AXIS_X", Vector4i::AXIS_X);
  2331. _VariantCall::add_constant(Variant::VECTOR4I, "AXIS_Y", Vector4i::AXIS_Y);
  2332. _VariantCall::add_constant(Variant::VECTOR4I, "AXIS_Z", Vector4i::AXIS_Z);
  2333. _VariantCall::add_constant(Variant::VECTOR4I, "AXIS_W", Vector4i::AXIS_W);
  2334. _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_X", Vector4i::AXIS_X);
  2335. _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_Y", Vector4i::AXIS_Y);
  2336. _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_Z", Vector4i::AXIS_Z);
  2337. _VariantCall::add_enum_constant(Variant::VECTOR4I, "Axis", "AXIS_W", Vector4i::AXIS_W);
  2338. _VariantCall::add_variant_constant(Variant::VECTOR4I, "ZERO", Vector4i(0, 0, 0, 0));
  2339. _VariantCall::add_variant_constant(Variant::VECTOR4I, "ONE", Vector4i(1, 1, 1, 1));
  2340. _VariantCall::add_variant_constant(Variant::VECTOR4I, "MIN", Vector4i(INT32_MIN, INT32_MIN, INT32_MIN, INT32_MIN));
  2341. _VariantCall::add_variant_constant(Variant::VECTOR4I, "MAX", Vector4i(INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX));
  2342. _VariantCall::add_variant_constant(Variant::VECTOR3I, "ZERO", Vector3i(0, 0, 0));
  2343. _VariantCall::add_variant_constant(Variant::VECTOR3I, "ONE", Vector3i(1, 1, 1));
  2344. _VariantCall::add_variant_constant(Variant::VECTOR3I, "MIN", Vector3i(INT32_MIN, INT32_MIN, INT32_MIN));
  2345. _VariantCall::add_variant_constant(Variant::VECTOR3I, "MAX", Vector3i(INT32_MAX, INT32_MAX, INT32_MAX));
  2346. _VariantCall::add_variant_constant(Variant::VECTOR3I, "LEFT", Vector3i(-1, 0, 0));
  2347. _VariantCall::add_variant_constant(Variant::VECTOR3I, "RIGHT", Vector3i(1, 0, 0));
  2348. _VariantCall::add_variant_constant(Variant::VECTOR3I, "UP", Vector3i(0, 1, 0));
  2349. _VariantCall::add_variant_constant(Variant::VECTOR3I, "DOWN", Vector3i(0, -1, 0));
  2350. _VariantCall::add_variant_constant(Variant::VECTOR3I, "FORWARD", Vector3i(0, 0, -1));
  2351. _VariantCall::add_variant_constant(Variant::VECTOR3I, "BACK", Vector3i(0, 0, 1));
  2352. _VariantCall::add_constant(Variant::VECTOR2, "AXIS_X", Vector2::AXIS_X);
  2353. _VariantCall::add_constant(Variant::VECTOR2, "AXIS_Y", Vector2::AXIS_Y);
  2354. _VariantCall::add_enum_constant(Variant::VECTOR2, "Axis", "AXIS_X", Vector2::AXIS_X);
  2355. _VariantCall::add_enum_constant(Variant::VECTOR2, "Axis", "AXIS_Y", Vector2::AXIS_Y);
  2356. _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_X", Vector2i::AXIS_X);
  2357. _VariantCall::add_constant(Variant::VECTOR2I, "AXIS_Y", Vector2i::AXIS_Y);
  2358. _VariantCall::add_enum_constant(Variant::VECTOR2I, "Axis", "AXIS_X", Vector2i::AXIS_X);
  2359. _VariantCall::add_enum_constant(Variant::VECTOR2I, "Axis", "AXIS_Y", Vector2i::AXIS_Y);
  2360. _VariantCall::add_variant_constant(Variant::VECTOR2, "ZERO", Vector2(0, 0));
  2361. _VariantCall::add_variant_constant(Variant::VECTOR2, "ONE", Vector2(1, 1));
  2362. _VariantCall::add_variant_constant(Variant::VECTOR2, "INF", Vector2(INFINITY, INFINITY));
  2363. _VariantCall::add_variant_constant(Variant::VECTOR2, "LEFT", Vector2(-1, 0));
  2364. _VariantCall::add_variant_constant(Variant::VECTOR2, "RIGHT", Vector2(1, 0));
  2365. _VariantCall::add_variant_constant(Variant::VECTOR2, "UP", Vector2(0, -1));
  2366. _VariantCall::add_variant_constant(Variant::VECTOR2, "DOWN", Vector2(0, 1));
  2367. _VariantCall::add_variant_constant(Variant::VECTOR2I, "ZERO", Vector2i(0, 0));
  2368. _VariantCall::add_variant_constant(Variant::VECTOR2I, "ONE", Vector2i(1, 1));
  2369. _VariantCall::add_variant_constant(Variant::VECTOR2I, "MIN", Vector2i(INT32_MIN, INT32_MIN));
  2370. _VariantCall::add_variant_constant(Variant::VECTOR2I, "MAX", Vector2i(INT32_MAX, INT32_MAX));
  2371. _VariantCall::add_variant_constant(Variant::VECTOR2I, "LEFT", Vector2i(-1, 0));
  2372. _VariantCall::add_variant_constant(Variant::VECTOR2I, "RIGHT", Vector2i(1, 0));
  2373. _VariantCall::add_variant_constant(Variant::VECTOR2I, "UP", Vector2i(0, -1));
  2374. _VariantCall::add_variant_constant(Variant::VECTOR2I, "DOWN", Vector2i(0, 1));
  2375. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "IDENTITY", Transform2D());
  2376. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_X", Transform2D(-1, 0, 0, 1, 0, 0));
  2377. _VariantCall::add_variant_constant(Variant::TRANSFORM2D, "FLIP_Y", Transform2D(1, 0, 0, -1, 0, 0));
  2378. Transform3D identity_transform;
  2379. Transform3D flip_x_transform = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
  2380. Transform3D flip_y_transform = Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
  2381. Transform3D flip_z_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
  2382. _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "IDENTITY", identity_transform);
  2383. _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_X", flip_x_transform);
  2384. _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Y", flip_y_transform);
  2385. _VariantCall::add_variant_constant(Variant::TRANSFORM3D, "FLIP_Z", flip_z_transform);
  2386. Basis identity_basis;
  2387. Basis flip_x_basis = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1);
  2388. Basis flip_y_basis = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1);
  2389. Basis flip_z_basis = Basis(1, 0, 0, 0, 1, 0, 0, 0, -1);
  2390. _VariantCall::add_variant_constant(Variant::BASIS, "IDENTITY", identity_basis);
  2391. _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_X", flip_x_basis);
  2392. _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Y", flip_y_basis);
  2393. _VariantCall::add_variant_constant(Variant::BASIS, "FLIP_Z", flip_z_basis);
  2394. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_YZ", Plane(Vector3(1, 0, 0), 0));
  2395. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XZ", Plane(Vector3(0, 1, 0), 0));
  2396. _VariantCall::add_variant_constant(Variant::PLANE, "PLANE_XY", Plane(Vector3(0, 0, 1), 0));
  2397. _VariantCall::add_variant_constant(Variant::QUATERNION, "IDENTITY", Quaternion(0, 0, 0, 1));
  2398. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_NEAR", Projection::PLANE_NEAR);
  2399. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_FAR", Projection::PLANE_FAR);
  2400. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_LEFT", Projection::PLANE_LEFT);
  2401. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_TOP", Projection::PLANE_TOP);
  2402. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_RIGHT", Projection::PLANE_RIGHT);
  2403. _VariantCall::add_constant(Variant::PROJECTION, "PLANE_BOTTOM", Projection::PLANE_BOTTOM);
  2404. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_NEAR", Projection::PLANE_NEAR);
  2405. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_FAR", Projection::PLANE_FAR);
  2406. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_LEFT", Projection::PLANE_LEFT);
  2407. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_TOP", Projection::PLANE_TOP);
  2408. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_RIGHT", Projection::PLANE_RIGHT);
  2409. _VariantCall::add_enum_constant(Variant::PROJECTION, "Planes", "PLANE_BOTTOM", Projection::PLANE_BOTTOM);
  2410. Projection p;
  2411. _VariantCall::add_variant_constant(Variant::PROJECTION, "IDENTITY", p);
  2412. p.set_zero();
  2413. _VariantCall::add_variant_constant(Variant::PROJECTION, "ZERO", p);
  2414. }
  2415. void Variant::_register_variant_methods() {
  2416. _register_variant_builtin_methods(); //needs to be out due to namespace
  2417. }
  2418. void Variant::_unregister_variant_methods() {
  2419. //clear methods
  2420. memdelete_arr(builtin_method_names);
  2421. memdelete_arr(builtin_method_info);
  2422. memdelete_arr(_VariantCall::constant_data);
  2423. memdelete_arr(_VariantCall::enum_data);
  2424. }