Skip to content

namespaces in js / nested objects in output #5874

@sijakret

Description

@sijakret

I am crosscompiling an existing c++ library to wasm and i would like to transfer also the organization of namespaces from c++ to js as transparently as possible.

I have been looking all over but couldn't find anything on this topic.
Ill i could find is this old post: https://www.mail-archive.com/search?l=emscripten-discuss@googlegroups.com&q=subject:%22Using+embind+on+an+API+using+namespaces%22&o=newest&f=1

So, for instance i would like the constructor a::b::c::MyClass to be exposed as MyModule.a.b.c.MyClass in js.

I tried this

EMSCRIPTEN_BINDINGS(MyClass) {
  class_< a::b::c::MyClass >("a.b.c.MyClass")
 //...
}

But it gives me some sort of mangeled output where the export goes to a$b$c$.

Is there an off-the-shelve way of accomplishing what i am looking for or do i need do generate some sort js glue code to do this?

Seems like a relevant feature for exposing apis of larger libraries..

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions