本文整理汇总了Python中pypy.translator.cli.dotnet.unbox函数的典型用法代码示例。如果您正苦于以下问题:Python unbox函数的具体用法?Python unbox怎么用?Python unbox使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unbox函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cli2py
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)
开发者ID:alkorzt,项目名称:pypy,代码行数:29,代码来源:interp_clr.py
示例2: cli2py
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))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:26,代码来源:interp_clr.py
示例3: fn
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)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:8,代码来源:test_dotnet.py
示例4: revealconst
def revealconst(self, T):
assert isinstance(T, ootype.OOType)
return unbox(self.obj, T)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:3,代码来源:rgenop.py
注:本文中的pypy.translator.cli.dotnet.unbox函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论