engineAPI.h 179 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _ENGINEAPI_H_
  23. #define _ENGINEAPI_H_
  24. #ifndef _CONSOLETYPES_H_
  25. #include "console/consoleTypes.h"
  26. #endif
  27. #ifndef _CONSOLE_H_
  28. #include "console/console.h"
  29. #endif
  30. #ifndef _STRINGFUNCTIONS_H_
  31. #include "core/strings/stringFunctions.h"
  32. #endif
  33. #ifndef _SIMOBJECT_H_
  34. #include "console/simObject.h"
  35. #endif
  36. #ifndef _ENGINEFUNCTIONS_H_
  37. #include "console/engineFunctions.h"
  38. #endif
  39. // Whatever types are used in API definitions, their DECLAREs must be visible to the
  40. // macros. We include the basic primitive and struct types here.
  41. #ifndef _ENGINEPRIMITIVES_H_
  42. #include "console/enginePrimitives.h"
  43. #endif
  44. #ifndef _ENGINESTRUCTS_H_
  45. #include "console/engineStructs.h"
  46. #endif
  47. /// @file
  48. /// Definitions for exposing engine functionality to the control layer.
  49. ///
  50. /// This file provides a convenience layer around the underlying engine interop system (which at
  51. /// the moment still includes the legacy TorqueScript interop a.k.a. "console system"). The
  52. /// macros exposed here will automatically take care of all marshalling, value type constraints,
  53. /// reflection info instancing, etc. involved in defining engine API call-ins and call-outs.
  54. ///
  55. /// @note At the moment, this file supplies both the legacy TorqueScript console system as well
  56. /// as the new engine export system with the structures and information they need. In the
  57. /// near future, the console-based parts will get purged. This will not result in visible
  58. /// changes to users of the functionality here except for the string-based marshalling
  59. /// functions currently exposed (which will also disappear).
  60. //TODO: Disable warning for extern "C" functions returning UDTs for now; need to take a closer look at this
  61. #pragma warning( disable : 4190 )
  62. // Disable some VC warnings that are irrelevant to us.
  63. #pragma warning( push )
  64. #pragma warning( disable : 4510 ) // default constructor could not be generated; all the Args structures are never constructed by us
  65. #pragma warning( disable : 4610 ) // can never be instantiated; again Args is never constructed by us
  66. namespace engineAPI {
  67. /// Flag for enabling legacy console behavior in the interop system while
  68. /// we still have it around. Will disappear along with console.
  69. extern bool gUseConsoleInterop;
  70. /// Flag to allow engine functions to detect whether the engine had been
  71. /// initialized or shut down.
  72. extern bool gIsInitialized;
  73. }
  74. //FIXME: this allows const char* to be used as a struct field type
  75. // Temp support for allowing const char* to remain in the API functions as long as we
  76. // still have the console system around. When that is purged, these definitions should
  77. // be deleted and all const char* uses be replaced with String.
  78. template<> struct EngineTypeTraits< const char* > : public EngineTypeTraits< String > {};
  79. template<> inline const EngineTypeInfo* TYPE< const char* >() { return TYPE< String >(); }
  80. /// @name Marshalling
  81. ///
  82. /// Functions for converting to/from string-based data representations.
  83. ///
  84. /// @note This functionality is specific to the console interop.
  85. /// @{
  86. /// Marshal a single piece of data from native into client form.
  87. template< typename T >
  88. inline const char* EngineMarshallData( const T& value )
  89. {
  90. return castConsoleTypeToString( value );
  91. }
  92. inline const char* EngineMarshallData( bool value )
  93. {
  94. if( value )
  95. return "1";
  96. else
  97. return "0";
  98. }
  99. inline const char* EngineMarshallData( const char* str )
  100. {
  101. // The API assumes that if you pass a plain "const char*" through it, then you are referring
  102. // to string storage with non-local lifetime that can be safely passed to the control layer.
  103. return str;
  104. }
  105. template< typename T >
  106. inline const char* EngineMarshallData( T* object )
  107. {
  108. return ( object ? object->getIdString() : "0" );
  109. }
  110. template< typename T >
  111. inline const char* EngineMarshallData( const T* object )
  112. {
  113. return ( object ? object->getIdString() : "0" );
  114. }
  115. inline const char* EngineMarshallData( U32 value )
  116. {
  117. return EngineMarshallData( S32( value ) );
  118. }
  119. /// Marshal data from native into client form stored directly in
  120. /// client function invocation vector.
  121. template< typename T >
  122. inline void EngineMarshallData( const T& arg, S32& argc, ConsoleValueRef *argv )
  123. {
  124. argv[ argc ] = Con::getStringArg( castConsoleTypeToString( arg ) );
  125. argc ++;
  126. }
  127. inline void EngineMarshallData( bool arg, S32& argc, ConsoleValueRef *argv )
  128. {
  129. if( arg )
  130. argv[ argc ] = "1";
  131. else
  132. argv[ argc ] = "0";
  133. argc ++;
  134. }
  135. inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv )
  136. {
  137. argv[ argc ] = arg;
  138. argc ++;
  139. }
  140. inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv )
  141. {
  142. EngineMarshallData( S32( arg ), argc, argv );
  143. }
  144. inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValueRef *argv )
  145. {
  146. argv[ argc ] = arg;
  147. argc ++;
  148. }
  149. inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv )
  150. {
  151. argv[ argc ] = arg;
  152. argc ++;
  153. }
  154. template< typename T >
  155. inline void EngineMarshallData( T* object, S32& argc, ConsoleValueRef *argv )
  156. {
  157. argv[ argc ] = ( object ? object->getIdString() : "0" );
  158. argc ++;
  159. }
  160. template< typename T >
  161. inline void EngineMarshallData( const T* object, S32& argc, ConsoleValueRef *argv )
  162. {
  163. argv[ argc ] = ( object ? object->getIdString() : "0" );
  164. argc ++;
  165. }
  166. /// Unmarshal data from client form to engine form.
  167. ///
  168. /// This is wrapped in an a struct as partial specializations on function
  169. /// templates are not allowed in C++.
  170. template< typename T >
  171. struct EngineUnmarshallData
  172. {
  173. T operator()( const char* str ) const
  174. {
  175. T value;
  176. castConsoleTypeFromString( value, str );
  177. return value;
  178. }
  179. };
  180. template<>
  181. struct EngineUnmarshallData< S32 >
  182. {
  183. S32 operator()( ConsoleValueRef &ref ) const
  184. {
  185. return (S32)ref;
  186. }
  187. S32 operator()( const char* str ) const
  188. {
  189. return dAtoi( str );
  190. }
  191. };
  192. template<>
  193. struct EngineUnmarshallData< U32 >
  194. {
  195. U32 operator()( ConsoleValueRef &ref ) const
  196. {
  197. return (U32)((S32)ref);
  198. }
  199. U32 operator()( const char* str ) const
  200. {
  201. return dAtoui( str );
  202. }
  203. };
  204. template<>
  205. struct EngineUnmarshallData< F32 >
  206. {
  207. F32 operator()( ConsoleValueRef &ref ) const
  208. {
  209. return (F32)ref;
  210. }
  211. F32 operator()( const char* str ) const
  212. {
  213. return dAtof( str );
  214. }
  215. };
  216. template<>
  217. struct EngineUnmarshallData< const char* >
  218. {
  219. const char* operator()( const char* str ) const
  220. {
  221. return str;
  222. }
  223. };
  224. template< typename T >
  225. struct EngineUnmarshallData< T* >
  226. {
  227. T* operator()( const char* str ) const
  228. {
  229. return dynamic_cast< T* >( Sim::findObject( str ) );
  230. }
  231. };
  232. template<>
  233. struct EngineUnmarshallData< void >
  234. {
  235. void operator()( const char* ) const {}
  236. };
  237. /// @}
  238. /// @name C to C++ Trampolines
  239. ///
  240. /// The trampolines serve two purposes:
  241. ///
  242. /// For one, they ensure that no matter what argument types are specified by users of the engine API macros, the correct
  243. /// argument value types are enforced on the functions exported by the engine. Let's say, for example, the user writes
  244. /// a function that takes a "Point3F direction" argument, then the template machinery here will automatically expose an
  245. /// API function that takes a "Point3F& direction" argument.
  246. ///
  247. /// Secondly, the templates jump the incoming calls from extern "C" space into C++ space. This is mostly relevant for
  248. /// methods only as they will need an implicit object type argument.
  249. ///
  250. /// @{
  251. // Helper type to factor out commonalities between function and method trampolines.
  252. template< typename T >
  253. struct _EngineTrampoline
  254. {
  255. struct Args {};
  256. };
  257. template< typename R, typename A >
  258. struct _EngineTrampoline< R( A ) >
  259. {
  260. struct Args
  261. {
  262. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ];
  263. typename EngineTypeTraits< A >::ValueType a() const
  264. {
  265. return EngineTypeTraits< A >::ArgumentToValue(
  266. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  267. }
  268. };
  269. };
  270. template< typename R, typename A, typename B >
  271. struct _EngineTrampoline< R( A, B ) >
  272. {
  273. struct Args
  274. {
  275. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  276. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ];
  277. typename EngineTypeTraits< A >::ValueType a() const
  278. {
  279. return EngineTypeTraits< A >::ArgumentToValue(
  280. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  281. }
  282. typename EngineTypeTraits< B >::ValueType b() const
  283. {
  284. return EngineTypeTraits< B >::ArgumentToValue(
  285. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  286. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  287. }
  288. };
  289. };
  290. template< typename R, typename A, typename B, typename C >
  291. struct _EngineTrampoline< R( A, B, C ) >
  292. {
  293. struct Args
  294. {
  295. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  296. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  297. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ];
  298. typename EngineTypeTraits< A >::ValueType a() const
  299. {
  300. return EngineTypeTraits< A >::ArgumentToValue(
  301. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  302. }
  303. typename EngineTypeTraits< B >::ValueType b() const
  304. {
  305. return EngineTypeTraits< B >::ArgumentToValue(
  306. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  307. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  308. }
  309. typename EngineTypeTraits< C >::ValueType c() const
  310. {
  311. return EngineTypeTraits< C >::ArgumentToValue(
  312. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  313. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  314. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  315. }
  316. };
  317. };
  318. template< typename R, typename A, typename B, typename C, typename D >
  319. struct _EngineTrampoline< R( A, B, C, D ) >
  320. {
  321. struct Args
  322. {
  323. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  324. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  325. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  326. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ];
  327. typename EngineTypeTraits< A >::ValueType a() const
  328. {
  329. return EngineTypeTraits< A >::ArgumentToValue(
  330. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  331. }
  332. typename EngineTypeTraits< B >::ValueType b() const
  333. {
  334. return EngineTypeTraits< B >::ArgumentToValue(
  335. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  336. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  337. }
  338. typename EngineTypeTraits< C >::ValueType c() const
  339. {
  340. return EngineTypeTraits< C >::ArgumentToValue(
  341. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  342. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  343. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  344. }
  345. typename EngineTypeTraits< D >::ValueType d() const
  346. {
  347. return EngineTypeTraits< D >::ArgumentToValue(
  348. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  349. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  350. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  351. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  352. }
  353. };
  354. };
  355. template< typename R, typename A, typename B, typename C, typename D, typename E >
  356. struct _EngineTrampoline< R( A, B, C, D, E ) >
  357. {
  358. struct Args
  359. {
  360. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  361. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  362. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  363. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  364. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ];
  365. typename EngineTypeTraits< A >::ValueType a() const
  366. {
  367. return EngineTypeTraits< A >::ArgumentToValue(
  368. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  369. }
  370. typename EngineTypeTraits< B >::ValueType b() const
  371. {
  372. return EngineTypeTraits< B >::ArgumentToValue(
  373. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  374. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  375. }
  376. typename EngineTypeTraits< C >::ValueType c() const
  377. {
  378. return EngineTypeTraits< C >::ArgumentToValue(
  379. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  380. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  381. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  382. }
  383. typename EngineTypeTraits< D >::ValueType d() const
  384. {
  385. return EngineTypeTraits< D >::ArgumentToValue(
  386. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  387. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  388. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  389. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  390. }
  391. typename EngineTypeTraits< E >::ValueType e() const
  392. {
  393. return EngineTypeTraits< E >::ArgumentToValue(
  394. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  395. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  396. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  397. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  398. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  399. }
  400. };
  401. };
  402. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  403. struct _EngineTrampoline< R( A, B, C, D, E, F ) >
  404. {
  405. struct Args
  406. {
  407. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  408. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  409. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  410. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  411. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  412. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ];
  413. typename EngineTypeTraits< A >::ValueType a() const
  414. {
  415. return EngineTypeTraits< A >::ArgumentToValue(
  416. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  417. }
  418. typename EngineTypeTraits< B >::ValueType b() const
  419. {
  420. return EngineTypeTraits< B >::ArgumentToValue(
  421. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  422. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  423. }
  424. typename EngineTypeTraits< C >::ValueType c() const
  425. {
  426. return EngineTypeTraits< C >::ArgumentToValue(
  427. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  428. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  429. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  430. }
  431. typename EngineTypeTraits< D >::ValueType d() const
  432. {
  433. return EngineTypeTraits< D >::ArgumentToValue(
  434. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  435. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  436. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  437. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  438. }
  439. typename EngineTypeTraits< E >::ValueType e() const
  440. {
  441. return EngineTypeTraits< E >::ArgumentToValue(
  442. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  443. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  444. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  445. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  446. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  447. }
  448. typename EngineTypeTraits< F >::ValueType f() const
  449. {
  450. return EngineTypeTraits< F >::ArgumentToValue(
  451. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  452. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  453. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  454. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  455. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  456. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  457. }
  458. };
  459. };
  460. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  461. struct _EngineTrampoline< R( A, B, C, D, E, F, G ) >
  462. {
  463. struct Args
  464. {
  465. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  466. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  467. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  468. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  469. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  470. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  471. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) ];
  472. typename EngineTypeTraits< A >::ValueType a() const
  473. {
  474. return EngineTypeTraits< A >::ArgumentToValue(
  475. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  476. }
  477. typename EngineTypeTraits< B >::ValueType b() const
  478. {
  479. return EngineTypeTraits< B >::ArgumentToValue(
  480. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  481. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  482. }
  483. typename EngineTypeTraits< C >::ValueType c() const
  484. {
  485. return EngineTypeTraits< C >::ArgumentToValue(
  486. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  487. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  488. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  489. }
  490. typename EngineTypeTraits< D >::ValueType d() const
  491. {
  492. return EngineTypeTraits< D >::ArgumentToValue(
  493. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  494. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  495. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  496. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  497. }
  498. typename EngineTypeTraits< E >::ValueType e() const
  499. {
  500. return EngineTypeTraits< E >::ArgumentToValue(
  501. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  502. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  503. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  504. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  505. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  506. }
  507. typename EngineTypeTraits< F >::ValueType f() const
  508. {
  509. return EngineTypeTraits< F >::ArgumentToValue(
  510. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  511. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  512. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  513. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  514. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  515. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  516. }
  517. typename EngineTypeTraits< G >::ValueType g() const
  518. {
  519. return EngineTypeTraits< G >::ArgumentToValue(
  520. *( reinterpret_cast< const typename EngineTypeTraits< G >::ArgumentValueType* >
  521. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  522. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  523. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  524. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  525. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  526. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ] ) ) );
  527. }
  528. };
  529. };
  530. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  531. struct _EngineTrampoline< R( A, B, C, D, E, F, G, H ) >
  532. {
  533. struct Args
  534. {
  535. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  536. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  537. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  538. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  539. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  540. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  541. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  542. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) ];
  543. typename EngineTypeTraits< A >::ValueType a() const
  544. {
  545. return EngineTypeTraits< A >::ArgumentToValue(
  546. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  547. }
  548. typename EngineTypeTraits< B >::ValueType b() const
  549. {
  550. return EngineTypeTraits< B >::ArgumentToValue(
  551. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  552. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  553. }
  554. typename EngineTypeTraits< C >::ValueType c() const
  555. {
  556. return EngineTypeTraits< C >::ArgumentToValue(
  557. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  558. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  559. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  560. }
  561. typename EngineTypeTraits< D >::ValueType d() const
  562. {
  563. return EngineTypeTraits< D >::ArgumentToValue(
  564. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  565. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  566. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  567. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  568. }
  569. typename EngineTypeTraits< E >::ValueType e() const
  570. {
  571. return EngineTypeTraits< E >::ArgumentToValue(
  572. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  573. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  574. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  575. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  576. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  577. }
  578. typename EngineTypeTraits< F >::ValueType f() const
  579. {
  580. return EngineTypeTraits< F >::ArgumentToValue(
  581. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  582. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  583. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  584. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  585. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  586. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  587. }
  588. typename EngineTypeTraits< G >::ValueType g() const
  589. {
  590. return EngineTypeTraits< G >::ArgumentToValue(
  591. *( reinterpret_cast< const typename EngineTypeTraits< G >::ArgumentValueType* >
  592. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  593. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  594. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  595. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  596. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  597. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ] ) ) );
  598. }
  599. typename EngineTypeTraits< H >::ValueType h() const
  600. {
  601. return EngineTypeTraits< H >::ArgumentToValue(
  602. *( reinterpret_cast< const typename EngineTypeTraits< H >::ArgumentValueType* >
  603. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  604. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  605. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  606. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  607. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  608. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  609. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) ] ) ) );
  610. }
  611. };
  612. };
  613. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  614. struct _EngineTrampoline< R( A, B, C, D, E, F, G, H, I ) >
  615. {
  616. struct Args
  617. {
  618. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  619. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  620. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  621. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  622. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  623. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  624. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  625. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  626. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) ];
  627. typename EngineTypeTraits< A >::ValueType a() const
  628. {
  629. return EngineTypeTraits< A >::ArgumentToValue(
  630. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  631. }
  632. typename EngineTypeTraits< B >::ValueType b() const
  633. {
  634. return EngineTypeTraits< B >::ArgumentToValue(
  635. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  636. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  637. }
  638. typename EngineTypeTraits< C >::ValueType c() const
  639. {
  640. return EngineTypeTraits< C >::ArgumentToValue(
  641. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  642. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  643. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  644. }
  645. typename EngineTypeTraits< D >::ValueType d() const
  646. {
  647. return EngineTypeTraits< D >::ArgumentToValue(
  648. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  649. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  650. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  651. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  652. }
  653. typename EngineTypeTraits< E >::ValueType e() const
  654. {
  655. return EngineTypeTraits< E >::ArgumentToValue(
  656. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  657. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  658. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  659. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  660. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  661. }
  662. typename EngineTypeTraits< F >::ValueType f() const
  663. {
  664. return EngineTypeTraits< F >::ArgumentToValue(
  665. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  666. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  667. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  668. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  669. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  670. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  671. }
  672. typename EngineTypeTraits< G >::ValueType g() const
  673. {
  674. return EngineTypeTraits< G >::ArgumentToValue(
  675. *( reinterpret_cast< const typename EngineTypeTraits< G >::ArgumentValueType* >
  676. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  677. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  678. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  679. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  680. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  681. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ] ) ) );
  682. }
  683. typename EngineTypeTraits< H >::ValueType h() const
  684. {
  685. return EngineTypeTraits< H >::ArgumentToValue(
  686. *( reinterpret_cast< const typename EngineTypeTraits< H >::ArgumentValueType* >
  687. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  688. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  689. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  690. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  691. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  692. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  693. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) ] ) ) );
  694. }
  695. typename EngineTypeTraits< I >::ValueType i() const
  696. {
  697. return EngineTypeTraits< I >::ArgumentToValue(
  698. *( reinterpret_cast< const typename EngineTypeTraits< I >::ArgumentValueType* >
  699. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  700. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  701. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  702. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  703. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  704. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  705. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  706. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) ] ) ) );
  707. }
  708. };
  709. };
  710. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  711. struct _EngineTrampoline< R( A, B, C, D, E, F, G, H, I, J ) >
  712. {
  713. struct Args
  714. {
  715. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  716. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  717. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  718. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  719. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  720. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  721. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  722. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  723. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) +
  724. sizeof( typename EngineTypeTraits< J >::ArgumentValueType ) ];
  725. typename EngineTypeTraits< A >::ValueType a() const
  726. {
  727. return EngineTypeTraits< A >::ArgumentToValue(
  728. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  729. }
  730. typename EngineTypeTraits< B >::ValueType b() const
  731. {
  732. return EngineTypeTraits< B >::ArgumentToValue(
  733. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  734. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  735. }
  736. typename EngineTypeTraits< C >::ValueType c() const
  737. {
  738. return EngineTypeTraits< C >::ArgumentToValue(
  739. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  740. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  741. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  742. }
  743. typename EngineTypeTraits< D >::ValueType d() const
  744. {
  745. return EngineTypeTraits< D >::ArgumentToValue(
  746. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  747. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  748. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  749. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  750. }
  751. typename EngineTypeTraits< E >::ValueType e() const
  752. {
  753. return EngineTypeTraits< E >::ArgumentToValue(
  754. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  755. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  756. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  757. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  758. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  759. }
  760. typename EngineTypeTraits< F >::ValueType f() const
  761. {
  762. return EngineTypeTraits< F >::ArgumentToValue(
  763. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  764. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  765. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  766. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  767. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  768. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  769. }
  770. typename EngineTypeTraits< G >::ValueType g() const
  771. {
  772. return EngineTypeTraits< G >::ArgumentToValue(
  773. *( reinterpret_cast< const typename EngineTypeTraits< G >::ArgumentValueType* >
  774. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  775. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  776. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  777. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  778. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  779. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ] ) ) );
  780. }
  781. typename EngineTypeTraits< H >::ValueType h() const
  782. {
  783. return EngineTypeTraits< H >::ArgumentToValue(
  784. *( reinterpret_cast< const typename EngineTypeTraits< H >::ArgumentValueType* >
  785. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  786. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  787. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  788. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  789. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  790. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  791. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) ] ) ) );
  792. }
  793. typename EngineTypeTraits< I >::ValueType i() const
  794. {
  795. return EngineTypeTraits< I >::ArgumentToValue(
  796. *( reinterpret_cast< const typename EngineTypeTraits< I >::ArgumentValueType* >
  797. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  798. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  799. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  800. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  801. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  802. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  803. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  804. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) ] ) ) );
  805. }
  806. typename EngineTypeTraits< J >::ValueType j() const
  807. {
  808. return EngineTypeTraits< J >::ArgumentToValue(
  809. *( reinterpret_cast< const typename EngineTypeTraits< J >::ArgumentValueType* >
  810. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  811. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  812. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  813. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  814. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  815. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  816. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  817. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  818. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) ] ) ) );
  819. }
  820. };
  821. };
  822. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  823. struct _EngineTrampoline< R( A, B, C, D, E, F, G, H, I, J, K ) >
  824. {
  825. struct Args
  826. {
  827. char data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  828. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  829. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  830. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  831. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  832. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  833. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  834. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  835. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) +
  836. sizeof( typename EngineTypeTraits< J >::ArgumentValueType ) +
  837. sizeof( typename EngineTypeTraits< K >::ArgumentValueType ) ];
  838. typename EngineTypeTraits< A >::ValueType a() const
  839. {
  840. return EngineTypeTraits< A >::ArgumentToValue(
  841. *( reinterpret_cast< const typename EngineTypeTraits< A >::ArgumentValueType* >( &data[ 0 ] ) ) );
  842. }
  843. typename EngineTypeTraits< B >::ValueType b() const
  844. {
  845. return EngineTypeTraits< B >::ArgumentToValue(
  846. *( reinterpret_cast< const typename EngineTypeTraits< B >::ArgumentValueType* >
  847. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) ] ) ) );
  848. }
  849. typename EngineTypeTraits< C >::ValueType c() const
  850. {
  851. return EngineTypeTraits< C >::ArgumentToValue(
  852. *( reinterpret_cast< const typename EngineTypeTraits< C >::ArgumentValueType* >
  853. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  854. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) ] ) ) );
  855. }
  856. typename EngineTypeTraits< D >::ValueType d() const
  857. {
  858. return EngineTypeTraits< D >::ArgumentToValue(
  859. *( reinterpret_cast< const typename EngineTypeTraits< D >::ArgumentValueType* >
  860. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  861. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  862. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) ] ) ) );
  863. }
  864. typename EngineTypeTraits< E >::ValueType e() const
  865. {
  866. return EngineTypeTraits< E >::ArgumentToValue(
  867. *( reinterpret_cast< const typename EngineTypeTraits< E >::ArgumentValueType* >
  868. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  869. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  870. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  871. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) ] ) ) );
  872. }
  873. typename EngineTypeTraits< F >::ValueType f() const
  874. {
  875. return EngineTypeTraits< F >::ArgumentToValue(
  876. *( reinterpret_cast< const typename EngineTypeTraits< F >::ArgumentValueType* >
  877. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  878. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  879. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  880. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  881. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) ] ) ) );
  882. }
  883. typename EngineTypeTraits< G >::ValueType g() const
  884. {
  885. return EngineTypeTraits< G >::ArgumentToValue(
  886. *( reinterpret_cast< const typename EngineTypeTraits< G >::ArgumentValueType* >
  887. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  888. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  889. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  890. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  891. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  892. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) ] ) ) );
  893. }
  894. typename EngineTypeTraits< H >::ValueType h() const
  895. {
  896. return EngineTypeTraits< H >::ArgumentToValue(
  897. *( reinterpret_cast< const typename EngineTypeTraits< H >::ArgumentValueType* >
  898. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  899. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  900. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  901. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  902. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  903. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  904. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) ] ) ) );
  905. }
  906. typename EngineTypeTraits< I >::ValueType i() const
  907. {
  908. return EngineTypeTraits< I >::ArgumentToValue(
  909. *( reinterpret_cast< const typename EngineTypeTraits< I >::ArgumentValueType* >
  910. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  911. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  912. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  913. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  914. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  915. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  916. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  917. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) ] ) ) );
  918. }
  919. typename EngineTypeTraits< J >::ValueType j() const
  920. {
  921. return EngineTypeTraits< J >::ArgumentToValue(
  922. *( reinterpret_cast< const typename EngineTypeTraits< J >::ArgumentValueType* >
  923. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  924. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  925. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  926. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  927. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  928. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  929. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  930. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  931. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) ] ) ) );
  932. }
  933. typename EngineTypeTraits< K >::ValueType k() const
  934. {
  935. return EngineTypeTraits< K >::ArgumentToValue(
  936. *( reinterpret_cast< const typename EngineTypeTraits< K >::ArgumentValueType* >
  937. ( &data[ sizeof( typename EngineTypeTraits< A >::ArgumentValueType ) +
  938. sizeof( typename EngineTypeTraits< B >::ArgumentValueType ) +
  939. sizeof( typename EngineTypeTraits< C >::ArgumentValueType ) +
  940. sizeof( typename EngineTypeTraits< D >::ArgumentValueType ) +
  941. sizeof( typename EngineTypeTraits< E >::ArgumentValueType ) +
  942. sizeof( typename EngineTypeTraits< F >::ArgumentValueType ) +
  943. sizeof( typename EngineTypeTraits< G >::ArgumentValueType ) +
  944. sizeof( typename EngineTypeTraits< H >::ArgumentValueType ) +
  945. sizeof( typename EngineTypeTraits< I >::ArgumentValueType ) +
  946. sizeof( typename EngineTypeTraits< J >::ArgumentValueType ) ] ) ) );
  947. }
  948. };
  949. };
  950. template< typename T >
  951. struct _EngineFunctionTrampolineBase : public _EngineTrampoline< T >
  952. {
  953. typedef T FunctionType;
  954. };
  955. // Trampolines for any call-ins that aren't methods.
  956. template< typename T >
  957. struct _EngineFunctionTrampoline {};
  958. template< typename R >
  959. struct _EngineFunctionTrampoline< R() > : public _EngineFunctionTrampolineBase< R() >
  960. {
  961. static R jmp( R ( *fn )(), const typename _EngineFunctionTrampolineBase< R() >::Args& args )
  962. {
  963. return R( fn() );
  964. }
  965. };
  966. template< typename R, typename A >
  967. struct _EngineFunctionTrampoline< R( A ) > : public _EngineFunctionTrampolineBase< R( A ) >
  968. {
  969. static R jmp( R ( *fn )( A ), const typename _EngineFunctionTrampolineBase< R( A ) >::Args& args )
  970. {
  971. return R( fn( args.a() ) );
  972. }
  973. };
  974. template< typename R, typename A, typename B >
  975. struct _EngineFunctionTrampoline< R( A, B ) > : public _EngineFunctionTrampolineBase< R( A, B ) >
  976. {
  977. static R jmp( R ( *fn )( A, B ), const typename _EngineFunctionTrampolineBase< R( A, B ) >::Args& args )
  978. {
  979. return R( fn( args.a(), args.b() ) );
  980. }
  981. };
  982. template< typename R, typename A, typename B, typename C >
  983. struct _EngineFunctionTrampoline< R( A, B, C ) > : public _EngineFunctionTrampolineBase< R( A, B, C ) >
  984. {
  985. static R jmp( R ( *fn )( A, B, C ), const typename _EngineFunctionTrampolineBase< R( A, B, C ) >::Args& args )
  986. {
  987. return R( fn( args.a(), args.b(), args.c() ) );
  988. }
  989. };
  990. template< typename R, typename A, typename B, typename C, typename D >
  991. struct _EngineFunctionTrampoline< R( A, B, C, D ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D ) >
  992. {
  993. static R jmp( R ( *fn )( A, B, C, D ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D ) >::Args& args )
  994. {
  995. return R( fn( args.a(), args.b(), args.c(), args.d() ) );
  996. }
  997. };
  998. template< typename R, typename A, typename B, typename C, typename D, typename E >
  999. struct _EngineFunctionTrampoline< R( A, B, C, D, E ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E ) >
  1000. {
  1001. static R jmp( R ( *fn )( A, B, C, D, E ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E ) >::Args& args )
  1002. {
  1003. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e() ) );
  1004. }
  1005. };
  1006. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  1007. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F ) >
  1008. {
  1009. static R jmp( R ( *fn )( A, B, C, D, E, F ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F ) >::Args& args )
  1010. {
  1011. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f() ) );
  1012. }
  1013. };
  1014. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  1015. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F, G ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G ) >
  1016. {
  1017. static R jmp( R ( *fn )( A, B, C, D, E, F, G ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G ) >::Args& args )
  1018. {
  1019. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g() ) );
  1020. }
  1021. };
  1022. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  1023. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F, G, H ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H ) >
  1024. {
  1025. static R jmp( R ( *fn )( A, B, C, D, E, F, G, H ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H ) >::Args& args )
  1026. {
  1027. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h() ) );
  1028. }
  1029. };
  1030. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  1031. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F, G, H, I ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I ) >
  1032. {
  1033. static R jmp( R ( *fn )( A, B, C, D, E, F, G, H, I ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I ) >::Args& args )
  1034. {
  1035. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i() ) );
  1036. }
  1037. };
  1038. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  1039. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F, G, H, I, J ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J ) >
  1040. {
  1041. static R jmp( R ( *fn )( A, B, C, D, E, F, G, H, I, J ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J ) >::Args& args )
  1042. {
  1043. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i(), args.j() ) );
  1044. }
  1045. };
  1046. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  1047. struct _EngineFunctionTrampoline< R( A, B, C, D, E, F, G, H, I, J, K ) > : public _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J, K ) >
  1048. {
  1049. static R jmp( R ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J, K ) >::Args& args )
  1050. {
  1051. return R( fn( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i(), args.j(), args.k() ) );
  1052. }
  1053. };
  1054. template< typename T >
  1055. struct _EngineMethodTrampolineBase : public _EngineTrampoline< T > {};
  1056. template< typename Frame, typename T >
  1057. struct _EngineMethodTrampoline {};
  1058. template< typename Frame, typename R >
  1059. struct _EngineMethodTrampoline< Frame, R() > : public _EngineMethodTrampolineBase< R() >
  1060. {
  1061. typedef R( FunctionType )( typename Frame::ObjectType* );
  1062. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R() >::Args& args )
  1063. {
  1064. Frame f;
  1065. f.object = object;
  1066. return R( f._exec() );
  1067. }
  1068. };
  1069. template< typename Frame, typename R, typename A >
  1070. struct _EngineMethodTrampoline< Frame, R( A ) > : public _EngineMethodTrampolineBase< R( A ) >
  1071. {
  1072. typedef R( FunctionType )( typename Frame::ObjectType*, A );
  1073. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A ) >::Args& args )
  1074. {
  1075. Frame f;
  1076. f.object = object;
  1077. return R( f._exec( args.a() ) );
  1078. }
  1079. };
  1080. template< typename Frame, typename R, typename A, typename B >
  1081. struct _EngineMethodTrampoline< Frame, R( A, B ) > : public _EngineMethodTrampolineBase< R( A, B ) >
  1082. {
  1083. typedef R( FunctionType )( typename Frame::ObjectType*, A, B );
  1084. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B ) >::Args& args )
  1085. {
  1086. Frame f;
  1087. f.object = object;
  1088. return R( f._exec( args.a(), args.b() ) );
  1089. }
  1090. };
  1091. template< typename Frame, typename R, typename A, typename B, typename C >
  1092. struct _EngineMethodTrampoline< Frame, R( A, B, C ) > : public _EngineMethodTrampolineBase< R( A, B, C ) >
  1093. {
  1094. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C );
  1095. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C ) >::Args& args )
  1096. {
  1097. Frame f;
  1098. f.object = object;
  1099. return R( f._exec( args.a(), args.b(), args.c() ) );
  1100. }
  1101. };
  1102. template< typename Frame, typename R, typename A, typename B, typename C, typename D >
  1103. struct _EngineMethodTrampoline< Frame, R( A, B, C, D ) > : public _EngineMethodTrampolineBase< R( A, B, C, D ) >
  1104. {
  1105. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D );
  1106. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D ) >::Args& args )
  1107. {
  1108. Frame f;
  1109. f.object = object;
  1110. return R( f._exec( args.a(), args.b(), args.c(), args.d() ) );
  1111. }
  1112. };
  1113. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E >
  1114. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E ) >
  1115. {
  1116. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E );
  1117. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E ) >::Args& args )
  1118. {
  1119. Frame f;
  1120. f.object = object;
  1121. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e() ) );
  1122. }
  1123. };
  1124. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  1125. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F ) >
  1126. {
  1127. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F );
  1128. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F ) >::Args& args )
  1129. {
  1130. Frame f;
  1131. f.object = object;
  1132. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f() ) );
  1133. }
  1134. };
  1135. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  1136. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F, G ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F, G ) >
  1137. {
  1138. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F, G );
  1139. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G ) >::Args& args )
  1140. {
  1141. Frame f;
  1142. f.object = object;
  1143. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g() ) );
  1144. }
  1145. };
  1146. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  1147. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F, G, H ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F, G, H ) >
  1148. {
  1149. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F, G, H );
  1150. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H ) >::Args& args )
  1151. {
  1152. Frame f;
  1153. f.object = object;
  1154. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h() ) );
  1155. }
  1156. };
  1157. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  1158. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F, G, H, I ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F, G, H, I ) >
  1159. {
  1160. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I );
  1161. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I ) >::Args& args )
  1162. {
  1163. Frame f;
  1164. f.object = object;
  1165. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i() ) );
  1166. }
  1167. };
  1168. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  1169. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F, G, H, I, J ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F, G, H, I, J ) >
  1170. {
  1171. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J );
  1172. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J ) >::Args& args )
  1173. {
  1174. Frame f;
  1175. f.object = object;
  1176. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i(), args.j() ) );
  1177. }
  1178. };
  1179. template< typename Frame, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  1180. struct _EngineMethodTrampoline< Frame, R( A, B, C, D, E, F, G, H, I, J, K ) > : public _EngineMethodTrampolineBase< R( A, B, C, D, E, F, G, H, I, J, K ) >
  1181. {
  1182. typedef R( FunctionType )( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K );
  1183. static R jmp( typename Frame::ObjectType* object, const typename _EngineFunctionTrampolineBase< R( A, B, C, D, E, F, G, H, I, J, K ) >::Args& args )
  1184. {
  1185. Frame f;
  1186. f.object = object;
  1187. return R( f._exec( args.a(), args.b(), args.c(), args.d(), args.e(), args.f(), args.g(), args.h(), args.i(), args.j(), args.k() ) );
  1188. }
  1189. };
  1190. /// @}
  1191. /// @name Thunking
  1192. ///
  1193. /// Internal functionality for thunks placed between TorqueScript calls of engine functions and their native
  1194. /// implementations.
  1195. ///
  1196. /// @note The functionality in this group is specific to the console interop system.
  1197. /// @{
  1198. // Helper function to return data from a thunk.
  1199. template< typename T >
  1200. inline const char* _EngineConsoleThunkReturnValue( const T& value )
  1201. {
  1202. return EngineMarshallData( value );
  1203. }
  1204. inline bool _EngineConsoleThunkReturnValue( bool value )
  1205. {
  1206. return value;
  1207. }
  1208. inline S32 _EngineConsoleThunkReturnValue( S32 value )
  1209. {
  1210. return value;
  1211. }
  1212. inline F32 _EngineConsoleThunkReturnValue( F32 value )
  1213. {
  1214. return value;
  1215. }
  1216. inline const char* _EngineConsoleThunkReturnValue( const String& str )
  1217. {
  1218. return Con::getReturnBuffer( str );
  1219. }
  1220. inline const char* _EngineConsoleThunkReturnValue( const char* value )
  1221. {
  1222. return EngineMarshallData( value );
  1223. }
  1224. template< typename T >
  1225. inline const char* _EngineConsoleThunkReturnValue( T* value )
  1226. {
  1227. return ( value ? value->getIdString() : "" );
  1228. }
  1229. template< typename T >
  1230. inline const char* _EngineConsoleThunkReturnValue( const T* value )
  1231. {
  1232. return ( value ? value->getIdString() : "" );
  1233. }
  1234. // Helper class to determine the type of callback registered with the console system.
  1235. template< typename R >
  1236. struct _EngineConsoleThunkType
  1237. {
  1238. typedef const char* ReturnType;
  1239. typedef StringCallback CallbackType;
  1240. };
  1241. template<>
  1242. struct _EngineConsoleThunkType< S32 >
  1243. {
  1244. typedef S32 ReturnType;
  1245. typedef IntCallback CallbackType;
  1246. };
  1247. template<>
  1248. struct _EngineConsoleThunkType< U32 >
  1249. {
  1250. typedef U32 ReturnType;
  1251. typedef IntCallback CallbackType;
  1252. };
  1253. template<>
  1254. struct _EngineConsoleThunkType< F32 >
  1255. {
  1256. typedef F32 ReturnType;
  1257. typedef FloatCallback CallbackType;
  1258. };
  1259. template<>
  1260. struct _EngineConsoleThunkType< bool >
  1261. {
  1262. typedef bool ReturnType;
  1263. typedef BoolCallback CallbackType;
  1264. };
  1265. template<>
  1266. struct _EngineConsoleThunkType< void >
  1267. {
  1268. typedef void ReturnType;
  1269. typedef VoidCallback CallbackType;
  1270. };
  1271. // Helper struct to count the number of parameters in a function list.
  1272. // The setup through operator () allows omitting the the argument list entirely.
  1273. struct _EngineConsoleThunkCountArgs
  1274. {
  1275. template< typename A >
  1276. U32 operator ()( A a )
  1277. {
  1278. return 1;
  1279. }
  1280. template< typename A, typename B >
  1281. U32 operator ()( A a, B b )
  1282. {
  1283. return 2;
  1284. }
  1285. template< typename A, typename B, typename C >
  1286. U32 operator ()( A a, B b, C c )
  1287. {
  1288. return 3;
  1289. }
  1290. template< typename A, typename B, typename C, typename D >
  1291. U32 operator ()( A a, B b, C c, D d )
  1292. {
  1293. return 4;
  1294. }
  1295. template< typename A, typename B, typename C, typename D, typename E >
  1296. U32 operator ()( A a, B b, C c, D d, E e )
  1297. {
  1298. return 5;
  1299. }
  1300. template< typename A, typename B, typename C, typename D, typename E, typename F >
  1301. U32 operator ()( A a, B b, C c, D d, E e, F f )
  1302. {
  1303. return 6;
  1304. }
  1305. template< typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  1306. U32 operator ()( A a, B b, C c, D d, E e, F f, G g )
  1307. {
  1308. return 7;
  1309. }
  1310. template< typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  1311. U32 operator ()( A a, B b, C c, D d, E e, F f, G g, H h )
  1312. {
  1313. return 8;
  1314. }
  1315. template< typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  1316. U32 operator ()( A a, B b, C c, D d, E e, F f, G g, H h, I i )
  1317. {
  1318. return 9;
  1319. }
  1320. template< typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  1321. U32 operator ()( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j )
  1322. {
  1323. return 10;
  1324. }
  1325. template< typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  1326. U32 operator ()( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k )
  1327. {
  1328. return 11;
  1329. }
  1330. operator U32() const
  1331. {
  1332. return 0;
  1333. }
  1334. };
  1335. // Encapsulation of a legacy console function invocation.
  1336. template< S32 startArgc, typename T >
  1337. struct _EngineConsoleThunk {};
  1338. template< S32 startArgc, typename R >
  1339. struct _EngineConsoleThunk< startArgc, R() >
  1340. {
  1341. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1342. static const S32 NUM_ARGS = 0;
  1343. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
  1344. {
  1345. return _EngineConsoleThunkReturnValue( fn() );
  1346. }
  1347. template< typename Frame >
  1348. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
  1349. {
  1350. return _EngineConsoleThunkReturnValue( ( frame->*fn )() );
  1351. }
  1352. };
  1353. template< S32 startArgc >
  1354. struct _EngineConsoleThunk< startArgc, void() >
  1355. {
  1356. typedef void ReturnType;
  1357. static const S32 NUM_ARGS = 0;
  1358. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )(), const _EngineFunctionDefaultArguments< void() >& )
  1359. {
  1360. fn();
  1361. }
  1362. template< typename Frame >
  1363. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )() const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType* ) >& )
  1364. {
  1365. return ( frame->*fn )();
  1366. }
  1367. };
  1368. template< S32 startArgc, typename R, typename A >
  1369. struct _EngineConsoleThunk< startArgc, R( A ) >
  1370. {
  1371. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1372. static const S32 NUM_ARGS = 1 + startArgc;
  1373. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
  1374. {
  1375. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1376. return _EngineConsoleThunkReturnValue( fn( a ) );
  1377. }
  1378. template< typename Frame >
  1379. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
  1380. {
  1381. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1382. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a ) );
  1383. }
  1384. };
  1385. template< S32 startArgc, typename A >
  1386. struct _EngineConsoleThunk< startArgc, void( A ) >
  1387. {
  1388. typedef void ReturnType;
  1389. static const S32 NUM_ARGS = 1 + startArgc;
  1390. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A ), const _EngineFunctionDefaultArguments< void( A ) >& defaultArgs )
  1391. {
  1392. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1393. fn( a );
  1394. }
  1395. template< typename Frame >
  1396. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A ) >& defaultArgs )
  1397. {
  1398. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1399. ( frame->*fn )( a );
  1400. }
  1401. };
  1402. template< S32 startArgc, typename R, typename A, typename B >
  1403. struct _EngineConsoleThunk< startArgc, R( A, B ) >
  1404. {
  1405. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1406. static const S32 NUM_ARGS = 2 + startArgc;
  1407. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
  1408. {
  1409. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1410. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1411. return _EngineConsoleThunkReturnValue( fn( a, b ) );
  1412. }
  1413. template< typename Frame >
  1414. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
  1415. {
  1416. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1417. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1418. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b ) );
  1419. }
  1420. };
  1421. template< S32 startArgc, typename A, typename B >
  1422. struct _EngineConsoleThunk< startArgc, void( A, B ) >
  1423. {
  1424. typedef void ReturnType;
  1425. static const S32 NUM_ARGS = 2 + startArgc;
  1426. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B ), const _EngineFunctionDefaultArguments< void( A, B ) >& defaultArgs )
  1427. {
  1428. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1429. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1430. fn( a, b );
  1431. }
  1432. template< typename Frame >
  1433. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B ) >& defaultArgs )
  1434. {
  1435. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1436. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1437. ( frame->*fn )( a, b );
  1438. }
  1439. };
  1440. template< S32 startArgc, typename R, typename A, typename B, typename C >
  1441. struct _EngineConsoleThunk< startArgc, R( A, B, C ) >
  1442. {
  1443. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1444. static const S32 NUM_ARGS = 3 + startArgc;
  1445. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
  1446. {
  1447. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1448. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1449. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1450. return _EngineConsoleThunkReturnValue( fn( a, b, c ) );
  1451. }
  1452. template< typename Frame >
  1453. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
  1454. {
  1455. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1456. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1457. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1458. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c ) );
  1459. }
  1460. };
  1461. template< S32 startArgc, typename A, typename B, typename C >
  1462. struct _EngineConsoleThunk< startArgc, void( A, B, C ) >
  1463. {
  1464. typedef void ReturnType;
  1465. static const S32 NUM_ARGS = 3 + startArgc;
  1466. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C ), const _EngineFunctionDefaultArguments< void( A, B, C ) >& defaultArgs )
  1467. {
  1468. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1469. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1470. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1471. fn( a, b, c );
  1472. }
  1473. template< typename Frame >
  1474. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C ) >& defaultArgs )
  1475. {
  1476. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1477. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1478. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1479. ( frame->*fn )( a, b, c );
  1480. }
  1481. };
  1482. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D >
  1483. struct _EngineConsoleThunk< startArgc, R( A, B, C, D ) >
  1484. {
  1485. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1486. static const S32 NUM_ARGS = 4 + startArgc;
  1487. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
  1488. {
  1489. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1490. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1491. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1492. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1493. return _EngineConsoleThunkReturnValue( fn( a, b, c, d ) );
  1494. }
  1495. template< typename Frame >
  1496. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
  1497. {
  1498. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1499. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1500. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1501. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1502. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d ) );
  1503. }
  1504. };
  1505. template< S32 startArgc, typename A, typename B, typename C, typename D >
  1506. struct _EngineConsoleThunk< startArgc, void( A, B, C, D ) >
  1507. {
  1508. typedef void ReturnType;
  1509. static const S32 NUM_ARGS = 4 + startArgc;
  1510. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D ), const _EngineFunctionDefaultArguments< void( A, B, C, D ) >& defaultArgs )
  1511. {
  1512. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1513. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1514. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1515. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1516. fn( a, b, c, d );
  1517. }
  1518. template< typename Frame >
  1519. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D ) >& defaultArgs )
  1520. {
  1521. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1522. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1523. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1524. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1525. ( frame->*fn )( a, b, c, d );
  1526. }
  1527. };
  1528. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E >
  1529. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E ) >
  1530. {
  1531. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1532. static const S32 NUM_ARGS = 5 + startArgc;
  1533. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
  1534. {
  1535. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1536. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1537. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1538. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1539. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1540. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e ) );
  1541. }
  1542. template< typename Frame >
  1543. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
  1544. {
  1545. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1546. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1547. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1548. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1549. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1550. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e ) );
  1551. }
  1552. };
  1553. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E >
  1554. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E ) >
  1555. {
  1556. typedef void ReturnType;
  1557. static const S32 NUM_ARGS = 5 + startArgc;
  1558. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E ) >& defaultArgs )
  1559. {
  1560. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1561. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1562. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1563. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1564. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1565. fn( a, b, c, d, e );
  1566. }
  1567. template< typename Frame >
  1568. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E ) >& defaultArgs )
  1569. {
  1570. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1571. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1572. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1573. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1574. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1575. ( frame->*fn )( a, b, c, d, e );
  1576. }
  1577. };
  1578. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  1579. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F ) >
  1580. {
  1581. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1582. static const S32 NUM_ARGS = 6 + startArgc;
  1583. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
  1584. {
  1585. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1586. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1587. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1588. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1589. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1590. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1591. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f ) );
  1592. }
  1593. template< typename Frame >
  1594. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
  1595. {
  1596. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1597. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1598. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1599. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1600. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1601. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1602. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f ) );
  1603. }
  1604. };
  1605. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F >
  1606. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F ) >
  1607. {
  1608. typedef void ReturnType;
  1609. static const S32 NUM_ARGS = 6 + startArgc;
  1610. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F ) >& defaultArgs )
  1611. {
  1612. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1613. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1614. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1615. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1616. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1617. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1618. fn( a, b, c, d, e, f );
  1619. }
  1620. template< typename Frame >
  1621. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F ) >& defaultArgs )
  1622. {
  1623. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1624. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1625. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1626. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1627. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1628. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1629. ( frame->*fn )( a, b, c, d, e, f );
  1630. }
  1631. };
  1632. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  1633. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G ) >
  1634. {
  1635. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1636. static const S32 NUM_ARGS = 7 + startArgc;
  1637. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
  1638. {
  1639. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1640. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1641. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1642. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1643. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1644. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1645. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1646. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g ) );
  1647. }
  1648. template< typename Frame >
  1649. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
  1650. {
  1651. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1652. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1653. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1654. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1655. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1656. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1657. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1658. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f, g ) );
  1659. }
  1660. };
  1661. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  1662. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G ) >
  1663. {
  1664. typedef void ReturnType;
  1665. static const S32 NUM_ARGS = 7 + startArgc;
  1666. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G ) >& defaultArgs )
  1667. {
  1668. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1669. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1670. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1671. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1672. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1673. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1674. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1675. fn( a, b, c, d, e, f, g );
  1676. }
  1677. template< typename Frame >
  1678. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G ) >& defaultArgs )
  1679. {
  1680. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1681. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1682. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1683. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1684. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1685. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1686. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1687. ( frame->*fn )( a, b, c, d, e, f, g );
  1688. }
  1689. };
  1690. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  1691. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H ) >
  1692. {
  1693. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1694. static const S32 NUM_ARGS = 8 + startArgc;
  1695. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
  1696. {
  1697. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1698. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1699. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1700. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1701. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1702. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1703. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1704. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1705. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h ) );
  1706. }
  1707. template< typename Frame >
  1708. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
  1709. {
  1710. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1711. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1712. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1713. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1714. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1715. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1716. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1717. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1718. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f, g, h ) );
  1719. }
  1720. };
  1721. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  1722. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H ) >
  1723. {
  1724. typedef void ReturnType;
  1725. static const S32 NUM_ARGS = 8 + startArgc;
  1726. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H ) >& defaultArgs )
  1727. {
  1728. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1729. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1730. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1731. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1732. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1733. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1734. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1735. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1736. fn( a, b, c, d, e, f, g, h );
  1737. }
  1738. template< typename Frame >
  1739. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H ) >& defaultArgs )
  1740. {
  1741. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1742. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1743. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1744. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1745. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1746. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1747. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1748. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1749. ( frame->*fn )( a, b, c, d, e, f, g, h );
  1750. }
  1751. };
  1752. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  1753. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I ) >
  1754. {
  1755. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1756. static const S32 NUM_ARGS = 9 + startArgc;
  1757. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
  1758. {
  1759. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1760. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1761. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1762. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1763. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1764. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1765. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1766. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1767. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1768. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i ) );
  1769. }
  1770. template< typename Frame >
  1771. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
  1772. {
  1773. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1774. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1775. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1776. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1777. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1778. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1779. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1780. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1781. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1782. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f, g, h, i ) );
  1783. }
  1784. };
  1785. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  1786. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I ) >
  1787. {
  1788. typedef void ReturnType;
  1789. static const S32 NUM_ARGS = 9 + startArgc;
  1790. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I ) >& defaultArgs )
  1791. {
  1792. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1793. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1794. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1795. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1796. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1797. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1798. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1799. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1800. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1801. fn( a, b, c, d, e, f, g, h, i );
  1802. }
  1803. template< typename Frame >
  1804. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I ) >& defaultArgs )
  1805. {
  1806. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1807. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1808. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1809. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1810. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1811. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1812. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1813. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1814. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1815. ( frame->*fn )( a, b, c, d, e, f, g, h, i );
  1816. }
  1817. };
  1818. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  1819. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J ) >
  1820. {
  1821. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1822. static const S32 NUM_ARGS = 10 + startArgc;
  1823. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
  1824. {
  1825. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1826. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1827. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1828. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1829. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1830. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1831. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1832. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1833. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1834. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.j ) );
  1835. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i, j ) );
  1836. }
  1837. template< typename Frame >
  1838. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
  1839. {
  1840. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1841. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1842. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1843. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1844. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1845. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1846. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1847. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1848. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1849. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.k ) );
  1850. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f, g, h, i, j ) );
  1851. }
  1852. };
  1853. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  1854. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J ) >
  1855. {
  1856. typedef void ReturnType;
  1857. static const S32 NUM_ARGS = 10 + startArgc;
  1858. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
  1859. {
  1860. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1861. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1862. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1863. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1864. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1865. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1866. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1867. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1868. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1869. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.j ) );
  1870. fn( a, b, c, d, e, f, g, h, i, j );
  1871. }
  1872. template< typename Frame >
  1873. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J ) >& defaultArgs )
  1874. {
  1875. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1876. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1877. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1878. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1879. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1880. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1881. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1882. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1883. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1884. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.k ) );
  1885. ( frame->*fn )( a, b, c, d, e, f, g, h, i, j );
  1886. }
  1887. };
  1888. template< S32 startArgc, typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  1889. struct _EngineConsoleThunk< startArgc, R( A, B, C, D, E, F, G, H, I, J, K ) >
  1890. {
  1891. typedef typename _EngineConsoleThunkType< R >::ReturnType ReturnType;
  1892. static const S32 NUM_ARGS = 11 + startArgc;
  1893. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
  1894. {
  1895. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1896. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1897. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1898. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1899. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1900. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1901. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1902. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1903. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1904. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.j ) );
  1905. K k = ( startArgc + 10 < argc ? EngineUnmarshallData< K >()( argv[ startArgc + 10 ] ) : K( defaultArgs.k ) );
  1906. return _EngineConsoleThunkReturnValue( fn( a, b, c, d, e, f, g, h, i, j, k ) );
  1907. }
  1908. template< typename Frame >
  1909. static ReturnType thunk( S32 argc, ConsoleValueRef *argv, R ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
  1910. {
  1911. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1912. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1913. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1914. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1915. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1916. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1917. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1918. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1919. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1920. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.k ) );
  1921. K k = ( startArgc + 10 < argc ? EngineUnmarshallData< K >()( argv[ startArgc + 10 ] ) : K( defaultArgs.l ) );
  1922. return _EngineConsoleThunkReturnValue( ( frame->*fn )( a, b, c, d, e, f, g, h, i, j, k ) );
  1923. }
  1924. };
  1925. template< S32 startArgc, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  1926. struct _EngineConsoleThunk< startArgc, void( A, B, C, D, E, F, G, H, I, J, K ) >
  1927. {
  1928. typedef void ReturnType;
  1929. static const S32 NUM_ARGS = 11 + startArgc;
  1930. static void thunk( S32 argc, ConsoleValueRef *argv, void ( *fn )( A, B, C, D, E, F, G, H, I, J, K ), const _EngineFunctionDefaultArguments< void( A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
  1931. {
  1932. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.a ) );
  1933. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.b ) );
  1934. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.c ) );
  1935. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.d ) );
  1936. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.e ) );
  1937. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.f ) );
  1938. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.g ) );
  1939. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.h ) );
  1940. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.i ) );
  1941. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.j ) );
  1942. K k = ( startArgc + 10 < argc ? EngineUnmarshallData< K >()( argv[ startArgc + 10 ] ) : K( defaultArgs.k ) );
  1943. fn( a, b, c, d, e, f, g, h, i, j, k );
  1944. }
  1945. template< typename Frame >
  1946. static void thunk( S32 argc, ConsoleValueRef *argv, void ( Frame::*fn )( A, B, C, D, E, F, G, H, I, J, K ) const, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, A, B, C, D, E, F, G, H, I, J, K ) >& defaultArgs )
  1947. {
  1948. A a = ( startArgc < argc ? EngineUnmarshallData< A >()( argv[ startArgc ] ) : A( defaultArgs.b ) );
  1949. B b = ( startArgc + 1 < argc ? EngineUnmarshallData< B >()( argv[ startArgc + 1 ] ) : B( defaultArgs.c ) );
  1950. C c = ( startArgc + 2 < argc ? EngineUnmarshallData< C >()( argv[ startArgc + 2 ] ) : C( defaultArgs.d ) );
  1951. D d = ( startArgc + 3 < argc ? EngineUnmarshallData< D >()( argv[ startArgc + 3 ] ) : D( defaultArgs.e ) );
  1952. E e = ( startArgc + 4 < argc ? EngineUnmarshallData< E >()( argv[ startArgc + 4 ] ) : E( defaultArgs.f ) );
  1953. F f = ( startArgc + 5 < argc ? EngineUnmarshallData< F >()( argv[ startArgc + 5 ] ) : F( defaultArgs.g ) );
  1954. G g = ( startArgc + 6 < argc ? EngineUnmarshallData< G >()( argv[ startArgc + 6 ] ) : G( defaultArgs.h ) );
  1955. H h = ( startArgc + 7 < argc ? EngineUnmarshallData< H >()( argv[ startArgc + 7 ] ) : H( defaultArgs.i ) );
  1956. I i = ( startArgc + 8 < argc ? EngineUnmarshallData< I >()( argv[ startArgc + 8 ] ) : I( defaultArgs.j ) );
  1957. J j = ( startArgc + 9 < argc ? EngineUnmarshallData< J >()( argv[ startArgc + 9 ] ) : J( defaultArgs.k ) );
  1958. K k = ( startArgc + 10 < argc ? EngineUnmarshallData< K >()( argv[ startArgc + 10 ] ) : K( defaultArgs.l ) );
  1959. ( frame->*fn )( a, b, c, d, e, f, g, h, i, j, k );
  1960. }
  1961. };
  1962. /// @}
  1963. /// @name API Definition Macros
  1964. ///
  1965. /// The macros in this group allow to create engine API functions that work both with the
  1966. /// legacy console system as well as with the new engine export system. As such, they only
  1967. /// support those function features that are available in both systems. This means that for
  1968. /// console-style variadic functions, the ConsoleXXX must be used and that for overloaded
  1969. /// and/or C-style variadic functions as well as for placing functions in export scopes,
  1970. /// DEFINE_CALLIN must be used directly.
  1971. ///
  1972. /// When the console system is removed, the console thunking functionality will be removed
  1973. /// from these macros but otherwise they will remain unchanged and in place.
  1974. ///
  1975. /// @{
  1976. // Helpers to implement initialization checks. Pulled out into separate macros so this can be deactivated easily.
  1977. // Especially important for the initialize() function itself.
  1978. #define _CHECK_ENGINE_INITIALIZED_IMPL( fnName, returnType ) \
  1979. if( !engineAPI::gIsInitialized ) \
  1980. { \
  1981. Con::errorf( "EngineAPI: Engine not initialized when calling " #fnName ); \
  1982. return EngineTypeTraits< returnType >::ReturnValue( EngineTypeTraits< returnType >::ReturnValueType() ); \
  1983. }
  1984. #define _CHECK_ENGINE_INITIALIZED( fnName, returnType ) _CHECK_ENGINE_INITIALIZED_IMPL( fnName, returnType )
  1985. /// Define a call-in point for calling into the engine.
  1986. ///
  1987. /// @param name The name of the function as it should be seen by the control layer.
  1988. /// @param returnType The value type returned to the control layer.
  1989. /// @param args The argument list as it would appear on the function definition
  1990. /// @param defaultArgs The list of default argument values.
  1991. /// @param usage The usage doc string for the engine API reference.
  1992. ///
  1993. /// @code
  1994. /// DefineEngineFunction( myFunction, int, ( float f, const String& s ), ( "value for s" ), "This is my function." )
  1995. /// {
  1996. /// return int( f ) + dAtoi( s );
  1997. /// }
  1998. /// @endcode
  1999. #define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \
  2000. static inline returnType _fn ## name ## impl args; \
  2001. TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
  2002. ( _EngineFunctionTrampoline< returnType args >::Args a ) \
  2003. { \
  2004. _CHECK_ENGINE_INITIALIZED( name, returnType ); \
  2005. return EngineTypeTraits< returnType >::ReturnValue( \
  2006. _EngineFunctionTrampoline< returnType args >::jmp( _fn ## name ## impl, a ) \
  2007. ); \
  2008. } \
  2009. static _EngineFunctionDefaultArguments< void args > _fn ## name ## DefaultArgs defaultArgs; \
  2010. static EngineFunctionInfo _fn ## name ## FunctionInfo( \
  2011. #name, \
  2012. &_SCOPE<>()(), \
  2013. usage, \
  2014. #returnType " " #name #args, \
  2015. "fn" #name, \
  2016. TYPE< returnType args >(), \
  2017. &_fn ## name ## DefaultArgs, \
  2018. ( void* ) &fn ## name, \
  2019. 0 \
  2020. ); \
  2021. static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
  2022. { \
  2023. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
  2024. argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
  2025. ) ); \
  2026. } \
  2027. static ConsoleFunctionHeader _ ## name ## header \
  2028. ( #returnType, #args, #defaultArgs ); \
  2029. static ConsoleConstructor \
  2030. _ ## name ## obj( NULL, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## name ## caster ), usage, \
  2031. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2032. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS, \
  2033. false, &_ ## name ## header \
  2034. ); \
  2035. static inline returnType _fn ## name ## impl args
  2036. // The next thing is a bit tricky. DefineEngineMethod allows to make the 'object' (=this) argument to the function
  2037. // implicit which presents quite an obstacle for the macro internals as the engine export system requires the
  2038. // name of a DLL symbol that represents an extern "C" function with an explicit first object pointer argument.
  2039. //
  2040. // Even if we ignored the fact that we don't have a guarantee how the various C++ compilers implement implicit 'this' arguments,
  2041. // we could still not just use a C++ method for this as then we would have to get past the C++ compiler's mangling to
  2042. // get to the function symbol name (let alone the fact that typing this method correctly would be tricky).
  2043. //
  2044. // So, the trick employed here is to package all but the implicit 'this' argument in a structure and then define an
  2045. // extern "C" function that takes the object pointer as a first argument and the struct type as the second argument.
  2046. // This will result in a function with an identical stack call frame layout to the function we want.
  2047. //
  2048. // Unfortunately, that still requires that function to chain on to the real user-defined function. To do this
  2049. // cleanly and portably, _EngineMethodTrampoline is used to unpack and jump the call from extern "C" into C++ space.
  2050. // In optimized builds, the compiler should be smart enough to pretty much optimize all our trickery here away.
  2051. #define _DefineMethodTrampoline( className, name, returnType, args ) \
  2052. TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \
  2053. fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::Args a ) \
  2054. { \
  2055. _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
  2056. return EngineTypeTraits< returnType >::ReturnValue( \
  2057. _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::jmp( object, a ) \
  2058. ); \
  2059. }
  2060. /// Define a call-in point for calling a method on an engine object.
  2061. ///
  2062. /// @param name The name of the C++ class.
  2063. /// @param name The name of the method as it should be seen by the control layer.
  2064. /// @param returnType The value type returned to the control layer.
  2065. /// @param args The argument list as it would appear on the function definition
  2066. /// @param defaultArgs The list of default argument values.
  2067. /// @param usage The usage doc string for the engine API reference.
  2068. ///
  2069. /// @code
  2070. /// DefineEngineMethod( MyClass, myMethod, int, ( float f, const String& s ), ( "value for s" ), "This is my method." )
  2071. /// {
  2072. /// return object->someMethod( f, s );
  2073. /// }
  2074. /// @endcode
  2075. #define DefineEngineMethod( className, name, returnType, args, defaultArgs, usage ) \
  2076. struct _ ## className ## name ## frame \
  2077. { \
  2078. typedef className ObjectType; \
  2079. className* object; \
  2080. inline returnType _exec args const; \
  2081. }; \
  2082. _DefineMethodTrampoline( className, name, returnType, args ); \
  2083. static _EngineFunctionDefaultArguments< _EngineMethodTrampoline< _ ## className ## name ## frame, void args >::FunctionType > \
  2084. _fn ## className ## name ## DefaultArgs defaultArgs; \
  2085. static EngineFunctionInfo _fn ## className ## name ## FunctionInfo( \
  2086. #name, \
  2087. &_SCOPE< className >()(), \
  2088. usage, \
  2089. "virtual " #returnType " " #name #args, \
  2090. "fn" #className "_" #name, \
  2091. TYPE< _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::FunctionType >(), \
  2092. &_fn ## className ## name ## DefaultArgs, \
  2093. ( void* ) &fn ## className ## _ ## name, \
  2094. 0 \
  2095. ); \
  2096. static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv ) \
  2097. { \
  2098. _ ## className ## name ## frame frame; \
  2099. frame.object = static_cast< className* >( object ); \
  2100. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 2, returnType args >::thunk( \
  2101. argc, argv, &_ ## className ## name ## frame::_exec, &frame, _fn ## className ## name ## DefaultArgs \
  2102. ) ); \
  2103. } \
  2104. static ConsoleFunctionHeader _ ## className ## name ## header \
  2105. ( #returnType, #args, #defaultArgs ); \
  2106. static ConsoleConstructor \
  2107. className ## name ## obj( #className, #name, \
  2108. _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage, \
  2109. _EngineConsoleThunk< 2, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2110. _EngineConsoleThunk< 2, returnType args >::NUM_ARGS, \
  2111. false, &_ ## className ## name ## header \
  2112. ); \
  2113. returnType _ ## className ## name ## frame::_exec args const
  2114. /// Define a call-in point for calling into the engine. Unlike with DefineEngineFunction, the statically
  2115. /// callable function will be confined to the namespace of the given class.
  2116. ///
  2117. /// @param name The name of the C++ class (or a registered export scope).
  2118. /// @param name The name of the method as it should be seen by the control layer.
  2119. /// @param returnType The value type returned to the control layer.
  2120. /// @param args The argument list as it would appear on the function definition
  2121. /// @param defaultArgs The list of default argument values.
  2122. /// @param usage The usage doc string for the engine API reference.
  2123. ///
  2124. /// @code
  2125. /// DefineEngineStaticMethod( MyClass, myMethod, int, ( float f, string s ), ( "value for s" ), "This is my method." )
  2126. /// {
  2127. /// }
  2128. /// @endcode
  2129. #define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
  2130. static inline returnType _fn ## className ## name ## impl args; \
  2131. TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
  2132. ( _EngineFunctionTrampoline< returnType args >::Args a ) \
  2133. { \
  2134. _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
  2135. return EngineTypeTraits< returnType >::ReturnValue( \
  2136. _EngineFunctionTrampoline< returnType args >::jmp( _fn ## className ## name ## impl, a ) \
  2137. ); \
  2138. } \
  2139. static _EngineFunctionDefaultArguments< void args > _fn ## className ## name ## DefaultArgs defaultArgs; \
  2140. static EngineFunctionInfo _fn ## name ## FunctionInfo( \
  2141. #name, \
  2142. &_SCOPE< className >()(), \
  2143. usage, \
  2144. #returnType " " #name #args, \
  2145. "fn" #className "_" #name, \
  2146. TYPE< returnType args >(), \
  2147. &_fn ## className ## name ## DefaultArgs, \
  2148. ( void* ) &fn ## className ## _ ## name, \
  2149. 0 \
  2150. ); \
  2151. static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\
  2152. { \
  2153. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
  2154. argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs \
  2155. ) ); \
  2156. } \
  2157. static ConsoleFunctionHeader _ ## className ## name ## header \
  2158. ( #returnType, #args, #defaultArgs, true ); \
  2159. static ConsoleConstructor \
  2160. _ ## className ## name ## obj( #className, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage, \
  2161. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2162. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS, \
  2163. false, &_ ## className ## name ## header \
  2164. ); \
  2165. static inline returnType _fn ## className ## name ## impl args
  2166. // Convenience macros to allow defining functions that use the new marshalling features
  2167. // while being only visible in the console interop. When we drop the console system,
  2168. // these macros can be removed and all definitions that make use of them can be removed
  2169. // as well.
  2170. #define DefineConsoleFunction( name, returnType, args, defaultArgs, usage ) \
  2171. static inline returnType _fn ## name ## impl args; \
  2172. static _EngineFunctionDefaultArguments< void args > _fn ## name ## DefaultArgs defaultArgs; \
  2173. static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
  2174. { \
  2175. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
  2176. argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
  2177. ) ); \
  2178. } \
  2179. static ConsoleFunctionHeader _ ## name ## header \
  2180. ( #returnType, #args, #defaultArgs ); \
  2181. static ConsoleConstructor \
  2182. _ ## name ## obj( NULL, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## name ## caster ), usage, \
  2183. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2184. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS, \
  2185. false, &_ ## name ## header \
  2186. ); \
  2187. static inline returnType _fn ## name ## impl args
  2188. #define DefineConsoleMethod( className, name, returnType, args, defaultArgs, usage ) \
  2189. struct _ ## className ## name ## frame \
  2190. { \
  2191. typedef className ObjectType; \
  2192. className* object; \
  2193. inline returnType _exec args const; \
  2194. }; \
  2195. static _EngineFunctionDefaultArguments< _EngineMethodTrampoline< _ ## className ## name ## frame, void args >::FunctionType > \
  2196. _fn ## className ## name ## DefaultArgs defaultArgs; \
  2197. static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv ) \
  2198. { \
  2199. _ ## className ## name ## frame frame; \
  2200. frame.object = static_cast< className* >( object ); \
  2201. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 2, returnType args >::thunk( \
  2202. argc, argv, &_ ## className ## name ## frame::_exec, &frame, _fn ## className ## name ## DefaultArgs \
  2203. ) ); \
  2204. } \
  2205. static ConsoleFunctionHeader _ ## className ## name ## header \
  2206. ( #returnType, #args, #defaultArgs ); \
  2207. static ConsoleConstructor \
  2208. className ## name ## obj( #className, #name, \
  2209. _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage, \
  2210. _EngineConsoleThunk< 2, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2211. _EngineConsoleThunk< 2, returnType args >::NUM_ARGS, \
  2212. false, &_ ## className ## name ## header \
  2213. ); \
  2214. returnType _ ## className ## name ## frame::_exec args const
  2215. #define DefineConsoleStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
  2216. static inline returnType _fn ## className ## name ## impl args; \
  2217. static _EngineFunctionDefaultArguments< void args > _fn ## className ## name ## DefaultArgs defaultArgs; \
  2218. static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\
  2219. { \
  2220. return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
  2221. argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs \
  2222. ) ); \
  2223. } \
  2224. static ConsoleFunctionHeader _ ## className ## name ## header \
  2225. ( #returnType, #args, #defaultArgs, true ); \
  2226. static ConsoleConstructor \
  2227. _ ## className ## name ## obj( #className, #name, _EngineConsoleThunkType< returnType >::CallbackType( _ ## className ## name ## caster ), usage, \
  2228. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS - _EngineConsoleThunkCountArgs() defaultArgs, \
  2229. _EngineConsoleThunk< 1, returnType args >::NUM_ARGS, \
  2230. false, &_ ## className ## name ## header \
  2231. ); \
  2232. static inline returnType _fn ## className ## name ## impl args
  2233. // The following three macros are only temporary. They allow to define engineAPI functions using the framework
  2234. // here in this file while being visible only in the new API. When the console interop is removed, these macros
  2235. // can be removed and all their uses be replaced with their corresponding versions that now still include support
  2236. // for the console (e.g. DefineNewEngineFunction should become DefineEngineFunction).
  2237. #define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \
  2238. static inline returnType _fn ## name ## impl args; \
  2239. TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
  2240. ( _EngineFunctionTrampoline< returnType args >::Args a ) \
  2241. { \
  2242. _CHECK_ENGINE_INITIALIZED( name, returnType ); \
  2243. return EngineTypeTraits< returnType >::ReturnValue( \
  2244. _EngineFunctionTrampoline< returnType args >::jmp( _fn ## name ## impl, a ) \
  2245. ); \
  2246. } \
  2247. static _EngineFunctionDefaultArguments< void args > _fn ## name ## DefaultArgs defaultArgs; \
  2248. static EngineFunctionInfo _fn ## name ## FunctionInfo( \
  2249. #name, \
  2250. &_SCOPE<>()(), \
  2251. usage, \
  2252. #returnType " " #name #args, \
  2253. "fn" #name, \
  2254. TYPE< returnType args >(), \
  2255. &_fn ## name ## DefaultArgs, \
  2256. ( void* ) &fn ## name, \
  2257. 0 \
  2258. ); \
  2259. static inline returnType _fn ## name ## impl args
  2260. #define DefineNewEngineMethod( className, name, returnType, args, defaultArgs, usage ) \
  2261. struct _ ## className ## name ## frame \
  2262. { \
  2263. typedef className ObjectType; \
  2264. className* object; \
  2265. inline returnType _exec args const; \
  2266. }; \
  2267. _DefineMethodTrampoline( className, name, returnType, args ); \
  2268. static _EngineFunctionDefaultArguments< _EngineMethodTrampoline< _ ## className ## name ## frame, void args >::FunctionType > \
  2269. _fn ## className ## name ## DefaultArgs defaultArgs; \
  2270. static EngineFunctionInfo _fn ## className ## name ## FunctionInfo( \
  2271. #name, \
  2272. &_SCOPE< className >()(), \
  2273. usage, \
  2274. "virtual " #returnType " " #name #args, \
  2275. "fn" #className "_" #name, \
  2276. TYPE< _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::FunctionType >(), \
  2277. &_fn ## className ## name ## DefaultArgs, \
  2278. ( void* ) &fn ## className ## _ ## name, \
  2279. 0 \
  2280. ); \
  2281. returnType _ ## className ## name ## frame::_exec args const
  2282. #define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
  2283. static inline returnType _fn ## className ## name ## impl args; \
  2284. TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
  2285. ( _EngineFunctionTrampoline< returnType args >::Args a ) \
  2286. { \
  2287. _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
  2288. return EngineTypeTraits< returnType >::ReturnValue( \
  2289. _EngineFunctionTrampoline< returnType args >::jmp( _fn ## className ## name ## impl, a ) \
  2290. ); \
  2291. } \
  2292. static _EngineFunctionDefaultArguments< void args > _fn ## className ## name ## DefaultArgs defaultArgs; \
  2293. static EngineFunctionInfo _fn ## name ## FunctionInfo( \
  2294. #name, \
  2295. &_SCOPE< className >()(), \
  2296. usage, \
  2297. #returnType " " #name #args, \
  2298. "fn" #className "_" #name, \
  2299. TYPE< returnType args >(), \
  2300. &_fn ## className ## name ## DefaultArgs, \
  2301. ( void* ) &fn ## className ## _ ## name, \
  2302. 0 \
  2303. ); \
  2304. static inline returnType _fn ## className ## name ## impl args
  2305. /// @}
  2306. //=============================================================================
  2307. // Callbacks.
  2308. //=============================================================================
  2309. /// Matching implement for DECLARE_CALLBACK.
  2310. ///
  2311. ///
  2312. /// @warn With the new interop system, method-style callbacks <em>must not</em> be triggered on object
  2313. /// that are being created! This is because the control layer will likely not yet have a fully valid wrapper
  2314. /// object in place for the EngineObject under construction.
  2315. #define IMPLEMENT_CALLBACK( class, name, returnType, args, argNames, usageString ) \
  2316. struct _ ## class ## name ## frame { typedef class ObjectType; }; \
  2317. TORQUE_API _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType* cb ## class ## _ ## name; \
  2318. TORQUE_API void set_cb ## class ## _ ## name( \
  2319. _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType fn ) \
  2320. { cb ## class ## _ ## name = fn; } \
  2321. _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType* cb ## class ## _ ## name; \
  2322. namespace { \
  2323. ::EngineFunctionInfo _cb ## class ## name( \
  2324. #name, \
  2325. &::_SCOPE< class >()(), \
  2326. usageString, \
  2327. "virtual " #returnType " " #name #args, \
  2328. "cb" #class "_" #name, \
  2329. ::TYPE< _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType >(), \
  2330. NULL, \
  2331. ( void* ) &cb ## class ## _ ## name, \
  2332. EngineFunctionCallout \
  2333. ); \
  2334. } \
  2335. returnType class::name ## _callback args \
  2336. { \
  2337. if( cb ## class ## _ ## name ) { \
  2338. _EngineCallbackHelper cbh( this, reinterpret_cast< const void* >( cb ## class ## _ ## name ) ); \
  2339. return returnType( cbh.call< returnType > argNames ); \
  2340. } \
  2341. if( engineAPI::gUseConsoleInterop ) \
  2342. { \
  2343. static StringTableEntry sName = StringTable->insert( #name ); \
  2344. _EngineConsoleCallbackHelper cbh( sName, this ); \
  2345. return returnType( cbh.call< returnType > argNames ); \
  2346. } \
  2347. return returnType(); \
  2348. } \
  2349. namespace { \
  2350. ConsoleFunctionHeader _ ## class ## name ## header( \
  2351. #returnType, #args, "" ); \
  2352. ConsoleConstructor _ ## class ## name ## obj( #class, #name, usageString, &_ ## class ## name ## header ); \
  2353. }
  2354. /// Used to define global callbacks not associated with
  2355. /// any particular class or namespace.
  2356. #define IMPLEMENT_GLOBAL_CALLBACK( name, returnType, args, argNames, usageString ) \
  2357. DEFINE_CALLOUT( cb ## name, name,, returnType, args, 0, usageString ); \
  2358. returnType name ## _callback args \
  2359. { \
  2360. if( cb ## name ) \
  2361. return returnType( cb ## name argNames ); \
  2362. if( engineAPI::gUseConsoleInterop ) \
  2363. { \
  2364. static StringTableEntry sName = StringTable->insert( #name ); \
  2365. _EngineConsoleCallbackHelper cbh( sName, NULL ); \
  2366. return returnType( cbh.call< returnType > argNames ); \
  2367. } \
  2368. return returnType(); \
  2369. } \
  2370. namespace { \
  2371. ConsoleFunctionHeader _ ## name ## header( \
  2372. #returnType, #args, "" ); \
  2373. ConsoleConstructor _ ## name ## obj( NULL, #name, usageString, &_ ## name ## header ); \
  2374. }
  2375. // Again, temporary macros to allow splicing the API while we still have the console interop around.
  2376. #define IMPLEMENT_CONSOLE_CALLBACK( class, name, returnType, args, argNames, usageString ) \
  2377. returnType class::name ## _callback args \
  2378. { \
  2379. if( engineAPI::gUseConsoleInterop ) \
  2380. { \
  2381. static StringTableEntry sName = StringTable->insert( #name ); \
  2382. _EngineConsoleCallbackHelper cbh( sName, this ); \
  2383. return returnType( cbh.call< returnType > argNames ); \
  2384. } \
  2385. return returnType(); \
  2386. } \
  2387. namespace { \
  2388. ConsoleFunctionHeader _ ## class ## name ## header( \
  2389. #returnType, #args, "" ); \
  2390. ConsoleConstructor _ ## class ## name ## obj( #class, #name, usageString, &_ ## class ## name ## header ); \
  2391. }
  2392. #define IMPLEMENT_NEW_CALLBACK( class, name, returnType, args, argNames, usageString ) \
  2393. struct _ ## class ## name ## frame { typedef class ObjectType; }; \
  2394. TORQUE_API _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType* cb ## class ## _ ## name; \
  2395. TORQUE_API void set_cb ## class ## _ ## name( \
  2396. _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType fn ) \
  2397. { cb ## class ## _ ## name = fn; } \
  2398. _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType* cb ## class ## _ ## name; \
  2399. namespace { \
  2400. ::EngineFunctionInfo _cb ## class ## name( \
  2401. #name, \
  2402. &::_SCOPE< class >()(), \
  2403. usageString, \
  2404. "virtual " #returnType " " #name #args, \
  2405. "cb" #class "_" #name, \
  2406. ::TYPE< _EngineMethodTrampoline< _ ## class ## name ## frame, returnType args >::FunctionType >(), \
  2407. NULL, \
  2408. &cb ## class ## _ ## name, \
  2409. EngineFunctionCallout \
  2410. ); \
  2411. } \
  2412. returnType class::name ## _callback args \
  2413. { \
  2414. if( cb ## class ## _ ## name ) { \
  2415. _EngineCallbackHelper cbh( this, reinterpret_cast< const void* >( cb ## class ## _ ## name ) ); \
  2416. return returnType( cbh.call< returnType > argNames ); \
  2417. } \
  2418. return returnType(); \
  2419. }
  2420. // Internal helper class for doing call-outs in the new interop.
  2421. struct _EngineCallbackHelper
  2422. {
  2423. protected:
  2424. EngineObject* mThis;
  2425. const void* mFn;
  2426. public:
  2427. _EngineCallbackHelper( EngineObject* pThis, const void* fn )
  2428. : mThis( pThis ),
  2429. mFn( fn ) {}
  2430. template< typename R >
  2431. R call() const
  2432. {
  2433. typedef R( FunctionType )( EngineObject* );
  2434. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis ) );
  2435. }
  2436. template< typename R, typename A >
  2437. R call( A a ) const
  2438. {
  2439. typedef R( FunctionType )( EngineObject*, A );
  2440. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a ) );
  2441. }
  2442. template< typename R, typename A, typename B >
  2443. R call( A a, B b ) const
  2444. {
  2445. typedef R( FunctionType )( EngineObject*, A, B );
  2446. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b ) );
  2447. }
  2448. template< typename R, typename A, typename B, typename C >
  2449. R call( A a, B b, C c ) const
  2450. {
  2451. typedef R( FunctionType )( EngineObject*, A, B, C );
  2452. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c ) );
  2453. }
  2454. template< typename R, typename A, typename B, typename C, typename D >
  2455. R call( A a, B b, C c, D d ) const
  2456. {
  2457. typedef R( FunctionType )( EngineObject*, A, B, C, D );
  2458. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d ) );
  2459. }
  2460. template< typename R, typename A, typename B, typename C, typename D, typename E >
  2461. R call( A a, B b, C c, D d, E e ) const
  2462. {
  2463. typedef R( FunctionType )( EngineObject*, A, B, C, D, E );
  2464. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e ) );
  2465. }
  2466. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  2467. R call( A a, B b, C c, D d, E e, F f ) const
  2468. {
  2469. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F );
  2470. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f ) );
  2471. }
  2472. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  2473. R call( A a, B b, C c, D d, E e, F f, G g ) const
  2474. {
  2475. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G );
  2476. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g ) );
  2477. }
  2478. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  2479. R call( A a, B b, C c, D d, E e, F f, G g, H h ) const
  2480. {
  2481. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H );
  2482. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h ) );
  2483. }
  2484. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  2485. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i ) const
  2486. {
  2487. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I );
  2488. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i ) );
  2489. }
  2490. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  2491. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j ) const
  2492. {
  2493. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J );
  2494. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j ) );
  2495. }
  2496. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  2497. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k ) const
  2498. {
  2499. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J, K );
  2500. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j, k ) );
  2501. }
  2502. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
  2503. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l ) const
  2504. {
  2505. typedef R( FunctionType )( EngineObject*, A, B, C, D, E, F, G, H, I, J, K, L l );
  2506. return R( reinterpret_cast< FunctionType* >( const_cast<void*>(mFn) )( mThis, a, b, c, d, e, f, g, h, i, j, k, l ) );
  2507. }
  2508. };
  2509. // Internal helper for callback support in legacy console system.
  2510. struct _EngineConsoleCallbackHelper
  2511. {
  2512. protected:
  2513. /// Matches up to storeArgs.
  2514. static const U32 MAX_ARGUMENTS = 11;
  2515. SimObject* mThis;
  2516. S32 mArgc;
  2517. ConsoleValueRef mArgv[ MAX_ARGUMENTS + 2 ];
  2518. const char* _exec()
  2519. {
  2520. if( mThis )
  2521. {
  2522. // Cannot invoke callback until object has been registered
  2523. if (mThis->isProperlyAdded()) {
  2524. return Con::execute( mThis, mArgc, mArgv );
  2525. } else {
  2526. Con::resetStackFrame(); // We might have pushed some vars here
  2527. return "";
  2528. }
  2529. }
  2530. else
  2531. return Con::execute( mArgc, mArgv );
  2532. }
  2533. public:
  2534. _EngineConsoleCallbackHelper( StringTableEntry callbackName, SimObject* pThis )
  2535. : mThis( pThis ),
  2536. mArgc( pThis ? 2 : 1 )
  2537. {
  2538. mArgv[ 0 ] = callbackName;
  2539. }
  2540. template< typename R >
  2541. R call()
  2542. {
  2543. return R( EngineUnmarshallData< R >()( _exec() ) );
  2544. }
  2545. template< typename R, typename A >
  2546. R call( A a )
  2547. {
  2548. EngineMarshallData( a, mArgc, mArgv );
  2549. return R( EngineUnmarshallData< R >()( _exec() ) );
  2550. }
  2551. template< typename R, typename A, typename B >
  2552. R call( A a, B b )
  2553. {
  2554. EngineMarshallData( a, mArgc, mArgv );
  2555. EngineMarshallData( b, mArgc, mArgv );
  2556. return R( EngineUnmarshallData< R >()( _exec() ) );
  2557. }
  2558. template< typename R, typename A, typename B, typename C >
  2559. R call( A a, B b, C c )
  2560. {
  2561. EngineMarshallData( a, mArgc, mArgv );
  2562. EngineMarshallData( b, mArgc, mArgv );
  2563. EngineMarshallData( c, mArgc, mArgv );
  2564. return R( EngineUnmarshallData< R >()( _exec() ) );
  2565. }
  2566. template< typename R, typename A, typename B, typename C, typename D >
  2567. R call( A a, B b, C c, D d )
  2568. {
  2569. EngineMarshallData( a, mArgc, mArgv );
  2570. EngineMarshallData( b, mArgc, mArgv );
  2571. EngineMarshallData( c, mArgc, mArgv );
  2572. EngineMarshallData( d, mArgc, mArgv );
  2573. return R( EngineUnmarshallData< R >()( _exec() ) );
  2574. }
  2575. template< typename R, typename A, typename B, typename C, typename D, typename E >
  2576. R call( A a, B b, C c, D d, E e )
  2577. {
  2578. EngineMarshallData( a, mArgc, mArgv );
  2579. EngineMarshallData( b, mArgc, mArgv );
  2580. EngineMarshallData( c, mArgc, mArgv );
  2581. EngineMarshallData( d, mArgc, mArgv );
  2582. EngineMarshallData( e, mArgc, mArgv );
  2583. return R( EngineUnmarshallData< R >()( _exec() ) );
  2584. }
  2585. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F >
  2586. R call( A a, B b, C c, D d, E e, F f )
  2587. {
  2588. EngineMarshallData( a, mArgc, mArgv );
  2589. EngineMarshallData( b, mArgc, mArgv );
  2590. EngineMarshallData( c, mArgc, mArgv );
  2591. EngineMarshallData( d, mArgc, mArgv );
  2592. EngineMarshallData( e, mArgc, mArgv );
  2593. EngineMarshallData( f, mArgc, mArgv );
  2594. return R( EngineUnmarshallData< R >()( _exec() ) );
  2595. }
  2596. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G >
  2597. R call( A a, B b, C c, D d, E e, F f, G g )
  2598. {
  2599. EngineMarshallData( a, mArgc, mArgv );
  2600. EngineMarshallData( b, mArgc, mArgv );
  2601. EngineMarshallData( c, mArgc, mArgv );
  2602. EngineMarshallData( d, mArgc, mArgv );
  2603. EngineMarshallData( e, mArgc, mArgv );
  2604. EngineMarshallData( f, mArgc, mArgv );
  2605. EngineMarshallData( g, mArgc, mArgv );
  2606. return R( EngineUnmarshallData< R >()( _exec() ) );
  2607. }
  2608. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H >
  2609. R call( A a, B b, C c, D d, E e, F f, G g, H h )
  2610. {
  2611. EngineMarshallData( a, mArgc, mArgv );
  2612. EngineMarshallData( b, mArgc, mArgv );
  2613. EngineMarshallData( c, mArgc, mArgv );
  2614. EngineMarshallData( d, mArgc, mArgv );
  2615. EngineMarshallData( e, mArgc, mArgv );
  2616. EngineMarshallData( f, mArgc, mArgv );
  2617. EngineMarshallData( g, mArgc, mArgv );
  2618. EngineMarshallData( h, mArgc, mArgv );
  2619. return R( EngineUnmarshallData< R >()( _exec() ) );
  2620. }
  2621. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I >
  2622. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i )
  2623. {
  2624. EngineMarshallData( a, mArgc, mArgv );
  2625. EngineMarshallData( b, mArgc, mArgv );
  2626. EngineMarshallData( c, mArgc, mArgv );
  2627. EngineMarshallData( d, mArgc, mArgv );
  2628. EngineMarshallData( e, mArgc, mArgv );
  2629. EngineMarshallData( f, mArgc, mArgv );
  2630. EngineMarshallData( g, mArgc, mArgv );
  2631. EngineMarshallData( h, mArgc, mArgv );
  2632. EngineMarshallData( i, mArgc, mArgv );
  2633. return R( EngineUnmarshallData< R >()( _exec() ) );
  2634. }
  2635. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J >
  2636. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j )
  2637. {
  2638. EngineMarshallData( a, mArgc, mArgv );
  2639. EngineMarshallData( b, mArgc, mArgv );
  2640. EngineMarshallData( c, mArgc, mArgv );
  2641. EngineMarshallData( d, mArgc, mArgv );
  2642. EngineMarshallData( e, mArgc, mArgv );
  2643. EngineMarshallData( f, mArgc, mArgv );
  2644. EngineMarshallData( g, mArgc, mArgv );
  2645. EngineMarshallData( h, mArgc, mArgv );
  2646. EngineMarshallData( i, mArgc, mArgv );
  2647. EngineMarshallData( j, mArgc, mArgv );
  2648. return R( EngineUnmarshallData< R >()( _exec() ) );
  2649. }
  2650. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K >
  2651. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k )
  2652. {
  2653. EngineMarshallData( a, mArgc, mArgv );
  2654. EngineMarshallData( b, mArgc, mArgv );
  2655. EngineMarshallData( c, mArgc, mArgv );
  2656. EngineMarshallData( d, mArgc, mArgv );
  2657. EngineMarshallData( e, mArgc, mArgv );
  2658. EngineMarshallData( f, mArgc, mArgv );
  2659. EngineMarshallData( g, mArgc, mArgv );
  2660. EngineMarshallData( h, mArgc, mArgv );
  2661. EngineMarshallData( i, mArgc, mArgv );
  2662. EngineMarshallData( j, mArgc, mArgv );
  2663. EngineMarshallData( k, mArgc, mArgv );
  2664. return R( EngineUnmarshallData< R >()( _exec() ) );
  2665. }
  2666. template< typename R, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L >
  2667. R call( A a, B b, C c, D d, E e, F f, G g, H h, I i, J j, K k, L l )
  2668. {
  2669. EngineMarshallData( a, mArgc, mArgv );
  2670. EngineMarshallData( b, mArgc, mArgv );
  2671. EngineMarshallData( c, mArgc, mArgv );
  2672. EngineMarshallData( d, mArgc, mArgv );
  2673. EngineMarshallData( e, mArgc, mArgv );
  2674. EngineMarshallData( f, mArgc, mArgv );
  2675. EngineMarshallData( g, mArgc, mArgv );
  2676. EngineMarshallData( h, mArgc, mArgv );
  2677. EngineMarshallData( i, mArgc, mArgv );
  2678. EngineMarshallData( j, mArgc, mArgv );
  2679. EngineMarshallData( k, mArgc, mArgv );
  2680. EngineMarshallData( l, mArgc, mArgv );
  2681. return R( EngineUnmarshallData< R >()( _exec() ) );
  2682. }
  2683. };
  2684. // Re-enable some VC warnings we disabled for this file.
  2685. #pragma warning( pop ) // 4510 and 4610
  2686. #endif // !_ENGINEAPI_H_