<commit_before>#!/usr/bin/env python

'''
ctypesgencore.ctypedescs contains classes to represent a C type. All of them
classes are subclasses of CtypesType.

Unlike in previous versions of ctypesgen, CtypesType and its subclasses are
completely independent of the parser module.

The most important method of CtypesType and its subclasses is the py_string
method. str(ctype) returns a string which, when evaluated in the wrapper
at runtime, results in a ctypes type object.

For example, a CtypesType
representing an array of four integers could be created using:

>>> ctype = CtypesArray(CtypesSimple("int",True,0),4)

str(ctype) would evaluate to "c_int * 4".
'''

import warnings

__docformat__ = 'restructuredtext'

ctypes_type_map = {
   # typename   signed  longs
    ('void',    True,   0): 'None',
    ('int',     True,   0): 'c_int',
    ('int',     False,  0): 'c_uint',
    ('int',     True,   1): 'c_long',
    ('int',     False,  1): 'c_ulong',
    ('int',     True,   2): 'c_longlong',
    ('int',     False,  2): 'c_ulonglong',
    ('char',    True,   0): 'c_char',
    ('char',    False,  0): 'c_ubyte',
    ('short',   True,   0): 'c_short',
    ('short',   False,  0): 'c_ushort',
    ('float',   True,   0): 'c_float',
    ('double',  True,   0): 'c_double',
    ('size_t',  True,   0): 'c_size_t',
    ('int8_t',  True,   0): 'c_int8',
    ('int16_t', True,   0): 'c_int16',
    ('int32_t', True,   0): 'c_int32',
    ('int64_t', True,   0): 'c_int64',
    ('apr_int64_t',True,0): 'c_int64',
    ('off64_t', True,   0): 'c_int64',
    ('uint8_t', True,   0): 'c_uint8',
    ('uint16_t',True,   0): 'c_uint16',
    ('uint32_t',True,   0): 'c_uint32',
    ('uint64_t',True,   0): 'c_uint64',
    ('apr_uint64_t',True,0): 'c_uint64',
    ('wchar_t', True,   0): 'c_wchar',
    ('ptrdiff_t',True,  0): 'c_ptrdiff_t',  # Requires definition in preamble
    ('ssize_t', True,   0): 'c_ptrdiff_t',  # Requires definition in preamble
    ('va_list', True,   0): 'c_void_p',
}

# This protocol is used for walking type trees.
class CtypesTypeVisitor(object):
    def visit_struct(self, struct):
        pass

    def visit_enum(self, enum):
        pass
    
    def visit_typedef(self, name):
        pass
    <commit_msg>* ctypesgencore/ctypedescs.py:   Define more aliases with extra underscores for Mac OS X  <commit_after>#!/usr/bin/env python

'''
ctypesgencore.ctypedescs contains classes to represent a C type. All of them
classes are subclasses of CtypesType.

Unlike in previous versions of ctypesgen, CtypesType and its subclasses are
completely independent of the parser module.

The most important method of CtypesType and its subclasses is the py_string
method. str(ctype) returns a string which, when evaluated in the wrapper
at runtime, results in a ctypes type object.

For example, a CtypesType
representing an array of four integers could be created using:

>>> ctype = CtypesArray(CtypesSimple("int",True,0),4)

str(ctype) would evaluate to "c_int * 4".
'''

import warnings

__docformat__ = 'restructuredtext'

ctypes_type_map = {
   # typename   signed  longs
    ('void',    True,   0): 'None',
    ('int',     True,   0): 'c_int',
    ('int',     False,  0): 'c_uint',
    ('int',     True,   1): 'c_long',
    ('int',     False,  1): 'c_ulong',
    ('int',     True,   2): 'c_longlong',
    ('int',     False,  2): 'c_ulonglong',
    ('char',    True,   0): 'c_char',
    ('char',    False,  0): 'c_ubyte',
    ('short',   True,   0): 'c_short',
    ('short',   False,  0): 'c_ushort',
    ('float',   True,   0): 'c_float',
    ('double',  True,   0): 'c_double',
    ('size_t',  True,   0): 'c_size_t',
    ('int8_t',  True,   0): 'c_int8',
    ('int16_t', True,   0): 'c_int16',
    ('int32_t', True,   0): 'c_int32',
    ('int64_t', True,   0): 'c_int64',
    ('apr_int64_t',True,0): 'c_int64',
    ('off64_t', True,   0): 'c_int64',
    ('uint8_t', True,   0): 'c_uint8',
    ('uint16_t',True,   0): 'c_uint16',
    ('uint32_t',True,   0): 'c_uint32',
    ('uint64_t',True,   0): 'c_uint64',
    ('apr_uint64_t',True,0): 'c_uint64',
    ('wchar_t', True,   0): 'c_wchar',
    ('ptrdiff_t',True,  0): 'c_ptrdiff_t',  # Requires definition in preamble
    ('ssize_t', True,   0): 'c_ptrdiff_t',  # Requires definition in preamble
    ('va_list', True,   0): 'c_void_p',
}

# Some compilers define these built-in types with extra underscores in front as well --
# make those work too
for typename, signed, bits in ctypes_type_map.keys():
    ctypes_type_map[("__%s" % typename, signed, bits)] = ctypes_type_map[(typename, signed, bits)]

# This protocol is used for walking type trees.
class CtypesTypeVisitor(object):
    def visit_struct(self, struct):
        pass

    def visit_enum(self, enum):
        pass
    
    def visit_typedef(self, name):
        pass
    
{'fraction_non_alphanumeric': 0.1572052401746725, 'fraction_numerical': 0.02994385527136619, 'mean_word_length': 3.302325581395349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7431402', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1780, 'n_words': 510}