コード例 #1
0
ファイル: interp_clr.py プロジェクト: alkorzt/pypy
def cli2py(space, b_obj):
    # TODO: support other types and find the most efficient way to
    # select the correct case
    if b_obj is None:
        return space.w_None

    w_obj = unbox(b_obj, W_Root)
    if w_obj is not None:
        return w_obj # it's already a wrapped object!
    
    b_type = b_obj.GetType()
    if b_type == typeof(System.Int32):
        intval = unbox(b_obj, ootype.Signed)
        return space.wrap(intval)
    elif b_type == typeof(System.Double):
        floatval = unbox(b_obj, ootype.Float)
        return space.wrap(floatval)
    elif b_type == typeof(System.Boolean):
        boolval = unbox(b_obj, ootype.Bool)
        return space.wrap(boolval)
    elif b_type == typeof(System.String):
        strval = unbox(b_obj, ootype.String)
        return space.wrap(strval)
    else:
        namespace, classname = split_fullname(b_type.ToString())
        assemblyname = b_type.get_Assembly().get_FullName()
        w_cls = load_cli_class(space, assemblyname, namespace, classname)
        cliobj = W_CliObject(space, b_obj)
        return wrapper_from_cliobj(space, w_cls, cliobj)
コード例 #2
0
ファイル: interp_clr.py プロジェクト: TheDunn/flex-pypy
def cli2py(space, b_obj):
    # TODO: support other types and find the most efficient way to
    # select the correct case
    if b_obj is None:
        return space.w_None

    w_obj = unbox(b_obj, W_Root)
    if w_obj is not None:
        return w_obj # it's already a wrapped object!
    
    b_type = b_obj.GetType()
    if b_type == typeof(System.Int32):
        intval = unbox(b_obj, ootype.Signed)
        return space.wrap(intval)
    elif b_type == typeof(System.Double):
        floatval = unbox(b_obj, ootype.Float)
        return space.wrap(floatval)
    elif b_type == typeof(System.Boolean):
        boolval = unbox(b_obj, ootype.Bool)
        return space.wrap(boolval)
    elif b_type == typeof(System.String):
        strval = unbox(b_obj, ootype.String)
        return space.wrap(strval)
    else:
        msg = "Can't convert object %s to Python" % str(b_obj.ToString())
        raise OperationError(space.w_TypeError, space.wrap(msg))
コード例 #3
0
def cli2py(space, b_obj):
    # TODO: support other types and find the most efficient way to
    # select the correct case
    if b_obj is None:
        return space.w_None

    w_obj = unbox(b_obj, W_Root)
    if w_obj is not None:
        return w_obj # it's already a wrapped object!
    
    b_type = b_obj.GetType()
    if b_type == typeof(System.Int32):
        intval = unbox(b_obj, ootype.Signed)
        return space.wrap(intval)
    elif b_type == typeof(System.Double):
        floatval = unbox(b_obj, ootype.Float)
        return space.wrap(floatval)
    elif b_type == typeof(System.Boolean):
        boolval = unbox(b_obj, ootype.Bool)
        return space.wrap(boolval)
    elif b_type == typeof(System.String):
        strval = unbox(b_obj, ootype.String)
        return space.wrap(strval)
    else:
        namespace, classname = split_fullname(b_type.ToString())
        assemblyname = b_type.get_Assembly().get_FullName()
        w_cls = load_cli_class(space, assemblyname, namespace, classname)
        cliobj = W_CliObject(space, b_obj)
        return wrapper_from_cliobj(space, w_cls, cliobj)
コード例 #4
0
 def fn():
     const.xx = 42
     obj = fieldinfo.GetValue(None)
     # get the 'xx' field by using reflection
     t = obj.GetType()
     x_info = t.GetField('xx')
     x_value = x_info.GetValue(obj)
     return unbox(x_value, ootype.Signed)
コード例 #5
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     const.xx = 42
     obj = fieldinfo.GetValue(None)
     # get the 'xx' field by using reflection
     t = obj.GetType()
     x_info = t.GetField('xx')
     x_value = x_info.GetValue(obj)
     return unbox(x_value, ootype.Signed)
コード例 #6
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = ArrayList()
     x.Add(box(42))
     return unbox(x.get_Item(0), ootype.Signed)
コード例 #7
0
 def fn():
     obj = Foo()
     x = ArrayList()
     x.Add(box(obj))
     obj2 = unbox(x.get_Item(0), Foo)
     return obj is obj2
