diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-07-16 10:27:10 +0200 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-07-16 12:48:49 +0200 |
commit | f10d51709d08bdafdbd5c92f73ddb62cb217b6dd (patch) | |
tree | 979359e5fe78c4cc0d5a8420f58150974f9bc70c /static | |
parent | e8e6a5f7951da0cf94171fd4b9457864e9528a08 (diff) |
Embind: Implement UNO interface attributes as JS accessor properties
Change-Id: I39b1f5676b2e5ba6071b39bf031c10d9c85f1ad1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170566
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'static')
-rw-r--r-- | static/source/embindmaker/embindmaker.cxx | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/static/source/embindmaker/embindmaker.cxx b/static/source/embindmaker/embindmaker.cxx index 78bc94b9087d..9953512a8bf0 100644 --- a/static/source/embindmaker/embindmaker.cxx +++ b/static/source/embindmaker/embindmaker.cxx @@ -481,57 +481,44 @@ void dumpAttributes(std::ostream& out, rtl::Reference<TypeManager> const& manage { for (auto const& attr : entity->getDirectAttributes()) { - out << " .function(\"get" << attr.name << "\", "; - if (baseTrail.empty()) + out << " .property<"; + dumpType(out, manager, attr.type); + out << ">(\"" << attr.name << "\", +[](" << cppName(name) << " const & the_self) { return "; + for (auto const& base : baseTrail) { - out << "&" << cppName(name) << "::get" << attr.name; + out << "static_cast<" << cppName(base) << " &>("; } - else + out << "const_cast<" << cppName(name) << " &>(the_self)"; + for (std::size_t i = 0; i != baseTrail.size(); ++i) { - out << "+[](::com::sun::star::uno::Reference<" << cppName(name) - << "> const & the_self) { return "; - for (auto const& base : baseTrail) - { - out << "static_cast<" << cppName(base) << " *>("; - } - out << "the_self.get()"; - for (std::size_t i = 0; i != baseTrail.size(); ++i) - { - out << ")"; - } - out << "->get" << attr.name << "(); }"; + out << ")"; } - out << ", ::emscripten::pure_virtual())\n"; + out << ".get" << attr.name << "(); }"; if (!attr.readOnly) { - out << " .function(\"set" << attr.name << "\", "; - if (baseTrail.empty()) + out << ", +[](" << cppName(name) << " & the_self, "; + dumpType(out, manager, attr.type); + if (passByReference(manager, attr.type)) { - out << "&" << cppName(name) << "::set" << attr.name; + out << " const &"; } - else + out << " the_value) { "; + for (auto const& base : baseTrail) { - out << "+[](::com::sun::star::uno::Reference<" << cppName(name) - << "> const & the_self, "; - dumpType(out, manager, attr.type); - if (passByReference(manager, attr.type)) - { - out << " const &"; - } - out << " the_value) { "; - for (auto const& base : baseTrail) - { - out << "static_cast<" << cppName(base) << " *>("; - } - out << "the_self.get()"; - for (std::size_t i = 0; i != baseTrail.size(); ++i) - { - out << ")"; - } - out << "->set" << attr.name << "(the_value); }"; + out << "static_cast<" << cppName(base) << " &>("; + } + out << "the_self"; + for (std::size_t i = 0; i != baseTrail.size(); ++i) + { + out << ")"; } - out << ", ::emscripten::pure_virtual())\n"; + out << ".set" << attr.name << "(the_value); }"; } + out << "/*only supported since " + "<https://github.com/emscripten-core/emscripten/commit/" + "09b765f76e052e6bfcf741ed6d2bae1788200734> \"[embind] Return value policy support " + "for properties. (#21935)\" towards emsdk 3.1.62: , " + "::emscripten::pure_virtual()*/)\n"; } } |