xref: /AOO42X/main/testtools/source/bridgetest/cli/cli_cs_testobj.cs (revision a230972184deb427a995e0eb922a5743673d1d16)
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 
echoTwoFloats( TwoFloats arg)243     public TwoFloats echoTwoFloats(/*[in]*/TwoFloats arg)
244     {
245         return arg;
246     }
247 
echoThreeDoubles( ThreeDoubles arg)248     public ThreeDoubles echoThreeDoubles(/*[in]*/ThreeDoubles arg)
249     {
250         return arg;
251     }
252 
echoMixedFloatLong( MixedFloatLong arg)253     public MixedFloatLong echoMixedFloatLong(/*[in]*/MixedFloatLong arg)
254     {
255         return arg;
256     }
257 
echoOneByte( OneByte arg)258     public OneByte echoOneByte(/*[in]*/OneByte arg)
259     {
260         return arg;
261     }
262 
echoThreeLongs( ThreeLongs arg)263     public ThreeLongs echoThreeLongs(/*[in]*/ThreeLongs arg)
264     {
265         return arg;
266     }
267 
testPPCAlignment( long l1, long l2, int i1, long l3, int i2 )268     public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 )
269     {
270         return i2;
271     }
272 
273     // UNO byte maps to the unsigned System.Byte here, so the signed terms are
274     // recovered with an sbyte cast to match the other language bindings.
testPackedStack( long a0, long a1, long a2, long a3, long a4, long a5, long a6, byte b, byte c, short s, int l, byte d, long h )275     public long testPackedStack( long a0, long a1, long a2, long a3, long a4, long a5, long a6,
276                                  byte b, byte c, short s, int l, byte d, long h )
277     {
278         return ((((long)(sbyte)b) << 56) |
279                 (((long)c) << 48) |
280                 (((long)(ushort)s) << 32) |
281                 ((long)(uint)l)) ^
282                 (((long)(sbyte)d) << 24) ^ h;
283     }
284 
testFpStack( double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, float f8, double d9 )285     public double testFpStack( double a0, double a1, double a2, double a3, double a4,
286                                double a5, double a6, double a7, float f8, double d9 )
287     {
288         return (double)f8 + d9;
289     }
290 
291     // Attributes
292     public bool Bool
293     {
294         get { return _bool; }
295         set { _bool = value; }
296     }
297     public byte Byte
298     {
299         get { return _byte; }
300         set { _byte = value; }
301     }
302     public char Char
303     {
304         get { return _char; }
305         set { _char = value; }
306     }
307     public short Short
308     {
309         get { return _short; }
310         set { _short = value; }
311     }
312     public ushort UShort
313     {
314         get { return _ushort; }
315         set { _ushort = value; }
316     }
317     public int Long
318     {
319         get { return _long; }
320         set { _long = value; }
321     }
322     public uint ULong
323     {
324         get { return _ulong; }
325         set { _ulong = value; }
326     }
327     public long Hyper
328     {
329         get { return _hyper; }
330         set { _hyper = value; }
331     }
332     public ulong UHyper
333     {
334         get { return _uhyper; }
335         set { _uhyper = value; }
336     }
337     public float Float
338     {
339         get { return _float; }
340         set { _float = value; }
341     }
342     public double Double
343     {
344         get { return _double; }
345         set { _double = value; }
346     }
347     public TestEnum Enum
348     {
349         get { return _testEnum; }
350         set { _testEnum = value; }
351     }
352     public String String
353     {
354         get { return _string; }
355         set { _string = value; }
356     }
357     public Object Interface
358     {
359         get { return _xInterface; }
360         set { _xInterface = value; }
361     }
362     public uno.Any Any
363     {
364         get {
365 
366             Debug.WriteLine( "##### " + GetType().FullName + ".Any" );
367             return _any;
368         }
369         set {
370             Debug.WriteLine( "##### " + GetType().FullName + ".Any:" + value );
371             _any = value;
372         }
373     }
374     public TestElement [] Sequence
375     {
376         get { return _testElements; }
377         set { _testElements = value; }
378     }
379     public TestDataElements Struct
380     {
381         get { return _testDataElements; }
382         set { _testDataElements = value; }
383     }
transportAny(Any value)384     public Any transportAny(Any value)
385     {
386         return value;
387     }
call(int nCallId , int nWaitMUSEC)388     public void call(int nCallId , int nWaitMUSEC)
389     {
390         Thread.Sleep(nWaitMUSEC / 10000);
391 
392         if(_bFirstCall)
393             _bFirstCall = false;
394 
395         else
396             _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
397 
398         _nLastCallId = nCallId;
399     }
callOneway( int nCallId , int nWaitMUSEC )400     public void callOneway( int nCallId , int nWaitMUSEC )
401     {
402         Thread.Sleep(nWaitMUSEC / 10000);
403 
404         _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
405         _nLastCallId = nCallId;
406     }
sequenceOfCallTestPassed()407     public bool sequenceOfCallTestPassed()
408     {
409         return _bSequenceOfCallTestPassed;
410     }
411     [MethodImpl( MethodImplOptions.Synchronized )]
callRecursivly( XRecursiveCall xCall, int nToCall )412     public void callRecursivly( XRecursiveCall xCall,   int nToCall )
413     {
414         lock (this)
415         {
416             if(nToCall != 0)
417             {
418                 nToCall --;
419                 xCall.callRecursivly(this , nToCall);
420             }
421         }
422     }
423     [MethodImpl( MethodImplOptions.Synchronized )]
startRecursiveCall( XRecursiveCall xCall, int nToCall )424     public void startRecursiveCall( XRecursiveCall xCall, int nToCall )
425     {
426         lock (this)
427         {
428             if(nToCall != 0)
429             {
430                 nToCall --;
431                 xCall.callRecursivly( this , nToCall );
432             }
433         }
434     }
435 
436     // XBridgeTest
raiseException( short nArgumentPos, String rMsg, Object xContext )437     public TestDataElements raiseException(
438         short nArgumentPos, String rMsg, Object xContext )
439     {
440         throw new IllegalArgumentException(rMsg, xContext, nArgumentPos);
441     }
raiseRuntimeExceptionOneway( String rMsg, Object xContext )442     public void raiseRuntimeExceptionOneway( String rMsg, Object xContext )
443     {
444         throw new RuntimeException(rMsg, xContext);
445     }
446 
dothrow( System.Exception e )447     private void dothrow( System.Exception e )
448     {
449         throw e;
450     }
451     public int RuntimeException
452     {
453         get {
454             try
455             {
456                 dothrow( new RuntimeException(_string, _xInterface) );
457                 return 0; // dummy
458             }
459             catch (System.Exception exc)
460             {
461                 throw exc;
462             }
463         }
464         set { throw new RuntimeException(_string, _xInterface); }
465     }
466 
467     // XBridgeTest2
setDim2(int[][] val)468     public int[][] setDim2(int[][] val)
469     {
470         _arLong2 = val;
471         return val;
472     }
473 
setDim3(int[][][] val)474     public int[][][] setDim3(int[][][] val)
475     {
476         _arLong3 = val;
477         return val;
478     }
479 
setSequenceAny(Any[] val)480     public Any[] setSequenceAny(Any[] val)
481     {
482         _arAny = val;
483         return val;
484     }
485 
setSequenceBool(bool[] val)486     public bool[] setSequenceBool(bool[] val)
487     {
488         _arBool = val;
489         return val;
490     }
491 
setSequenceByte(byte[] val)492     public byte[] setSequenceByte(byte[] val)
493     {
494         _arByte = val;
495         return val;
496     }
497 
setSequenceChar(char[] val)498     public char[] setSequenceChar(char[] val)
499     {
500         _arChar = val;
501         return val;
502     }
503 
setSequenceShort(short[] val)504     public short[] setSequenceShort(short[] val)
505     {
506         _arShort = val;
507         return val;
508     }
509 
setSequenceLong(int[] val)510     public int[] setSequenceLong(int[] val)
511     {
512         _arLong = val;
513         return val;
514     }
515 
setSequenceHyper(long[] val)516     public long[] setSequenceHyper(long[] val)
517     {
518         _arHyper = val;
519         return val;
520     }
521 
setSequenceFloat(float[] val)522     public float[] setSequenceFloat(float[] val)
523     {
524         _arFloat = val;
525         return val;
526     }
527 
setSequenceDouble(double[] val)528     public double[] setSequenceDouble(double[] val)
529     {
530         _arDouble = val;
531         return val;
532     }
533 
setSequenceEnum(TestEnum[] val)534     public TestEnum[] setSequenceEnum(TestEnum[] val)
535     {
536         _arEnum = val;
537         return val;
538     }
539 
setSequenceUShort(UInt16[] val)540     public UInt16[] setSequenceUShort(UInt16[] val)
541     {
542         _arUShort = val;
543         return val;
544     }
545 
setSequenceULong(UInt32[] val)546     public UInt32[] setSequenceULong(UInt32[] val)
547     {
548         _arULong = val;
549         return  val;
550     }
551 
setSequenceUHyper(UInt64[] val)552     public UInt64[] setSequenceUHyper(UInt64[] val)
553     {
554         _arUHyper = val;
555         return val;
556     }
557 
setSequenceXInterface(Object[] val)558     public Object[] setSequenceXInterface(Object[] val)
559     {
560         _arObject = val;
561         return val;
562     }
563 
setSequenceString(string[] val)564     public string[] setSequenceString(string[] val)
565     {
566         _arString = val;
567         return val;
568     }
569 
setSequenceStruct(TestElement[] val)570     public TestElement[] setSequenceStruct(TestElement[] val)
571     {
572         _testElements = val;
573         return val;
574     }
575 
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)576     public void setSequencesInOut(ref bool[] aSeqBoolean,
577                                ref char[] aSeqChar,
578                                ref byte[] aSeqByte,
579                                ref short[] aSeqShort,
580                                ref UInt16[] aSeqUShort,
581                                ref int[] aSeqLong,
582                                ref UInt32[] aSeqULong,
583                                ref long[] aSeqHyper,
584                                ref UInt64[] aSeqUHyper,
585                                ref float[] aSeqFloat,
586                                ref double[] aSeqDouble,
587                                ref TestEnum[] aSeqTestEnum,
588                                ref string[] aSeqString,
589                                ref object[] aSeqXInterface,
590                                ref Any[] aSeqAny,
591                                ref int[][] aSeqDim2,
592                                ref int[][][] aSeqDim3)
593     {
594         _arBool = aSeqBoolean;
595         _arChar = aSeqChar;
596         _arByte = aSeqByte;
597         _arShort = aSeqShort;
598         _arUShort = aSeqUShort;
599         _arLong = aSeqLong;
600         _arULong = aSeqULong;
601         _arHyper  = aSeqHyper;
602         _arUHyper = aSeqUHyper;
603         _arFloat = aSeqFloat;
604         _arDouble = aSeqDouble;
605         _arEnum = aSeqTestEnum;
606         _arString = aSeqString;
607         _arObject = aSeqXInterface;
608         _arAny = aSeqAny;
609         _arLong2 = aSeqDim2;
610         _arLong3 = aSeqDim3;
611     }
612 
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)613     public void setSequencesOut(out bool[] aSeqBoolean,
614                                out char[] aSeqChar,
615                                out byte[] aSeqByte,
616                                out short[] aSeqShort,
617                                out UInt16[] aSeqUShort,
618                                out int[] aSeqLong,
619                                out UInt32[] aSeqULong,
620                                out long[] aSeqHyper,
621                                out UInt64[] aSeqUHyper,
622                                out float[] aSeqFloat,
623                                out double[] aSeqDouble,
624                                out TestEnum[] aSeqTestEnum,
625                                out string[] aSeqString,
626                                out object[] aSeqXInterface,
627                                out Any[] aSeqAny,
628                                out int[][] aSeqDim2,
629                                out int[][][] aSeqDim3)
630     {
631         aSeqBoolean = _arBool;
632         aSeqChar = _arChar;
633         aSeqByte = _arByte;
634         aSeqShort = _arShort;
635         aSeqUShort = _arUShort;
636         aSeqLong = _arLong;
637         aSeqULong = _arULong;
638         aSeqHyper = _arHyper;
639         aSeqUHyper = _arUHyper;
640         aSeqFloat = _arFloat;
641         aSeqDouble = _arDouble;
642         aSeqTestEnum = _arEnum;
643         aSeqString = _arString;
644         aSeqXInterface = _arObject;
645         aSeqAny = _arAny;
646         aSeqDim2 = _arLong2;
647         aSeqDim3 = _arLong3;
648 
649     }
650 
651     /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
652      * which do not occur when running normally (Visual Studio 2003)
653      */
testConstructorsService(XComponentContext context)654     public void testConstructorsService(XComponentContext context)
655     {
656         Constructors.create1(context,
657             true,
658             0x80, // -128 in C++,
659             Int16.MinValue,
660             UInt16.MaxValue,
661             Int32.MinValue,
662             UInt32.MaxValue,
663             Int64.MinValue,
664             UInt64.MaxValue,
665             0.123f,
666             0.456,
667             'X',
668             "test",
669             typeof(Any),
670             new Any(true),
671             new bool[] { true },
672             new byte[] { 0x80}, // in C++ the value is compared with SAL_MIN_INT8 which is -128
673             new short[] { Int16.MinValue },
674             new UInt16[] { UInt16.MaxValue },
675             new Int32[] {Int32.MinValue},
676             new UInt32[] { UInt32.MaxValue },
677             new long[] { Int64.MinValue },
678             new UInt64[] { UInt64.MaxValue },
679             new float[] { 0.123f },
680             new double[] { 0.456 },
681             new char[] { 'X' },
682             new string[] { "test" },
683             new Type[] { typeof(Any) },
684             new Any[] { new Any(true) },
685             new bool[][] { new bool[] { true } },
686             new Any[][] { new Any[] { new Any(true) } },
687             new TestEnum[] { TestEnum.TWO },
688             new TestStruct[] { new TestStruct(10) },
689             new TestPolyStruct[] { new TestPolyStruct(true) },
690             new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
691             new object[] { null },
692             TestEnum.TWO,
693             new TestStruct(10),
694             new TestPolyStruct(true),
695             new TestPolyStruct(new Any(true)),
696             null
697             );
698 
699     Constructors.create2(context,
700              new Any(true),
701              new Any((System.Byte) 0x80),
702              new Any(Int16.MinValue),
703              new Any(UInt16.MaxValue),
704              new Any(Int32.MinValue),
705              new Any(UInt32.MaxValue),
706              new Any(Int64.MinValue),
707              new Any(UInt64.MaxValue),
708              new Any(0.123f),
709              new Any(0.456),
710              new Any('X'),
711              new Any("test"),
712              new Any(typeof(Any)),
713              new Any(true),
714              new Any(typeof(bool[]), new bool[] { true }),
715              new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80}),
716              new Any(typeof(short[]), new short[] { Int16.MinValue }),
717              new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
718              new Any(typeof(int[]), new int[] { Int32.MinValue }),
719              new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
720              new Any(typeof(long[]), new long[] { Int64.MinValue }),
721              new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
722              new Any(typeof(float[]), new float[] { 0.123f }),
723              new Any(typeof(double[]), new double[] { 0.456 }),
724              new Any(typeof(char[]), new char[] { 'X' }),
725              new Any(typeof(string[]), new string[] { "test" }),
726              new Any(typeof(Type[]), new Type[] { typeof(Any) }),
727              new Any(typeof(Any[]), new Any[] { new Any(true) }),
728              new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
729              new Any(
730                  typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
731              new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
732              new Any(
733                  typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
734              new Any(
735                  PolymorphicType.GetType(
736                      typeof(TestPolyStruct[]),
737                      "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
738                  new TestPolyStruct[] { new TestPolyStruct(true) }) ,
739              new Any(
740                  PolymorphicType.GetType(
741                      typeof(TestPolyStruct[]),
742                      "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
743                  new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
744              new Any(typeof(object[])/*TODO*/, new object[] { null }),
745              new Any(typeof(TestEnum), TestEnum.TWO),
746              new Any(typeof(TestStruct), new TestStruct(10)),
747              new Any(
748                  PolymorphicType.GetType(
749                      typeof(TestPolyStruct),
750                      "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
751                  new TestPolyStruct(true)),
752              new Any(
753                  PolymorphicType.GetType(
754                      typeof(TestPolyStruct),
755                      "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
756                  new TestPolyStruct(new Any(true))),
757              new Any(typeof(object), null)
758         );
759 
760 
761     XMultiBase1 xMulti = Constructors2.create1(
762             context,
763             new TestPolyStruct(typeof(int)),
764             new TestPolyStruct(new Any(true)),
765             new TestPolyStruct(true),
766             new TestPolyStruct((Byte) 0x80),
767             new TestPolyStruct(Int16.MinValue),
768             new TestPolyStruct(Int32.MinValue),
769             new TestPolyStruct(Int64.MinValue),
770             new TestPolyStruct('X'),
771             new TestPolyStruct("test"),
772             new TestPolyStruct(0.123f),
773             new TestPolyStruct(0.456d),
774             new TestPolyStruct(new object()),
775             new TestPolyStruct(new uno.util.WeakComponentBase()),
776             new TestPolyStruct(TestEnum.TWO),
777             new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
778             new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
779             new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
780             new TestPolyStruct2( new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
781             new TestPolyStruct(new Type[] { typeof(int)}),
782             new TestPolyStruct(new Any[] { new Any(true) }),
783             new TestPolyStruct(new bool[] {true}),
784             new TestPolyStruct(new byte[] {0x80}),
785             new TestPolyStruct(new short[] {Int16.MinValue}),
786             new TestPolyStruct(new int[] {Int32.MinValue}),
787             new TestPolyStruct(new long[] {Int64.MinValue}),
788             new TestPolyStruct(new char[] {'X'}),
789             new TestPolyStruct(new string[] {"test"}),
790             new TestPolyStruct(new float[] {0.123f}),
791             new TestPolyStruct(new double[] {0.456d}),
792             new TestPolyStruct(new object[] {new object()}),
793             new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] {new uno.util.WeakComponentBase()}),
794             new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
795             new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2('X', new Any[] {new Any(true)})}),
796             new TestPolyStruct(new TestPolyStruct2[] {
797                 new TestPolyStruct2(new TestPolyStruct('X'), new Any[] {new Any(true)})}),
798             new TestPolyStruct(new int[][] { new int[] {Int32.MinValue} }),
799             new TestPolyStruct[]{ new TestPolyStruct(Int32.MinValue)},
800             new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))},
801             new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test"))},
802             new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true))))},
803             new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)),new TestPolyStruct('X'))},
804             new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct('X')}},
805             new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))}},
806             new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)), "test"))}},
807             new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X',new TestPolyStruct(new Any(true))))}},
808             new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)),new TestPolyStruct('X'))}}
809             );
810 
811     //test the returned interface
812     xMulti.fn11(1);
813 
814 
815     }
816 
getCurrentContextChecker()817     public XCurrentContextChecker getCurrentContextChecker()
818     {
819         return null; //TODO: not yet tested in CLI UNO
820     }
821 
transportPolyBoolean( TestPolyStruct arg)822     public TestPolyStruct transportPolyBoolean(/*[in]*/TestPolyStruct arg)
823     {
824         return arg;
825     }
826 
transportPolyHyper( ref TestPolyStruct arg)827     public  void  transportPolyHyper(/*[in][out]*/ ref TestPolyStruct arg)
828     {
829     }
830 
transportPolySequence(TestPolyStruct arg1, out TestPolyStruct arg2)831     public void  transportPolySequence(TestPolyStruct arg1,
832                                        out TestPolyStruct arg2)
833     {
834         arg2 = arg1;
835     }
836 
getNullPolyBadEnum()837     public TestPolyStruct getNullPolyBadEnum()
838     {
839         return new TestPolyStruct(unoidl.test.testtools.bridgetest.TestBadEnum.M);
840     }
841 
getNullPolyLong()842     public TestPolyStruct getNullPolyLong()
843     {
844         return new TestPolyStruct();
845     }
846 
getNullPolyString()847     public TestPolyStruct getNullPolyString()
848     {
849         return new TestPolyStruct();
850     }
851 
getNullPolyType()852     public TestPolyStruct getNullPolyType()
853     {
854         return new TestPolyStruct();
855     }
856 
getNullPolyAny()857     public TestPolyStruct getNullPolyAny()
858     {
859         return new TestPolyStruct();
860     }
861 
getNullPolySequence()862     public TestPolyStruct getNullPolySequence()
863     {
864         return new TestPolyStruct();
865     }
866 
getNullPolyEnum()867     public TestPolyStruct getNullPolyEnum()
868     {
869         return new TestPolyStruct();
870     }
871 
getNullPolyStruct()872     public TestPolyStruct getNullPolyStruct()
873     {
874         return new TestPolyStruct();
875     }
876 
getNullPolyInterface()877     public TestPolyStruct getNullPolyInterface()
878     {
879         return new TestPolyStruct();
880     }
881 
getMulti()882     public XMulti getMulti()
883     {
884         return new testtools.bridgetest.cli_cs.Multi();
885     }
886 
checkEqual(int value, int argument)887     private static void checkEqual(int value, int argument) {
888         if (argument != value) {
889             throw new CheckFailed(value + " != " + argument);
890         }
891     }
892 
checkEqual(double value, double argument)893     private static void checkEqual(double value, double argument) {
894         if (argument != value) {
895             throw new CheckFailed(value + " != " + argument);
896         }
897     }
898 
checkEqual(string value, string argument)899     private static void checkEqual(string value, string argument) {
900         if (argument != value) {
901             throw new CheckFailed(value + " != " + argument);
902         }
903     }
904 
testMulti(XMulti multi)905     public string testMulti(XMulti multi)
906     {
907         try {
908             checkEqual(0.0, multi.att1);
909             multi.att1 = 0.1;
910             checkEqual(0.1, multi.att1);
911             checkEqual(11 * 1, multi.fn11(1));
912             checkEqual("12" + "abc", multi.fn12("abc"));
913             checkEqual(21 * 2, multi.fn21(2));
914             checkEqual("22" + "de", multi.fn22("de"));
915             checkEqual(0.0, multi.att3);
916             multi.att3 = 0.3;
917             checkEqual(0.3, multi.att3);
918             checkEqual(31 * 3, multi.fn31(3));
919             checkEqual("32" + "f", multi.fn32("f"));
920             checkEqual(33, multi.fn33());
921             checkEqual(41 * 4, multi.fn41(4));
922             checkEqual(61 * 6, multi.fn61(6));
923             checkEqual("62" + "", multi.fn62(""));
924             checkEqual(71 * 7, multi.fn71(7));
925             checkEqual("72" + "g", multi.fn72("g"));
926             checkEqual(73, multi.fn73());
927         } catch (CheckFailed f) {
928             return f.Message;
929         }
930         return "";
931     }
932 
933     public int RaiseAttr1
934     {
935         get { throw new RuntimeException(); }
936         set { throw new IllegalArgumentException(); }
937     }
938 
939     public int RaiseAttr2
940     {
941         get { throw new IllegalArgumentException(); }
942         set { throw new IllegalArgumentException(); }
943     }
944 
945 
946 }
947 
948 }
949