codemaker/source/cppumaker/cpputype.cxx |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 2bc1c113a4b37e97d9faf9c88aec01d5a0af7dae
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Thu Jan 18 21:10:35 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Fri Jan 19 08:12:18 2024 +0100

    Clean up generated embind code a bit
    
    For one, no need to wrap in #ifdef EMSCRIPTEN code that is only ever fed 
into
    emcc anyway.  For another, better use fully qualified names throughout 
generated
    code, to avoid unexpected collisions.
    
    Change-Id: I939728c7e0601e5fb3f3634bbd62f35042d91105
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162266
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/codemaker/source/cppumaker/cpputype.cxx 
b/codemaker/source/cppumaker/cpputype.cxx
index f600cff8ad8c..cfb1fd750a5f 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -610,12 +610,9 @@ void CppuType::dumpHFileContent(
 
 void CppuType::dumpEmbindCppFile(FileStream &out)
 {
-    out << "#ifdef EMSCRIPTEN
";
     out << "#include <emscripten/bind.h>
"
            "#include <" << name_.replace('.', '/') << ".hpp>
";
-    out << "using namespace emscripten;

";
     dumpEmbindDeclaration(out);
-    out << "#endif
";
 }
 
 void CppuType::dumpGetCppuType(FileStream & out)
@@ -1232,7 +1229,7 @@ void InterfaceType::dumpEmbindDeclaration(FileStream & 
out)
     codemaker::cppumaker::dumpTypeIdentifier(out, name_);
     out << ") {
";
 
-    out << "
class_<" << codemaker::cpp::scopedCppName(u2b(name_)) << ">(\"";
+    out << "
::emscripten::class_<" << codemaker::cpp::scopedCppName(u2b(name_)) << ">(\"";
     codemaker::cppumaker::dumpTypeFullWithDecorator(out, name_, u"$");
     codemaker::cppumaker::dumpTypeIdentifier(out, name_);
     out << "\")
";
@@ -1245,7 +1242,7 @@ void InterfaceType::dumpEmbindDeclaration(FileStream & 
out)
     dec();
 
     // dump reference bindings.
-    out << "
class_<::css::uno::Reference<" << codemaker::cpp::scopedCppName(u2b(name_)) << 
">, base<::css::uno::BaseReference>>(\"";
+    out << "
::emscripten::class_<::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">, 
::emscripten::base<::css::uno::BaseReference>>(\"";
     codemaker::cppumaker::dumpTypeFullWithDecorator(out, name_, u"$");
     codemaker::cppumaker::dumpTypeIdentifier(out, name_);
     out << "Ref\")
";
@@ -1253,8 +1250,8 @@ void InterfaceType::dumpEmbindDeclaration(FileStream & 
out)
     out << indent() << ".constructor<>()
"
         << indent() << ".constructor<::css::uno::BaseReference, 
::css::uno::UnoReference_Query>()
"
         << indent() << ".function(\"is\", &::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">::is)
"
-        << indent() << ".function(\"get\", &::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">::get, allow_raw_pointers())
"
-        << indent() << ".function(\"set\", 
emscripten::select_overload<bool(const ::css::uno::Any&, 
com::sun::star::uno::UnoReference_Query)>(&::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">::set))
";
+        << indent() << ".function(\"get\", &::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">::get, 
::emscripten::allow_raw_pointers())
"
+        << indent() << ".function(\"set\", 
::emscripten::select_overload<bool(const ::css::uno::Any&, 
com::sun::star::uno::UnoReference_Query)>(&::css::uno::Reference<" << 
codemaker::cpp::scopedCppName(u2b(name_)) << ">::set))
";
     dumpEmbindAttributeBindings(out);
     dumpEmbindMethodBindings(out, true);
     out << indent() << ";
";
@@ -1447,7 +1444,7 @@ void InterfaceType::dumpEmbindWrapperFunc(FileStream& out,
     }
 
     dumpParameters(/*bDumpType=*/false);
-    out << "); }, allow_raw_pointers() )
";
+    out << "); }, ::emscripten::allow_raw_pointers() )
";
 }
 
 void InterfaceType::dumpEmbindMethodBindings(FileStream & out, bool 
bDumpForReference) const

Reply via email to