기능 포인터 인수를 변환 할 수 없습니다
-
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처럼 보이고 실제 함수 서명은 동일합니다.
편집 : 하나의 선언을 잊어 버렸습니다.
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