Init Embind-ings manually, once UNO is set up
Upcoming code that changes the Embind'ing of UNO sequences will require availability of the UNO type manager during that Embind init code, so only call that after UNO has been bootstrapped (rather than as part of the initialization of global static data, which is what EMSCRIPTEN_BINDINGS does). Change-Id: Iba19851ffb82c055dcab10a28a8c1fafa9d2a414 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164065 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
parent
4c20fb09d7
commit
c7664f12a9
4 changed files with 39 additions and 12 deletions
|
@ -37,6 +37,12 @@ $(eval $(call gb_Library_use_custom_headers,sofficeapp,\
|
|||
officecfg/registry \
|
||||
))
|
||||
|
||||
ifeq ($(OS),EMSCRIPTEN)
|
||||
$(eval $(call gb_Library_use_custom_headers,sofficeapp, \
|
||||
static/unoembind \
|
||||
))
|
||||
endif
|
||||
|
||||
$(eval $(call gb_Library_use_api,sofficeapp,\
|
||||
udkapi \
|
||||
offapi \
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#if defined EMSCRIPTEN
|
||||
#include <bindings_uno.hxx>
|
||||
#endif
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
using namespace ::com::sun::star::beans;
|
||||
|
@ -83,6 +87,9 @@ void Desktop::InitApplicationServiceManager()
|
|||
UNO_QUERY_THROW);
|
||||
#endif
|
||||
comphelper::setProcessServiceFactory(sm);
|
||||
#if defined EMSCRIPTEN
|
||||
init_unoembind_uno();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Desktop::RegisterServices()
|
||||
|
|
|
@ -15,14 +15,14 @@ $(eval $(call gb_CustomTarget_register_targets,static/unoembind, \
|
|||
))
|
||||
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.cxx \
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.hxx \
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.js: \
|
||||
$(call gb_Executable_get_target_for_build,embindmaker) $(call gb_UnoApi_get_target,udkapi) \
|
||||
$(call gb_UnoApi_get_target,offapi) \
|
||||
$(if $(ENABLE_DBGUTIL),$(call gb_UnoApiTarget_get_target,embindtest))
|
||||
$(call gb_UnoApi_get_target,offapi)
|
||||
$(call gb_Executable_get_command,embindmaker) uno \
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.cxx \
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.hxx \
|
||||
$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.js \
|
||||
+$(call gb_UnoApi_get_target,udkapi) +$(call gb_UnoApi_get_target,offapi) \
|
||||
+$(if $(ENABLE_DBGUTIL),$(call gb_UnoApiTarget_get_target,embindtest))
|
||||
+$(call gb_UnoApi_get_target,udkapi) +$(call gb_UnoApi_get_target,offapi)
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
|
@ -46,13 +46,13 @@ void badUsage()
|
|||
{
|
||||
std::cerr
|
||||
<< "Usage:\n\n"
|
||||
" embindmaker <name> <cpp-output> <js-output> <registries>\n\n"
|
||||
" embindmaker <name> <cpp-output> <hpp-output> <js-output> <registries>\n\n"
|
||||
"where each <registry> is '+' (primary) or ':' (secondary), followed by: either a\n"
|
||||
"new- or legacy-format .rdb file, a single .idl file, or a root directory of an\n"
|
||||
".idl file tree. For all primary registries, Embind code is written to\n"
|
||||
"<cpp-output> and corresponding JavaScript scaffolding code is written to\n"
|
||||
"<js-output>. The <name> is used as part of some of the identifiers in those\n"
|
||||
"generated files.\n";
|
||||
"<cpp-output>/<hpp-output> and corresponding JavaScript scaffolding code is\n"
|
||||
"written to <js-output>. The <name> is used as part of some of the identifiers\n"
|
||||
"in those generated files.\n";
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -708,16 +708,17 @@ SAL_IMPLEMENT_MAIN()
|
|||
try
|
||||
{
|
||||
auto const args = rtl_getAppCommandArgCount();
|
||||
if (args < 3)
|
||||
if (args < 4)
|
||||
{
|
||||
badUsage();
|
||||
}
|
||||
OUString name;
|
||||
rtl_getAppCommandArg(0, &name.pData);
|
||||
auto const cppPathname = getPathnameArgument(1);
|
||||
auto const jsPathname = getPathnameArgument(2);
|
||||
auto const hppPathname = getPathnameArgument(2);
|
||||
auto const jsPathname = getPathnameArgument(3);
|
||||
rtl::Reference<TypeManager> mgr(new TypeManager);
|
||||
for (sal_uInt32 i = 3; i != args; ++i)
|
||||
for (sal_uInt32 i = 4; i != args; ++i)
|
||||
{
|
||||
auto const & [ uri, primary ] = parseRegistryArgument(i);
|
||||
try
|
||||
|
@ -906,7 +907,7 @@ SAL_IMPLEMENT_MAIN()
|
|||
<< "::get);\n";
|
||||
dumpRegisterFunctionEpilog(cppOut, n);
|
||||
}
|
||||
cppOut << "EMSCRIPTEN_BINDINGS(unoembind_" << name << ") {\n";
|
||||
cppOut << "void init_unoembind_" << name << "() {\n";
|
||||
for (unsigned long long i = 0; i != n; ++i)
|
||||
{
|
||||
cppOut << " register" << i << "();\n";
|
||||
|
@ -933,6 +934,19 @@ SAL_IMPLEMENT_MAIN()
|
|||
std::cerr << "Failed to write \"" << cppPathname << "\"\n";
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
std::ofstream hppOut(hppPathname, std::ios_base::out | std::ios_base::trunc);
|
||||
if (!hppOut)
|
||||
{
|
||||
std::cerr << "Cannot open \"" << hppPathname << "\" for writing\n";
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
hppOut << "void init_unoembind_" << name << "();\n";
|
||||
hppOut.close();
|
||||
if (!hppOut)
|
||||
{
|
||||
std::cerr << "Failed to write \"" << hppPathname << "\"\n";
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
std::ofstream jsOut(jsPathname, std::ios_base::out | std::ios_base::trunc);
|
||||
if (!jsOut)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue