tsa / vu8 Goto Github PK
View Code? Open in Web Editor NEWvu8 is a system for wrapping C++ classes and functions within javascript modules and classes.
License: MIT License
vu8 is a system for wrapping C++ classes and functions within javascript modules and classes.
License: MIT License
How do you install vu8?
There's a reference to python2. I was able to create a sym-link and avoid the error. I'm running python2.6 and it seems to work fine. It could be an issue specific to my machine, but just wanted to bring it to your attention. Thanks for the awesome project.
ln -s /usr/bin/python /usr/bin/python2
The V8 API seems to change quite often. Node.js has the resources to track it, and NAN abstracts the different versions behind a single API.
I wrote nbind on top of Node.js and NAN, with similar objectives as vu8, but also targeting Asm.js and later mobile platforms with various engines, so it's already independent of any specific JavaScript engine. It has survived one v8 API change so far. Bindings are automatically generated using templates and the C++ code only needs to deal with normal C++ types.
If you still have a need for this kind of binding library, it would be good to collaborate. There are many similar projects, although I'm not aware of any other than mine that wouldn't be dead at the moment.
The class binding example in the readme uses a module. Is it possible to bind a class directly to global without using a module?
Cheers.
Steve.
I've got a singleton class called Settings with lots of public instance members (mostly ints & floats). Is it possible to bind public instance members from c++ to javascript using vu8? How do I go about it?
Cheers.
Steve.
I'm new to c++ templates and I'm struggling to understand the code.
Is it possible to create a factory such as Factory? This gives the following error:
error: no matching function for call to 'FromV8(v8::Localv8::Value)'
What is the correct syntax?
Cheers.
Steve.
The following code compiles fine on linux (gcc), but gives an error on windows (visual studio)
class Test
{
public:
Test()
{
std::cout << "Test()" << std::endl;
}
void open(const std::string &filename)
{
std::cout << "Opening: " << filename << std::endl;
}
void close()
{
std::cout << "Closing" << std::endl;
}
};
...
vu8::Class<Test> renderer_class;
renderer_class
.Set<void (), &Test::close>("close")
.Set<void (const std::string&), &Test::open>("open");
The error is:
error C2440: 'specialization' : cannot convert from 'void (__thiscall Test::* )(void)' to 'void (__thiscall Test::* const )(const v8::Arguments &)(void)'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2973: 'vu8::Class<T>::Set' : invalid template argument 'void (__thiscall Test::* )(void)'
with
[
T=Test
]
vu8/Class.hpp(168) : see declaration of 'vu8::Class<T>::Set'
with
[
T=Test
]
error C2440: 'specialization' : cannot convert from 'void (__thiscall Test::* )(void)' to 'void (__thiscall Test::* const )(void) const'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
#include <vu8/Module.hpp>
void test() {}
void register()
{
vu8::Module module;
module("print", &print)
.Set<void(), &test>("test");
}
gives the following errors with Visual Studio 2010 x64:
1> error C2975: 'Ptr' : invalid template argument for 'vu8::Module::Set', expected compile-time constant expression
1> vu8\src\vu8/Module.hpp(74) : see declaration of 'Ptr'
1> error C2977: 'vu8::Module::Set' : too many template arguments
1> vu8\src\vu8/Module.hpp(69) : see declaration of 'vu8::Module::Set'
1> error C2780: 'vu8::Module &vu8::Module::Set(const char *,vu8::Class<T,F> &)' : expects 2 arguments - 1 provided
1> vu8\src\vu8/Module.hpp(64) : see declaration of 'vu8::Module::Set'
Hiya!
From Context.cpp:
void *sym = dlsym(dl, "vu8_module_init");
if (! sym) {
return scope.Close(
Throw("loadmodule: initialisation function not found"));
}
// g++ 3 is broken and can only handle a C-style cast for this
#if 0
v8::Handle<v8::Value> value =
(*reinterpret_cast<Context::ModuleLoadCallback>(sym))();
#else
v8::Handle<v8::Value> value = ((Context::ModuleLoadCallback) sym)();
#endif
Casting to a function pointer that way relies on undefined behaviour. It is 99% likely to work on all modern platforms but is technically undefined. There are two portable workarounds that i know of, one for C (which will also work for the above case):
and one for C++:
http://wanderinghorse.net/computing/papers/#classloading_cpp
(disclosure: i wrote both of those pages)
Hi, it would be helpful to know if I can return objects from c++ to javascript with this plugin too. And in general how vu8 is different/better than http://code.google.com/p/v8-juice
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.