# Path: ctypeslib/codegen/typedesc.py
# class T(object):
# class Argument(T):
# class _HasArgs(T):
# class Alias(T):
# class Macro(T):
# class File(T):
# class Function(_HasArgs):
# class Ignored(_HasArgs):
# class OperatorFunction(_HasArgs):
# class FunctionType(_HasArgs):
# class Method(_HasArgs):
# class FundamentalType(T):
# class PointerType(T):
# class Typedef(T):
# class ArrayType(T):
# class StructureHead(T):
# class StructureBody(T):
# class _Struct_Union_Base(T):
# class Structure(_Struct_Union_Base):
# class Union(_Struct_Union_Base):
# class Field(T):
# class CvQualifiedType(T):
# class Enumeration(T):
# class EnumValue(T):
# class Variable(T):
# class UndefinedIdentifier(T):
#     def __repr__(self):
#     def __init__(self, name, _type):
#     def __init__(self):
#     def add_argument(self, arg):
#     def iterArgTypes(self):
#     def iterArgNames(self):
#     def fixup_argtypes(self, cb):
#     def __init__(self, name, alias, typ=None):
#     def __init__(self, name, args, body):
#     def __init__(self, name):
#     def __init__(self, name, returns, attributes, extern):
#     def __init__(self, name):
#     def __init__(self, name, returns):
#     def __init__(self, returns, attributes, name=''):
#     def __init__(self, name, returns):
#     def __init__(self, name, size, align):
#     def __init__(self, typ, size, align):
#     def __init__(self, name, typ):
#     def __init__(self, typ, size):
#     def __init__(self, struct):
#     def name(self):
#     def __init__(self, struct):
#     def name(self):
#     def get_body(self):
#     def get_head(self):
#     def __init__(self, name, align, members, bases, size, artificial=None,
#                  packed=False):
#     def __init__(self, name, align, members, bases, size, artificial=None,
#                  packed=False):
#     def __init__(self, name, typ, offset, bits, is_bitfield=False,
#                  is_anonymous=False, is_padding=False):
#     def __init__(self, typ, const, volatile):
#     def __init__(self, name, size, align):
#     def add_value(self, v):
#     def __init__(self, name, value, enumeration):
#     def __init__(self, name, typ, init=None, extern=False):
#     def __init__(self, name):
#     def __str__(self):
# def is_record(t):


from clang.cindex import Cursor
from clang.cindex import TranslationUnit
from collections.abc import Iterable
from ctypeslib.codegen import typedesc
import logging
import re

class ADict(dict):

    def __getattr__(self, name):
        try:
            return self[name]
        except KeyError:
            raise AttributeError(name)


_c_literal_regex = re.compile(
    r"^([+-]?((\d+(e|E)[+-]?\d+)|(\d+(\.\d*)?((e|E)[+-]?\d+)?)|(\.\d+((e|E)[+-]?\d+)?)))(f|F|l|L)?$"
)


def from_c_float_literal(value):
    if (not isinstance(value, str) and
            isinstance(value, Iterable) and
            all(map(lambda v: isinstance(v, str), value))):
        value = "".join(value)
    if not isinstance(value, str):
        return None
    match = _c_literal_regex.match(value)
    if not match:
        return None
    return match.group(1)


def contains_undefined_identifier(macro):
    # body is undefined

# Path: ctypeslib/codegen/typedesc.py
# class T(object):
# class Argument(T):
# class _HasArgs(T):
# class Alias(T):
# class Macro(T):
# class File(T):
# class Function(_HasArgs):
# class Ignored(_HasArgs):
# class OperatorFunction(_HasArgs):
# class FunctionType(_HasArgs):
# class Method(_HasArgs):
# class FundamentalType(T):
# class PointerType(T):
# class Typedef(T):
# class ArrayType(T):
# class StructureHead(T):
# class StructureBody(T):
# class _Struct_Union_Base(T):
# class Structure(_Struct_Union_Base):
# class Union(_Struct_Union_Base):
# class Field(T):
# class CvQualifiedType(T):
# class Enumeration(T):
# class EnumValue(T):
# class Variable(T):
# class UndefinedIdentifier(T):
#     def __repr__(self):
#     def __init__(self, name, _type):
#     def __init__(self):
#     def add_argument(self, arg):
#     def iterArgTypes(self):
#     def iterArgNames(self):
#     def fixup_argtypes(self, cb):
#     def __init__(self, name, alias, typ=None):
#     def __init__(self, name, args, body):
#     def __init__(self, name):
#     def __init__(self, name, returns, attributes, extern):
#     def __init__(self, name):
#     def __init__(self, name, returns):
#     def __init__(self, returns, attributes, name=''):
#     def __init__(self, name, returns):
#     def __init__(self, name, size, align):
#     def __init__(self, typ, size, align):
#     def __init__(self, name, typ):
#     def __init__(self, typ, size):
#     def __init__(self, struct):
#     def name(self):
#     def __init__(self, struct):
#     def name(self):
#     def get_body(self):
#     def get_head(self):
#     def __init__(self, name, align, members, bases, size, artificial=None,
#                  packed=False):
#     def __init__(self, name, align, members, bases, size, artificial=None,
#                  packed=False):
#     def __init__(self, name, typ, offset, bits, is_bitfield=False,
#                  is_anonymous=False, is_padding=False):
#     def __init__(self, typ, const, volatile):
#     def __init__(self, name, size, align):
#     def add_value(self, v):
#     def __init__(self, name, value, enumeration):
#     def __init__(self, name, typ, init=None, extern=False):
#     def __init__(self, name):
#     def __str__(self):
# def is_record(t):


# Path: ctypeslib/codegen/util.py
from clang.cindex import Cursor
from clang.cindex import TranslationUnit
from collections.abc import Iterable
from ctypeslib.codegen import typedesc
import logging
import re


class ADict(dict):

    def __getattr__(self, name):
        try:
            return self[name]
        except KeyError:
            raise AttributeError(name)


_c_literal_regex = re.compile(
    r"^([+-]?((\d+(e|E)[+-]?\d+)|(\d+(\.\d*)?((e|E)[+-]?\d+)?)|(\.\d+((e|E)[+-]?\d+)?)))(f|F|l|L)?$"
)


def from_c_float_literal(value):
    if (not isinstance(value, str) and
            isinstance(value, Iterable) and
            all(map(lambda v: isinstance(v, str), value))):
        value = "".join(value)
    if not isinstance(value, str):
        return None
    match = _c_literal_regex.match(value)
    if not match:
        return None
    return match.group(1)


def contains_undefined_identifier(macro):
    # body is undefined

    if isinstance(macro.body, typedesc.UndefinedIdentifier):