(self)
return "\n".join(lines)
Generates a ctypes.Structure declaration for self.
Generates a ctypes.Structure declaration for self.
Generates a ctypes . Structure declaration for self .
def ctypes_decl(self):
    """Generates a ctypes.Structure declaration for self."""
    indent = codegen_util.Indenter()
    lines = []
    lines.append(textwrap.dedent("""
    class {0.ctypes_typename}(ctypes.Structure):
      \"\"\"{0.docstring}\"\"\"""".format(self)))
    anonymous_fields = [member.name for member in self.members.values()
                        if isinstance(member, AnonymousUnion)]
    with indent:
      if anonymous_fields:
        lines.append(indent("_anonymous_ = ["))
        with indent:
          with indent:
            for name in anonymous_fields:
              lines.append(indent("'" + name + "',"))
        lines.append(indent("]"))

      if self.members:
        lines.append(indent("_fields_ = ["))
        with indent:
          with indent:
            for member in self.members.values():
              lines.append(indent(member.ctypes_field_decl + ","))
        lines.append(indent("]\n"))
    return "\n".join(lines)
def ctypes_decl ( self ) : indent = codegen_util . Indenter ( ) lines = [ ] lines . append ( textwrap . dedent ( """
    class {0.ctypes_typename}(ctypes.Structure):
      \"\"\"{0.docstring}\"\"\"""" . format ( self ) ) ) anonymous_fields = [ member . name for member in self . members . values ( ) if isinstance ( member , AnonymousUnion ) ] with indent : if anonymous_fields : lines . append ( indent ( "_anonymous_ = [" ) ) with indent : with indent : for name in anonymous_fields : lines . append ( indent ( "'" + name + "'," ) ) lines . append ( indent ( "]" ) ) if self . members : lines . append ( indent ( "_fields_ = [" ) ) with indent : with indent : for member in self . members . values ( ) : lines . append ( indent ( member . ctypes_field_decl + "," ) ) lines . append ( indent ( "]\n" ) ) return "\n" . join ( lines )