sourcehook/generate/sourcehook.hxx
changeset 412 43098e572d24
parent 387 093c72464b35
child 413 59bbed37595c
     1.1 --- a/sourcehook/generate/sourcehook.hxx	Wed Oct 10 21:48:44 2007 +0000
     1.2 +++ b/sourcehook/generate/sourcehook.hxx	Fri Oct 12 19:17:52 2007 +0000
     1.3 @@ -171,8 +171,9 @@
     1.4  			PassFlag_ByVal		= (1<<0),		/**< Passing by value */
     1.5  			PassFlag_ByRef		= (1<<1),		/**< Passing by reference */
     1.6  			PassFlag_ODtor		= (1<<2),		/**< Object has a destructor */
     1.7 -			PassFlag_OCtor		= (1<<3),		/**< Object has a constructor */
     1.8 -			PassFlag_AssignOp	= (1<<4)		/**< Object has an assignment operator */
     1.9 +			PassFlag_OCtor		= (1<<3),		/**< Object has a normal non-trivial constructor */
    1.10 +			PassFlag_AssignOp	= (1<<4),		/**< Object has a non-trivial assignment operator */
    1.11 +			PassFlag_CCtor		= (1<<5)		/**< Object has a copy constructor (which takes const Object& as only parameter) */
    1.12  		};
    1.13  
    1.14  		size_t size;			//!< Size of the data being passed
    1.15 @@ -181,6 +182,14 @@
    1.16  		//  (might be used in future versions for automatic hookfunc generation)
    1.17  		int type;				//!< PassType value
    1.18  		unsigned int flags;		//!< Pass/return flags
    1.19 +
    1.20 +		struct V2Info
    1.21 +		{
    1.22 +			void *pDefCtor;
    1.23 +			void *pCopyCtor;
    1.24 +			void *pNormalCtor;
    1.25 +			void *pAssignOperator;
    1.26 +		};
    1.27  	};
    1.28  
    1.29  	struct ProtoInfo
    1.30 @@ -196,8 +205,15 @@
    1.31  		PassInfo retPassInfo;		//!< PassInfo for the return value. size=0 -> no retval
    1.32  		const PassInfo *paramsPassInfo;	//!< PassInfos for the parameters
    1.33  
    1.34 +		// paramsPassInfo[0] is basically a dummy parameter.
    1.35 +		// However, paramsPassInfo[0].size stores the version of the ProtoInfo structure.
    1.36 +
    1.37  		// Extra info:
    1.38  		int convention;
    1.39 +
    1.40 +		// Version2:
    1.41 +		//  PassInfo::V2Info retPassInfo2;
    1.42 +		//  const PassInfo::V2Info *paramsPassInfo2;
    1.43  	};
    1.44  
    1.45  	struct IHookManagerInfo;
    1.46 @@ -488,6 +504,18 @@
    1.47  
    1.48  		return origentry ? origentry : *reinterpret_cast<void**>(vfnptr);
    1.49  	}
    1.50 +
    1.51 +	template <class T> struct GetPassInfo
    1.52 +	{
    1.53 +		static const int type = 0;
    1.54 +		static const unsigned int flags = PassInfo::PassFlag_ByVal;
    1.55 +	};
    1.56 +
    1.57 +	template <class T> struct GetPassInfo<T&>
    1.58 +	{
    1.59 +		static const int type = 0;
    1.60 +		static const unsigned int flags = PassInfo::PassFlag_ByRef;
    1.61 +	};
    1.62  }
    1.63  
    1.64  /************************************************************************/
    1.65 @@ -831,7 +859,7 @@
    1.66  	META_RES prev_res; \
    1.67  	META_RES cur_res; \
    1.68  	\
    1.69 -	typedef ReferenceCarrier<rettype>::type my_rettype; \
    1.70 +	typedef ReferenceCarrier< rettype >::type my_rettype; \
    1.71  	my_rettype orig_ret; \
    1.72  	my_rettype override_ret; \
    1.73  	my_rettype plugin_ret; \
    1.74 @@ -966,6 +994,8 @@
    1.75  //  -> one should probably flag references in __SourceHook_ParamSizes_* !
    1.76  //		or simply assume that their size is sizeof(void*)=SH_PTRSIZE... could be doable through a simple template
    1.77  
    1.78 +#define __SH_GPI(tt) { sizeof(tt), ::SourceHook::GetPassInfo< tt >::type, ::SourceHook::GetPassInfo< tt >::flags }
    1.79 +
    1.80  @[$1,0,$a:
    1.81  // ********* Support for $1 arguments *********
    1.82  #define SH_DECL_HOOK$1(ifacetype, ifacefunc, attr, overload, rettype@[$2,1,$1:, param$2@]) \
    1.83 @@ -978,8 +1008,8 @@
    1.84  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
    1.85  		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
    1.86  	\
    1.87 -	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
    1.88 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
    1.89 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, __SH_GPI(param$2)@] }; \
    1.90 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, __SH_GPI(rettype), \
    1.91  		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
    1.92  
    1.93  
    1.94 @@ -993,7 +1023,7 @@
    1.95  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
    1.96  		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
    1.97  	\
    1.98 -	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
    1.99 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:,__SH_GPI(param$2)@] }; \
   1.100  	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { 0, 0, 0 }, \
   1.101  		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
   1.102  
   1.103 @@ -1014,8 +1044,8 @@
   1.104  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
   1.105  		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
   1.106  	\
   1.107 -	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
   1.108 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
   1.109 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, __SH_GPI(param$2)@] }; \
   1.110 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, __SH_GPI(rettype), \
   1.111  		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
   1.112  
   1.113  #define SH_DECL_HOOK$1_void_vafmt(ifacetype, ifacefunc, attr, overload@[$2,1,$1:, param$2@]) \
   1.114 @@ -1035,7 +1065,7 @@
   1.115  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
   1.116  		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
   1.117  	\
   1.118 -	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
   1.119 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, __SH_GPI(param$2)@] }; \
   1.120  	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { 0, 0, 0 }, \
   1.121  		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
   1.122  
   1.123 @@ -1049,8 +1079,8 @@
   1.124  		typedef rettype RetType; \
   1.125  	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
   1.126  	\
   1.127 -	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
   1.128 -	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
   1.129 +	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, __SH_GPI(param$2)@] }; \
   1.130 +	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto = { $1, __SH_GPI(rettype), \
   1.131  		__SourceHook_ParamInfosM_##hookname, 0 };
   1.132  
   1.133  #define SH_DECL_MANUALHOOK$1_void(hookname, vtblidx, vtbloffs, thisptroffs@[$2,1,$1:, param$2@]) \
   1.134 @@ -1062,7 +1092,7 @@
   1.135  		typedef void(::SourceHook::EmptyClass::*ECMFP)(@[$2,1,$1|, :param$2@]); \
   1.136  	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
   1.137  	\
   1.138 -	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
   1.139 +	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, __SH_GPI(param$2)@] }; \
   1.140  	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto = { $1, { 0, 0, 0 }, \
   1.141  		__SourceHook_ParamInfosM_##hookname	, 0 };
   1.142