GithubHelp home page GithubHelp logo

tsa / vu8 Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 12.0 256 KB

vu8 is a system for wrapping C++ classes and functions within javascript modules and classes.

License: MIT License

JavaScript 2.79% C++ 97.21%

vu8's People

Contributors

insidewhy avatar tsa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vu8's Issues

Reference to python2

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

Keeping up with changes in the V8 API

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.

Can the factory use primitive types?

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.

More visual studio compiler errors

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

Compiler errors Visual Studio.

#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'

undefined behaviour in plugin handling

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):

http://blog.s11n.net/?p=82

and one for C++:

http://wanderinghorse.net/computing/papers/#classloading_cpp

(disclosure: i wrote both of those pages)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.