当前位置: 首页>>代码示例>>Python>>正文


Python dotnet.typeof函数代码示例

本文整理汇总了Python中pypy.translator.cli.dotnet.typeof函数的典型用法代码示例。如果您正苦于以下问题:Python typeof函数的具体用法?Python typeof怎么用?Python typeof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了typeof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fn

 def fn(flag):
     if flag:
         clitype = typeof(System.Int32)
     else:
         clitype = typeof(System.String)
     cls = type2class(clitype)
     return cls is cInt32
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_dotnet.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:
        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

示例3: 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

示例4: build_fn

 def build_fn():
     tInt = typeof(System.Int32)
     args = init_array(System.Type, tInt, tInt)
     meth = Utils.CreateDynamicMethod("add", tInt, args)
     il = meth.GetILGenerator()
     il.Emit(OpCodes.Ldarg_0)
     il.Emit(OpCodes.Ldarg_1)
     il.Emit(OpCodes.Add)
     il.Emit(OpCodes.Ret)
     myfunc = meth.CreateDelegate(typeof(FUNCTYPE))
     return myfunc
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:11,代码来源:test_dotnet.py

示例5: getCliType

 def getCliType(self, meth):
     if self in meth.box2type:
         return meth.box2type[self]
     
     if self.type == history.INT:
         return dotnet.typeof(System.Int32)
     elif self.type == history.FLOAT:
         return dotnet.typeof(System.Double)
     elif self.type == history.REF:
         return dotnet.typeof(System.Object)
     else:
         assert False, 'Unknown type: %s' % self.type
开发者ID:alkorzt,项目名称:pypy,代码行数:12,代码来源:method.py

示例6: emit_op_subclassof

 def emit_op_subclassof(self, op):
     clitype_utils = dotnet.typeof(Utils)
     methinfo = clitype_utils.GetMethod('SubclassOf')
     op.args[0].load(self)
     op.args[1].load(self)
     self.il.Emit(OpCodes.Call, methinfo)
     self.store_result(op)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:method.py

示例7: load

 def load(self, meth):
     holdertype = self.holder.GetType()
     funcfield = holdertype.GetField('func')
     Const.load(self, meth)
     meth.il.Emit(OpCodes.Castclass, holdertype)
     meth.il.Emit(OpCodes.Ldfld, funcfield)
     meth.il.Emit(OpCodes.Castclass, dotnet.typeof(LoopDelegate))
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:method.py

示例8: emit_op_guard_class

 def emit_op_guard_class(self, op):
     assert len(op.args) == 2
     il_label = self.newbranch(op)
     self.push_arg(op, 0)
     meth = dotnet.typeof(System.Object).GetMethod("GetType")
     self.il.Emit(OpCodes.Callvirt, meth)
     self.push_arg(op, 1)
     self.il.Emit(OpCodes.Bne_Un, il_label)
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:method.py

示例9: emit_new_arrayofvoids

 def emit_new_arrayofvoids(self, op):
     clitype = dotnet.typeof(ListOfVoid)
     ctor = clitype.GetConstructor(dotnet.new_array(System.Type, 0))
     _ll_resize = clitype.GetMethod('_ll_resize')
     self.il.Emit(OpCodes.Newobj, ctor)
     self.il.Emit(OpCodes.Dup)
     op.args[0].load(self)
     self.il.Emit(OpCodes.Callvirt, _ll_resize)
     self.store_result(op)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py

示例10: emit_return_failed_op

 def emit_return_failed_op(self, op, args):
     # store the index of the failed op
     index_op = self.get_index_for_failing_op(op)
     self.av_inputargs.load(self)
     self.il.Emit(OpCodes.Ldc_I4, index_op)
     field = dotnet.typeof(InputArgs).GetField('failed_op')
     self.il.Emit(OpCodes.Stfld, field)
     self.emit_store_opargs(args)
     self.il.Emit(OpCodes.Ret)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py

示例11: finish_code

 def finish_code(self):
     delegatetype = dotnet.typeof(LoopDelegate)
     # initialize the array of genconsts
     consts = dotnet.new_array(System.Object, len(self.consts))
     for av_const, i in self.consts.iteritems():
         consts[i] = av_const.get_cliobj()
     # build the delegate
     func = self.meth_wrapper.create_delegate(delegatetype, consts)
     return dotnet.clidowncast(func, LoopDelegate)
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:method.py

示例12: get_inputarg_field

 def get_inputarg_field(self, type):
     t = dotnet.typeof(InputArgs)
     if type == history.INT:
         fieldname = 'ints'
     elif type == history.FLOAT:
         fieldname = 'floats'
     elif type == history.REF:
         fieldname = 'objs'
     else:
         assert False, 'Unknown type %s' % type
     return t.GetField(fieldname)        
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:method.py

示例13: emit_ovf_op_and_guard

 def emit_ovf_op_and_guard(self, op, opguard, emit_op):
     # emit the checked operation
     lbl = self.il.BeginExceptionBlock()
     emit_op(self, op)
     self.il.Emit(OpCodes.Leave, lbl)
     self.il.BeginCatchBlock(dotnet.typeof(System.OverflowException))
     # emit the guard
     assert len(opguard.args) == 0
     il_label = self.newbranch(opguard)
     self.il.Emit(OpCodes.Leave, il_label)
     self.il.EndExceptionBlock()
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:method.py

示例14: rewrap_args

def rewrap_args(space, w_args, startfrom):
    args = space.unpackiterable(w_args)
    paramlen = len(args)-startfrom
    b_args = new_array(System.Object, paramlen)
    b_paramtypes = new_array(System.Type, paramlen)
    for i in range(startfrom, len(args)):
        j = i-startfrom
        b_obj = py2cli(space, args[i])
        b_args[j] = b_obj
        if b_obj is None:
            b_paramtypes[j] = typeof(System.Object) # we really can't be more precise
        else:
            b_paramtypes[j] = b_obj.GetType() # XXX: potentially inefficient
    return b_args, b_paramtypes
开发者ID:alkorzt,项目名称:pypy,代码行数:14,代码来源:interp_clr.py

示例15: emit_ovf_op

 def emit_ovf_op(self, op, emit_op):
     next_op = self.oplist[self.i+1]
     if next_op.opnum == rop.GUARD_NO_OVERFLOW:
             self.i += 1
             self.emit_ovf_op_and_guard(op, next_op, emit_op)
             return
     # clear the overflow flag
     self.il.Emit(OpCodes.Ldc_I4_0)
     self.av_ovf_flag.store(self)
     lbl = self.il.BeginExceptionBlock()
     emit_op(self, op)
     self.il.Emit(OpCodes.Leave, lbl)
     self.il.BeginCatchBlock(dotnet.typeof(System.OverflowException))
     self.il.Emit(OpCodes.Ldc_I4_1)
     self.av_ovf_flag.store(self)
     self.il.EndExceptionBlock()
开发者ID:alkorzt,项目名称:pypy,代码行数:16,代码来源:method.py


注:本文中的pypy.translator.cli.dotnet.typeof函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。