コード例 #8
0
 def fn():
     myfunc = unbox(build_fn(), FUNCTYPE)
     return myfunc(30, 12)
コード例 #9
0
 def fn():
     obj = Foo()
     b_obj = box(obj)
     obj2 = unbox(b_obj, Foo)
     return obj is obj2
コード例 #10
0
 def fn(flag):
     b_obj = System.Object()
     a2 = unbox(b_obj, A)
     return a2
コード例 #11
0
 def fn():
     x = ArrayList()
     x.Add(box('foo'))
     return unbox(x.get_Item(0), ootype.String)
コード例 #12
0
 def fn():
     x = new_array(System.Object, 2)
     x[0] = box(42)
     x[1] = box(43)
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
コード例 #13
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     b_obj = box(42)
     return unbox(b_obj, Foo)
コード例 #14
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn(flag):
     b_obj = System.Object()
     a2 = unbox(b_obj, A)
     return a2
コード例 #15
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = init_array(System.Object, box(42), box(43))
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
コード例 #16
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     obj = Foo()
     b_obj = box(obj)
     obj2 = unbox(b_obj, Foo)
     return obj is obj2
コード例 #17
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = new_array(System.Object, 2)
     x[0] = box(42)
     x[1] = box(43)
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
コード例 #18
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = ArrayList()
     x.Add(box(42))
     array = x.ToArray()
     return unbox(array[0], ootype.Signed)
コード例 #19
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = ArrayList()
     x.Add(box('foo'))
     return unbox(x.get_Item(0), ootype.String)
コード例 #20
0
 def fn():
     boxed = box(Foo())
     return unbox(boxed, Foo)
コード例 #21
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn(flag):
     a = ootype.new(A)
     a.xx = 42
     b_obj = box(a)
     a2 = unbox(b_obj, A)
     return a2.xx
コード例 #22
0
 def fn():
     x = ArrayList()
     x.Add(box(42))
     return unbox(x.get_Item(0), ootype.Signed)
コード例 #23
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     obj = Foo()
     x = ArrayList()
     x.Add(box(obj))
     obj2 = unbox(x.get_Item(0), Foo)
     return obj is obj2
コード例 #24
0
 def fn():
     x = ArrayList()
     x.Add(box(42))
     array = x.ToArray()
     return unbox(array[0], ootype.Signed)
コード例 #25
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn(x, y):
     myfunc = unbox(build_fn(), FUNCTYPE)
     a = myfunc(x, y)
     mytuple = (x, y)
     b = myfunc(*mytuple)
     return a + b
コード例 #26
0
 def fn():
     x = init_array(System.Object, box(42), box(43))
     return unbox(x[0], ootype.Signed) + unbox(x[1], ootype.Signed)
コード例 #27
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     myfunc = unbox(build_fn(), FUNCTYPE)
     return myfunc(30, 12)
コード例 #28
0
 def fn():
     b_obj = box(42)
     return unbox(b_obj, Foo)
コード例 #29
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = box(42)
     return unbox(x, Foo)
コード例 #30
0
 def fn(flag):
     a = ootype.new(A)
     a.xx = 42
     b_obj = box(a)
     a2 = unbox(b_obj, A)
     return a2.xx
コード例 #31
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     x = box(42)
     return unbox(x, ootype.Signed)
コード例 #32
0
 def fn(x, y):
     myfunc = unbox(build_fn(), FUNCTYPE)
     a = myfunc(x, y)
     mytuple = (x, y)
     b = myfunc(*mytuple)
     return a+b
コード例 #33
0
 def fn():
     x = box(42)
     return unbox(x, Foo)
コード例 #34
0
ファイル: rgenop.py プロジェクト: antoine1fr/pygirl
 def revealconst(self, T):
     assert isinstance(T, ootype.OOType)
     return unbox(self.obj, T)
コード例 #35
0
ファイル: test_dotnet.py プロジェクト: griels/pypy-sc
 def fn():
     boxed = box(Foo())
     return unbox(boxed, Foo)
コード例 #36
0
 def fn():
     x = box(42)
     return unbox(x, ootype.Signed)
コード例 #37
0
ファイル: rgenop.py プロジェクト: antoine1fr/pygirl
 def revealconst(self, T):
     assert isinstance(T, ootype.OOType)
     return unbox(self.holder.GetFunc(), T)