ส่งจากโทรศัพท์มือถือ Huawei ของฉัน
-------- ข้อความต้นฉบับ --------
เรื่อง: Re: "TypeError: Module.X is not a constructor" while creating C++ object in _javascript_ code after compilation with intermediate bitcode state
จาก: Pawel
ถึง: emscripten-discuss
สำเนา:
Hi Thomas,--I reproduce it using version 1.36.14.I cannot use newer versions (>=1.37.0) yet due to required dependencies I'm obligated not to use in my project.
W dniu środa, 4 września 2019 17:53:12 UTC+2 użytkownik Thomas Lively napisał:Hi Pawel,I notice that the emscripten version you’re using is quite old. Can you reproduce the issue with the latest version?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 bitcodeem++ class_a.cpp glue_wrapper.cpp --post-js class_a_glue.js -o class_a.bcand finally the _javascript_em++ class_a.bc -o class_a.jsUp 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 getclient.js:1 Uncaught TypeError: Module.ClassA is not a constructor at client.js:1The 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.bcem++ class_b.cpp b_glue_wrapper.cpp --post-js class_b_glue.js -o class_b.bcem++ 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.23clang 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 emscripten-discuss+[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
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/b3b0c1e1-74cd-401f-a7d2-093cff32ddea%40googlegroups.com.
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/ytodt5kij0a4-7chnz-41ge2lpi411psa4g4iq8f6e6cuz554uu2tf4-9jjxhqwdxp1r-7y5iaz-7nfne1-7ouo36mlidhj-wjn2wl-ukow62mcj1ir-qph2j6-wx2omi9yc443-er8syn-f6k87m-lhncvy.1567687168972%40email.android.com.
