Hello All,

I get a TypeError: Module.ClassA is not a constructor error while creating 
object.
I'm having a simple header class defined in header class_a.h:

namespace MyNamespace

{

  class ClassA

  {

  public:

    ClassA();

    void PrintName();

  };

}


and its implemetation in class_a.cpp

#include <iostream>

#include "class_a.h"

namespace MyNamespace

{

  ClassA::ClassA()

  {

    std::cout << "MyNamespace::ClassA constructor" << std::endl;

  }

  void ClassA::PrintName()

  {

    std::cout << "MyNamespace::ClassA::PrintName method" << std::endl;

  }

}


I described in interface in class_a.idl:

[Prefix="MyNamespace::"]

interface ClassA

{

  void ClassA();

  void PrintName();

};


Next I create glue files with:

python ${EMSCRIPTEN_ROOT}/tools/webidl_binder.py class_a.idl class_a_glue


And glue_wrapper.cpp containing

#include "class_a.h"

#include "class_a_glue.cpp"


Now I'd like to create bitcode

em++ class_a.cpp glue_wrapper.cpp --post-js class_a_glue.js -o class_a.bc

and finally the javascript

em++ class_a.bc -o class_a.js


Up to now everything works fine, neither error nor warning reported.

I define simle client.js script creating object and calling method:

var obj = new Module.ClassA();

obj.PrintName();


When I load both class_a.jd and client.js scripts in html I get

client.js:1 Uncaught TypeError: Module.ClassA is not a constructor at 
client.js:1



The interesting is that, if I create javascript in one step (without 
intermediate .bc) then it works fine - I see proper printouts in browser 
console.
I'm however not likely going this way because I've got a bunch of classes 
I'd like to put into one javascript, e.g.

em++ class_a.cpp glue_wrapper.cpp --post-js class_a_glue.js -o class_a.bc
em++ class_b.cpp b_glue_wrapper.cpp --post-js class_b_glue.js -o class_b.bc
em++ class_c.cpp c_glue_wrapper.cpp --post-js class_c_glue.js -o class_c.bc
...
em++ class_a.bc class_b.bc class_c.bc ... -o class_a.js.

I'm using:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 
1.35.23
clang version 3.9.0  (emscripten 1.35.23 : 1.35.23)

Why it does not work with intermediate bitcode step? Or maybe my approach 
is incorrect?

Best regards, Paweł

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/fba850f3-944d-4626-a28b-bf1d376b76aa%40googlegroups.com.

Reply via email to