Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "js_host.h"
- #include "js_class.h"
- ///////////////////////////////////////// test class for binding
- struct A
- {
- A(xstr s)
- : tag(s)
- {std::cout << "A::A(" << tag << ")" << std::endl;}
- virtual ~A()
- {
- std::cout << "A::~A [" << tag << "]" << std::endl;
- }
- void f1(int i) {std::cout << "A::f1(" << i << ")" << " -> "<< tag <<std::endl;}
- void f2(int i) {std::cout << "A::f2(" << i << ")" << " -> "<< tag <<std::endl;}
- void f3(int i) {std::cout << "A::f3(" << i << ")" << " -> "<< tag <<std::endl;}
- int m1;
- int m2;
- int m3;
- static void s1(int i) {std::cout << "A::s1(" << i << ")"<< std::endl;}
- static void s2(int i) {std::cout << "A::s2(" << i << ")"<< std::endl;}
- private:
- std::string tag;
- };
- int main(int argc, char **argv)
- {
- JSHost host ("oop");
- JSClass<A> cls("A");
- cls
- .ctor<xstr> ()
- .meth<int> ("f1", &A::f1)
- .meth<int> ("f2", &A::f2)
- .meth<int> ("s1", &A::s1)
- .meth<int> ("s2", &A::s2)
- .meth<int> ("xxx", [&](int i) {std::cout << "statix xxx(" << i <<")\n";});
- cls.bind(host);
- host.ExecuteFile("js_tests/test.js");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement