Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
20 KiB

  1. //========== Copyright � 2008, Valve Corporation, All rights reserved. ========
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef VSCRIPT_TEMPLATES_H
  7. #define VSCRIPT_TEMPLATES_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #define FUNC_APPEND_PARAMS_0
  12. #define FUNC_APPEND_PARAMS_1 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 1 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) );
  13. #define FUNC_APPEND_PARAMS_2 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 2 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) );
  14. #define FUNC_APPEND_PARAMS_3 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 3 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) );
  15. #define FUNC_APPEND_PARAMS_4 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 4 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) );
  16. #define FUNC_APPEND_PARAMS_5 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 5 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) );
  17. #define FUNC_APPEND_PARAMS_6 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 6 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) );
  18. #define FUNC_APPEND_PARAMS_7 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 7 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) );
  19. #define FUNC_APPEND_PARAMS_8 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 8 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) );
  20. #define FUNC_APPEND_PARAMS_9 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 9 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) );
  21. #define FUNC_APPEND_PARAMS_10 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 10 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_10 *)(0) ) );
  22. #define FUNC_APPEND_PARAMS_11 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 11 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_10 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_11 *)(0) ) );
  23. #define FUNC_APPEND_PARAMS_12 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 12 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_10 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_11 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_12 *)(0) ) );
  24. #define FUNC_APPEND_PARAMS_13 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 13 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_10 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_11 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_12 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_13 *)(0) ) );
  25. #define FUNC_APPEND_PARAMS_14 pDesc->m_Parameters.SetGrowSize( 1 ); pDesc->m_Parameters.EnsureCapacity( 14 ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_1 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_2 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_3 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_4 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_5 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_6 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_7 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_8 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_9 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_10 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_11 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_12 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_13 *)(0) ) ); pDesc->m_Parameters.AddToTail( ScriptDeduceType( (FUNC_ARG_TYPE_14 *)(0) ) );
  26. #define DEFINE_NONMEMBER_FUNC_TYPE_DEDUCER(N) \
  27. template <typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  28. inline void ScriptDeduceFunctionSignature(ScriptFuncDescriptor_t *pDesc, FUNCTION_RETTYPE (*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) ) \
  29. { \
  30. pDesc->m_ReturnType = ScriptDeduceType((FUNCTION_RETTYPE *)(0)); \
  31. FUNC_APPEND_PARAMS_##N \
  32. }
  33. FUNC_GENERATE_ALL( DEFINE_NONMEMBER_FUNC_TYPE_DEDUCER );
  34. #define DEFINE_MEMBER_FUNC_TYPE_DEDUCER(N) \
  35. template <typename OBJECT_TYPE_PTR, typename FUNCTION_CLASS, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  36. inline void ScriptDeduceFunctionSignature(ScriptFuncDescriptor_t *pDesc, OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) ) \
  37. { \
  38. pDesc->m_ReturnType = ScriptDeduceType((FUNCTION_RETTYPE *)(0)); \
  39. FUNC_APPEND_PARAMS_##N \
  40. }
  41. FUNC_GENERATE_ALL( DEFINE_MEMBER_FUNC_TYPE_DEDUCER );
  42. //-------------------------------------
  43. #define DEFINE_CONST_MEMBER_FUNC_TYPE_DEDUCER(N) \
  44. template <typename OBJECT_TYPE_PTR, typename FUNCTION_CLASS, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  45. inline void ScriptDeduceFunctionSignature(ScriptFuncDescriptor_t *pDesc, OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const ) \
  46. { \
  47. pDesc->m_ReturnType = ScriptDeduceType((FUNCTION_RETTYPE *)(0)); \
  48. FUNC_APPEND_PARAMS_##N \
  49. }
  50. FUNC_GENERATE_ALL( DEFINE_CONST_MEMBER_FUNC_TYPE_DEDUCER );
  51. #define ScriptInitMemberFuncDescriptor_( pDesc, class, func, scriptName ) if ( 0 ) {} else { (pDesc)->m_pszScriptName = scriptName; (pDesc)->m_pszFunction = #func; ScriptDeduceFunctionSignature( pDesc, (class *)(0), &class::func ); }
  52. #define ScriptInitFuncDescriptorNamed( pDesc, func, scriptName ) if ( 0 ) {} else { (pDesc)->m_pszScriptName = scriptName; (pDesc)->m_pszFunction = #func; ScriptDeduceFunctionSignature( pDesc, &func ); }
  53. #define ScriptInitFuncDescriptor( pDesc, func ) ScriptInitFuncDescriptorNamed( pDesc, func, #func )
  54. #define ScriptInitMemberFuncDescriptorNamed( pDesc, class, func, scriptName ) ScriptInitMemberFuncDescriptor_( pDesc, class, func, scriptName )
  55. #define ScriptInitMemberFuncDescriptor( pDesc, class, func ) ScriptInitMemberFuncDescriptorNamed( pDesc, class, func, #func )
  56. //-----------------------------------------------------------------------------
  57. //
  58. //-----------------------------------------------------------------------------
  59. template <typename FUNCPTR_TYPE>
  60. inline void *ScriptConvertFuncPtrToVoid( FUNCPTR_TYPE pFunc )
  61. {
  62. union FuncPtrConvert
  63. {
  64. void *p;
  65. FUNCPTR_TYPE pFunc;
  66. };
  67. Assert( sizeof( pFunc ) == sizeof( void * ) );
  68. FuncPtrConvert convert;
  69. convert.pFunc = pFunc;
  70. return convert.p;
  71. }
  72. template <typename FUNCPTR_TYPE>
  73. inline FUNCPTR_TYPE ScriptConvertFuncPtrFromVoid( void *p )
  74. {
  75. union FuncPtrConvert
  76. {
  77. void *p;
  78. FUNCPTR_TYPE pFunc;
  79. };
  80. Assert( sizeof( FUNCPTR_TYPE ) == sizeof( void * ) );
  81. FuncPtrConvert convert;
  82. convert.p = p;
  83. return convert.pFunc;
  84. }
  85. //-----------------------------------------------------------------------------
  86. //
  87. //-----------------------------------------------------------------------------
  88. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_0
  89. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_1 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_1
  90. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_2 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_2
  91. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_3 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_3
  92. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_4 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_4
  93. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_5 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_5
  94. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_6 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_6
  95. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_7 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_7
  96. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_8 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_8
  97. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_9 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_9
  98. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_10 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_10
  99. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_11 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_11
  100. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_12 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_12
  101. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_13 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_13
  102. #define FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_14 , FUNC_BASE_TEMPLATE_FUNC_PARAMS_14
  103. #define SCRIPT_BINDING_ARGS_0
  104. #define SCRIPT_BINDING_ARGS_1 pArguments[0]
  105. #define SCRIPT_BINDING_ARGS_2 pArguments[0], pArguments[1]
  106. #define SCRIPT_BINDING_ARGS_3 pArguments[0], pArguments[1], pArguments[2]
  107. #define SCRIPT_BINDING_ARGS_4 pArguments[0], pArguments[1], pArguments[2], pArguments[3]
  108. #define SCRIPT_BINDING_ARGS_5 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4]
  109. #define SCRIPT_BINDING_ARGS_6 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5]
  110. #define SCRIPT_BINDING_ARGS_7 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6]
  111. #define SCRIPT_BINDING_ARGS_8 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7]
  112. #define SCRIPT_BINDING_ARGS_9 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8]
  113. #define SCRIPT_BINDING_ARGS_10 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8], pArguments[9]
  114. #define SCRIPT_BINDING_ARGS_11 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8], pArguments[9], pArguments[10]
  115. #define SCRIPT_BINDING_ARGS_12 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8], pArguments[9], pArguments[10], pArguments[11]
  116. #define SCRIPT_BINDING_ARGS_13 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8], pArguments[9], pArguments[10], pArguments[11], pArguments[12]
  117. #define SCRIPT_BINDING_ARGS_14 pArguments[0], pArguments[1], pArguments[2], pArguments[3], pArguments[4], pArguments[5], pArguments[6], pArguments[7], pArguments[8], pArguments[9], pArguments[10], pArguments[11], pArguments[12], pArguments[13]
  118. #define DEFINE_SCRIPT_BINDINGS(N) \
  119. template <typename FUNC_TYPE, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  120. class CNonMemberScriptBinding##N \
  121. { \
  122. public: \
  123. static bool Call( void *pFunction, void *pContext, ScriptVariant_t *pArguments, int nArguments, ScriptVariant_t *pReturn ) \
  124. { \
  125. Assert( nArguments == N ); \
  126. Assert( pReturn ); \
  127. Assert( !pContext ); \
  128. \
  129. if ( nArguments != N || !pReturn || pContext ) \
  130. { \
  131. return false; \
  132. } \
  133. *pReturn = ((FUNC_TYPE)pFunction)( SCRIPT_BINDING_ARGS_##N ); \
  134. return true; \
  135. } \
  136. }; \
  137. \
  138. template <typename FUNC_TYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  139. class CNonMemberScriptBinding##N<FUNC_TYPE, void FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_##N> \
  140. { \
  141. public: \
  142. static bool Call( void *pFunction, void *pContext, ScriptVariant_t *pArguments, int nArguments, ScriptVariant_t *pReturn ) \
  143. { \
  144. Assert( nArguments == N ); \
  145. Assert( !pReturn ); \
  146. Assert( !pContext ); \
  147. \
  148. if ( nArguments != N || pReturn || pContext ) \
  149. { \
  150. return false; \
  151. } \
  152. ((FUNC_TYPE)pFunction)( SCRIPT_BINDING_ARGS_##N ); \
  153. return true; \
  154. } \
  155. }; \
  156. \
  157. template <class OBJECT_TYPE_PTR, typename FUNC_TYPE, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  158. class CMemberScriptBinding##N \
  159. { \
  160. public: \
  161. static bool Call( void *pFunction, void *pContext, ScriptVariant_t *pArguments, int nArguments, ScriptVariant_t *pReturn ) \
  162. { \
  163. Assert( nArguments == N ); \
  164. Assert( pReturn ); \
  165. Assert( pContext ); \
  166. \
  167. if ( nArguments != N || !pReturn || !pContext ) \
  168. { \
  169. return false; \
  170. } \
  171. *pReturn = (((OBJECT_TYPE_PTR)(pContext))->*ScriptConvertFuncPtrFromVoid<FUNC_TYPE>(pFunction))( SCRIPT_BINDING_ARGS_##N ); \
  172. return true; \
  173. } \
  174. }; \
  175. \
  176. template <class OBJECT_TYPE_PTR, typename FUNC_TYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  177. class CMemberScriptBinding##N<OBJECT_TYPE_PTR, FUNC_TYPE, void FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_##N> \
  178. { \
  179. public: \
  180. static bool Call( void *pFunction, void *pContext, ScriptVariant_t *pArguments, int nArguments, ScriptVariant_t *pReturn ) \
  181. { \
  182. Assert( nArguments == N ); \
  183. Assert( !pReturn ); \
  184. Assert( pContext ); \
  185. \
  186. if ( nArguments != N || pReturn || !pContext ) \
  187. { \
  188. return false; \
  189. } \
  190. (((OBJECT_TYPE_PTR)(pContext))->*ScriptConvertFuncPtrFromVoid<FUNC_TYPE>(pFunction))( SCRIPT_BINDING_ARGS_##N ); \
  191. return true; \
  192. } \
  193. }; \
  194. \
  195. template <typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  196. inline ScriptBindingFunc_t ScriptCreateBinding(FUNCTION_RETTYPE (*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) ) \
  197. { \
  198. typedef FUNCTION_RETTYPE (*Func_t)(FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N); \
  199. return &CNonMemberScriptBinding##N<Func_t, FUNCTION_RETTYPE FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_##N>::Call; \
  200. } \
  201. \
  202. template <typename OBJECT_TYPE_PTR, typename FUNCTION_CLASS, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  203. inline ScriptBindingFunc_t ScriptCreateBinding(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE (FUNCTION_CLASS::*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) ) \
  204. { \
  205. typedef FUNCTION_RETTYPE (FUNCTION_CLASS::*Func_t)(FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N); \
  206. return &CMemberScriptBinding##N<OBJECT_TYPE_PTR, Func_t, FUNCTION_RETTYPE FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_##N>::Call; \
  207. } \
  208. \
  209. template <typename OBJECT_TYPE_PTR, typename FUNCTION_CLASS, typename FUNCTION_RETTYPE FUNC_TEMPLATE_FUNC_PARAMS_##N> \
  210. inline ScriptBindingFunc_t ScriptCreateBinding(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE (FUNCTION_CLASS::*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const ) \
  211. { \
  212. typedef FUNCTION_RETTYPE (FUNCTION_CLASS::*Func_t)(FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N); \
  213. return &CMemberScriptBinding##N<OBJECT_TYPE_PTR, Func_t, FUNCTION_RETTYPE FUNC_BASE_TEMPLATE_FUNC_PARAMS_PASSTHRU_##N>::Call; \
  214. }
  215. FUNC_GENERATE_ALL( DEFINE_SCRIPT_BINDINGS );
  216. //-----------------------------------------------------------------------------
  217. //
  218. //-----------------------------------------------------------------------------
  219. #endif // VSCRIPT_TEMPLATES_H