1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| class MyClass
{
public:
int func(QString s, int i) { return i*2; }
QString prop;
};
CAMP_TYPE(MyClass)
int main()
{
camp::Class::declare<MyClass>("MyClass")
.function("func", &MyClass::func)
.property("prop", &MyClass::prop)
;
MyClass o;
o.prop = "coucou";
std::cout << "prop: " << o.prop.toLatin1().constData() << std::endl;
camp::UserObject object = o;
object.set("prop", "hello");
std::string s = object.get("prop");
std::cout << "prop (camp): " << o.prop.toLatin1().constData() << std::endl;
int i = object.call("func", camp::Args("hello", 20));
std::cout << "func (camp): " << i << std::endl;
return 0;
} |