1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 using System;
25 using System.Diagnostics;
26 using System.Threading;
27 using System.Runtime.CompilerServices;
28 using uno;
29 using uno.util;
30 using unoidl.com.sun.star.uno;
31 using unoidl.com.sun.star.lang;
32 using unoidl.test.testtools.bridgetest;
33 
34 namespace cs_testobj
35 {
36 
37 class CheckFailed: System.Exception {
CheckFailed(string message)38     public CheckFailed(string message): base(message) {}
39 }
40 
41 public class BridgeTestObject : WeakBase, XRecursiveCall, XBridgeTest2
42 {
43     private XComponentContext m_xContext;
44 
BridgeTestObject( XComponentContext xContext )45     public BridgeTestObject( XComponentContext xContext )
46     {
47         m_xContext = xContext;
48     }
BridgeTestObject()49     public BridgeTestObject()
50     {
51     }
52 
53     private bool  _bool;
54     private char     _char;
55     private byte     _byte;
56     private short    _short;
57     private ushort    _ushort;
58     private int      _long;
59     private uint      _ulong;
60     private long     _hyper;
61     private ulong     _uhyper;
62     private float    _float;
63     private double   _double;
64     private String   _string;
65     private Object   _xInterface;
66     private Any   _any;
67     private TestEnum _testEnum = TestEnum.TEST;
68     private TestElement[] _testElements = new TestElement[0];
69     private TestDataElements _testDataElements = new TestDataElements();
70     private int     _nLastCallId = 0;
71     private bool _bFirstCall = true;
72     private bool _bSequenceOfCallTestPassed = true;
73 
74     private bool[] _arBool;
75     private char[] _arChar;
76     private byte[] _arByte;
77     private short[]_arShort;
78     private int[] _arLong;
79     private long[] _arHyper;
80     private UInt16[] _arUShort;
81     private UInt32[] _arULong;
82     private UInt64[] _arUHyper;
83     private string[] _arString;
84     private float[] _arFloat;
85     private double[] _arDouble;
86     private TestEnum[] _arEnum;
87     private Object[] _arObject;
88     private int[][] _arLong2;
89     private int[][][] _arLong3;
90     private Any[] _arAny;
91 
92 //    private int _raiseAttr1;
93 
94 
setValues( bool bBool, char cChar, byte nByte, short nShort, ushort nUShort, int nLong, uint nULong, long nHyper, ulong nUHyper, float fFloat, double fDouble, TestEnum testEnum, String str, Object xInterface, Any any, TestElement [] testElements, TestDataElements testDataElements )95     public void setValues(
96         bool          bBool,
97         char             cChar,
98         byte             nByte,
99         short            nShort,
100         ushort            nUShort,
101         int              nLong,
102         uint              nULong,
103         long             nHyper,
104         ulong             nUHyper,
105         float            fFloat,
106         double           fDouble,
107         TestEnum         testEnum,
108         String           str,
109         Object           xInterface,
110         Any              any,
111         TestElement []      testElements,
112         TestDataElements testDataElements )
113     {
114          Debug.WriteLine( "##### " + GetType().FullName + ".setValues:" + any );
115 
116         _bool             = bBool;
117         _char             = cChar;
118         _byte             = nByte;
119         _short            = nShort;
120         _ushort           = nUShort;
121         _long             = nLong;
122         _ulong            = nULong;
123         _hyper            = nHyper;
124         _uhyper           = nUHyper;
125         _float            = fFloat;
126         _double           = fDouble;
127         _testEnum         = testEnum;
128         _string           = str;
129         _xInterface       = xInterface;
130         _any              = any;
131         _testElements     = testElements;
132         _testDataElements = testDataElements;
133     }
134 
setValues2( ref bool io_bool, ref char io_char, ref byte io_byte, ref short io_short, ref ushort io_ushort, ref int io_long, ref uint io_ulong, ref long io_hyper, ref ulong io_uhyper, ref float io_float, ref double io_double, ref TestEnum io_testEnum, ref String io_string, ref Object io_xInterface, ref Any io_any, ref TestElement[] io_testElements, ref TestDataElements io_testDataElements )135     public TestDataElements setValues2(
136         /*INOUT*/ref bool          io_bool,
137         /*INOUT*/ref char             io_char,
138         /*INOUT*/ref byte             io_byte,
139         /*INOUT*/ref short            io_short,
140         /*INOUT*/ref ushort            io_ushort,
141         /*INOUT*/ref int              io_long,
142         /*INOUT*/ref uint              io_ulong,
143         /*INOUT*/ref long             io_hyper,
144         /*INOUT*/ref ulong             io_uhyper,
145         /*INOUT*/ref float            io_float,
146         /*INOUT*/ref double           io_double,
147         /*INOUT*/ref TestEnum         io_testEnum,
148         /*INOUT*/ref String           io_string,
149         /*INOUT*/ref Object           io_xInterface,
150         /*INOUT*/ref Any           io_any,
151         /*INOUT*/ref TestElement[]    io_testElements,
152         /*INOUT*/ref TestDataElements io_testDataElements )
153     {
154         Debug.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any );
155 
156         _bool             = io_bool;
157         _char             = io_char;
158         _byte             = io_byte;
159         _short            = io_short;
160         _ushort           = io_ushort;
161         _long             = io_long;
162         _ulong            = io_ulong;
163         _hyper            = io_hyper;
164         _uhyper           = io_uhyper;
165         _float            = io_float;
166         _double           = io_double;
167         _testEnum         = io_testEnum;
168         _string           = io_string;
169         _xInterface       = io_xInterface;
170         _any              = io_any;
171         _testElements     = (TestElement[]) io_testElements.Clone();
172         _testDataElements = io_testDataElements;
173 
174         TestElement temp = io_testElements[ 0 ];
175         io_testElements[ 0 ] = io_testElements[ 1 ];
176         io_testElements[ 1 ] = temp;
177 
178         return _testDataElements;
179     }
180 
getValues( out bool o_bool, out char o_char, out byte o_byte, out short o_short, out ushort o_ushort, out int o_long, out uint o_ulong, out long o_hyper, out ulong o_uhyper, out float o_float, out double o_double, out TestEnum o_testEnum, out String o_string, out Object o_xInterface, out Any o_any, out TestElement[] o_testElements, out TestDataElements o_testDataElements )181     public TestDataElements getValues(
182         /*OUT*/out bool          o_bool,
183         /*OUT*/out char             o_char,
184         /*OUT*/out byte             o_byte,
185         /*OUT*/out short            o_short,
186         /*OUT*/out ushort            o_ushort,
187         /*OUT*/out int              o_long,
188         /*OUT*/out uint              o_ulong,
189         /*OUT*/out long             o_hyper,
190         /*OUT*/out ulong             o_uhyper,
191         /*OUT*/out float            o_float,
192         /*OUT*/out double           o_double,
193         /*OUT*/out TestEnum         o_testEnum,
194         /*OUT*/out String           o_string,
195         /*OUT*/out Object           o_xInterface,
196         /*OUT*/out Any           o_any,
197         /*OUT*/out TestElement[]    o_testElements,
198         /*OUT*/out TestDataElements o_testDataElements )
199     {
200         Debug.WriteLine( "##### " + GetType().FullName + ".getValues" );
201 
202         o_bool             = _bool;
203         o_char             = _char;
204         o_byte             = _byte;
205         o_short            = _short;
206         o_ushort           = _ushort;
207         o_long             = _long;
208         o_ulong            = _ulong;
209         o_hyper            = _hyper;
210         o_uhyper           = _uhyper;
211         o_float            = _float;
212         o_double           = _double;
213         o_testEnum         = _testEnum;
214         o_string           = _string;
215         o_xInterface       = _xInterface;
216         o_any              = _any;
217         o_testElements     = _testElements;
218         o_testDataElements = _testDataElements;
219 
220         return _testDataElements;
221     }
222 
echoSmallStruct( SmallStruct arg)223     public SmallStruct echoSmallStruct(/*[in]*/SmallStruct arg)
224     {
225         return arg;
226     }
227 
echoMediumStruct( MediumStruct arg)228     public MediumStruct echoMediumStruct(/*[in]*/MediumStruct arg)
229     {
230         return arg;
231     }
232 
echoBigStruct( BigStruct arg)233     public BigStruct echoBigStruct(/*[in]*/BigStruct arg)
234     {
235         return arg;
236     }
237 
echoAllFloats( AllFloats arg)238     public AllFloats echoAllFloats(/*[in]*/AllFloats arg)
239     {
240         return arg;
241     }
242 
testPPCAlignment( long l1, long l2, int i1, long l3, int i2 )243     public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 )
244     {
245         return i2;
246     }
247 
248     // Attributes
249     public bool Bool
250     {
251         get { return _bool; }
252         set { _bool = value; }
253     }
254     public byte Byte
255     {
256         get { return _byte; }
257         set { _byte = value; }
258     }
259     public char Char
260     {
261         get { return _char; }
262         set { _char = value; }
263     }
264     public short Short
265     {
266         get { return _short; }
267         set { _short = value; }
268     }
269     public ushort UShort
270     {
271         get { return _ushort; }
272         set { _ushort = value; }
273     }
274     public int Long
275     {
276         get { return _long; }
277         set { _long = value; }
278     }
279     public uint ULong
280     {
281         get { return _ulong; }
282         set { _ulong = value; }
283     }
284     public long Hyper
285     {
286         get { return _hyper; }
287         set { _hyper = value; }
288     }
289     public ulong UHyper
290     {
291         get { return _uhyper; }
292         set { _uhyper = value; }
293     }
294     public float Float
295     {
296         get { return _float; }
297         set { _float = value; }
298     }
299     public double Double
300     {
301         get { return _double; }
302         set { _double = value; }
303     }
304     public TestEnum Enum
305     {
306         get { return _testEnum; }
307         set { _testEnum = value; }
308     }
309     public String String
310     {
311         get { return _string; }
312         set { _string = value; }
313     }
314     public Object Interface
315     {
316         get { return _xInterface; }
317         set { _xInterface = value; }
318     }
319     public uno.Any Any
320     {
321         get {
322 
323             Debug.WriteLine( "##### " + GetType().FullName + ".Any" );
324             return _any;
325         }
326         set {
327             Debug.WriteLine( "##### " + GetType().FullName + ".Any:" + value );
328             _any = value;
329         }
330     }
331     public TestElement [] Sequence
332     {
333         get { return _testElements; }
334         set { _testElements = value; }
335     }
336     public TestDataElements Struct
337     {
338         get { return _testDataElements; }
339         set { _testDataElements = value; }
340     }
transportAny(Any value)341     public Any transportAny(Any value)
342     {
343         return value;
344     }
call(int nCallId , int nWaitMUSEC)345     public void call(int nCallId , int nWaitMUSEC)
346     {
347         Thread.Sleep(nWaitMUSEC / 10000);
348 
349         if(_bFirstCall)
350             _bFirstCall = false;
351 
352         else
353             _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
354 
355         _nLastCallId = nCallId;
356     }
callOneway( int nCallId , int nWaitMUSEC )357     public void callOneway( int nCallId , int nWaitMUSEC )
358     {
359         Thread.Sleep(nWaitMUSEC / 10000);
360 
361         _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
362         _nLastCallId = nCallId;
363     }
sequenceOfCallTestPassed()364     public bool sequenceOfCallTestPassed()
365     {
366         return _bSequenceOfCallTestPassed;
367     }
368     [MethodImpl( MethodImplOptions.Synchronized )]
callRecursivly( XRecursiveCall xCall, int nToCall )369     public void callRecursivly( XRecursiveCall xCall,   int nToCall )
370     {
371         lock (this)
372         {
373             if(nToCall != 0)
374             {
375                 nToCall --;
376                 xCall.callRecursivly(this , nToCall);
377             }
378         }
379     }
380     [MethodImpl( MethodImplOptions.Synchronized )]
startRecursiveCall( XRecursiveCall xCall, int nToCall )381     public void startRecursiveCall( XRecursiveCall xCall, int nToCall )
382     {
383         lock (this)
384         {
385             if(nToCall != 0)
386             {
387                 nToCall --;
388                 xCall.callRecursivly( this , nToCall );
389             }
390         }
391     }
392 
393     // XBridgeTest
raiseException( short nArgumentPos, String rMsg, Object xContext )394     public TestDataElements raiseException(
395         short nArgumentPos, String rMsg, Object xContext )
396     {
397         throw new IllegalArgumentException(rMsg, xContext, nArgumentPos);
398     }
raiseRuntimeExceptionOneway( String rMsg, Object xContext )399     public void raiseRuntimeExceptionOneway( String rMsg, Object xContext )
400     {
401         throw new RuntimeException(rMsg, xContext);
402     }
403 
dothrow( System.Exception e )404     private void dothrow( System.Exception e )
405     {
406         throw e;
407     }
408     public int RuntimeException
409     {
410         get {
411             try
412             {
413                 dothrow( new RuntimeException(_string, _xInterface) );
414                 return 0; // dummy
415             }
416             catch (System.Exception exc)
417             {
418                 throw exc;
419             }
420         }
421         set { throw new RuntimeException(_string, _xInterface); }
422     }
423 
424     // XBridgeTest2
setDim2(int[][] val)425     public int[][] setDim2(int[][] val)
426     {
427         _arLong2 = val;
428         return val;
429     }
430 
setDim3(int[][][] val)431     public int[][][] setDim3(int[][][] val)
432     {
433         _arLong3 = val;
434         return val;
435     }
436 
setSequenceAny(Any[] val)437     public Any[] setSequenceAny(Any[] val)
438     {
439         _arAny = val;
440         return val;
441     }
442 
setSequenceBool(bool[] val)443     public bool[] setSequenceBool(bool[] val)
444     {
445         _arBool = val;
446         return val;
447     }
448 
setSequenceByte(byte[] val)449     public byte[] setSequenceByte(byte[] val)
450     {
451         _arByte = val;
452         return val;
453     }
454 
setSequenceChar(char[] val)455     public char[] setSequenceChar(char[] val)
456     {
457         _arChar = val;
458         return val;
459     }
460 
setSequenceShort(short[] val)461     public short[] setSequenceShort(short[] val)
462     {
463         _arShort = val;
464         return val;
465     }
466 
setSequenceLong(int[] val)467     public int[] setSequenceLong(int[] val)
468     {
469         _arLong = val;
470         return val;
471     }
472 
setSequenceHyper(long[] val)473     public long[] setSequenceHyper(long[] val)
474     {
475         _arHyper = val;
476         return val;
477     }
478 
setSequenceFloat(float[] val)479     public float[] setSequenceFloat(float[] val)
480     {
481         _arFloat = val;
482         return val;
483     }
484 
setSequenceDouble(double[] val)485     public double[] setSequenceDouble(double[] val)
486     {
487         _arDouble = val;
488         return val;
489     }
490 
setSequenceEnum(TestEnum[] val)491     public TestEnum[] setSequenceEnum(TestEnum[] val)
492     {
493         _arEnum = val;
494         return val;
495     }
496 
setSequenceUShort(UInt16[] val)497     public UInt16[] setSequenceUShort(UInt16[] val)
498     {
499         _arUShort = val;
500         return val;
501     }
502 
setSequenceULong(UInt32[] val)503     public UInt32[] setSequenceULong(UInt32[] val)
504     {
505         _arULong = val;
506         return  val;
507     }
508 
setSequenceUHyper(UInt64[] val)509     public UInt64[] setSequenceUHyper(UInt64[] val)
510     {
511         _arUHyper = val;
512         return val;
513     }
514 
setSequenceXInterface(Object[] val)515     public Object[] setSequenceXInterface(Object[] val)
516     {
517         _arObject = val;
518         return val;
519     }
520 
setSequenceString(string[] val)521     public string[] setSequenceString(string[] val)
522     {
523         _arString = val;
524         return val;
525     }
526 
setSequenceStruct(TestElement[] val)527     public TestElement[] setSequenceStruct(TestElement[] val)
528     {
529         _testElements = val;
530         return val;
531     }
532 
setSequencesInOut(ref bool[] aSeqBoolean, ref char[] aSeqChar, ref byte[] aSeqByte, ref short[] aSeqShort, ref UInt16[] aSeqUShort, ref int[] aSeqLong, ref UInt32[] aSeqULong, ref long[] aSeqHyper, ref UInt64[] aSeqUHyper, ref float[] aSeqFloat, ref double[] aSeqDouble, ref TestEnum[] aSeqTestEnum, ref string[] aSeqString, ref object[] aSeqXInterface, ref Any[] aSeqAny, ref int[][] aSeqDim2, ref int[][][] aSeqDim3)533     public void setSequencesInOut(ref bool[] aSeqBoolean,
534                                ref char[] aSeqChar,
535                                ref byte[] aSeqByte,
536                                ref short[] aSeqShort,
537                                ref UInt16[] aSeqUShort,
538                                ref int[] aSeqLong,
539                                ref UInt32[] aSeqULong,
540                                ref long[] aSeqHyper,
541                                ref UInt64[] aSeqUHyper,
542                                ref float[] aSeqFloat,
543                                ref double[] aSeqDouble,
544                                ref TestEnum[] aSeqTestEnum,
545                                ref string[] aSeqString,
546                                ref object[] aSeqXInterface,
547                                ref Any[] aSeqAny,
548                                ref int[][] aSeqDim2,
549                                ref int[][][] aSeqDim3)
550     {
551         _arBool = aSeqBoolean;
552         _arChar = aSeqChar;
553         _arByte = aSeqByte;
554         _arShort = aSeqShort;
555         _arUShort = aSeqUShort;
556         _arLong = aSeqLong;
557         _arULong = aSeqULong;
558         _arHyper  = aSeqHyper;
559         _arUHyper = aSeqUHyper;
560         _arFloat = aSeqFloat;
561         _arDouble = aSeqDouble;
562         _arEnum = aSeqTestEnum;
563         _arString = aSeqString;
564         _arObject = aSeqXInterface;
565         _arAny = aSeqAny;
566         _arLong2 = aSeqDim2;
567         _arLong3 = aSeqDim3;
568     }
569 
setSequencesOut(out bool[] aSeqBoolean, out char[] aSeqChar, out byte[] aSeqByte, out short[] aSeqShort, out UInt16[] aSeqUShort, out int[] aSeqLong, out UInt32[] aSeqULong, out long[] aSeqHyper, out UInt64[] aSeqUHyper, out float[] aSeqFloat, out double[] aSeqDouble, out TestEnum[] aSeqTestEnum, out string[] aSeqString, out object[] aSeqXInterface, out Any[] aSeqAny, out int[][] aSeqDim2, out int[][][] aSeqDim3)570     public void setSequencesOut(out bool[] aSeqBoolean,
571                                out char[] aSeqChar,
572                                out byte[] aSeqByte,
573                                out short[] aSeqShort,
574                                out UInt16[] aSeqUShort,
575                                out int[] aSeqLong,
576                                out UInt32[] aSeqULong,
577                                out long[] aSeqHyper,
578                                out UInt64[] aSeqUHyper,
579                                out float[] aSeqFloat,
580                                out double[] aSeqDouble,
581                                out TestEnum[] aSeqTestEnum,
582                                out string[] aSeqString,
583                                out object[] aSeqXInterface,
584                                out Any[] aSeqAny,
585                                out int[][] aSeqDim2,
586                                out int[][][] aSeqDim3)
587     {
588         aSeqBoolean = _arBool;
589         aSeqChar = _arChar;
590         aSeqByte = _arByte;
591         aSeqShort = _arShort;
592         aSeqUShort = _arUShort;
593         aSeqLong = _arLong;
594         aSeqULong = _arULong;
595         aSeqHyper = _arHyper;
596         aSeqUHyper = _arUHyper;
597         aSeqFloat = _arFloat;
598         aSeqDouble = _arDouble;
599         aSeqTestEnum = _arEnum;
600         aSeqString = _arString;
601         aSeqXInterface = _arObject;
602         aSeqAny = _arAny;
603         aSeqDim2 = _arLong2;
604         aSeqDim3 = _arLong3;
605 
606     }
607 
608     /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
609      * which do not occur when running normally (Visual Studio 2003)
610      */
testConstructorsService(XComponentContext context)611     public void testConstructorsService(XComponentContext context)
612 	{
613 		Constructors.create1(context,
614 			true,
615 			0x80, // -128 in C++,
616 			Int16.MinValue,
617 			UInt16.MaxValue,
618 			Int32.MinValue,
619 			UInt32.MaxValue,
620 			Int64.MinValue,
621 			UInt64.MaxValue,
622 			0.123f,
623 			0.456,
624 			'X',
625 			"test",
626 			typeof(Any),
627 			new Any(true),
628 			new bool[] { true },
629 			new byte[] { 0x80}, // in C++ the value is compared with SAL_MIN_INT8 which is -128
630 			new short[] { Int16.MinValue },
631 			new UInt16[] { UInt16.MaxValue },
632 			new Int32[] {Int32.MinValue},
633 			new UInt32[] { UInt32.MaxValue },
634 			new long[] { Int64.MinValue },
635 			new UInt64[] { UInt64.MaxValue },
636 			new float[] { 0.123f },
637 			new double[] { 0.456 },
638 			new char[] { 'X' },
639 			new string[] { "test" },
640 			new Type[] { typeof(Any) },
641 			new Any[] { new Any(true) },
642 			new bool[][] { new bool[] { true } },
643 			new Any[][] { new Any[] { new Any(true) } },
644 			new TestEnum[] { TestEnum.TWO },
645 			new TestStruct[] { new TestStruct(10) },
646 			new TestPolyStruct[] { new TestPolyStruct(true) },
647 			new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
648 			new object[] { null },
649 			TestEnum.TWO,
650 			new TestStruct(10),
651 			new TestPolyStruct(true),
652 			new TestPolyStruct(new Any(true)),
653 			null
654 			);
655 
656 	Constructors.create2(context,
657              new Any(true),
658              new Any((System.Byte) 0x80),
659              new Any(Int16.MinValue),
660              new Any(UInt16.MaxValue),
661              new Any(Int32.MinValue),
662              new Any(UInt32.MaxValue),
663              new Any(Int64.MinValue),
664              new Any(UInt64.MaxValue),
665              new Any(0.123f),
666              new Any(0.456),
667              new Any('X'),
668              new Any("test"),
669              new Any(typeof(Any)),
670              new Any(true),
671              new Any(typeof(bool[]), new bool[] { true }),
672              new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80}),
673              new Any(typeof(short[]), new short[] { Int16.MinValue }),
674              new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
675              new Any(typeof(int[]), new int[] { Int32.MinValue }),
676              new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
677              new Any(typeof(long[]), new long[] { Int64.MinValue }),
678              new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
679              new Any(typeof(float[]), new float[] { 0.123f }),
680              new Any(typeof(double[]), new double[] { 0.456 }),
681              new Any(typeof(char[]), new char[] { 'X' }),
682              new Any(typeof(string[]), new string[] { "test" }),
683              new Any(typeof(Type[]), new Type[] { typeof(Any) }),
684              new Any(typeof(Any[]), new Any[] { new Any(true) }),
685              new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
686              new Any(
687                  typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
688              new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
689              new Any(
690                  typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
691              new Any(
692                  PolymorphicType.GetType(
693                      typeof(TestPolyStruct[]),
694                      "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
695                  new TestPolyStruct[] { new TestPolyStruct(true) }) ,
696              new Any(
697                  PolymorphicType.GetType(
698                      typeof(TestPolyStruct[]),
699                      "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
700                  new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
701              new Any(typeof(object[])/*TODO*/, new object[] { null }),
702              new Any(typeof(TestEnum), TestEnum.TWO),
703              new Any(typeof(TestStruct), new TestStruct(10)),
704              new Any(
705                  PolymorphicType.GetType(
706                      typeof(TestPolyStruct),
707                      "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
708                  new TestPolyStruct(true)),
709              new Any(
710                  PolymorphicType.GetType(
711                      typeof(TestPolyStruct),
712                      "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
713                  new TestPolyStruct(new Any(true))),
714              new Any(typeof(object), null)
715 		);
716 
717 
718     XMultiBase1 xMulti = Constructors2.create1(
719             context,
720             new TestPolyStruct(typeof(int)),
721             new TestPolyStruct(new Any(true)),
722             new TestPolyStruct(true),
723             new TestPolyStruct((Byte) 0x80),
724             new TestPolyStruct(Int16.MinValue),
725             new TestPolyStruct(Int32.MinValue),
726             new TestPolyStruct(Int64.MinValue),
727             new TestPolyStruct('X'),
728             new TestPolyStruct("test"),
729             new TestPolyStruct(0.123f),
730             new TestPolyStruct(0.456d),
731             new TestPolyStruct(new object()),
732             new TestPolyStruct(new uno.util.WeakComponentBase()),
733             new TestPolyStruct(TestEnum.TWO),
734             new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
735             new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
736             new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
737             new TestPolyStruct2( new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
738             new TestPolyStruct(new Type[] { typeof(int)}),
739             new TestPolyStruct(new Any[] { new Any(true) }),
740             new TestPolyStruct(new bool[] {true}),
741             new TestPolyStruct(new byte[] {0x80}),
742             new TestPolyStruct(new short[] {Int16.MinValue}),
743             new TestPolyStruct(new int[] {Int32.MinValue}),
744             new TestPolyStruct(new long[] {Int64.MinValue}),
745             new TestPolyStruct(new char[] {'X'}),
746             new TestPolyStruct(new string[] {"test"}),
747             new TestPolyStruct(new float[] {0.123f}),
748             new TestPolyStruct(new double[] {0.456d}),
749             new TestPolyStruct(new object[] {new object()}),
750             new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] {new uno.util.WeakComponentBase()}),
751             new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
752             new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2('X', new Any[] {new Any(true)})}),
753             new TestPolyStruct(new TestPolyStruct2[] {
754                 new TestPolyStruct2(new TestPolyStruct('X'), new Any[] {new Any(true)})}),
755             new TestPolyStruct(new int[][] { new int[] {Int32.MinValue} }),
756             new TestPolyStruct[]{ new TestPolyStruct(Int32.MinValue)},
757             new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))},
758             new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test"))},
759             new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true))))},
760             new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)),new TestPolyStruct('X'))},
761             new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct('X')}},
762             new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))}},
763             new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)), "test"))}},
764             new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X',new TestPolyStruct(new Any(true))))}},
765             new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)),new TestPolyStruct('X'))}}
766             );
767 
768     //test the returned interface
769     xMulti.fn11(1);
770 
771 
772     }
773 
getCurrentContextChecker()774     public XCurrentContextChecker getCurrentContextChecker()
775     {
776         return null; //TODO: not yet tested in CLI UNO
777     }
778 
transportPolyBoolean( TestPolyStruct arg)779     public TestPolyStruct transportPolyBoolean(/*[in]*/TestPolyStruct arg)
780     {
781         return arg;
782     }
783 
transportPolyHyper( ref TestPolyStruct arg)784     public  void  transportPolyHyper(/*[in][out]*/ ref TestPolyStruct arg)
785     {
786     }
787 
transportPolySequence(TestPolyStruct arg1, out TestPolyStruct arg2)788     public void  transportPolySequence(TestPolyStruct arg1,
789                                        out TestPolyStruct arg2)
790     {
791         arg2 = arg1;
792     }
793 
getNullPolyBadEnum()794     public TestPolyStruct getNullPolyBadEnum()
795     {
796         return new TestPolyStruct(unoidl.test.testtools.bridgetest.TestBadEnum.M);
797     }
798 
getNullPolyLong()799     public TestPolyStruct getNullPolyLong()
800     {
801         return new TestPolyStruct();
802     }
803 
getNullPolyString()804     public TestPolyStruct getNullPolyString()
805     {
806         return new TestPolyStruct();
807     }
808 
getNullPolyType()809     public TestPolyStruct getNullPolyType()
810     {
811         return new TestPolyStruct();
812     }
813 
getNullPolyAny()814     public TestPolyStruct getNullPolyAny()
815     {
816         return new TestPolyStruct();
817     }
818 
getNullPolySequence()819     public TestPolyStruct getNullPolySequence()
820     {
821         return new TestPolyStruct();
822     }
823 
getNullPolyEnum()824     public TestPolyStruct getNullPolyEnum()
825     {
826         return new TestPolyStruct();
827     }
828 
getNullPolyStruct()829     public TestPolyStruct getNullPolyStruct()
830     {
831         return new TestPolyStruct();
832     }
833 
getNullPolyInterface()834     public TestPolyStruct getNullPolyInterface()
835     {
836         return new TestPolyStruct();
837     }
838 
getMulti()839     public XMulti getMulti()
840     {
841         return new testtools.bridgetest.cli_cs.Multi();
842     }
843 
checkEqual(int value, int argument)844     private static void checkEqual(int value, int argument) {
845         if (argument != value) {
846             throw new CheckFailed(value + " != " + argument);
847         }
848     }
849 
checkEqual(double value, double argument)850     private static void checkEqual(double value, double argument) {
851         if (argument != value) {
852             throw new CheckFailed(value + " != " + argument);
853         }
854     }
855 
checkEqual(string value, string argument)856     private static void checkEqual(string value, string argument) {
857         if (argument != value) {
858             throw new CheckFailed(value + " != " + argument);
859         }
860     }
861 
testMulti(XMulti multi)862     public string testMulti(XMulti multi)
863     {
864         try {
865             checkEqual(0.0, multi.att1);
866             multi.att1 = 0.1;
867             checkEqual(0.1, multi.att1);
868             checkEqual(11 * 1, multi.fn11(1));
869             checkEqual("12" + "abc", multi.fn12("abc"));
870             checkEqual(21 * 2, multi.fn21(2));
871             checkEqual("22" + "de", multi.fn22("de"));
872             checkEqual(0.0, multi.att3);
873             multi.att3 = 0.3;
874             checkEqual(0.3, multi.att3);
875             checkEqual(31 * 3, multi.fn31(3));
876             checkEqual("32" + "f", multi.fn32("f"));
877             checkEqual(33, multi.fn33());
878             checkEqual(41 * 4, multi.fn41(4));
879             checkEqual(61 * 6, multi.fn61(6));
880             checkEqual("62" + "", multi.fn62(""));
881             checkEqual(71 * 7, multi.fn71(7));
882             checkEqual("72" + "g", multi.fn72("g"));
883             checkEqual(73, multi.fn73());
884         } catch (CheckFailed f) {
885             return f.Message;
886         }
887         return "";
888     }
889 
890     public int RaiseAttr1
891     {
892         get { throw new RuntimeException(); }
893         set { throw new IllegalArgumentException(); }
894     }
895 
896     public int RaiseAttr2
897     {
898         get { throw new IllegalArgumentException(); }
899         set { throw new IllegalArgumentException(); }
900     }
901 
902 
903 }
904 
905 }
906