Hi Guillaume, register_vector is indeed the way to go when using vectors. What does the vector become in js ? An array ?
I don't think binding std::pair is automatic, you should use value_array or value_object (see Embind doc). Le jeudi 14 mai 2015 09:14:35 UTC+2, guillaume godin a écrit : > > Ok i used the register_vector option. > > But how to convert the object back in javascript. > > best regards. > > Le mercredi 13 mai 2015 14:35:12 UTC+2, guillaume godin a écrit : >> >> Dear all, >> >> I try to expose a function that return std::pair<int,double> using em++ >> --bind >> >> https://github.com/thegodone/RDKitjs >> >> there is no issue during compilation, but when I called js script in >> chrome I have this error message any idea how to solved that. >> >> mol.MMFFoptimizeMolecule() >> rdmol.js:1 Uncaught ReferenceError: getTypeName is not definedmessage: >> "getTypeName is not defined"stack: (...)get stack: function () { [native >> code] }set stack: function () { [native code] }__proto__: >> ErrorthrowUnboundTypeError @ rdmol.js:1unboundTypesHandler @ >> rdmol.js:1(anonymous function) @ VM2312:2InjectedScript._evaluateOn @ >> VM2308:883InjectedScript._evaluateAndWrap @ >> VM2308:816InjectedScript.evaluate @ VM2308:682 >> >> >> --------------- >> >> class Molecule { >> >> public: >> >> Molecule(RWMol* mol): rdmol(mol) {}; >> >> std::pair<int, double> MMFFoptimizeMolecule() >> >> { >> >> return RDKit::MMFF::MMFFOptimizeMolecule(*rdmol); >> >> } >> >> >> static Molecule *fromSmiles(std::string smiles) { >> >> rdErrorLog->df_enabled = false; >> >> return new Molecule(RDKit::SmilesToMol(smiles)); >> >> }; >> >> private: >> >> RWMol* rdmol; >> >> >> >> }; >> >> // Binding code >> >> EMSCRIPTEN_BINDINGS(rdmol) { >> >> class_<Molecule>("Molecule") >> >> .function("MMFFoptimizeMolecule", &Molecule::MMFFoptimizeMolecule, >> allow_raw_pointers()) >> >> .class_function("fromSmiles", &Molecule::fromSmiles, >> allow_raw_pointers()); >> >> } >> > -- 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]. For more options, visit https://groups.google.com/d/optout.
