Coder Social home page Coder Social logo

Comments (5)

brendandahl avatar brendandahl commented on May 31, 2024

Are you trying to avoid just calling register_vector for each bound type or avoid register_vector and a class_ binding for each type?

If you're fine with still doing the class bindings, you can create a template wrapper around class_ or a macro that registers the class and vector at the same time.

from emscripten.

fraguada avatar fraguada commented on May 31, 2024

I already have all of the class bindings. How would I

create a template wrapper around class_ or a macro that registers the class and vector at the same time.

?

from emscripten.

brendandahl avatar brendandahl commented on May 31, 2024

Something like:

using namespace emscripten;

struct Foo {};

template<typename T>
class_<T> class_and_vector(const char* name) {
  std::string vectorName(name);
  vectorName.append("Vector");
  register_vector<T>(vectorName.c_str());
  return class_<T>(name);
}

EMSCRIPTEN_BINDINGS(xxx) {
  class_and_vector<Foo>("Foo")
    .constructor<>();
}

from emscripten.

fraguada avatar fraguada commented on May 31, 2024

So on the js side, I'd have Module.Foo and Module.FooVector?

from emscripten.

fraguada avatar fraguada commented on May 31, 2024

I believe I didn't have a great understanding of emscripten::val and am fine with having function args in cpp that I then interrogate for myArray["length"] and access like myArray[i].as<MyBoundClass>();

I appreciate your help in any case!

from emscripten.

Related Issues (20)

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.