Exemple #1
0
def couple(stltype, prefix = None, element = None):
  if prefix is None:
    prefix = stltype.__name__.split("<")[0]
  
  if prefix == "std::vector":
    _vector_from_list(stltype, element or _guess_container_type(prefix, stltype))
    stltype.__to__ = __builtin__.list
  elif prefix == "std::list":
    _list_from_list(stltype, element or _guess_container_type(prefix, stltype))
    stltype.__to__ = __builtin__.list
  elif prefix == "std::set":
    _set_from_list(stltype, element or _guess_container_type(prefix, stltype))
    stltype.__to__ = __builtin__.list
  elif prefix == "std::pair":
    _pair_with_tuple(stltype)
    stltype.__to__ = tuple
  elif prefix == "std::complex":
    stltype.__from__[0j] = lambda z, c=stltype: c(z.real, z.imag)
    stltype.__to__ = lambda z: __builtin__.complex(z.real(), z.imag())
  elif prefix == "std::map":
    _map_from_dict(stltype, element)
    stltype.__to__ = _map_to_dict
  elif prefix == "__gnu_cxx::hash_map":
    _map_from_dict(stltype, element)
    stltype.__to__ = _map_to_dict
  else:
    raise TypeError, "invalid STL prefix: " + prefix
Exemple #2
0
 def _bytes_to_complex(s):
     return complex(s.decode('ascii'))
Exemple #3
0
 def toobject(c, type):
     return builtins.complex(c.real, c.imag)
Exemple #4
0
 def _bytes_to_complex(s):
     return complex(s.decode("ascii"))