ctype_util.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:gym-dolphin 作者: vladfi1 项目源码 文件源码
def allValues(ctype):
  if issubclass(ctype, IntEnum):
    return list(ctype)

  if issubclass(ctype, Structure):
    names, types = zip(*ctype._fields)
    values = [allValues(t) for t in types]

    def make(vals):
      obj = ctype()
      for name, val in zip(names, vals):
        setattr(obj, name, val)
      return obj

    return [make(vals) for vals in product(*values)]

  # TODO: handle bounded ints via _fields
  # TODO: handle arrays
  raise TypeError("Unsupported type %s" % ctype)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号