def _class_factory(base):
class ClsPyPy(base):<EOL><INDENT>def __repr__(self):<EOL><INDENT>return repr(base(super(ClsPyPy, self).value))<EOL><DEDENT>@classmethod<EOL>def from_buffer(cls, ba):<EOL><INDENT>try:<EOL><INDENT>integer = struct.unpack_from(getattr(cls, '<STR_LIT>'), ba)[<NUM_LIT:0>]<EOL><DEDENT>except struct.error:<EOL><INDENT>len_ = len(ba)<EOL>size = struct.calcsize(getattr(cls, '<STR_LIT>'))<EOL>if len_ < size:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(len_, size))<EOL><DEDENT>raise<EOL><DEDENT>return cls(integer)<EOL><DEDENT><DEDENT>class ClsPy26(base):<EOL><INDENT>def __repr__(self):<EOL><INDENT>return repr(base(super(ClsPy26, self).value))<EOL><DEDENT>def __iter__(self):<EOL><INDENT>return iter(struct.pack(getattr(super(ClsPy26, self), '<STR_LIT>'), super(ClsPy26, self).value))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>base.from_buffer(bytearray(base()))<EOL><DEDENT>except TypeError:<EOL><INDENT>return ClsPy26<EOL><DEDENT>except AttributeError:<EOL><INDENT>return ClsPyPy<EOL><DEDENT>except ValueError:<EOL><INDENT>return ClsPyPy<EOL><DEDENT>return base<EOL>
Create subclasses of ctypes.

    Positional arguments:
    base -- base class to subclass.

    Returns:
    New class definition.