ChaiScript troubles

I'm using script language ChaiScript with c++ and Qt. I've defined such function:

void ChaiPainter::drawRectangle(QPainter *painter, int x, int y, int height, int width)
    painter.drawRect(x, y, width, height);

And in application paint-event:

void MainWindow::paintEvent(QPaintEvent *event)
    QPainter painter(this);

    chaiPainter->mChai.add(chaiscript::var(&painter), "painter");
    chaiPainter->mChai.add(chaiscript::fun(&ChaiPainter::drawRectangle), "drawRect");

    chaiPainter->mChai("drawRect(painter, 5, 5, 100, 100)");

The error is:

'chaiscript::Eval_Error' what(): Error: "No matching function to dispatch to with function 'drawRect'" during evaluation at (1, 1)

What I do wrong?


From the documentation it looks like you need to use the fun(mem_fn, instance) form to get pre-bound functions:

    chaiscript::fun(&ChaiPainter::drawRectangle, chaiPainter), "drawRect");

Need Your Help

Bookmarklets in Chrome's Bookmark Bar

javascript google-chrome bookmarklet

A bookmarklet I've developed and use in other browsers does not work in Chrome. More specifically, I've added it to the Chrome Bookmarks Bar, and it will not fire on Chrome's default home screen,

Why is epoll_ctl saying I have a bad fd?

c linux http sockets epoll

To learn more about the epoll notification facility in linux, I've been working on an http server. The structure of the server is to basically have an array of event structs which represent reques...