I am currently in the midst of building a simple game engine/basic library. Right now, i'm working on scripting support. Since i've always liked JavaScript more than, say, Lua or Python, i thought about using that as my principle scripting language. Google V8 struck me first, with its good performance and relatively simple means of exposing a class - by the heavy usage of templates. However, i can't seem to be able to compile V8 using MinGW on windows - it just doesn't want to. Then i looked at ChaiScript, which is also very interesting - especially because it takes embedding one step forward even compared to V8. It is, however, not my first choice.
Now, my question is as follows. How can i achieve exposing a complex C++ class to duktape? I know about this question, but it only uses a very simple foobar-like class. Say i have this class:
class Entity
{
public:
Entity(std::string name_item)
~Entity();
size_t getID();
bool hasComponent(size_t componentid_item);
EntityComponent* getComponent(size_t componentid_item);
void addComponent(EntityComponent* component_item);
EntityComponent* removeComponent(size_t componentid_item);
void deleteComponent(size_t componentid_item);
private:
unsigned long long m_ID;
std::unordered_map<size_t, EntityComponent*> m_Components;
};
How would i go about exposing it, so it can be used by duktape? Also, can i somehow automate (or make it easier) this process by using templates, like ChaiScript (especially) and Google V8 so heavily do?