関数ポインタ引数を変換できません。
-
22-08-2019 - |
質問
私は取得していますエラーます:
error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T> (__cdecl *)(const v8::Arguments &)' to 'v8::InvocationCallback'
関連定義:
typedef Handle<Value> (*InvocationCallback)(const Arguments& args);
template<class C> class V8ScriptClass
{
public:
template<class C, typename Rtype, typename Ptype1, Rtype (C::*FuncPtr)(Ptype1)>
void RegisterFunc(const char* const scriptname)
{
objtemplate->Set(
v8::String::New(scriptname),
v8::FunctionTemplate::New(
V8ScriptClass<C>::RelayCallback<C, Rtype, Ptype1, FuncPtr>
));
};
template<typename Rtype, typename Ptype1, Rtype (*FuncPtr)(Ptype1 param1)>
static v8::Handle<v8::Value> RelayCallback(const v8::Arguments& args)
{
std::cerr<<__FUNCTION__<<std::endl;
v8::HandleScope handle_scope;
return handle_scope.Close(toJSType( ((FuncPtr)(toCType(args[0]))) ));
};
typedefと実際の関数のシグネチャが同じであるように、私には見えます。
編集:1つの宣言を忘れてます:
class EXPORT FunctionTemplate : public Template {
public:
/** Creates a function template.*/
static Local<FunctionTemplate> New(
InvocationCallback callback = 0,
Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>());
解決
私は、エラーを検出しました。 RelayCallbackテンプレートは、引数として、静的な関数ポインタを取り、私はメンバ関数ポインタでそれをインスタンス化しようとしました。私はちょうどメンバ関数ポインタのテンプレート引数にそれを変更しなければならなかった。
所属していません StackOverflow