Python clr.StrongBox() Examples

The following are 30 code examples of clr.StrongBox(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module clr , or try the search function .
Example #1
Source File: InOutParams.py    From ironpython2 with Apache License 2.0 7 votes vote down vote up
def test_ref_params():
    f1 = 3.5;
    a = StrongBox[float](f1)
    com_obj.mSingleRefParam(a)
    AreEqual(a.Value, f1+ 2)
    
    com_obj.mSingleRefParam(5.2)    
    	
    str1 = "a"
    a = StrongBox[str](str1)
    b = StrongBox[object](com_obj)
    com_obj.mTwoRefParams(a,b)
    AreEqual(a.Value, "a")
    AreEqual(b.Value, com_obj)
    
#Try passing null to methods which accept pointers. TypeError should be thrown for all except strings 
Example #2
Source File: test_cliclass.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_iterator_dispose(self):
        # getting an enumerator from an enumerable should dispose the new enumerator
        from IronPythonTest import EnumerableTest, MyEnumerator
        box = clr.StrongBox[bool](False)
        ietest = EnumerableTest(box)
        for x in ietest:
            pass
            
        self.assertEqual(box.Value, True)
        
        # enumerating on an enumerator shouldn't dispose the box
        box = clr.StrongBox[bool](False)
        ietest = MyEnumerator(box)
        for x in ietest:
            pass
            
        self.assertEqual(box.Value, False) 
Example #3
Source File: test_cliclass.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_iterator_dispose(self):
        # getting an enumerator from an enumerable should dispose the new enumerator
        from IronPythonTest import EnumerableTest, MyEnumerator
        box = clr.StrongBox[bool](False)
        ietest = EnumerableTest(box)
        for x in ietest:
            pass
            
        self.assertEqual(box.Value, True)
        
        # enumerating on an enumerator shouldn't dispose the box
        box = clr.StrongBox[bool](False)
        ietest = MyEnumerator(box)
        for x in ietest:
            pass
            
        self.assertEqual(box.Value, False) 
Example #4
Source File: InOutParams.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_ref_params():
    f1 = 3.5;
    a = StrongBox[float](f1)
    com_obj.mSingleRefParam(a)
    AreEqual(a.Value, f1+ 2)
    
    com_obj.mSingleRefParam(5.2)    
    	
    str1 = "a"
    a = StrongBox[str](str1)
    b = StrongBox[object](com_obj)
    com_obj.mTwoRefParams(a,b)
    AreEqual(a.Value, "a")
    AreEqual(b.Value, com_obj)
    
#Try passing null to methods which accept pointers. TypeError should be thrown for all except strings 
Example #5
Source File: paramsinretval.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_sanity_int_types_broken():
    a = StrongBox[ErrorWrapper](ErrorWrapper(System.Int32.MinValue))
    AreEqual(com_obj.mScode(a), System.Int32.MinValue)
    
    a = ErrorWrapper(5)
    AreEqual(com_obj.mScode(a), 5)
    
    AssertErrorWithMessage(ValueError, "Could not convert argument 0 for call to mScode.",
                           com_obj.mScode, 0)
    
        
###############################################################################
##SIMPLE TYPES################################################################# 
Example #6
Source File: test_methodbinder1.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_ref_bytearr(self):
        from IronPythonTest.BinderTest import COtherConcern, Flag
        import clr
        self.target = COtherConcern()
        
        arr = System.Array[System.Byte]((2,3,4))
        
        res = self.target.M702(arr)
        self.assertEqual(Flag.Value, 702)
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        i, res = self.target.M703(arr)
        self.assertEqual(Flag.Value, 703)
        self.assertEqual(i, 42)
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        i, res = self.target.M704(arr, arr)
        self.assertEqual(Flag.Value, 704)
        self.assertEqual(i, 42)
        self.assertEqual(arr, res)
        
        sarr = clr.StrongBox[System.Array[System.Byte]](arr)
        res = self.target.M702(sarr)
        self.assertEqual(Flag.Value, 702)
        self.assertEqual(res, None)
        res = sarr.Value
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        sarr.Value = arr
        i = self.target.M703(sarr)
        self.assertEqual(Flag.Value, 703)
        self.assertEqual(i, 42)
        self.assertEqual(len(sarr.Value), 0)
        
        i = self.target.M704(arr, sarr)
        self.assertEqual(Flag.Value, 704)
        self.assertEqual(i, 42)
        self.assertEqual(sarr.Value, arr) 
Example #7
Source File: properties.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_properties_param():
    com_obj.PropertyWithParam[20] = 42
    AreEqual(com_obj.PropertyWithParam[0], 62)
    AreEqual(com_obj.PropertyWithParam[20], 42)
    
    strongVar = StrongBox[str]("a")
    com_obj.PropertyWithOutParam[strongVar] = "abcd"
    AreEqual(com_obj.PropertyWithOutParam[strongVar], "abcd")
    AreEqual(strongVar.Value, "abcd")
    
    com_obj.PropertyWithTwoParams[2, 2] = 2
    AreEqual(com_obj.PropertyWithTwoParams[0, 0], 6)
    AreEqual(com_obj.PropertyWithTwoParams[2,2], 2)
  
#Validate that one is able to call default properties with indexers. 
Example #8
Source File: OptionalParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_optional_out_params():
    b = StrongBox[object]()
    com_obj.mOptionalOutParam("a", b)
    AreEqual(b.Value, "a")
    com_obj.mOptionalOutParam("a") 
Example #9
Source File: OptionalParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_python_keyword_syntax():
    com_obj.mSingleOptionalParam(a="a")
    com_obj.mOneOptionalParam("a", b="b")
    com_obj.mTwoOptionalParams("a", b=32.0)
    com_obj.mTwoOptionalParams("a", c=32.0)
    com_obj.mTwoOptionalParams("a", c=32.0, b="b")
    com_obj.mOptionalParamWithDefaultValue(3, b=5)
    #test out params with the keyword syntax
    strongObject = StrongBox[object]()
    com_obj.mOptionalOutParam("a", b=strongObject)
    AreEqual(strongObject.Value, "a")
    #test types with the keyword syntax
    
    AreEqual(com_obj.mOptionalStringParam(a="a"), "a")
    AreEqual(com_obj.mOptionalIntParam(a=3), 3) 
Example #10
Source File: OutParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def callMethodWithStrongBox(func, arg, outparamType):
    strongArg = StrongBox[outparamType]()
    func(arg, strongArg)
    return strongArg.Value
#--------------------------------------------------------------------------------- 
Example #11
Source File: OutParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_sanity():
    for test_data in simple_primitives_data:
        testFunctionName = test_data[0]
        testType = test_data[1]
        testValue = test_data[2]

        testFunction = getattr(com_obj, testFunctionName)
        strongBox = StrongBox[testType]()
        testFunction(testValue, strongBox)
        AreEqual(strongBox.Value, testValue)
        
        testFunction(1, strongBox)
        AreEqual(strongBox.Value, 1)
        
        testFunction(0, strongBox)
        AreEqual(strongBox.Value, 0)
    
    AreEqual(callMethodWithStrongBox(com_obj.mBstr, "Hello", str), "Hello")
    
    #Interface Types    
    strongVar = StrongBox[object](DispatchWrapper(None))
    com_obj.mIDispatch(com_obj, strongVar)
    AreEqual(strongVar.Value.WrappedObject, com_obj)

    strongVar = StrongBox[object](UnknownWrapper(None))
    com_obj.mIUnknown(com_obj, strongVar)
    AreEqual(strongVar.Value.WrappedObject, com_obj)    
    
    #Complex Types
    strongVar = StrongBox[object](CurrencyWrapper(444))
    com_obj.mCy(CurrencyWrapper(123), strongVar)
    AreEqual(strongVar.Value.WrappedObject, 123)    
    
    now = DateTime.Now
    AreEqual(str(callMethodWithStrongBox(com_obj.mDate, now, DateTime)), str(now))        
        
    AreEqual(callMethodWithStrongBox(com_obj.mVariant, Single(2.0), object), 2.0) 
Example #12
Source File: InOutParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_types():
    for funcName, type, inp, output in simple_primitives_data:        
        func = getattr(com_obj, funcName)
        strongBoxVar = StrongBox[type](inp)
        func(strongBoxVar)
        AreEqual(strongBoxVar.Value, output)
        
    strongBoxIDisp = StrongBox[object](com_obj)    
    com_obj.mIDispatch(strongBoxIDisp);
    AreEqual(strongBoxIDisp.Value, com_obj)
    
#Test different signatures of the functions 
Example #13
Source File: InOutParams.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_calling_signatures():
    f1 = 2.5;
    f2 = 5.5;
    a = StrongBox[float](f1)
    b = StrongBox[float](f2)
    com_obj.mTwoInOutParams(a,b) #The function adds two to every parameter
    AreEqual(a.Value, f1+2) 
    AreEqual(b.Value, f1 + f2+2)
    
    now = System.DateTime.Now
    a = StrongBox[System.DateTime](now)
    b = StrongBox[System.DateTime](now)
    com_obj.mOutAndInOutParams(a,b)
    
#Try calling the COM function with params passed in as if they were in params. 
Example #14
Source File: test_methoddispatch.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_system_drawing(self):
        import clr
        if is_netcoreapp:
            clr.AddReference("System.Drawing.Primitives")
        else:
            clr.AddReference("System.Drawing")
        from System.Drawing import Rectangle
        r = Rectangle(0, 0, 3, 7)
        s = Rectangle(3, 0, 8, 14)
        
        # calling the static method
        i = Rectangle.Intersect(r, s)
        self.assertEqual(i, Rectangle(3, 0, 0, 7))
        self.assertEqual(r, Rectangle(0, 0, 3, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # calling the instance
        i = r.Intersect(s)
        self.assertEqual(i, None)
        self.assertEqual(r, Rectangle(3, 0, 0, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # calling instance w/ StrongBox
        r = Rectangle(0, 0, 3, 7)
        box = clr.StrongBox[Rectangle](r)
        i = box.Intersect(s)
        self.assertEqual(i, None)
        self.assertEqual(box.Value, Rectangle(3, 0, 0, 7))
        self.assertEqual(s, Rectangle(3, 0, 8, 14))
        
        # should be able to access properties through the box
        self.assertEqual(box.X, 3)
        
        # multiple sites should produce the same function
        i = box.Intersect
        j = box.Intersect 
Example #15
Source File: test_ctor_override.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(CtorOverrideTest, self).setUp()
        from System import Array
        from clr import StrongBox
        self.box_int = StrongBox[int]
        self.array_int = Array[int]

        self.add_clr_assemblies("baseclasscs", "typesamples") 
Example #16
Source File: test_method_signature.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(MethodSignatureTest, self).setUp()
        from clr import StrongBox

        self.add_clr_assemblies("baseclasscs", "typesamples")
        self.box_int = StrongBox[int] 
Example #17
Source File: test_delegate.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_instantiation(self):
        import clr
        from Merlin.Testing.Delegate import ClassWithTargetMethods, VoidInt32Delegate, VoidVoidDelegate
        d = VoidInt32Delegate
        x = ClassWithTargetMethods()

        # positive
        y = d(x.MVoidInt32)
        y(3)
        y = d(x.MVoidByte)
        y(3)

        # negative
        y = d(x.MVoidDouble)
        self.assertRaises(TypeError, y, 3.234)

        y = d(x.MInt32Void)
        self.assertRaises(TypeError, y)
        
        y = d(x.MVoidInt32Int32)
        self.assertRaises(TypeError, y, 1, 2)
        
        # need more scenario coverage
        y = d(x.MVoidRefInt32)
        y(2)
        
        y = d(x.MVoidOutInt32)
        z = clr.StrongBox[int](2)
        #y(z)
        
        d = VoidVoidDelegate
        y = d(x.MVoidOutInt32)
        y() 
Example #18
Source File: test_arguments.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(ArgumentsTest, self).setUp()
        self.add_clr_assemblies("methodargs", "typesamples")

        from clr import StrongBox
        from Merlin.Testing.Call import VariousParameters
        self.box_int = StrongBox[int]

        self.o = VariousParameters() 
Example #19
Source File: test_arguments.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_2_byref_args(self):
        from Merlin.Testing import Flag
        from Merlin.Testing.Call import ByRefParameters
        obj = ByRefParameters()

        #public void M200(int arg1, ref int arg2) { Flag.Reset(); Flag.Value1 = arg1 * 10 + arg2; arg2 = 10; }
        f = obj.M200
        self.assertEqual(f(1, 2), 10); Flag.Check(12)
        self.assertEqual(f(3, arg2 = 4), 10); Flag.Check(34)
        self.assertEqual(f(arg2 = 6, arg1 = 5), 10); Flag.Check(56)
        self.assertEqual(f(*(7, 8)), 10); Flag.Check(78)
        self.assertEqual(f(9, *(1,)), 10); Flag.Check(91)

        x = self.box_int(5); self.assertEqual(f(1, x), None); self.assertEqual(x.Value, 10); Flag.Check(15)
        x = self.box_int(6); f(2, x); self.assertEqual(x.Value, 10); Flag.Check(26)
        x = self.box_int(7); f(3, *(x,)); self.assertEqual(x.Value, 10); Flag.Check(37)
        x = self.box_int(8); f(**{'arg1': 4, 'arg2' : x}); self.assertEqual(x.Value, 10); Flag.Check(48)

        #public void M201(ref int arg1, int arg2) { Flag.Reset(); Flag.Value1 = arg1 * 10 + arg2; arg1 = 20; }
        f = obj.M201
        self.assertEqual(f(1, 2), 20)
        x = self.box_int(2); f(x, *(2,)); self.assertEqual(x.Value, 20); Flag.Check(22)

        #public void M202(ref int arg1, ref int arg2) { Flag.Reset(); Flag.Value1 = arg1 * 10 + arg2; arg1 = 30; arg2 = 40; }
        f = obj.M202
        self.assertEqual(f(1, 2), (30, 40))
        self.assertEqual(f(arg2 = 1, arg1 = 2), (30, 40)); Flag.Check(21)

        self.assertRaisesMessage(TypeError, "expected int, got StrongBox[int]", lambda: f(self.box_int(3), 4))  # bug 311239
        x = self.box_int(3)
        y = self.box_int(4)
        #f(arg2 = y, *(x,)); Flag.Check(34) # bug 311169
        self.assertRaisesMessage(TypeError, "M202() got multiple values for keyword argument 'arg1'", lambda: f(arg1 = x, *(y,))) # msg

        # just curious
        x = y = self.box_int(5)
        f(x, y); self.assertEqual(x.Value, 40); self.assertEqual(y.Value, 40); Flag.Check(55) 
Example #20
Source File: test_ctor.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_ctor_1_arg(self):
        from clr import StrongBox
        from Merlin.Testing.Call import Ctor101, Ctor103, Ctor105, Ctor110
        box_int = StrongBox[int]
        Ctor101()

        #public class Ctor103 {
        #   public Ctor103(params int[] arg) { }
        #}
        Ctor103()
        Ctor103(1)
        Ctor103(1, 2, 3)
        Ctor105(a=1,b=2,c=3)
        #public class Ctor110 {
        #   public Ctor110(ref int arg) { arg = 10; }
        #}

        x, y = Ctor110(2)

        x = box_int()
        Ctor110(x)
        self.assertEqual(x.Value, 10)  # bug 313045

        #public class Ctor111 {
        #   public Ctor111(out int arg) { arg = 10; }
        #}

        #Ctor111() # bug 312989

        #x = box_int()
        #Ctor111(x)
        #self.assertEqual(x.Value, 10)   # bug 313045 
Example #21
Source File: path_planning.py    From compas_fab with MIT License 5 votes vote down vote up
def _transform_to_origin(mesh, xform):
    inverse = clr.StrongBox[rg.Transform]()
    if not xform.TryGetInverse(inverse):
        raise ValueError('Unable to get inverse of matrix')

    mesh.Transform(inverse.Value)

    return mesh 
Example #22
Source File: test_ctor.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_ctor_1_arg(self):
        from clr import StrongBox
        from Merlin.Testing.Call import Ctor101, Ctor103, Ctor105, Ctor110
        box_int = StrongBox[int]
        Ctor101()
        
        #public class Ctor103 {
        #   public Ctor103(params int[] arg) { }
        #}
        Ctor103()
        Ctor103(1)
        Ctor103(1, 2, 3)
        Ctor105(a=1,b=2,c=3)
        #public class Ctor110 {
        #   public Ctor110(ref int arg) { arg = 10; }
        #}
        
        
        x, y = Ctor110(2)

        x = box_int()
        Ctor110(x)
        self.assertEqual(x.Value, 10)  # bug 313045
        

        #public class Ctor111 {
        #   public Ctor111(out int arg) { arg = 10; }
        #}

        #Ctor111() # bug 312989

        #x = box_int()
        #Ctor111(x)
        #self.assertEqual(x.Value, 10)   # bug 313045 
Example #23
Source File: test_methodbinder1.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_ref_bytearr(self):
        from IronPythonTest.BinderTest import COtherConcern, Flag
        import clr
        self.target = COtherConcern()
        
        arr = System.Array[System.Byte]((2,3,4))
        
        res = self.target.M702(arr)
        self.assertEqual(Flag.Value, 702)
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        i, res = self.target.M703(arr)
        self.assertEqual(Flag.Value, 703)
        self.assertEqual(i, 42)
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        i, res = self.target.M704(arr, arr)
        self.assertEqual(Flag.Value, 704)
        self.assertEqual(i, 42)
        self.assertEqual(arr, res)
        
        sarr = clr.StrongBox[System.Array[System.Byte]](arr)
        res = self.target.M702(sarr)
        self.assertEqual(Flag.Value, 702)
        self.assertEqual(res, None)
        res = sarr.Value
        self.assertEqual(type(res), System.Array[System.Byte])
        self.assertEqual(len(res), 0)
        
        sarr.Value = arr
        i = self.target.M703(sarr)
        self.assertEqual(Flag.Value, 703)
        self.assertEqual(i, 42)
        self.assertEqual(len(sarr.Value), 0)
        
        i = self.target.M704(arr, sarr)
        self.assertEqual(Flag.Value, 704)
        self.assertEqual(i, 42)
        self.assertEqual(sarr.Value, arr) 
Example #24
Source File: properties.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_properties_param():
    com_obj.PropertyWithParam[20] = 42
    AreEqual(com_obj.PropertyWithParam[0], 62)
    AreEqual(com_obj.PropertyWithParam[20], 42)
    
    strongVar = StrongBox[str]("a")
    com_obj.PropertyWithOutParam[strongVar] = "abcd"
    AreEqual(com_obj.PropertyWithOutParam[strongVar], "abcd")
    AreEqual(strongVar.Value, "abcd")
    
    com_obj.PropertyWithTwoParams[2, 2] = 2
    AreEqual(com_obj.PropertyWithTwoParams[0, 0], 6)
    AreEqual(com_obj.PropertyWithTwoParams[2,2], 2)
  
#Validate that one is able to call default properties with indexers. 
Example #25
Source File: OptionalParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_optional_out_params():
    b = StrongBox[object]()
    com_obj.mOptionalOutParam("a", b)
    AreEqual(b.Value, "a")
    com_obj.mOptionalOutParam("a") 
Example #26
Source File: OptionalParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_python_keyword_syntax():
    com_obj.mSingleOptionalParam(a="a")
    com_obj.mOneOptionalParam("a", b="b")
    com_obj.mTwoOptionalParams("a", b=32.0)
    com_obj.mTwoOptionalParams("a", c=32.0)
    com_obj.mTwoOptionalParams("a", c=32.0, b="b")
    com_obj.mOptionalParamWithDefaultValue(3, b=5)
    #test out params with the keyword syntax
    strongObject = StrongBox[object]()
    com_obj.mOptionalOutParam("a", b=strongObject)
    AreEqual(strongObject.Value, "a")
    #test types with the keyword syntax
    
    AreEqual(com_obj.mOptionalStringParam(a="a"), "a")
    AreEqual(com_obj.mOptionalIntParam(a=3), 3) 
Example #27
Source File: OutParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def callMethodWithStrongBox(func, arg, outparamType):
    strongArg = StrongBox[outparamType]()
    func(arg, strongArg)
    return strongArg.Value
#--------------------------------------------------------------------------------- 
Example #28
Source File: OutParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_sanity():
    for test_data in simple_primitives_data:
        testFunctionName = test_data[0]
        testType = test_data[1]
        testValue = test_data[2]

        testFunction = getattr(com_obj, testFunctionName)
        strongBox = StrongBox[testType]()
        testFunction(testValue, strongBox)
        AreEqual(strongBox.Value, testValue)
        
        testFunction(1, strongBox)
        AreEqual(strongBox.Value, 1)
        
        testFunction(0, strongBox)
        AreEqual(strongBox.Value, 0)
    
    AreEqual(callMethodWithStrongBox(com_obj.mBstr, "Hello", str), "Hello")
    
    #Interface Types    
    strongVar = StrongBox[object](DispatchWrapper(None))
    com_obj.mIDispatch(com_obj, strongVar)
    AreEqual(strongVar.Value.WrappedObject, com_obj)

    strongVar = StrongBox[object](UnknownWrapper(None))
    com_obj.mIUnknown(com_obj, strongVar)
    AreEqual(strongVar.Value.WrappedObject, com_obj)    
    
    #Complex Types
    strongVar = StrongBox[object](CurrencyWrapper(444))
    com_obj.mCy(CurrencyWrapper(123), strongVar)
    AreEqual(strongVar.Value.WrappedObject, 123)    
    
    now = DateTime.Now
    AreEqual(str(callMethodWithStrongBox(com_obj.mDate, now, DateTime)), str(now))        
        
    AreEqual(callMethodWithStrongBox(com_obj.mVariant, Single(2.0), object), 2.0) 
Example #29
Source File: InOutParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_types():
    for funcName, type, inp, output in simple_primitives_data:        
        func = getattr(com_obj, funcName)
        strongBoxVar = StrongBox[type](inp)
        func(strongBoxVar)
        AreEqual(strongBoxVar.Value, output)
        
    strongBoxIDisp = StrongBox[object](com_obj)    
    com_obj.mIDispatch(strongBoxIDisp);
    AreEqual(strongBoxIDisp.Value, com_obj)
    
#Test different signatures of the functions 
Example #30
Source File: InOutParams.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_calling_signatures():
    f1 = 2.5;
    f2 = 5.5;
    a = StrongBox[float](f1)
    b = StrongBox[float](f2)
    com_obj.mTwoInOutParams(a,b) #The function adds two to every parameter
    AreEqual(a.Value, f1+2) 
    AreEqual(b.Value, f1 + f2+2)
    
    now = System.DateTime.Now
    a = StrongBox[System.DateTime](now)
    b = StrongBox[System.DateTime](now)
    com_obj.mOutAndInOutParams(a,b)
    
#Try calling the COM function with params passed in as if they were in params.