def METHOD_NAME(fields):
    raw_fields = []
    wrappers = {}
    for field in fields:
        (name, type) = field
        if isinstance(type, Enum):
            raw_fields.append(('_raw_' + name, type.type))
            wrappers[name] = type
        else:
            raw_fields.append(field)
    class Raw(ctypes.Structure):
        _fields_ = raw_fields
        _pack_ = 1
        def __getattribute__(self, name):
            if name in wrappers:
                return wrappers[name].from_raw(
                    getattr(self, '_raw_' + name))
            else:
                return ctypes.Structure.__getattribute__(self, name)
        def __repr__(self):
            return '{' + ', '.join(
                '%s: %s' % (field, self.__getattribute__(field))
                for field, _ in fields) + '}'
    return Raw