我决定利用。 不幸的是,我不熟悉C++,因此,Im与继承建筑商打交道。
v8capi.h
typedef struct V8Context V8Context;
#ifdef __cplusplus
extern "C" {
#endif
V8Context *V8_NewContext();
#ifdef __cplusplus
}
#endif
v8capi.cpp
#include <v8.h>
struct V8Context : public v8::Handle<v8::Context> { };
V8Context *V8_NewContext() {
v8::HandleScope hscope;
return new V8Context(v8::Context::New());
}
From what I understand, new V8Context(...)
should call v8::Handle<T>
s constructor which takes a Handle<T>
. v8::Context::New()
returns a v8::Persistent<T>
, which inherits v8::Handle<T>
, so that should work. But in reality, it s trying to call a constructor that takes a const V8Context &
:
error C2664: V8Context::V8Context : cannot convert parameter 1 from
v8::Persistent<T> to const V8Context &
with
[
T=v8::Context
]
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
我做了什么错误?