Created
February 5, 2016 11:55
-
-
Save xaxxon/262dd835aae697c7132d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i->wrap_class<Child>().add_constructor("Child", i->get_object_template()); | |
i->wrap_class<Parent>().add_constructor("Parent", i->get_object_template()).set_compatible_types<Child>(); | |
i->wrap_class<NotFamily>().add_constructor("NotFamily", i->get_object_template()); | |
i->add_function("parent", [](Parent * p) { | |
printf("In 'parent' function\n"); | |
}); | |
auto c = i->create_context(); | |
c->run("parent(new Parent())"); | |
c->run("parent(new Child())"); | |
try { | |
c->run("parent(new NotFamily())"); | |
printf("Didn't catch exception\n"); | |
} catch(...) { | |
printf("Caught exception\n"); | |
} | |
output: | |
In 'parent' function | |
In 'parent' function | |
Caught exception |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment