本文整理汇总了Python中pypy.translator.cli.dotnet.box函数的典型用法代码示例。如果您正苦于以下问题:Python box函数的具体用法?Python box怎么用?Python box使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了box函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(self, builder):
holdertype = box(self.holder).GetType()
funcfield = holdertype.GetField('func')
delegatetype = self.delegatetype
index = self._get_index(builder)
self._load_from_array(builder, index, holdertype)
builder.il.Emit(OpCodes.Ldfld, funcfield)
builder.il.Emit(OpCodes.Castclass, delegatetype)
示例2: fn
def fn(flag):
a = ArrayList()
a.Add(None)
if flag:
obj = cliupcast(a, System.Object)
else:
obj = box(42)
b = clidowncast(obj, ArrayList)
return b.get_Item(0)
示例3: genconst
def genconst(self, llvalue):
T = ootype.typeOf(llvalue)
if T is ootype.Signed:
return IntConst(llvalue)
elif T is ootype.Bool:
return IntConst(int(llvalue))
elif isinstance(T, ootype.OOType):
return ObjectConst(box(llvalue))
else:
assert False, "XXX not implemented"
示例4: call_method
def call_method(space, b_obj, b_type, name, w_args, startfrom):
b_args, b_paramtypes = rewrap_args(space, w_args, startfrom)
b_meth = get_method(space, b_type, name, b_paramtypes)
try:
# for an explanation of the box() call, see the log message for revision 35167
b_res = box(b_meth.Invoke(b_obj, b_args))
except TargetInvocationException, e:
b_inner = native_exc(e).get_InnerException()
message = str(b_inner.get_Message())
# TODO: use the appropriate exception, not StandardError
raise OperationError(space.w_StandardError, space.wrap(message))
示例5: fn
def fn():
x = ArrayList()
t = x.GetType()
meth = t.GetMethod('get_Item')
args = init_array(System.Object, box(0))
try:
meth.Invoke(x, args)
return "Impossible!"
except TargetInvocationException, e:
inner = native_exc(e).get_InnerException()
message = str(inner.get_Message())
return message