This is an automated email from the ASF dual-hosted git repository. leginee pushed a commit to branch win10-msvc-trunk in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 682bfa99fac8b89e285ee0131110d50cba451804 Author: Peter Kovacs <[email protected]> AuthorDate: Fri Aug 21 20:33:31 2026 +0200 cli_ure: port native/, and let the .dxp wildcard filter match nothing The third and last piece. The whole CLI binding now builds: climaker.exe plus cli_basetypes, cli_cppuhelper, cli_uno, cli_ure, cli_uretypes and a policy assembly for each. native/ was small -- 723 lines, eleven MC++ constructs -- and needed three things a table does not cover: * __sealed is a PREFIX in MC++ and a suffix in C++/CLI: "public __sealed ref class X" becomes "public ref class X sealed". * GCHandle::op_Explicit -> GCHandle::FromIntPtr, and get_Target -> Target, same as in uno_bridge. * __pfnDliFailureHook2. A modern delayimp.h declares the delay-load failure hook const unless DELAYIMP_INSECURE_WRITABLE_HOOKS is defined, and a definition has to agree with its declaration. Guarded on _MSC_VER, since VC9's header still has it writable. AND A BUG OF MY OWN, in cc9450c3d9. The filter that keeps _ZTI* wildcards out of the MSVC export list is a grep -v, and grep -v EXITS 1 WHEN IT MATCHES NOTHING. cli_ure/source/native uses msvc.map, whose global: section is empty, so the filter had nothing to remove and failed the recipe: dmake: Error code 1, while making '.../msvc_cli_cppuhelper.dxp' The GCC branch of the same rule already guards against this with a leading "-", which tells dmake to ignore the exit code. Mine now does too. Eleven sites, the same eleven as before. Worth noting the shape: an empty result is not an error, but grep says it is. That is the second time today a grep exit code has broken something that looked right. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W7pjcp2sXU1HaUwXT7kc29 --- main/cli_ure/source/native/makefile.mk | 9 +++-- main/cli_ure/source/native/native_bootstrap.cxx | 48 ++++++++++++++----------- main/cli_ure/source/native/native_share.h | 19 +++++----- main/solenv/inc/_tg_def.mk | 20 +++++------ main/solenv/inc/tg_def.mk | 2 +- 5 files changed, 55 insertions(+), 43 deletions(-) diff --git a/main/cli_ure/source/native/makefile.mk b/main/cli_ure/source/native/makefile.mk index d89da683e6..8c921c57cf 100644 --- a/main/cli_ure/source/native/makefile.mk +++ b/main/cli_ure/source/native/makefile.mk @@ -76,7 +76,10 @@ UNOTYPES = \ #loader lock was solved as of VS 2005 (CCNUMVER = 0014..) # When compiling for CLR, disable "warning C4339: use of undefined type detected # in CLR meta-data - use of this type may lead to a runtime exception": -.IF "$(CCNUMVER)" >= "001399999999" +.IF "$(COMEX)"=="14" +# /clr:oldSyntax went away after VS2015; these sources are C++/CLI now. +CFLAGSCXX += -clr -AI $(BIN) -wd4339 +.ELIF "$(CCNUMVER)" >= "001399999999" CFLAGSCXX += -clr:oldSyntax -AI $(BIN) -wd4339 .ELSE CFLAGSCXX += -clr -AI $(BIN) -wd4339 @@ -125,7 +128,9 @@ ALLTAR: \ -.IF "$(CCNUMVER)" >= "001399999999" +.IF "$(COMEX)"=="14" +CFLAGSCXX += -clr +.ELIF "$(CCNUMVER)" >= "001399999999" CFLAGSCXX += -clr:oldSyntax .ENDIF diff --git a/main/cli_ure/source/native/native_bootstrap.cxx b/main/cli_ure/source/native/native_bootstrap.cxx index 75f6eff049..243549b31e 100644 --- a/main/cli_ure/source/native/native_bootstrap.cxx +++ b/main/cli_ure/source/native/native_bootstrap.cxx @@ -251,6 +251,12 @@ extern "C" FARPROC WINAPI delayLoadHook( } ExternC +#if defined(_MSC_VER) && _MSC_VER >= 1900 +// A modern delayimp.h declares this hook const unless +// DELAYIMP_INSECURE_WRITABLE_HOOKS is defined, and the definition has to +// agree with the declaration. VC9's is writable, so it keeps the old form. +const +#endif PfnDliHook __pfnDliFailureHook2 = delayLoadHook; namespace uno @@ -267,7 +273,7 @@ namespace util The default value contain the path to the office program dir. No separate URE anymore. */ -public __sealed __gc class Bootstrap +public ref class Bootstrap sealed { inline Bootstrap() {} @@ -277,7 +283,7 @@ public: @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext() */ - static ::unoidl::com::sun::star::uno::XComponentContext * + static ::unoidl::com::sun::star::uno::XComponentContext ^ defaultBootstrap_InitialComponentContext(); /** Bootstraps the initial component context from a native UNO installation. @@ -290,37 +296,37 @@ public: @see cppuhelper/bootstrap.hxx:defaultBootstrap_InitialComponentContext() */ - static ::unoidl::com::sun::star::uno::XComponentContext * + static ::unoidl::com::sun::star::uno::XComponentContext ^ defaultBootstrap_InitialComponentContext( - ::System::String * ini_file, - ::System::Collections::IDictionaryEnumerator * + ::System::String ^ ini_file, + ::System::Collections::IDictionaryEnumerator ^ bootstrap_parameters ); /** Bootstraps the initial component context from a native UNO installation. @see cppuhelper/bootstrap.hxx:bootstrap() */ - static ::unoidl::com::sun::star::uno::XComponentContext * + static ::unoidl::com::sun::star::uno::XComponentContext ^ bootstrap(); }; //______________________________________________________________________________ -::unoidl::com::sun::star::uno::XComponentContext * +::unoidl::com::sun::star::uno::XComponentContext ^ Bootstrap::defaultBootstrap_InitialComponentContext( - ::System::String * ini_file, - ::System::Collections::IDictionaryEnumerator * bootstrap_parameters ) + ::System::String ^ ini_file, + ::System::Collections::IDictionaryEnumerator ^ bootstrap_parameters ) { - if (0 != bootstrap_parameters) + if (nullptr != bootstrap_parameters) { bootstrap_parameters->Reset(); while (bootstrap_parameters->MoveNext()) { OUString key( - String_to_ustring( __try_cast< ::System::String * >( - bootstrap_parameters->get_Key() ) ) ); + String_to_ustring( safe_cast< ::System::String ^ >( + bootstrap_parameters->Key ) ) ); OUString value( - String_to_ustring( __try_cast< ::System::String * >( - bootstrap_parameters->get_Value() ) ) ); + String_to_ustring( safe_cast< ::System::String ^ >( + bootstrap_parameters->Value ) ) ); ::rtl::Bootstrap::set( key, value ); } @@ -328,31 +334,31 @@ Bootstrap::defaultBootstrap_InitialComponentContext( // bootstrap native UNO Reference< XComponentContext > xContext; - if (0 == ini_file) + if (nullptr == ini_file) { xContext = ::cppu::defaultBootstrap_InitialComponentContext(); } else { xContext = ::cppu::defaultBootstrap_InitialComponentContext( - String_to_ustring( __try_cast< ::System::String * >( ini_file ) ) ); + String_to_ustring( safe_cast< ::System::String ^ >( ini_file ) ) ); } - return __try_cast< ::unoidl::com::sun::star::uno::XComponentContext * >( + return safe_cast< ::unoidl::com::sun::star::uno::XComponentContext ^ >( to_cli( xContext ) ); } //______________________________________________________________________________ -::unoidl::com::sun::star::uno::XComponentContext * +::unoidl::com::sun::star::uno::XComponentContext ^ Bootstrap::defaultBootstrap_InitialComponentContext() { - return defaultBootstrap_InitialComponentContext( 0, 0 ); + return defaultBootstrap_InitialComponentContext( nullptr, nullptr ); } -::unoidl::com::sun::star::uno::XComponentContext * Bootstrap::bootstrap() +::unoidl::com::sun::star::uno::XComponentContext ^ Bootstrap::bootstrap() { Reference<XComponentContext> xContext = ::cppu::bootstrap(); - return __try_cast< ::unoidl::com::sun::star::uno::XComponentContext * >( + return safe_cast< ::unoidl::com::sun::star::uno::XComponentContext ^ >( to_cli( xContext ) ); } diff --git a/main/cli_ure/source/native/native_share.h b/main/cli_ure/source/native/native_share.h index afafcfc151..efe4d5d4e2 100644 --- a/main/cli_ure/source/native/native_share.h +++ b/main/cli_ure/source/native/native_share.h @@ -39,20 +39,20 @@ namespace util { //------------------------------------------------------------------------------ -inline ::System::String * ustring_to_String( ::rtl::OUString const & ustr ) +inline ::System::String ^ ustring_to_String( ::rtl::OUString const & ustr ) { - return new ::System::String( ustr.getStr(), 0, ustr.getLength() ); + return gcnew ::System::String( ustr.getStr(), 0, ustr.getLength() ); } //------------------------------------------------------------------------------ -inline ::rtl::OUString String_to_ustring( ::System::String * str ) +inline ::rtl::OUString String_to_ustring( ::System::String ^ str ) { OSL_ASSERT( sizeof (wchar_t) == sizeof (sal_Unicode) ); - wchar_t const __pin * chars = PtrToStringChars( str ); - return ::rtl::OUString( chars, str->get_Length() ); + pin_ptr< wchar_t const > chars = PtrToStringChars( str ); + return ::rtl::OUString( chars, str->Length ); } template< typename T > -inline ::System::Object * to_cli( +inline ::System::Object ^ to_cli( ::com::sun::star::uno::Reference< T > const & x ) { ::com::sun::star::uno::Mapping mapping( @@ -70,15 +70,16 @@ inline ::System::Object * to_cli( reinterpret_cast< intptr_t >( mapping.mapInterface( x.get(), ::getCppuType( &x ) ) ); ::System::Runtime::InteropServices::GCHandle handle( - ::System::Runtime::InteropServices::GCHandle::op_Explicit( intptr ) ); - ::System::Object * ret = handle.get_Target(); + ::System::Runtime::InteropServices::GCHandle::FromIntPtr( + ::System::IntPtr( intptr ) ) ); + ::System::Object ^ ret = handle.Target; handle.Free(); return ret; } template< typename T > inline void to_uno( - ::com::sun::star::uno::Reference< T > * pRet, ::System::Object * x ) + ::com::sun::star::uno::Reference< T > * pRet, ::System::Object ^ x ) { ::com::sun::star::uno::Mapping mapping( OUSTR(UNO_LB_CLI), OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ); diff --git a/main/solenv/inc/_tg_def.mk b/main/solenv/inc/_tg_def.mk index 8cb4459626..cdad8c8716 100644 --- a/main/solenv/inc/_tg_def.mk +++ b/main/solenv/inc/_tg_def.mk @@ -46,7 +46,7 @@ $(DEF1EXPORTFILE) : $(SHL1VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -338,7 +338,7 @@ $(DEF2EXPORTFILE) : $(SHL2VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -630,7 +630,7 @@ $(DEF3EXPORTFILE) : $(SHL3VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -922,7 +922,7 @@ $(DEF4EXPORTFILE) : $(SHL4VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -1214,7 +1214,7 @@ $(DEF5EXPORTFILE) : $(SHL5VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -1506,7 +1506,7 @@ $(DEF6EXPORTFILE) : $(SHL6VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -1798,7 +1798,7 @@ $(DEF7EXPORTFILE) : $(SHL7VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -2090,7 +2090,7 @@ $(DEF8EXPORTFILE) : $(SHL8VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -2382,7 +2382,7 @@ $(DEF9EXPORTFILE) : $(SHL9VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" @@ -2674,7 +2674,7 @@ $(DEF10EXPORTFILE) : $(SHL10VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC" diff --git a/main/solenv/inc/tg_def.mk b/main/solenv/inc/tg_def.mk index 7c6439557f..d63937a3d9 100644 --- a/main/solenv/inc/tg_def.mk +++ b/main/solenv/inc/tg_def.mk @@ -51,7 +51,7 @@ $(DEF$(TNR)EXPORTFILE) : $(SHL$(TNR)VERSIONMAP) # pulls them out into a .symbols-regexp and matches them against the real # objects. MSVC has no equivalent, and asking link.exe to export a literal # "_ZTI*" fails with LNK2001, so drop those lines here. - $(COMMAND_ECHO)$(GREP) -v "[*?]" $@ > [email protected] + $(COMMAND_ECHO)-$(GREP) -v "[*?]" $@ > [email protected] $(COMMAND_ECHO)$(RENAME) [email protected] $@ .ENDIF .IF "$(COM)"=="GCC"
