AngelScriptの周りに薄いラッパーを書き込もうとしています。特定の構造体をラップする方法がわかりません。
ラップしたい構造体の構造体定義は次のasSMethodPtr
とおりです。
template <int N>
struct asSMethodPtr
{
template<class M>
static asSFuncPtr Convert(M Mthd)
{
// This version of the function should never be executed, nor compiled,
// as it would mean that the size of the method pointer cannot be determined.
int ERROR_UnsupportedMethodPtr[N-100];
asSFuncPtr p;
return p;
}
};
の定義は次のasSFuncPtr
とおりです。
struct asSFuncPtr
{
union
{
char dummy[25]; // largest known class method pointer
struct {asFUNCTION_t func; char dummy[25-sizeof(asFUNCTION_t)];} f;
} ptr;
asBYTE flag; // 1 = generic, 2 = global func
};
これが私が見つけた(AngelBinderライブラリから取得した)コードで、それを「ラップ」することができます:
template<typename R> ClassExporter& method(std::string name, R (T::*func)())
{
MethodClass mthd(name, Type<R>::toString(), asSMethodPtr< sizeof( void (T::*)() ) >::Convert( AS_METHOD_AMBIGUITY_CAST( R (T::*)()) (func) ));
this->_methods.push(mthd);
return *this;
}
残念ながら、このコードが何をしているのかわかりません...
何T::*
をすべきですか?クラス型へのポインタ?
とはR (T::*func)()
?
助けていただければ幸いです...