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 71c0e052110e0265d54bd96a0feabdf1d108404b Author: Peter Kovacs <[email protected]> AuthorDate: Fri Aug 21 21:11:46 2026 +0200 Turn the CLI binding back on, and build its half of bridgetest DISABLE_CLI existed because /clr:oldSyntax was gone and cli_ure could not be built at all. It is C++/CLI now, so the automatic disable is wrong. The switch stays, as --disable-cli, because the binding still wants a .NET SDK -- csc.exe and mscoree.lib -- which a Windows machine need not have; the two hard errors for those now fire only when the binding is actually wanted. testtools/source/bridgetest/cli is the last MC++ in the tree: 978 lines, and the same table as cli_ure plus three things it does not cover. * Array declarations. "Byte ar[] = gcnew Byte[3]" is MC++; C++/CLI spells it "cli::array<Byte>^ ar = gcnew cli::array<Byte>(3)". 46 of them, in two shapes -- with a "new" initialiser and with a call. * Out parameters. UNO out parameters are tracking references (T%) in C++/CLI, so the argument is the field, not its address; "&aRet->Bool" yields an interior_ptr and does not convert. 51 sites. * Everything climaker generates is a managed class, so a pointer to one is a handle and "new" is "gcnew" -- including the exceptions. Interface methods need an explicit virtual, which MC++ inferred from the base list. Four things had to be true before it would run, none of which the build would have told us: * msvcmrt.lib. I had claimed a UCRT compiler has no mixed-mode runtime library and dropped it. It has one, in the same place, and without it the link fails on an unresolved .cctor. Which SYNTAX and which RUNTIME are separate questions and the makefile now treats them that way. * The CLR the C# half targets. oowintool hunts for the v2 csc on purpose, which was right when /clr also emitted CLR 2 assemblies. VS2019's has not since VS2010, and the mixture does not fail at build time -- it fails when the process loads them, as a BadImageFormatException saying an assembly "was created by a runtime that is newer than the currently loaded runtime". configure now picks the csc that matches the C++ compiler, overriding --with-csc-path when it has to, with a warning. * The architecture. csc defaults to anycpu, so on 64-bit Windows the test exe starts as a 64-bit process and cannot load the x86 mixed-mode assemblies. The error names cli_cppuhelper and does not mention bitness. -platform now follows the C++ build. * copyassemblies.done had no prerequisites, so a rebuilt cli_uretypes.dll never reached $(BIN) and the test kept running against the stale copy. The stamp now names what it copies. Where it stands: the binding builds -- climaker.exe, cli_basetypes, cli_cppuhelper, cli_uno, cli_ure, cli_uretypes, cli_oootypes and a policy assembly for each -- and all four bridgetest variants build, C++, C# and VB. The test bootstraps, maps the component context and reaches the tests. It then fails in testConstructorsService on a sequence of a polymorphic struct, which the native bridgetest passes, so it is CLI-specific and still open. One more thing that is not ours: cli_bridgetest_inprocess.cs passes the ini as a bare relative name, and defaultBootstrap_InitialComponentContext wants a file URL. Give it one on the command line and it bootstraps. Left alone here -- it is a separate fix and wants its own commit. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W7pjcp2sXU1HaUwXT7kc29 --- main/cli_ure/util/makefile.pmk | 10 +- main/configure.ac | 83 +++- main/odk/pack/copying/makefile.mk | 4 +- main/odk/util/check.pl | 4 +- .../source/bridgetest/cli/cli_cpp_bridgetest.cxx | 435 +++++++++++---------- main/testtools/source/bridgetest/cli/makefile.mk | 46 ++- main/testtools/util/makefile.pmk | 10 +- main/unoil/util/makefile.pmk | 10 +- 8 files changed, 344 insertions(+), 258 deletions(-) diff --git a/main/cli_ure/util/makefile.pmk b/main/cli_ure/util/makefile.pmk index 109fc92545..5a97a70f14 100644 --- a/main/cli_ure/util/makefile.pmk +++ b/main/cli_ure/util/makefile.pmk @@ -24,11 +24,11 @@ # no translation here anyway .IF "$(L10N_framework)"=="" .IF "$(COM)" == "MSC" -# ...but not when configure has ruled the binding out. It is written in Managed -# Extensions for C++ -- __gc, S"...", __pin -- which needs /clr:oldSyntax, and -# that switch was removed after VS2015; porting it to C++/CLI is its own piece -# of work. Every consumer already handles BUILD_FOR_CLI being empty, because -# that is how the non-MSC platforms build. VC9 is unaffected. +# ...but not when configure was told --disable-cli. The binding is C++/CLI now +# and builds with either compiler generation, but it still wants a .NET SDK -- +# csc.exe and mscoree.lib -- which a Windows machine need not have. Every +# consumer already handles BUILD_FOR_CLI being empty, because that is how the +# non-MSC platforms build. .IF "$(DISABLE_CLI)"=="" BUILD_FOR_CLI = "true" .ENDIF diff --git a/main/configure.ac b/main/configure.ac index a2e437beac..9168cbce59 100644 --- a/main/configure.ac +++ b/main/configure.ac @@ -2417,19 +2417,34 @@ AC_SUBST(USE_MINGW) dnl =================================================================== dnl The CLI/.NET language binding, and whether it can be built at all dnl =================================================================== -dnl cli_ure is written in Managed Extensions for C++ -- __gc, S"...", -dnl __pin -- which needs /clr:oldSyntax. That switch was removed after -dnl VS2015, so a UCRT-generation compiler cannot build the binding at -dnl all; porting it to C++/CLI is a separate piece of work. +dnl cli_ure, the .NET language binding. It was written in Managed +dnl Extensions for C++ -- __gc, S"...", __pin -- which needs /clr:oldSyntax, +dnl and that switch was removed after VS2015; it is now C++/CLI and builds +dnl with either compiler generation. dnl -dnl One variable rather than a COMEX test in each consumer: the module -dnl makefiles, the SDK's file lists and its checker all need the same -dnl answer, and they should not each rediscover it. +dnl It is still optional, because it wants a .NET SDK: csc.exe to compile the +dnl C# half and mscoree.lib to link the C++ half. --disable-cli is for a +dnl Windows box that has a compiler but no SDK. +dnl +dnl One variable rather than a test in each consumer: the module makefiles, +dnl the SDK's file lists and its checker all need the same answer, and they +dnl should not each rediscover it. +AC_ARG_ENABLE(cli, +[ --disable-cli Do not build the CLI (.NET) language binding. It + needs a .NET SDK -- csc.exe and mscoree.lib -- which + a Windows machine need not have. +],,) DISABLE_CLI= -if test \( "$_os" = "WINNT" \) -a \( -n "$MSVC_MODERN" \) ; then - AC_MSG_CHECKING([whether the CLI language binding can be built]) +if test "$_os" != "WINNT" -o "$enable_cli" = "no" ; then DISABLE_CLI="TRUE" - AC_MSG_RESULT([no, /clr:oldSyntax is gone from this compiler]) +fi +if test "$_os" = "WINNT" ; then + AC_MSG_CHECKING([whether to build the CLI language binding]) + if test -z "$DISABLE_CLI" ; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no, --disable-cli]) + fi fi AC_SUBST(DISABLE_CLI) @@ -2860,8 +2875,48 @@ if test "$WITH_MINGWIN" = "yes" || test "$COMEX" -ge "10"; then CSC_PATH="$csctest" fi fi - if test ! -x "$CSC_PATH/csc.exe"; then - AC_MSG_ERROR([csc.exe not found. Make sure it's in the path or use --with-csc-path]) + dnl Which CLR the C# half must target is decided by the C++ half, and a + dnl UCRT-generation compiler settles it: /clr has not emitted CLR 2 + dnl assemblies since VS2010. Mixing the two does not fail at build time, + dnl it fails when the process loads them -- + dnl + dnl System.BadImageFormatException: ... The assembly was created by a + dnl runtime that is newer than the currently loaded runtime + dnl + dnl oowintool goes looking for the v2 csc on purpose, which is right for + dnl VC9 and wrong here, so take the newest compiler beside it instead. + dnl This overrides an explicit --with-csc-path, because the constraint is + dnl the compiler's and not a preference; hence the warning. + if test -n "$MSVC_MODERN" -a -z "$DISABLE_CLI"; then + AC_MSG_CHECKING([for a csc.exe matching the C++ compiler's CLR]) + case "$CSC_PATH" in + *[[Vv]]1.*|*[[Vv]]2.*|*[[Vv]]3.*) + _csc_root=`dirname "$CSC_PATH"` + _csc_new= + for _c in `ls -d "$_csc_root"/[[Vv]]4* 2>/dev/null | sort -r`; do + if test -x "$_c/csc.exe"; then + _csc_new="$_c" + break + fi + done + if test -n "$_csc_new"; then + if test -n "$with_csc_path"; then + AC_MSG_WARN([--with-csc-path points at a CLR 2 compiler; using $_csc_new instead, because this C++ compiler emits CLR 4 assemblies]) + fi + CSC_PATH="$_csc_new" + AC_MSG_RESULT([$CSC_PATH]) + else + AC_MSG_RESULT([none found]) + AC_MSG_ERROR([This C++ compiler emits CLR 4 assemblies, but only a CLR 2 csc.exe was found. Point --with-csc-path at a v4 .NET Framework directory, or configure --disable-cli.]) + fi + ;; + *) + AC_MSG_RESULT([$CSC_PATH]) + ;; + esac + fi + if test ! -x "$CSC_PATH/csc.exe" -a -z "$DISABLE_CLI"; then + AC_MSG_ERROR([csc.exe not found. Make sure it's in the path or use --with-csc-path, or configure --disable-cli]) fi # Convert to posix path with 8.3 filename restrictions ( No spaces ) CSC_PATH=`cygpath -d "$CSC_PATH"` @@ -2890,8 +2945,8 @@ if test "$WITH_MINGWIN" = "yes" || test "$COMEX" -ge "10"; then fi fi fi - if test ! -f "$FRAME_HOME/lib/mscoree.lib"; then - AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-frame-home]) + if test ! -f "$FRAME_HOME/lib/mscoree.lib" -a -z "$DISABLE_CLI"; then + AC_MSG_ERROR([mscoree.lib (.NET Framework) not found. Make sure you use --with-frame-home, or configure --disable-cli]) fi AC_MSG_RESULT(found) # Convert to posix path with 8.3 filename restrictions ( No spaces ) diff --git a/main/odk/pack/copying/makefile.mk b/main/odk/pack/copying/makefile.mk index af2da232cf..54cd41a317 100644 --- a/main/odk/pack/copying/makefile.mk +++ b/main/odk/pack/copying/makefile.mk @@ -57,8 +57,8 @@ EXELIST = \ $(DESTDIRBIN)/uno-skeletonmaker$(EXEPOSTFIX) # Both of these are products of the CLI binding, so they exist only when it -# was built. DISABLE_CLI is what configure sets when the compiler cannot -# build it -- see cli_ure/util/makefile.pmk. +# was built. DISABLE_CLI is what configure sets for --disable-cli -- see +# cli_ure/util/makefile.pmk. .IF "$(GUI)"=="WNT" && "$(DISABLE_CLI)"=="" EXELIST += \ $(DESTDIRBIN)/climaker$(EXEPOSTFIX) diff --git a/main/odk/util/check.pl b/main/odk/util/check.pl index 11e3872720..03c25cf5f8 100644 --- a/main/odk/util/check.pl +++ b/main/odk/util/check.pl @@ -54,8 +54,8 @@ if (-d "$StartDir") { } # climaker is a product of the CLI binding, so it is only there when the - # binding was built. DISABLE_CLI is what configure sets when the compiler - # cannot build it -- see cli_ure/util/makefile.pmk. + # binding was built. DISABLE_CLI is what configure sets for --disable-cli + # -- see cli_ure/util/makefile.pmk. if (($OperatingSystem eq "windows" || $OperatingSystem eq "mingw") && ! $ENV{'DISABLE_CLI'}) { if ($OperatingSystem eq "windows" && ! -e "$StartDir/bin/climaker.exe") { diff --git a/main/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx b/main/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx index 560fb21f9a..cbc656e527 100644 --- a/main/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx +++ b/main/testtools/source/bridgetest/cli/cli_cpp_bridgetest.cxx @@ -43,17 +43,19 @@ using namespace unoidl::com::sun::star::lang; using namespace unoidl::test::testtools::bridgetest; namespace foo { - public __gc __interface MyInterface + public interface class MyInterface { }; } namespace cpp_bridgetest { - __gc class ORecursiveCall: public WeakBase, public XRecursiveCall + ref class ORecursiveCall: public WeakBase, public XRecursiveCall { public: - void callRecursivly(XRecursiveCall * xCall, int nToCall) + // Implementing an interface method needs an explicit virtual in + // C++/CLI; MC++ inferred it from the base list. + virtual void callRecursivly(XRecursiveCall ^ xCall, int nToCall) { Monitor::Enter(this); try @@ -74,32 +76,32 @@ namespace cpp_bridgetest } }; -public __gc class Constants +public ref class Constants { public: - static String* STRING_TEST_CONSTANT = new String(S"\" paco\' chorizo\\\' \"\'"); + static String ^ STRING_TEST_CONSTANT = gcnew String("\" paco\' chorizo\\\' \"\'"); }; -public __gc class BridgeTest : public WeakBase, public XMain +public ref class BridgeTest : public WeakBase, public XMain { - static bool compareData(Object* val1, Object* val2) + static bool compareData(Object ^ val1, Object ^ val2) { - if (val1 == 0 && val2 == 0 || val1 == val2) + if (val1 == nullptr && val2 == nullptr || val1 == val2) return true; - if ((val1 == 0 && val2 != 0) || - (val1 != 0 && val2 == 0) || val1->GetType() != val2->GetType()) + if ((val1 == nullptr && val2 != nullptr) || + (val1 != nullptr && val2 == nullptr) || val1->GetType() != val2->GetType()) return false; bool ret = false; - Type* t1 = val1->GetType(); + Type ^ t1 = val1->GetType(); //Sequence if (t1->IsArray) { - ret = compareSequence(static_cast<Array*>(val1), - static_cast<Array*>(val2)); + ret = compareSequence(static_cast<Array ^>(val1), + static_cast<Array ^>(val2)); } //String - else if (t1 == __typeof(String)) + else if (t1 == String::typeid) { ret = val1->Equals(val2); } @@ -113,7 +115,7 @@ public __gc class BridgeTest : public WeakBase, public XMain { ret = compareStruct(val1, val2); } - else if (t1 == __typeof(Any)) + else if (t1 == Any::typeid) { Any a1 = (Any) val1; Any a2 = (Any) val2; @@ -132,11 +134,11 @@ public __gc class BridgeTest : public WeakBase, public XMain } // Arrays have only one dimension - static bool compareSequence(Array* ar1, Array* ar2) + static bool compareSequence(Array ^ ar1, Array ^ ar2) { - Debug::Assert(ar1 != 0 && ar2 != 0); - Type* t1 = ar1->GetType(); - Type* t2 = ar2->GetType(); + Debug::Assert(ar1 != nullptr && ar2 != nullptr); + Type ^ t1 = ar1->GetType(); + Type ^ t2 = ar2->GetType(); if (!(ar1->Rank == 1 && ar2->Rank == 1 && ar1->Length == ar2->Length && t1->GetElementType() == t2->GetElementType())) @@ -156,20 +158,20 @@ public __gc class BridgeTest : public WeakBase, public XMain return ret; } - static bool compareStruct(Object* val1, Object* val2) + static bool compareStruct(Object ^ val1, Object ^ val2) { - Debug::Assert(val1 != 0 && val2 != 0); - Type* t1 = val1->GetType(); - Type* t2 = val2->GetType(); + Debug::Assert(val1 != nullptr && val2 != nullptr); + Type ^ t1 = val1->GetType(); + Type ^ t2 = val2->GetType(); if (t1 != t2) return false; - FieldInfo* fields[] = t1->GetFields(); + cli::array< FieldInfo ^ > ^ fields = t1->GetFields(); int cFields = fields->Length; bool ret = true; for (int i = 0; i < cFields; i++) { - Object* fieldVal1 = fields[i]->GetValue(val1); - Object* fieldVal2 = fields[i]->GetValue(val2); + Object ^ fieldVal1 = fields[i]->GetValue(val1); + Object ^ fieldVal2 = fields[i]->GetValue(val2); if ( ! compareData(fieldVal1, fieldVal2)) { ret = false; @@ -179,14 +181,14 @@ public __gc class BridgeTest : public WeakBase, public XMain return ret; } - static bool check( bool b , String* message ) + static bool check( bool b , String ^ message ) { if ( ! b) Console::WriteLine("{0} failed\n" , message); return b; } - static bool equals(TestElement* rData1, TestElement* rData2) + static bool equals(TestElement ^ rData1, TestElement ^ rData2) { check( rData1->Bool == rData2->Bool, "### bool does not match!" ); check( rData1->Char == rData2->Char, "### char does not match!" ); @@ -202,7 +204,7 @@ public __gc class BridgeTest : public WeakBase, public XMain check( rData1->Enum == rData2->Enum, "### enum does not match!" ); check( rData1->String == rData2->String, "### string does not match!" ); check( rData1->Interface == rData2->Interface, "### interface does not match!" ); - check( compareData(__box(rData1->Any), __box(rData2->Any)), "### any does not match!" ); + check( compareData((::System::Object ^)(rData1->Any), (::System::Object ^)(rData2->Any)), "### any does not match!" ); return (rData1->Bool == rData2->Bool && rData1->Char == rData2->Char && @@ -218,17 +220,17 @@ public __gc class BridgeTest : public WeakBase, public XMain rData1->Enum == rData2->Enum && rData1->String == rData2->String && rData1->Interface == rData2->Interface && - compareData(__box(rData1->Any), __box(rData2->Any))); + compareData((::System::Object ^)(rData1->Any), (::System::Object ^)(rData2->Any))); } -static void assign( TestElement* rData, +static void assign( TestElement ^ rData, bool bBool, Char cChar, Byte nByte, Int16 nShort, UInt16 nUShort, Int32 nLong, UInt32 nULong, Int64 nHyper, UInt64 nUHyper, float fFloat, double fDouble, - TestEnum eEnum, String* rStr, - Object* xTest, + TestEnum eEnum, String ^ rStr, + Object ^ xTest, uno::Any rAny ) { rData->Bool = bBool; @@ -248,33 +250,33 @@ static void assign( TestElement* rData, rData->Any = rAny; } -static void assign( TestDataElements* rData, +static void assign( TestDataElements ^ rData, bool bBool, Char cChar, Byte nByte, Int16 nShort, UInt16 nUShort, Int32 nLong, UInt32 nULong, Int64 nHyper, UInt64 nUHyper, float fFloat, double fDouble, - TestEnum eEnum, String* rStr, - Object* xTest, + TestEnum eEnum, String ^ rStr, + Object ^ xTest, Any rAny, - TestElement* rSequence[]) + cli::array< TestElement ^ > ^ rSequence) { - assign( static_cast<TestElement*>(rData), + assign( static_cast<TestElement ^>(rData), bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ); rData->Sequence = rSequence; } -static bool testAny(Type* typ, Object* value, XBridgeTest* xLBT ) +static bool testAny(Type ^ typ, Object ^ value, XBridgeTest ^ xLBT ) { Any any; - if (typ == 0) + if (typ == nullptr) any = Any(value->GetType(), value); else any = Any(typ, value); Any any2 = xLBT->transportAny(any); - bool ret = compareData(__box(any), __box(any2)); + bool ret = compareData((::System::Object ^)(any), (::System::Object ^)(any2)); if (!ret) { Console::WriteLine("any is different after roundtrip: in {0}, out {1}\n", @@ -285,38 +287,38 @@ static bool testAny(Type* typ, Object* value, XBridgeTest* xLBT ) -static bool performAnyTest(XBridgeTest* xLBT, TestDataElements* data) +static bool performAnyTest(XBridgeTest ^ xLBT, TestDataElements ^ data) { bool bReturn = true; - bReturn = testAny( 0, __box(data->Byte), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Short), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->UShort), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Long), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->ULong), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Hyper), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->UHyper), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Float), xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Double),xLBT ) && bReturn; - bReturn = testAny( 0, __box(data->Enum), xLBT ) && bReturn; - bReturn = testAny( 0, data->String,xLBT ) && bReturn; - bReturn = testAny(__typeof(XWeak), data->Interface,xLBT ) && bReturn; - bReturn = testAny(0, data, xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Byte), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Short), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->UShort), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Long), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->ULong), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Hyper), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->UHyper), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Float), xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Double),xLBT ) && bReturn; + bReturn = testAny( nullptr, (::System::Object ^)(data->Enum), xLBT ) && bReturn; + bReturn = testAny( nullptr, data->String,xLBT ) && bReturn; + bReturn = testAny(XWeak::typeid, data->Interface,xLBT ) && bReturn; + bReturn = testAny(nullptr, data, xLBT ) && bReturn; { Any a1(true); Any a2 = xLBT->transportAny( a1 ); - bReturn = compareData(__box(a2), __box(a1)) && bReturn; + bReturn = compareData((::System::Object ^)(a2), (::System::Object ^)(a1)) && bReturn; } { Any a1('A'); Any a2 = xLBT->transportAny(a1); - bReturn = compareData( __box(a2), __box(a1)) && bReturn; + bReturn = compareData( (::System::Object ^)(a2), (::System::Object ^)(a1)) && bReturn; } return bReturn; } -static bool performSequenceOfCallTest(XBridgeTest* xLBT) +static bool performSequenceOfCallTest(XBridgeTest ^ xLBT) { int i,nRounds; int nGlobalIndex = 0; @@ -340,22 +342,22 @@ static bool performSequenceOfCallTest(XBridgeTest* xLBT) -static bool performRecursiveCallTest(XBridgeTest* xLBT) +static bool performRecursiveCallTest(XBridgeTest ^ xLBT) { - xLBT->startRecursiveCall(new ORecursiveCall(), 50); + xLBT->startRecursiveCall(gcnew ORecursiveCall(), 50); // on failure, the test would lock up or crash return true; } -static bool performQueryForUnknownType(XBridgeTest* xLBT) +static bool performQueryForUnknownType(XBridgeTest ^ xLBT) { bool bRet = false; // test queryInterface for an unknown type try { - __try_cast<foo::MyInterface*>(xLBT); + safe_cast< foo::MyInterface ^ >(xLBT); } - catch( System::InvalidCastException*) + catch( System::InvalidCastException ^) { bRet = true; } @@ -364,19 +366,19 @@ static bool performQueryForUnknownType(XBridgeTest* xLBT) } // //================================================================================================== -static bool performTest(XBridgeTest* xLBT) +static bool performTest(XBridgeTest ^ xLBT) { - check( xLBT != 0, "### no test interface!" ); + check( xLBT != nullptr, "### no test interface!" ); bool bRet = true; - if (xLBT != 0) + if (xLBT != nullptr) { // this data is never ever granted access to by calls other than equals(), assign()! - TestDataElements* aData = new TestDataElements(); // test against this data + TestDataElements ^ aData = gcnew TestDataElements(); // test against this data - Object* xI= new WeakBase(); + Object ^ xI= gcnew WeakBase(); - Any aAny( __typeof(Object), xI); - assign( static_cast<TestElement*>(aData), + Any aAny( Object::typeid, xI); + assign( static_cast<TestElement ^>(aData), true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98, 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359, TestEnum::LOLA, @@ -386,21 +388,21 @@ static bool performTest(XBridgeTest* xLBT) bRet = check( aData->Any.Value == xI, "### unexpected any!" ) && bRet; bRet = check( !(aData->Any.Value != xI), "### unexpected any!" ) && bRet; - aData->Sequence = new TestElement*[2]; - aData->Sequence[0] = new TestElement( + aData->Sequence = gcnew cli::array< TestElement ^ >(2); + aData->Sequence[0] = gcnew TestElement( aData->Bool, aData->Char, aData->Byte, aData->Short, aData->UShort, aData->Long, aData->ULong, aData->Hyper, aData->UHyper, aData->Float, aData->Double, aData->Enum, aData->String, aData->Interface, aData->Any); //(TestElement) aData; - aData->Sequence[1] = new TestElement(); //is empty + aData->Sequence[1] = gcnew TestElement(); //is empty // aData complete // // this is a manually copy of aData for first setting... - TestDataElements* aSetData = new TestDataElements; - Any aAnySet(__typeof(Object), xI); - assign( static_cast<TestElement*>(aSetData), + TestDataElements ^ aSetData = gcnew TestDataElements(); + Any aAnySet(Object::typeid, xI); + assign( static_cast<TestElement ^>(aSetData), aData->Bool, aData->Char, aData->Byte, @@ -412,14 +414,14 @@ static bool performTest(XBridgeTest* xLBT) xI, aAnySet); - aSetData->Sequence = new TestElement*[2]; - aSetData->Sequence[0] = new TestElement( + aSetData->Sequence = gcnew cli::array< TestElement ^ >(2); + aSetData->Sequence[0] = gcnew TestElement( aSetData->Bool, aSetData->Char, aSetData->Byte, aSetData->Short, aSetData->UShort, aSetData->Long, aSetData->ULong, aSetData->Hyper, aSetData->UHyper, aSetData->Float, aSetData->Double, aSetData->Enum, aSetData->String, aSetData->Interface, aSetData->Any); //TestElement) aSetData; - aSetData->Sequence[1] = new TestElement(); // empty struct + aSetData->Sequence[1] = gcnew TestElement(); // empty struct xLBT->setValues( aSetData->Bool, aSetData->Char, aSetData->Byte, aSetData->Short, aSetData->UShort, @@ -427,26 +429,26 @@ static bool performTest(XBridgeTest* xLBT) aSetData->Enum, aSetData->String, aSetData->Interface, aSetData->Any, aSetData->Sequence, aSetData ); { - TestDataElements* aRet = new TestDataElements(); - TestDataElements* aRet2 = new TestDataElements(); + TestDataElements ^ aRet = gcnew TestDataElements(); + TestDataElements ^ aRet2 = gcnew TestDataElements(); xLBT->getValues( - & aRet->Bool, & aRet->Char, & aRet->Byte, & aRet->Short, & aRet->UShort, - & aRet->Long, & aRet->ULong, & aRet->Hyper, & aRet->UHyper, - & aRet->Float, & aRet->Double, & aRet->Enum, & aRet->String, - & aRet->Interface, & aRet->Any, & aRet->Sequence, & aRet2 ); + aRet->Bool, aRet->Char, aRet->Byte, aRet->Short, aRet->UShort, + aRet->Long, aRet->ULong, aRet->Hyper, aRet->UHyper, + aRet->Float, aRet->Double, aRet->Enum, aRet->String, + aRet->Interface, aRet->Any, aRet->Sequence, aRet2 ); bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "getValues test") && bRet; // set last retrieved values - TestDataElements* aSV2ret = xLBT->setValues2( - & aRet->Bool, & aRet->Char, & aRet->Byte, & aRet->Short, & aRet->UShort, - & aRet->Long, & aRet->ULong, & aRet->Hyper, & aRet->UHyper, & aRet->Float, - & aRet->Double, & aRet->Enum, & aRet->String, & aRet->Interface, & aRet->Any, - & aRet->Sequence, & aRet2 ); + TestDataElements ^ aSV2ret = xLBT->setValues2( + aRet->Bool, aRet->Char, aRet->Byte, aRet->Short, aRet->UShort, + aRet->Long, aRet->ULong, aRet->Hyper, aRet->UHyper, aRet->Float, + aRet->Double, aRet->Enum, aRet->String, aRet->Interface, aRet->Any, + aRet->Sequence, aRet2 ); // check inout sequence order // => inout sequence parameter was switched by test objects - TestElement* temp = aRet->Sequence[ 0 ]; + TestElement ^ temp = aRet->Sequence[ 0 ]; aRet->Sequence[ 0 ] = aRet->Sequence[ 1 ]; aRet->Sequence[ 1 ] = temp; @@ -455,14 +457,14 @@ static bool performTest(XBridgeTest* xLBT) "getValues2 test") && bRet; } { - TestDataElements* aRet = new TestDataElements(); - TestDataElements* aRet2 = new TestDataElements(); - TestDataElements* aGVret = xLBT->getValues( - & aRet->Bool, & aRet->Char, & aRet->Byte, & aRet->Short, - & aRet->UShort, & aRet->Long, & aRet->ULong, & aRet->Hyper, - & aRet->UHyper, & aRet->Float, & aRet->Double, & aRet->Enum, - & aRet->String, & aRet->Interface, & aRet->Any, & aRet->Sequence, - & aRet2 ); + TestDataElements ^ aRet = gcnew TestDataElements(); + TestDataElements ^ aRet2 = gcnew TestDataElements(); + TestDataElements ^ aGVret = xLBT->getValues( + aRet->Bool, aRet->Char, aRet->Byte, aRet->Short, + aRet->UShort, aRet->Long, aRet->ULong, aRet->Hyper, + aRet->UHyper, aRet->Float, aRet->Double, aRet->Enum, + aRet->String, aRet->Interface, aRet->Any, aRet->Sequence, + aRet2 ); bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) && compareData( aData, aGVret ), "getValues test" ) && bRet; @@ -486,8 +488,8 @@ static bool performTest(XBridgeTest* xLBT) xLBT->Struct = aRet2; } { - TestDataElements* aRet = new TestDataElements(); - TestDataElements* aRet2 = new TestDataElements(); + TestDataElements ^ aRet = gcnew TestDataElements(); + TestDataElements ^ aRet2 = gcnew TestDataElements(); aRet->Hyper = xLBT->Hyper; aRet->UHyper = xLBT->UHyper; aRet->Float = xLBT->Float; @@ -532,74 +534,74 @@ static bool performTest(XBridgeTest* xLBT) } return bRet; } -static bool performSequenceTest(XBridgeTest* xBT) +static bool performSequenceTest(XBridgeTest ^ xBT) { bool bRet = true; - XBridgeTest2* xBT2 = dynamic_cast<XBridgeTest2*>(xBT); - if ( xBT2 == 0) + XBridgeTest2 ^ xBT2 = dynamic_cast<XBridgeTest2 ^>(xBT); + if ( xBT2 == nullptr) return false; // perform sequence tests (XBridgeTest2) // create the sequence which are compared with the results - bool arBool __gc[] = new bool __gc [3]; + cli::array< bool > ^ arBool = gcnew cli::array< bool >(3); arBool[0] = true; arBool[1] = false; arBool[2] = true; - Char arChar[] = new Char[3]; + cli::array< Char > ^ arChar = gcnew cli::array< Char >(3); arChar[0] = 'A'; arChar[1] = 'B'; arChar[2] = 'C'; - Byte arByte[] = new Byte[3]; + cli::array< Byte > ^ arByte = gcnew cli::array< Byte >(3); arByte[0] = 1; arByte[1] = 2; arByte[2] = 0xff; - Int16 arShort[] = new Int16[3]; + cli::array< Int16 > ^ arShort = gcnew cli::array< Int16 >(3); arShort[0] = Int16::MinValue; arShort[1] = 1; arShort[2] = Int16::MaxValue; - UInt16 arUShort[] = new UInt16[3]; + cli::array< UInt16 > ^ arUShort = gcnew cli::array< UInt16 >(3); arUShort[0] = UInt16::MinValue; arUShort[1] = 1; arUShort[2] = UInt16::MaxValue; - Int32 arLong[] = new Int32[3]; + cli::array< Int32 > ^ arLong = gcnew cli::array< Int32 >(3); arLong[0] = Int32::MinValue; arLong[1] = 1; arLong[2] = Int32::MaxValue; - UInt32 arULong[] = new UInt32[3]; + cli::array< UInt32 > ^ arULong = gcnew cli::array< UInt32 >(3); arULong[0] = UInt32::MinValue; arULong[1] = 1; arULong[2] = UInt32::MaxValue; - Int64 arHyper[] = new Int64[3]; + cli::array< Int64 > ^ arHyper = gcnew cli::array< Int64 >(3); arHyper[0] = Int64::MinValue; arHyper[1] = 1; arHyper[2] = Int64::MaxValue; - UInt64 arUHyper[] = new UInt64[3]; + cli::array< UInt64 > ^ arUHyper = gcnew cli::array< UInt64 >(3); arUHyper[0] = UInt64::MinValue; arUHyper[1] = 1; arUHyper[2] = UInt64::MaxValue; - Single arFloat[] = new Single[3]; + cli::array< Single > ^ arFloat = gcnew cli::array< Single >(3); arFloat[0] = 1.1f; arFloat[1] = 2.2f; arFloat[2] = 3.3f; - Double arDouble[] = new Double[3]; + cli::array< Double > ^ arDouble = gcnew cli::array< Double >(3); arDouble[0] = 1.11; arDouble[1] = 2.22; arDouble[2] = 3.33; - String* arString[] = new String*[3]; - arString[0] = new String("String 1"); - arString[1] = new String("String 2"); - arString[2] = new String("String 3"); + cli::array< String ^ > ^ arString = gcnew cli::array< String ^ >( 3 ); + arString[0] = gcnew String("String 1"); + arString[1] = gcnew String("String 2"); + arString[2] = gcnew String("String 3"); - Any arAny[] = new Any[3]; + cli::array< Any > ^ arAny = gcnew cli::array< Any >( 3 ); arAny[0] = Any(true); arAny[1] = Any(11111); arAny[2] = Any(3.14); - Object* arObject[] = new Object*[3]; - arObject[0] = new WeakBase(); arObject[1] = new WeakBase(); - arObject[1] = new WeakBase(); + cli::array< Object ^ > ^ arObject = gcnew cli::array< Object ^ >( 3 ); + arObject[0] = gcnew WeakBase(); arObject[1] = gcnew WeakBase(); + arObject[1] = gcnew WeakBase(); //TestEnum arEnum[] = new TestEnum[3]; //arEnum[0] = TestEnum::ONE; arEnum[1] = TestEnum::TWO; //arEnum[2] = TestEnum::CHECK; - Console::WriteLine(new String("cli_cpp_bridgetest: Workaround for C++ compiler bug:" + Console::WriteLine(gcnew String("cli_cpp_bridgetest: Workaround for C++ compiler bug:" " using Array of Int32 instead of Array of enums w")); - Int32 arEnum[] = new Int32[3]; + cli::array< Int32 > ^ arEnum = gcnew cli::array< Int32 >(3); arEnum[0] = static_cast<Int32>(TestEnum::ONE); arEnum[1] = static_cast<Int32>(TestEnum::TWO); arEnum[2] = static_cast<Int32>(TestEnum::CHECK); - TestElement* arStruct[] = new TestElement*[3]; - arStruct[0] = new TestElement(); arStruct[1] = new TestElement(); - arStruct[2] = new TestElement(); + cli::array< TestElement ^ > ^ arStruct = gcnew cli::array< TestElement ^ >(3); + arStruct[0] = gcnew TestElement(); arStruct[1] = gcnew TestElement(); + arStruct[2] = gcnew TestElement(); assign( arStruct[0], true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98, 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359, TestEnum::LOLA, Constants::STRING_TEST_CONSTANT, arObject[0], - Any( __typeof(Object), arObject[0]) ); + Any( Object::typeid, arObject[0]) ); assign( arStruct[1], true, 'A', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98, 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359, TestEnum::TWO, Constants::STRING_TEST_CONSTANT, arObject[1], - Any( __typeof(Object), arObject[1]) ); + Any( Object::typeid, arObject[1]) ); assign( arStruct[2], true, 'B', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98, 0x123456789abcdef0, 0xfedcba9876543210, 17.0815f, 3.1415926359, TestEnum::CHECK, Constants::STRING_TEST_CONSTANT, arObject[2], - Any( __typeof(Object), arObject[2] ) ); + Any( Object::typeid, arObject[2] ) ); // int[][][] arLong3 = new int[][][]{ @@ -609,47 +611,48 @@ static bool performSequenceTest(XBridgeTest* xBT) { -// Console::WriteLine(new String("cli_cpp_bridgetest: +// Console::WriteLine(gcnew String("cli_cpp_bridgetest: // int[][] seqSeqRet = xBT2->setDim2(arLong3[0]); // bRet = check( compareData(seqSeqRet, arLong3[0]), "sequence test") && bRet; // int[][][] seqSeqRet2 = xBT2->setDim3(arLong3); // bRet = check( compareData(seqSeqRet2, arLong3), "sequence test") && bRet; - Any seqAnyRet[] = xBT2->setSequenceAny(arAny); + cli::array< Any > ^ seqAnyRet = xBT2->setSequenceAny(arAny); bRet = check( compareData(seqAnyRet, arAny), "sequence test") && bRet; - Boolean seqBoolRet[] = xBT2->setSequenceBool(arBool); + cli::array< Boolean > ^ seqBoolRet = xBT2->setSequenceBool(arBool); bRet = check( compareData(seqBoolRet, arBool), "sequence test") && bRet; - Byte seqByteRet[] = xBT2->setSequenceByte(arByte); + cli::array< Byte > ^ seqByteRet = xBT2->setSequenceByte(arByte); bRet = check( compareData(seqByteRet, arByte), "sequence test") && bRet; - Char seqCharRet[] = xBT2->setSequenceChar(arChar); + cli::array< Char > ^ seqCharRet = xBT2->setSequenceChar(arChar); bRet = check( compareData(seqCharRet, arChar), "sequence test") && bRet; - Int16 seqShortRet[] = xBT2->setSequenceShort(arShort); + cli::array< Int16 > ^ seqShortRet = xBT2->setSequenceShort(arShort); bRet = check( compareData(seqShortRet, arShort), "sequence test") && bRet; - Int32 seqLongRet[] = xBT2->setSequenceLong(arLong); + cli::array< Int32 > ^ seqLongRet = xBT2->setSequenceLong(arLong); bRet = check( compareData(seqLongRet, arLong), "sequence test") && bRet; - Int64 seqHyperRet[] = xBT2->setSequenceHyper(arHyper); + cli::array< Int64 > ^ seqHyperRet = xBT2->setSequenceHyper(arHyper); bRet = check( compareData(seqHyperRet,arHyper), "sequence test") && bRet; - Single seqFloatRet[] = xBT2->setSequenceFloat(arFloat); + cli::array< Single > ^ seqFloatRet = xBT2->setSequenceFloat(arFloat); bRet = check( compareData(seqFloatRet, arFloat), "sequence test") && bRet; - Double seqDoubleRet[] = xBT2->setSequenceDouble(arDouble); + cli::array< Double > ^ seqDoubleRet = xBT2->setSequenceDouble(arDouble); bRet = check( compareData(seqDoubleRet, arDouble), "sequence test") && bRet; - xBT2->setSequenceEnum(arEnum); + xBT2->setSequenceEnum( + safe_cast< cli::array< TestEnum > ^ >( (Object ^) arEnum ) ); //comparing seqEnumRet with arEnum will fail since they are of different //types because of workaround. arEnum is Int32[]. - Console::WriteLine(new String("cli_cpp_bridgetest: Test omitted because " + Console::WriteLine(gcnew String("cli_cpp_bridgetest: Test omitted because " "of C++ compiler bug. XBridgeTest2::setSequenceEnum(sequence<TestEnum>)")); // bRet = check( compareData(seqEnumRet, arEnum), "sequence test") && bRet; - UInt16 seqUShortRet[] = xBT2->setSequenceUShort(arUShort); + cli::array< UInt16 > ^ seqUShortRet = xBT2->setSequenceUShort(arUShort); bRet = check( compareData(seqUShortRet, arUShort), "sequence test") && bRet; - UInt32 seqULongRet[] = xBT2->setSequenceULong(arULong); + cli::array< UInt32 > ^ seqULongRet = xBT2->setSequenceULong(arULong); bRet = check( compareData(seqULongRet, arULong), "sequence test") && bRet; - UInt64 seqUHyperRet[] = xBT2->setSequenceUHyper(arUHyper); + cli::array< UInt64 > ^ seqUHyperRet = xBT2->setSequenceUHyper(arUHyper); bRet = check( compareData(seqUHyperRet, arUHyper), "sequence test") && bRet; - Object* seqObjectRet[] = xBT2->setSequenceXInterface(arObject); + cli::array< Object ^ > ^ seqObjectRet = xBT2->setSequenceXInterface(arObject); bRet = check( compareData(seqObjectRet, arObject), "sequence test") && bRet; - String* seqStringRet[] = xBT2->setSequenceString(arString); + cli::array< String ^ > ^ seqStringRet = xBT2->setSequenceString(arString); bRet = check( compareData(seqStringRet, arString), "sequence test") && bRet; - TestElement* seqStructRet[] = xBT2->setSequenceStruct(arStruct); + cli::array< TestElement ^ > ^ seqStructRet = xBT2->setSequenceStruct(arStruct); bRet = check( compareData(seqStructRet, arStruct), "sequence test") && bRet; } { @@ -665,9 +668,9 @@ static bool performSequenceTest(XBridgeTest* xBT) // Single arFloatTemp[] = static_cast<Single[]>(arFloat->Clone()); // Double arDoubleTemp[] = static_cast<Double[]>(arDouble->Clone()); // TestEnum arEnumTemp[] = static_cast<TestEnum[]>(arEnum->Clone()); -// String* arStringTemp[] = static_cast<String*[]>(arString->Clone()); -// Object* arObjectTemp = static_cast<Object*[]>(arObject->Clone()); -// Any arAnyTemp[] = static_cast<Any[]>(arAny->Clone()); +// cli::array< String ^ > ^ arStringTemp = static_cast<String ^[]>(arString->Clone()); +// Object ^ arObjectTemp = static_cast<Object ^[]>(arObject->Clone()); +// cli::array< Any > ^ arAnyTemp = static_cast<Any[]>(arAny->Clone()); // // make sure this are has the same contents as arLong3[0] // int[][] arLong2Temp = new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} }; // // make sure this are has the same contents as arLong3 @@ -675,7 +678,7 @@ static bool performSequenceTest(XBridgeTest* xBT) // new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9} }, // new int [][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}, // new int[][]{new int[]{1,2,3},new int[]{4,5,6}, new int[]{7,8,9}}}; - Console::WriteLine(new String("cli_cpp_bridgetest: no test of " + Console::WriteLine(gcnew String("cli_cpp_bridgetest: no test of " "XBridgeTest2::setSequencesInOut and XBridgeTest2.setSequencesOut " "because jagged arrays are not supported by C++ compiler")); // xBT2->setSequencesInOut(& arBoolTemp, & arCharTemp, & arByteTemp, @@ -715,9 +718,9 @@ static bool performSequenceTest(XBridgeTest* xBT) //Single arFloatOut[]; //Double arDoubleOut[]; //TestEnum arEnumOut[]; - //String* arStringOut[]; - //Object* arObjectOut[]; - //Any arAnyOut[]; + //cli::array< String ^ > ^ arStringOut; + //cli::array< Object ^ > ^ arObjectOut; + //cli::array< Any > ^ arAnyOut; // int[][] arLong2Out; // int[][][] arLong3Out; @@ -754,54 +757,54 @@ static bool performSequenceTest(XBridgeTest* xBT) // int[][][] _arLong3 = new int[0][][]; // int[][][] seqSeqRet2 = xBT2->setDim3(_arLong3); // bRet = check( compareData(seqSeqRet2, _arLong3), "sequence test") && bRet; - Any _arAny[] = new Any[0]; - Any seqAnyRet[] = xBT2->setSequenceAny(_arAny); + cli::array< Any > ^ _arAny = gcnew cli::array< Any >( 0 ); + cli::array< Any > ^ seqAnyRet = xBT2->setSequenceAny(_arAny); bRet = check( compareData(seqAnyRet, _arAny), "sequence test") && bRet; - Boolean _arBool[] = new Boolean[0]; - Boolean seqBoolRet[] = xBT2->setSequenceBool(_arBool); + cli::array< Boolean > ^ _arBool = gcnew cli::array< Boolean >(0); + cli::array< Boolean > ^ seqBoolRet = xBT2->setSequenceBool(_arBool); bRet = check( compareData(seqBoolRet, _arBool), "sequence test") && bRet; - Byte _arByte[] = new Byte[0]; - Byte seqByteRet[] = xBT2->setSequenceByte(_arByte); + cli::array< Byte > ^ _arByte = gcnew cli::array< Byte >(0); + cli::array< Byte > ^ seqByteRet = xBT2->setSequenceByte(_arByte); bRet = check( compareData(seqByteRet, _arByte), "sequence test") && bRet; - Char _arChar[] = new Char[0]; - Char seqCharRet[] = xBT2->setSequenceChar(_arChar); + cli::array< Char > ^ _arChar = gcnew cli::array< Char >(0); + cli::array< Char > ^ seqCharRet = xBT2->setSequenceChar(_arChar); bRet = check( compareData(seqCharRet, _arChar), "sequence test") && bRet; - Int16 _arShort[] = new Int16[0]; - Int16 seqShortRet[] = xBT2->setSequenceShort(_arShort); + cli::array< Int16 > ^ _arShort = gcnew cli::array< Int16 >(0); + cli::array< Int16 > ^ seqShortRet = xBT2->setSequenceShort(_arShort); bRet = check( compareData(seqShortRet, _arShort), "sequence test") && bRet; - Int32 _arLong[] = new Int32[0]; - Int32 seqLongRet[] = xBT2->setSequenceLong(_arLong); + cli::array< Int32 > ^ _arLong = gcnew cli::array< Int32 >(0); + cli::array< Int32 > ^ seqLongRet = xBT2->setSequenceLong(_arLong); bRet = check( compareData(seqLongRet, _arLong), "sequence test") && bRet; - Int64 _arHyper[] = new Int64[0]; - Int64 seqHyperRet[] = xBT2->setSequenceHyper(_arHyper); + cli::array< Int64 > ^ _arHyper = gcnew cli::array< Int64 >(0); + cli::array< Int64 > ^ seqHyperRet = xBT2->setSequenceHyper(_arHyper); bRet = check( compareData(seqHyperRet, _arHyper), "sequence test") && bRet; - Single _arFloat[] = new Single[0]; - Single seqFloatRet[] = xBT2->setSequenceFloat(_arFloat); + cli::array< Single > ^ _arFloat = gcnew cli::array< Single >(0); + cli::array< Single > ^ seqFloatRet = xBT2->setSequenceFloat(_arFloat); bRet = check( compareData(seqFloatRet, _arFloat), "sequence test") && bRet; - Double _arDouble[] = new Double[0]; - Double seqDoubleRet[] = xBT2->setSequenceDouble(_arDouble); + cli::array< Double > ^ _arDouble = gcnew cli::array< Double >(0); + cli::array< Double > ^ seqDoubleRet = xBT2->setSequenceDouble(_arDouble); bRet = check( compareData(seqDoubleRet, _arDouble), "sequence test") && bRet; - TestEnum _arEnum[] = new TestEnum[0]; + cli::array< TestEnum > ^ _arEnum = gcnew cli::array< TestEnum >(0); xBT2->setSequenceEnum(_arEnum); // compiler bug: _arEnum has type System.Enum and not TestEnum // bRet = check( compareData(seqEnumRet, _arEnum), "sequence test") && bRet; - UInt16 _arUShort[] = new UInt16[0]; - UInt16 seqUShortRet[] = xBT2->setSequenceUShort(_arUShort); + cli::array< UInt16 > ^ _arUShort = gcnew cli::array< UInt16 >(0); + cli::array< UInt16 > ^ seqUShortRet = xBT2->setSequenceUShort(_arUShort); bRet = check( compareData(seqUShortRet, _arUShort), "sequence test") && bRet; - UInt32 _arULong[] = new UInt32[0]; - UInt32 seqULongRet[] = xBT2->setSequenceULong(_arULong); + cli::array< UInt32 > ^ _arULong = gcnew cli::array< UInt32 >(0); + cli::array< UInt32 > ^ seqULongRet = xBT2->setSequenceULong(_arULong); bRet = check( compareData(seqULongRet, _arULong), "sequence test") && bRet; - UInt64 _arUHyper[] = new UInt64[0]; - UInt64 seqUHyperRet[] = xBT2->setSequenceUHyper(_arUHyper); + cli::array< UInt64 > ^ _arUHyper = gcnew cli::array< UInt64 >(0); + cli::array< UInt64 > ^ seqUHyperRet = xBT2->setSequenceUHyper(_arUHyper); bRet = check( compareData(seqUHyperRet, _arUHyper), "sequence test") && bRet; - Object* _arObject[] = new Object*[0]; - Object* seqObjectRet[] = xBT2->setSequenceXInterface(_arObject); + cli::array< Object ^ > ^ _arObject = gcnew cli::array< Object ^ >( 0 ); + cli::array< Object ^ > ^ seqObjectRet = xBT2->setSequenceXInterface(_arObject); bRet = check( compareData(seqObjectRet, _arObject), "sequence test") && bRet; - String* _arString[] = new String*[0]; - String* seqStringRet[] = xBT2->setSequenceString(_arString); + cli::array< String ^ > ^ _arString = gcnew cli::array< String ^ >( 0 ); + cli::array< String ^ > ^ seqStringRet = xBT2->setSequenceString(_arString); bRet = check( compareData(seqStringRet, _arString), "sequence test") && bRet; - TestElement* _arStruct[] = new TestElement*[0]; - TestElement* seqStructRet[] = xBT2->setSequenceStruct(_arStruct); + cli::array< TestElement ^ > ^ _arStruct = gcnew cli::array< TestElement ^ >(0); + cli::array< TestElement ^ > ^ seqStructRet = xBT2->setSequenceStruct(_arStruct); bRet = check( compareData(seqStructRet, _arStruct), "sequence test") && bRet; } @@ -809,12 +812,12 @@ static bool performSequenceTest(XBridgeTest* xBT) } /** Test the System::Object method on the proxy object */ -static bool testObjectMethodsImplemention(XBridgeTest* xLBT) +static bool testObjectMethodsImplemention(XBridgeTest ^ xLBT) { bool ret = false; - Object* obj = new Object(); - XBridgeTestBase* xBase = dynamic_cast<XBridgeTestBase*>(xLBT); - if (xBase == 0) + Object ^ obj = gcnew Object(); + XBridgeTestBase ^ xBase = dynamic_cast<XBridgeTestBase ^>(xLBT); + if (xBase == nullptr) return false; // Object.Equals ret = xLBT->Equals(obj) == false; @@ -828,23 +831,23 @@ static bool testObjectMethodsImplemention(XBridgeTest* xLBT) //Object.ToString // Don't know how to verify this automatically. - String* s = xLBT->ToString(); + String ^ s = xLBT->ToString(); ret = (s->Length > 0) && ret; return ret; } -static bool raiseOnewayException(XBridgeTest* xLBT) +static bool raiseOnewayException(XBridgeTest ^ xLBT) { bool bReturn = true; - String* sCompare = Constants::STRING_TEST_CONSTANT; + String ^ sCompare = Constants::STRING_TEST_CONSTANT; try { // Note : the exception may fly or not (e.g. remote scenario). // When it flies, it must contain the correct elements. xLBT->raiseRuntimeExceptionOneway(sCompare, xLBT->Interface ); } - catch (RuntimeException* e ) + catch (RuntimeException ^ e ) { bReturn = ( xLBT->Interface == e->Context ); } @@ -852,7 +855,7 @@ static bool raiseOnewayException(XBridgeTest* xLBT) } // //================================================================================================== -static bool raiseException(XBridgeTest* xLBT ) +static bool raiseException(XBridgeTest ^ xLBT ) { int nCount = 0; try @@ -864,7 +867,7 @@ static bool raiseException(XBridgeTest* xLBT ) xLBT->raiseException( 5, Constants::STRING_TEST_CONSTANT, xLBT->Interface ); } - catch (unoidl::com::sun::star::lang::IllegalArgumentException* aExc) + catch (unoidl::com::sun::star::lang::IllegalArgumentException ^ aExc) { if (aExc->ArgumentPosition == 5 && aExc->Context == xLBT->Interface) @@ -881,7 +884,7 @@ static bool raiseException(XBridgeTest* xLBT ) xLBT->RuntimeException = 0; } } - catch (unoidl::com::sun::star::uno::RuntimeException* rExc) + catch (unoidl::com::sun::star::uno::RuntimeException ^ rExc) { if (rExc->Context == xLBT->Interface ) { @@ -896,7 +899,7 @@ static bool raiseException(XBridgeTest* xLBT ) xLBT->RuntimeException = (int) 0xcafebabe; } } - catch (unoidl::com::sun::star::uno::Exception* rExc) + catch (unoidl::com::sun::star::uno::Exception ^ rExc) { if (rExc->Context == xLBT->Interface) { @@ -912,7 +915,7 @@ static bool raiseException(XBridgeTest* xLBT ) return false; } - static private void perform_test( XBridgeTest* xLBT ) + static private void perform_test( XBridgeTest ^ xLBT ) { bool bRet= true; bRet = check( performTest( xLBT ), "standard test" ) && bRet; @@ -922,55 +925,55 @@ static bool raiseException(XBridgeTest* xLBT ) bRet = performQueryForUnknownType( xLBT ) && bRet; if (! bRet) { - throw new unoidl::com::sun::star::uno::RuntimeException( - new String("error: test failed!"), 0); + throw gcnew unoidl::com::sun::star::uno::RuntimeException( + gcnew String("error: test failed!"), nullptr); } } - XComponentContext* m_xContext; + XComponentContext ^ m_xContext; public: - BridgeTest( XComponentContext* xContext ) + BridgeTest( XComponentContext ^ xContext ) { m_xContext = xContext; } - int run( String* args[] ) + virtual int run( cli::array< String ^ > ^ args ) { try { if (args->Length < 1) { - throw new RuntimeException( + throw gcnew RuntimeException( "missing argument for bridgetest!", this ); } - Object* test_obj = + Object ^ test_obj = m_xContext->getServiceManager()->createInstanceWithContext( args[ 0 ], m_xContext ); - if (test_obj == 0) + if (test_obj == nullptr) test_obj = m_xContext->getValueByName( args[ 0 ] ).Value; Console::WriteLine( "cli target bridgetest obj: {0}", test_obj->ToString() ); - XBridgeTest* xTest = __try_cast<XBridgeTest*>(test_obj) ; + XBridgeTest ^ xTest = safe_cast< XBridgeTest ^ >(test_obj) ; perform_test( xTest ); Console::WriteLine( "\n### cli_uno C++ bridgetest succeeded." ); return 0; } - catch (unoidl::com::sun::star::uno::RuntimeException* ) + catch (unoidl::com::sun::star::uno::RuntimeException ^ ) { throw; } - catch (System::Exception* exc) + catch (System::Exception ^ exc) { - System::Text::StringBuilder* s = new System::Text::StringBuilder(); - s->Append(S"cli_cpp_bridgetest: unexpected exception occurred in XMain::run. Original exception: "); + System::Text::StringBuilder ^ s = gcnew System::Text::StringBuilder(); + s->Append("cli_cpp_bridgetest: unexpected exception occurred in XMain::run. Original exception: "); s->Append(exc->GetType()->Name); - s->Append(S"\n Message: "); + s->Append("\n Message: "); s->Append(exc->Message); - throw new unoidl::com::sun::star::uno::RuntimeException( - s->ToString(), 0); + throw gcnew unoidl::com::sun::star::uno::RuntimeException( + s->ToString(), nullptr); } } }; diff --git a/main/testtools/source/bridgetest/cli/makefile.mk b/main/testtools/source/bridgetest/cli/makefile.mk index 6b215e2df9..7fc5b3deaf 100644 --- a/main/testtools/source/bridgetest/cli/makefile.mk +++ b/main/testtools/source/bridgetest/cli/makefile.mk @@ -44,19 +44,26 @@ CFLAGSENABLESYMBOLS:=-Z7 #These tests are for Windows only # ...and only when the CLI binding was actually built. This whole directory is -# the C++/CLI half of bridgetest and needs /clr:oldSyntax like the rest of it. -# No makefile.pmk here, so DISABLE_CLI comes from the environment. +# the C++/CLI half of bridgetest and follows cli_ure. No makefile.pmk here, +# so DISABLE_CLI comes from the environment. .IF "$(COM)" == "MSC" && "$(GUI)" == "WNT" && "$(DISABLE_CLI)" == "" -.IF "$(CCNUMVER)" >= "001399999999" +# Which syntax, and which mixed-mode runtime, are two separate questions. +# /clr:oldSyntax went away after VS2015, so a UCRT compiler gets plain -clr +# and this source is C++/CLI. msvcmrt.lib is needed either way from VS2005 +# on: it carries the managed module initializer, and without it the link +# fails on an unresolved .cctor. +.IF "$(CCNUMVER)" >= "001399999999" && "$(COMEX)" != "14" CFLAGSCXX += -clr:oldSyntax -AI $(OUT)$/bin -AI $(SOLARBINDIR) -SHL1STDLIBS = \ - mscoree.lib \ - msvcmrt.lib .ELSE CFLAGSCXX += -clr -AI $(OUT)$/bin -AI $(SOLARBINDIR) +.ENDIF + SHL1STDLIBS = \ mscoree.lib +.IF "$(CCNUMVER)" >= "001399999999" +SHL1STDLIBS += \ + msvcmrt.lib .ENDIF SLOFILES= \ $(SLO)$/cli_cpp_bridgetest.obj @@ -75,8 +82,8 @@ DEF1NAME = $(SHL1TARGET) .INCLUDE : target.mk # ...and only when the CLI binding was actually built. This whole directory is -# the C++/CLI half of bridgetest and needs /clr:oldSyntax like the rest of it. -# No makefile.pmk here, so DISABLE_CLI comes from the environment. +# the C++/CLI half of bridgetest and follows cli_ure. No makefile.pmk here, +# so DISABLE_CLI comes from the environment. .IF "$(COM)" == "MSC" && "$(GUI)" == "WNT" && "$(DISABLE_CLI)" == "" ALLTAR : $(BIN)$/cli_bridgetest_inprocess.exe @@ -91,11 +98,23 @@ CLI_OOOTYPES = $(SOLARBINDIR)$/cli_oootypes.dll CLI_TYPES_BRIDGETEST = $(BIN)$/cli_types_bridgetest.dll CSCFLAGS = -warnaserror+ + +# csc defaults to anycpu, so on 64-bit Windows the test exe would start as +# a 64-bit process and then fail to load the mixed-mode assemblies, which +# follow the C++ build and are x86. The error is a BadImageFormatException +# naming cli_cppuhelper, which does not sound like a bitness problem at all. +.IF "$(CPUNAME)" == "X86_64" +CLI_PLATFORM = x64 +.ELSE +CLI_PLATFORM = x86 +.ENDIF +CSCFLAGS += -platform:$(CLI_PLATFORM) .IF "$(CCNUMVER)" <= "001399999999" VBC_FLAGS = -warnaserror+ .ELSE VBC_FLAGS = -nowarn:42030 -warnaserror+ .ENDIF +VBC_FLAGS += -platform:$(CLI_PLATFORM) .IF "$(debug)" != "" CSCFLAGS += -debug+ -checked+ -define:DEBUG -define:TRACE VBC_FLAGS += -debug+ -define:DEBUG=TRUE -define:TRACE=TRUE @@ -167,7 +186,16 @@ $(BIN)$/cli_vb_testobj.uno.dll : \ -reference:System.Windows.Forms.dll \ cli_vb_testobj.vb -$(MISC)$/copyassemblies.done .ERRREMOVE: +# The stamp has to name what it copies. Without these prerequisites a +# rebuilt cli_uretypes.dll never reaches $(BIN), and the test then runs +# against the stale copy -- which fails at assembly-load time, a long way +# from the cause. +$(MISC)$/copyassemblies.done .ERRREMOVE: \ + $(CLI_CPPUHELPER) \ + $(CLI_BASETYPES) \ + $(CLI_URETYPES) \ + $(CLI_URE) \ + $(CLI_OOOTYPES) $(GNUCOPY) $(CLI_CPPUHELPER) $(BIN)$/$(CLI_CPPUHELPER:f) $(GNUCOPY) $(CLI_BASETYPES) $(BIN)$/$(CLI_BASETYPES:f) $(GNUCOPY) $(CLI_URETYPES) $(BIN)$/$(CLI_URETYPES:f) diff --git a/main/testtools/util/makefile.pmk b/main/testtools/util/makefile.pmk index 109fc92545..5a97a70f14 100644 --- a/main/testtools/util/makefile.pmk +++ b/main/testtools/util/makefile.pmk @@ -24,11 +24,11 @@ # no translation here anyway .IF "$(L10N_framework)"=="" .IF "$(COM)" == "MSC" -# ...but not when configure has ruled the binding out. It is written in Managed -# Extensions for C++ -- __gc, S"...", __pin -- which needs /clr:oldSyntax, and -# that switch was removed after VS2015; porting it to C++/CLI is its own piece -# of work. Every consumer already handles BUILD_FOR_CLI being empty, because -# that is how the non-MSC platforms build. VC9 is unaffected. +# ...but not when configure was told --disable-cli. The binding is C++/CLI now +# and builds with either compiler generation, but it still wants a .NET SDK -- +# csc.exe and mscoree.lib -- which a Windows machine need not have. Every +# consumer already handles BUILD_FOR_CLI being empty, because that is how the +# non-MSC platforms build. .IF "$(DISABLE_CLI)"=="" BUILD_FOR_CLI = "true" .ENDIF diff --git a/main/unoil/util/makefile.pmk b/main/unoil/util/makefile.pmk index 109fc92545..5a97a70f14 100644 --- a/main/unoil/util/makefile.pmk +++ b/main/unoil/util/makefile.pmk @@ -24,11 +24,11 @@ # no translation here anyway .IF "$(L10N_framework)"=="" .IF "$(COM)" == "MSC" -# ...but not when configure has ruled the binding out. It is written in Managed -# Extensions for C++ -- __gc, S"...", __pin -- which needs /clr:oldSyntax, and -# that switch was removed after VS2015; porting it to C++/CLI is its own piece -# of work. Every consumer already handles BUILD_FOR_CLI being empty, because -# that is how the non-MSC platforms build. VC9 is unaffected. +# ...but not when configure was told --disable-cli. The binding is C++/CLI now +# and builds with either compiler generation, but it still wants a .NET SDK -- +# csc.exe and mscoree.lib -- which a Windows machine need not have. Every +# consumer already handles BUILD_FOR_CLI being empty, because that is how the +# non-MSC platforms build. .IF "$(DISABLE_CLI)"=="" BUILD_FOR_CLI = "true" .ENDIF
