vscode,绑定代码如下
class_<CTZPoint>("CTZPoint")
.constructor<>()
.constructor<double, double, unsigned char, unsigned char>()
.property("x", &CTZPoint::x)
.property("y", &CTZPoint::y)
.property("State", &CTZPoint::State)
.property("Attr", &CTZPoint::Attr);
value_object<COLORREF>("COLORREF")
.field("red", &COLORREF::red)
.field("blue", &COLORREF::blue)
.field("green", &COLORREF::green);
class_<CDrawStkFont>("CDrawStkFont")
.constructor<COLORREF, wstring, wstring, CTZPoint, double>()
.property("font_info", &CDrawStkFont::font_info, allow_raw_pointer<FONT_CHAR_DATA *>())
.property("sti_info", &CDrawStkFont::sti_info, allow_raw_pointer<DST_DSB_UTTERLY *>());
类代码如下
class CTZPoint
{
public:
double x;
double y;
BYTE State;
BYTE Attr;
CTZPoint()
{
x = 0;
y = 0;
State = 0;
Attr = 0;
};、
CTZPoint(CTZPoint &a)
{
x = a.x;
y = a.y;
State = a.State;
Attr = a.Attr;
};
CTZPoint(double dx, double dy, BYTE bState, BYTE bAttr)
{
x = dx;
y = dy;
State = bState;
Attr = bAttr;
};
~CTZPoint(){};
void operator=(const CTZPoint &a)
{
x = a.x;
y = a.y;
State = a.State;
Attr = a.Attr;
};
bool operator==(const CTZPoint &a) { return ((x == a.x) && (y == a.y) && (State == a.State) && (Attr == a.Attr)); };
};
报错
error: no matching constructor for initialization of 'CTZPoint'
'emscripten::class_<CDrawStkFont>::constructor<COLORREF, std::wstring, std::wstring,
CTZPoint, double>' requested here
.constructor<COLORREF, wstring, wstring, CTZPoint, double>()
note: candidate constructor not viable: expects an lvalue for 1st argument
CTZPoint(CTZPoint &a)
note: candidate constructor not viable: requires 0 arguments, but 1 was provided
CTZPoint()
note: candidate constructor not viable: requires 4 arguments, but 1 was provided
CTZPoint(double dx, double dy, BYTE bState, BYTE bAttr)
将拷贝构造函数删除后解决此错误,搞不懂。
有可能是不支持地址传输的原因。。。。。。不懂