Created
February 16, 2016 08:16
-
-
Save xaxxon/49234d3921bacb6f4a72 to your computer and use it in GitHub Desktop.
This file contains 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
class Animal { | |
public: | |
virtual ~Animal()=default; | |
string get_type() {return "Cow";} | |
virtual string get_name() {return "This is the c++ get_name";}; | |
virtual string echo(string s){return s;} | |
virtual int add(int i, int j){return i + j;} | |
}; | |
... | |
auto i = PlatformHelper::create_isolate(); | |
(*i)([&]{ | |
i->add_print(); | |
auto & animal = i->wrap_class<Animal>(); // THESE 3 LINES ARE MY LIBRARY STUFF, BUT YOU CAN ENVISION WHAT THEY DO | |
animal.add_method(&Animal::get_type, "get_type").add_method(&Animal::get_name, "get_name"); | |
animal.add_constructor("Animal", *i); | |
auto c = i->create_context(); | |
c->run("a=new Animal();a.get_name();"); <=== This line works | |
c->run("b=Object.create(new Animal()); b.get_name();"); <== this line returns an internal field of nullptr in my callback for get_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment