From a4df4e9147019337fda07982c510a85d6f4c4062 Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Sat, 25 Aug 2012 13:51:40 -0400 Subject: convert cli_ure/source/native to new syntax Change-Id: I7dbb065c8b1b2fef85e6e7f42ef80991102785e0 --- cli_ure/Library_cli_cppuhelper_native.mk | 2 +- cli_ure/source/native/assembly.cxx | 2 -- cli_ure/source/native/native_bootstrap.cxx | 42 +++++++++++++++--------------- cli_ure/source/native/native_share.h | 22 +++++++--------- 4 files changed, 32 insertions(+), 36 deletions(-) (limited to 'cli_ure') diff --git a/cli_ure/Library_cli_cppuhelper_native.mk b/cli_ure/Library_cli_cppuhelper_native.mk index 745c69c9480c..5582e770b91e 100644 --- a/cli_ure/Library_cli_cppuhelper_native.mk +++ b/cli_ure/Library_cli_cppuhelper_native.mk @@ -13,7 +13,7 @@ $(eval $(call gb_Library_Library,cli_cppuhelper_native)) # in CLR meta-data - use of this type may lead to a runtime exception": $(eval $(call gb_Library_add_cxxflags,cli_cppuhelper_native,\ -AI $(gb_Helper_OUTDIRLIBDIR) \ - -clr:oldSyntax \ + -clr \ -wd4339 \ )) diff --git a/cli_ure/source/native/assembly.cxx b/cli_ure/source/native/assembly.cxx index 5e808122aab1..73345b94b895 100644 --- a/cli_ure/source/native/assembly.cxx +++ b/cli_ure/source/native/assembly.cxx @@ -17,8 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#using - [assembly:System::Reflection::AssemblyProduct( "CLI-UNO Language Binding" )]; [assembly:System::Reflection::AssemblyDescription( "CLI-UNO Helper Library" )]; [assembly:System::Reflection::AssemblyDelaySign(true)]; diff --git a/cli_ure/source/native/native_bootstrap.cxx b/cli_ure/source/native/native_bootstrap.cxx index f760a1a191bc..0a22d7bb5e63 100644 --- a/cli_ure/source/native/native_bootstrap.cxx +++ b/cli_ure/source/native/native_bootstrap.cxx @@ -315,7 +315,7 @@ namespace util These contain a named value UREINSTALLLOCATION which holds a path to the URE installation folder. */ -public __sealed __gc class Bootstrap +public ref class Bootstrap sealed { inline Bootstrap() {} @@ -325,7 +325,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. @@ -338,37 +338,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 ); } @@ -376,31 +376,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 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/cli_ure/source/native/native_share.h b/cli_ure/source/native/native_share.h index 8b24e1f5bbf6..23977dfb0f00 100644 --- a/cli_ure/source/native/native_share.h +++ b/cli_ure/source/native/native_share.h @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#using #using "cli_ure.dll" #using "cli_uretypes.dll" @@ -35,20 +34,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 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( @@ -65,16 +64,15 @@ inline ::System::Object * to_cli( intptr_t intptr = 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(); - handle.Free(); + ::System::Runtime::InteropServices::GCHandle ^ handle = (::System::Runtime::InteropServices::GCHandle ^)(gcnew ::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) ); -- cgit