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 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 "; + out << ")"; + } + out << ".get" << attr.name << "(); }"; + if (!attr.readOnly) + { + out << ", +[](" << cppName(name) << " & 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 << "static_cast<" << cppName(base) << " &>("; } - out << "the_self.get()"; + out << "the_self"; for (std::size_t i = 0; i != baseTrail.size(); ++i) { out << ")"; } - out << "->get" << attr.name << "(); }"; - } - out << ", ::emscripten::pure_virtual())\n"; - if (!attr.readOnly) - { - out << " .function(\"set" << attr.name << "\", "; - if (baseTrail.empty()) - { - out << "&" << cppName(name) << "::set" << attr.name; - } - else - { - 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 << ", ::emscripten::pure_virtual())\n"; + out << ".set" << attr.name << "(the_value); }"; } + out << "/*only supported since " + " \"[embind] Return value policy support " + "for properties. (#21935)\" towards emsdk 3.1.62: , " + "::emscripten::pure_virtual()*/)\n"; } } diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js index e923a4f85d0a..bb4d2716ee5d 100644 --- a/unotest/source/embindtest/embindtest.js +++ b/unotest/source/embindtest/embindtest.js @@ -688,22 +688,22 @@ Module.addOnPostRun(function() { css.task.XJobExecutor.query(obj).trigger('from JS'); { const attrs = Module.uno.org.libreoffice.embindtest.XAttributes.query(obj); - console.assert(attrs.getLongAttribute() === -123456); - attrs.setLongAttribute(789); - console.assert(attrs.getLongAttribute() === 789); - console.assert(attrs.getStringAttribute() === 'hä'); - attrs.setStringAttribute('foo'); - console.assert(attrs.getStringAttribute() === 'foo'); - console.assert(attrs.getReadOnlyAttribute() === 1); //TODO: true + console.assert(attrs.LongAttribute === -123456); + attrs.LongAttribute = 789; + console.assert(attrs.LongAttribute === 789); + console.assert(attrs.StringAttribute === 'hä'); + attrs.StringAttribute = 'foo'; + console.assert(attrs.StringAttribute === 'foo'); + console.assert(attrs.ReadOnlyAttribute === 1); //TODO: true try { - attrs.setReadOnlyAttribute(false); + attrs.ReadOnlyAttribute = false; console.assert(false); } catch (e) {} console.assert(test.checkAttributes(attrs)); } - console.assert(test.getStringAttribute() === 'hä'); - test.setStringAttribute('foo'); - console.assert(test.getStringAttribute() === 'foo'); + console.assert(test.StringAttribute === 'hä'); + test.StringAttribute = 'foo'; + console.assert(test.StringAttribute === 'foo'); const args = new Module.uno_Sequence_any( [new Module.uno_Any(Module.uno_Type.Interface('com.sun.star.uno.XInterface'), test)]);