AlkantarClanX12

Your IP : 3.16.70.99


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/cffi/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/cffi/__pycache__/cparser.cpython-311.pyc

�

l��fǬ��l�ddlmZddlmZmZddlmZmZ	ddlmZ	n#e
$rddl	Z	YnwxYwddlZddlZddl
Z
	e
jdkrddlZnddlZej��Zn
#e
$rdZYnwxYwd�Zd	Zejd
ejejz��Zejdejejz��Zejdej��Zejd
��Zejd��Zejd��Zejd��Zdaejdej ��Z!ejd��Z"ejd��Z#ejd��Z$ejd��Z%ejd��Z&ejd��Z'ejd��Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d �Z0d!�Z1Gd"�d#e2��Z3dS)$�)�model)�COMMON_TYPES�resolve_common_type)�FFIError�	CDefError)�
_pycparser�N)�c��ddl}ddl}dS�Nr	)�pycparser.yacctab�pycparser.lextab)�	pycparsers �n/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/cffi/cparser.py�%_workaround_for_static_import_findersrs"������������z<cdef source string>z/\*.*?\*/|//([^\n\\]|\\.)*?$z?^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)\b((?:[^\n\\]|\\.)*?)$z^[ \t]*#[ \t]*(?:line|\d+)\b.*$z=\s*\.\.\.\s*[,}]|\.\.\.\s*\}z__dotdotdot\d+__$z\[\s*\.\.\.\s*\]z\w+|\Sz-?0?x?[0-9a-f]+[lu]*$z\b(__stdcall|WINAPI)\bz[(]\s*(__stdcall|WINAPI)\bz\b__cdecl\bz9\bextern\s*"(Python|Python\s*\+\s*C|C\s*\+\s*Python)"\s*.z'[*]\s*((const|volatile|restrict)\b\s*)+z3(\b(int|long|short|signed|unsigned|char)\s*)+\.\.\.z\b(double|float)\s*\.\.\.c�D�t�tj��atS�N)�
_parser_cacher�CParser�rr�_get_parserr2s����!�)�+�+�
��rc���g}	t�|��}|s�n,|�|d|������|�d��d}|�|�����|���}|�d|��r|�d��|dz
}d}|}|t|��krJ||}|dkr|dz
}n|dkr
|dkrn)|dz}n|dvr|dkrn|dz
}|t|��k�J|||�|z||d�z}��J|�|��d�|��S)	NT�(�)�*r	rz,;=�)	�_r_star_const_space�search�append�start�group�end�
startswith�len�join)�csource�parts�match�closing�endpos�level�i�cs        r�_workaround_for_old_pycparserr/8s���
�E�<�#�*�*�7�3�3���	��
���W�^�e�k�k�m�m�^�,�-�-�-�
���S����S�7�
���U�[�[�]�]�#�#�#����������c�6�*�*�	.��L�L�����w�#�~�w������#�g�,�,�����
�A��C�x�x���
����c����A�:�:����
����e����A�:�:��
��F�A��#�g�,�,����&��(�#�g�-������;��3<�6
�L�L�����
�7�7�5�>�>�rc��g}	t�|��}|s�n�|���dz
}|�|d|������d|�d��vr|�d��n|�d��||dkr�|�d|��}|dkrtd	���|�d|dz|��dkrtd
���|�||dz|���||dzd�}nX|�d|��}|dkrtd���|�|||dz���||dzd�}|�d
�����|�|��d�	|��S)NTr�Cz(void __cffi_extern_python_plus_c_start; z!void __cffi_extern_python_start; �{�}r	z!'extern "Python" {': no '}' foundz7cannot use { } inside a block 'extern "Python" { ... }'�;z'extern "Python": no ';' foundz  void __cffi_extern_python_stop;r)
�_r_extern_pythonrr#r r!r"�findr�NotImplementedErrorr&)r'r(r)r+r*�	semicolons      r�_preprocess_extern_pythonr9bs���
�E�9� �'�'��0�0���	�������q���	���W�^�e�k�k�m�m�^�,�-�-�-��%�+�+�a�.�.� � ��L�L�C�D�D�D�D��L�L�<�=�=�=��6�?�c�!�!��l�l�3��/�/�G���{�{�� E�F�F�F��|�|�C��!��W�5�5��:�:�)�+H�I�I�I��L�L�����'�!1�2�3�3�3��g�a�i�j�j�)�G�G� ���S�&�1�1�I��1�}�}�� B�C�C�C��L�L���	�!��!3�4�5�5�5��i��k�l�l�+�G�
���7�8�8�8�=9�B
�L�L�����
�7�7�5�>�>�rc���d|vrdS|���D]I}d|vrC|����d��sddl}|�d��dS�JdS)N�"�#r	z�String literal found in cdef() or type source. String literals are ignored here, but you should remove them anyway because some character sequences confuse pre-parsing.)�
splitlines�lstripr$�warnings�warn)r'�liner?s   r�_warn_for_string_literalrB�s���
�'������"�"�$�$�����$�;�;�t�{�{�}�}�7�7��<�<�;��O�O�O��M�M�1�
2�
2�
2�
�E�E���rc�\�|js$ddl}|�d|j�d���dSdS)Nr	zGlobal variable 'z_' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern'))�storager?r@�name)�declr?s  r�/_warn_for_non_extern_non_static_global_variablerG�sO���<�;������
�
�
�.2�i�i�i�:�	;�	;�	;�	;�	;�;�;rc�P��g��fd�}t�||��}|�fS)Nc�z��t���}��|�����d|zS)Nz#line@%d)r%r r")�mr-�line_directivess  �r�replacez(_remove_line_directives.<locals>.replace�s6����� � �����q�w�w�y�y�)�)�)��A�~�r��_r_line_directive�sub)r'rLrKs  @r�_remove_line_directivesrP�sE���
�O������ �#�#�G�W�5�5�G��O�#�#rc�D���fd�}t�||��S)Nc���|���}|�d��std����t|dd���S)Nz#line@zBunexpected #line directive (should have been processed and removed�)r"r$�AssertionError�int)rJ�srKs  �rrLz*_put_back_line_directives.<locals>.replace�sY���
�G�G�I�I���|�|�H�%�%�	L� �"K�L�L�
L��s�1�Q�R�R�5�z�z�*�*rrM)r'rKrLs ` r�_put_back_line_directivesrW�s4���+�+�+�+�+�� � ��'�2�2�2rc�8�t|��\}}d�}t�||��}i}t�|��D]F}|���\}}|�dd�����}|||<�Gt�d|��}tj	dkrt|��}t�d|��}t�d|��}t�d|��}t|��}t|��t �d|��}t#t$�|����}t't)|����D]�\}}|���}	||	d	krM|�d
|	|�����}
|
|	ksJ�d|d|	�|||
dzd�fz}�r||	|	dz�d
ksJ�d
|d|	�|||	dzd�fz}��t0�d|��}t2�d|��}|�d
d��}t5||��}||fS)Nc�\�d|����d��dzzS)N� �
)r"�count)rJs r�replace_keeping_newlinesz-_preprocess.<locals>.replace_keeping_newlines�s&���Q�W�W�Y�Y�_�_�T�*�*�T�1�1�1rz\
rz2.14z volatile volatile const(z volatile volatile const rZz[__dotdotdotarray__]�=�...z%s,__dotdotdot%d__ %sr
z%s __dotdotdot%d__ %sz __dotdotdotint__ z __dotdotdotfloat__ z __dotdotdot__ )rP�
_r_commentrO�	_r_define�finditer�groupsrL�stripr�__version__r/�_r_stdcall2�_r_stdcall1�_r_cdeclr9rB�_r_partial_array�list�_r_partial_enum�	enumerate�reversedr!r6r#�_r_int_dotdotdot�_r_float_dotdotdotrW)r'rKr]�macrosr)�	macroname�
macrovalue�matches�number�p�p2s           r�_preprocessrw�s��� 7�w�?�?��G�_�2�2�2��n�n�5�w�?�?�G�
�F��#�#�G�,�,�'�'�� %������	�:��'�'���3�3�9�9�;�;�
�&��y����m�m�B��(�(�G���v�%�%�/��8�8���o�o�9�7�C�C�G��o�o�9�7�C�C�G��l�l�3��(�(�G�(��0�0�G��W�%�%�%��"�"�#9�7�C�C�G��?�+�+�G�4�4�5�5�G�"�8�G�#4�#4�5�5�
@�
@�
����K�K�M�M���1�:�������e�Q��	�	���4�4�B���6�6�6�6�-���!���f�18��A�����1A�A�G�G��1�Q�q�S�5�>�U�*�*�*�*�-���!���f�18��1�����1@�@�G�G��"�"�#7��A�A�G� �$�$�%;�W�E�E�G��o�o�e�%6�7�7�G�'���A�A�G��F�?�rc��tt��}|�d��|�d��|�d��|�d��|�d��t��}d}d}d}t�|��D]�}||vr�|dkr/|r,|�|��|�|��d}nq|dkrd	}d}nf|dkr|d
z
}nZ|dkr|d
z}nN|dkr3|r0|dkr*|�|��|�|��n|�|��|}��|S)Nr4�,rr�typedefFr	rTr)�setr�add�_r_words�findall�discard)r'�look_for_words�
words_used�
is_typedef�paren�
previous_word�words       r�_common_type_namesr��s�����&�&�N����s�������s�������s�������s�������y�!�!�!����J��J�
�E��M�� � ��)�)�����>�!�!��s�{�{��'��&�&�}�5�5�5�"�*�*�=�9�9�9�!&�J����"�"�!�
����������
���������
��������:�%�1�*�*��&�&�}�5�5�5�"�*�*�=�9�9�9�����t�$�$�$��
�
��rc���eZdZd�Zd�Zd�Zd�Z		dd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd d�Zd�Zd!d�Z		d"d�Zd!d�Zd�Zd#d�Zd�Zd$d�Zd�Zd�Zd�Zd�Zd�ZdS)%�Parserc��i|_t��|_d|_t	j��|_i|_i|_g|_	d|_
dSr)�
_declarationsr{�_included_declarations�_anonymous_counter�weakref�WeakKeyDictionary�_structnode2type�_options�_int_constants�_recomplete�_uses_new_feature)�selfs r�__init__zParser.__init__)sT�����&)�e�e��#�"#��� '� 9� ;� ;�����
� ������!%����rc���t|��\}}t|��}g}t|j��D]K}|�d��r4|dd�}|�|��|�|���L|t|��z
}g}|�d��|D]}|�d|z���|�d��|�dt�d���|�|��d�|��}t�t�
��	t���|��}	n7#tjj$r }
|�|
|��Yd}
~
nd}
~
wwxYwt�t���n&#t�t���wwxYw|	||fS)	N�typedef �z*# 1 "<cdef automatic initialization code>"ztypedef int %s;z@typedef int __dotdotdotint__, __dotdotdotfloat__, __dotdotdot__;z# 1 "r;r[)rwr��sortedr�r$r r�CDEF_SOURCE_STRINGr&�lock�acquirer�parser�c_parser�
ParseError�convert_pycparser_error�release)r�r'rp�ctn�	typenamesrE�csourcelines�typename�fullcsource�ast�es           r�_parsez
Parser._parse3s��%�g�.�.����
!��)�)���	��4�-�.�.�	"�	"�D����z�*�*�
"��A�B�B�x��� � ��&�&�&����D�!�!�!���V�C�[�[� �	������H�I�I�I�!�	>�	>�H���� 1�H� <�=�=�=�=����.�	/�	/�	/�	����*<�*<�*<�>�?�?�?����G�$�$�$��i�i��-�-�����L�L�N�N�N�	��-�-�%�%�k�2�2�C�C���!�,�	5�	5�	5��(�(��G�4�4�4�4�4�4�4�4�����	5����������������������� �����F�G�#�#s0�!E*�)G�*F�>F�G�F�G�#G%c�$�d}t|��}tjt�d�|��}|r_t	|�d��d��}|���}d|cxkrt|��krnn||dz
}|S)Nz:(\d+):r�
)�str�rer)r�rUr"r=r%)r�r�r'rA�msgr)�linenumr�s        r�_convert_pycparser_errorzParser._convert_pycparser_errorYs������!�f�f����);�);�);�=�s�C�C���	/��%�+�+�a�.�.�"�-�-�G�"�-�-�/�/�L��G�0�0�0�0�s�<�0�0�0�0�0�0�0�#�G�A�I�.���rc��|�||��}t|��}|rd|����d|��}nd|��}t|���)Nzcannot parse "z"
zparse error
)r�r�rdr)r�r�r'rAr�s     rr�zParser.convert_pycparser_errorgsf���,�,�Q��8�8���!�f�f���	-�	-�-1�Z�Z�\�\�\�\�3�3�?�C�C�	-�(+�s�,�C���n�n�rFNc��|r)|dkrtd���|rtd���d}n|r||dz
zrtd|�����nd}|j}	|||d�|_|�|��||_dS#||_wxYw)NTzB'packed' should be False or True; use 'pack' to give another valuez$cannot give both 'pack' and 'packed'rz#'pack' must be a power of two, not r	)�override�packed�	dllexport)�
ValueErrorr��_internal_parse)r�r'r�r��packr��prev_optionss       rr�zParser.parseqs����	���~�~� �"@�A�A�A��
I� �!G�H�H�H��D�D�
�	��t�a�x� �
� �j��T�"����
��D��}��	)�)1�'+�*3�5�5�D�M�
� � ��)�)�)�(�D�M�M�M��L�D�M�(�(�(�(s� A<�<	Bc	��|�|��\}}}|�|��t|j��}|D]}|jdkrn�J�d}	d|_|D�]}|}t
|tjj	��r|�
|���:t
|tjj���r�|jstd|���d}t
|j
j
tjj��r@|j
j
jd�d��r|�|��}n�t
|j
tjj��r�t
|j
j
tjj��rst
|j
j
j
tjj��rE|j
j
j
jd�d��r|�|��}n/|�|j
|jdd|j�d	��
��\}}|�d|jz||������|jjd
kr���td|jjz|���dS#t$r.}	t3|	j��dkr|	j|fz|	_�d}	~	wt6$r7}	|�|	|��}
|
r|	jdd|
zzf|	_�d}	~	wwxYw)N�
__dotdotdot__r	�__cffi_extern_python_stopz!typedef does not declare any name����__dotdotdotTz*(z *)0)rE�partial_length_ok�typedef_exampler���quals�PragmazBunexpected <%s>: this construct is valid C but not valid in cdef()rz
    *** Err: %s)r��_process_macros�iter�extrE�_inside_extern_python�
isinstancer�c_ast�Decl�_parse_decl�Typedefr�type�IdentifierType�namesr$�_get_unknown_type�PtrDecl�TypeDecl�_get_unknown_ptr_type�_get_type_and_quals�_declare�	__class__�__name__r%�argsrr�)r�r'r�rp�iteratorrF�current_declr��realtyper�r�s           rr�zParser._internal_parse�s0��#�{�{�7�3�3���V�W����V�$�$�$����=�=���	�	�D��y�O�+�+���,�
�1���'	�)D�D�&� �
C�
C��#���d�I�O�$8�9�9�C��$�$�T�*�*�*�*���i�o�&=�>�>�C��9�.�'�(K�(,�.�.�.��E�"�4�9�>�9�?�3Q�R�R�G� �I�N�0��4�?�?�
�N�N�G�#'�#9�#9�$�#?�#?���$�T�Y�	��0G�H�H�	G�$�T�Y�^�Y�_�5M�N�N�	G�$�T�Y�^�%8�%.�_�%C�E�E�	G��)�.�-�3�B�7�B�B�=�Q�Q�		G�
$(�#=�#=�d�#C�#C���*.�*B�*B� �I�D�I���:>�)�)�)�,E�+C�+G�+G���%��M�M�*�t�y�"8�(�%�M�P�P�P�P��^�,��8�8��#�%@�$(�N�$;�%<�=A�C�C�C�5
C�
C��:�	�	�	��1�6�{�{�a�����<�/�1���������	�	�	��/�/��7�;�;�C��
B��&��)�&9�C�&?�?�A��������		���s%�H%J�
K8�)J4�4
K8�2K3�3K8c�v�||jvr%|j||krdStd|�����||j|<dS)Nz#multiple declarations of constant: )r�r)r��key�vals   r�_add_constantszParser._add_constants�sZ���$�%�%�%��"�3�'�3�.�.����(�;>�3�@�B�B�
B�#&���C� � � rc��|����d��}|�d��}|r
|dd�}|�d��r(|dkr"|�d��s
d|dd�z}t|d��}|r|}|�||��|�d|z|��dS)	N�ul�-r�0�0x�0or	�macro )�lower�rstripr$rUr�r�)r�rE�int_str�neg�pyvalues     r�_add_integer_constantzParser._add_integer_constant�s����-�-�/�/�(�(��.�.��� � ��%�%���	"��a�b�b�k�G����s�#�#�	)��3����*�*�4�0�0�)7��W�Q�R�R�[�(�G��g�q�/�/���	��h�G����D�'�*�*�*��
�
�h��o�w�/�/�/�/�/rc�8�|���D]�\}}|���}t�|��r|�||���J|dkr|�d|z|���jt
d|�d|�d|�d|�����dS)Nr_r�z5only supports one of the following syntax:
  #define z+ ...     (literally dot-dot-dot)
  #define zM NUMBER  (with NUMBER an integer constant, decimal/hex/octal)
got:
  #define rZ)�itemsrd�_r_int_literalr)r�r�r)r�rpr��values    rr�zParser._process_macros�s��� �,�,�.�.�	.�	.�J�C���K�K�M�M�E��#�#�E�*�*�
.��*�*�3��6�6�6�6��%����
�
�h��n�e�4�4�4�4��i��s�s�C�C�C����e�e�
-�.�.�.�	.�	.rc���|�||��}|j�d��rd}n|jdkrd}n|jdkrd}nd}|�||jz|��dS)Nr�zdllexport_python �__cffi_extern_python_startzextern_python �!__cffi_extern_python_plus_c_startzextern_python_plus_c z	function )�_get_type_pointerr��getr�r�rE)r��tpr�rF�tags     r�_declare_functionzParser._declare_function�s���
�
#�
#�B��
.�
.���=���[�)�)�	�%�C�C�
�
'�+G�
G�
G�"�C�C�
�
'�+N�
N�
N�)�C�C��C��
�
�c�D�I�o�r�*�*�*�*�*rc���|j}t|tjj��rT|�||j���\}}t|tj��sJ�|�	|||��dSt|tjj
��r|�d|��n�t|tjj��r|�d|��nMt|tjj
��r|�d|��n|jstd|���|j�r1|�|d���\}}|jr|�	|||��dS|���rpt#|d��r`t#|jd	��rKt&�|jj��r'|�|j|jj��dS|���r�t|jtjj��r�|jjd
krrt#|jjd	��rXt&�|jjj��r/|�|jd
|jjjz��dS|tjur(|j�d��r|j|_dS|jdkrtd
���|tjzr)|js"|�d|jz||���dStA|��|�d|jz||���dSdS)N)rE�struct�union�enumz'construct does not declare any variableT�r��initr�r��__cffi_extern_python_r�z<cannot declare constants or variables with 'extern "Python"'z	constant r�z	variable )!r�r�rr��FuncDeclr�rEr�RawFunctionTyper��Struct�_get_struct_union_enum_type�Union�Enumr�is_raw_function�is_integer_type�hasattrr�r�r)r�r��UnaryOp�op�expr�	void_typer$r��Q_CONST�
is_array_typer�rG)r�rF�noder�r�s     rr�zParser._parse_decl�s����y���d�I�O�4�5�5�/	P��0�0��D�I�0�F�F�I�B���b�%�"7�8�8�8�8�8��"�"�2�u�d�3�3�3�3�3��$�	�� 6�7�7�
&��0�0��4�@�@�@�@��D�)�/�"7�8�8�
&��0�0��$�?�?�?�?��D�)�/�"6�7�7�
&��0�0���>�>�>�>��Y�
&�� I� $�&�&�&��y� 
P� �4�4�T�GK�5�M�M�	��E��%�P��*�*�2�u�d�;�;�;�;�;��(�(�*�*�P���f�-�-�P���	�7�3�3�P�'�,�,�T�Y�_�=�=�P��.�.�t�y�$�)�/�J�J�J�J�J��(�(�*�*�P�"�4�9�i�o�.E�F�F�P��	���+�+���	���8�8�,�&�,�,�T�Y�^�-A�B�B�,��.�.�t�y�/2�T�Y�^�5I�/I�K�K�K�K�K��E�O�+�+��i�*�*�+B�C�C�,�
26��D�.�.�.��1�4O�O�O�'�A�B�B�B���
�-�P�r�7G�P��
�
�k�D�I�&=�r��
�O�O�O�O�O�G��M�M�M��
�
�k�D�I�&=�r��
�O�O�O�O�O�A 
P� 
Prc�8�|�|��dSr)�parse_type_and_quals)r��cdecls  r�
parse_typezParser.parse_type's���(�(��/�/��2�2rc�6�|�d|z��dd�\}}|rJ�|jdjjjd}t|tjj��rtd|j
�d����|�|j��S)Nzvoid __dummy(
%s
);�r�r	zunknown identifier '�')r�r�r�r��paramsr�rr��IDrrEr�)r�rr�rp�exprnodes     rrzParser.parse_type_and_quals*s����k�k�"9�E�"A�B�B�2�A�2�F���V����z��7�2�;�#�(�/��2���h�	�� 2�3�3�	J��)�����H�I�I�I��'�'��
�6�6�6rr	c�.�||jvrI|j|\}}||ur||krdS|j�d��std|�d����d|���vsJ�||f|j|<|r|j�|��dSdS)Nr�zmultiple declarations of z5 (for interactive usage, try cdef(xx, override=True))r�)r�r�r�r�splitr�r|)r�rE�obj�includedr��prevobj�	prevqualss       rr�zParser._declare2s����4�%�%�%�!%�!3�D�!9��G�Y��#�~�~�)�u�"4�"4����=�$�$�Z�0�0�
>��h�6:�d�d�=�>�>�>��d�j�j�l�l�2�2�2�2�$'��<���4� ��	1��'�+�+�C�0�0�0�0�0�	1�	1rc��d}t|tjjtjjf��rHd|jvr|tjz}d|jvr|tjz}d|jvr|tj	z}|S)Nr	�const�volatile�restrict)
r�rr�r�r�r�rr
�
Q_VOLATILE�
Q_RESTRICT�r�r�r�s   r�_extract_qualszParser._extract_quals@s������d�Y�_�5�&�_�4�6�7�7�	*��$�*�$�$����&���T�Z�'�'���)�)���T�Z�'�'���)�)���rc�p�t|tj��r|���St|tj��rZ|j�d��r@|jdd����r|j�|�tj	|||��Stj
||��S)N�$r)r�rr�as_function_pointer�StructOrUnionOrEnumrEr$�isdigit�	forcename�NamedPointerType�PointerType)r�r�r��declnames    rr�zParser._get_type_pointerLs����d�E�1�2�2�	.��+�+�-�-�-��t�U�6�7�7�	A��	�$�$�S�)�)�	A�.2�i����m�.C�.C�.E�.E�	A���&�8�+?��)�$��%�@�@�@�� ��u�-�-�-rc�4	�t|tjj��r�t|jtjj��rxt
|jj��dkr[d|jjdz|jvr?|jd|jjdz\}}||�	|��z}||fSt|tjj
��rp|j�d}n|�|j|���}|�|dkrd|�d�}d|z}|�
|j||�	��\}}tj||��|fSt|tjj��rN|�
|j��\}}	|�||	|�
��}|�	|��}||fSt|tjj���r�|�	|��}|j}
t|
tjj���rt%|
j��}|ddgkr�i}|r/|d}|d
vr |�|d��dz||<|d=nn|�/g}
dD]=}t)|�|d����D]}|
�|����>|sdg}|dgkr
d|vsd|vrg}|
|z}d�|��}|dkrtj|fS|dkrt1d|jjz���t7||��\}}|||zfSt|
tjj��r|�d|
|��}||fSt|
tjj��r|�d|
|��}||fSt|
tjj��r|�d|
|��}||fSt|tjj ��r|�!||��dfSt|tjj��r|�d||d���dfSt|tjj��r|�d||d���dfSt1d|jjz���)Nrr�r	r�r_z_cffi_array_len(rr)r�r�)r0�signed�char)�short�longr2�unsigned)r6r4r5rUr4r5rZ�voidr�z:%d: bad usage of "..."r�r�r�T)�nestedz(:%d: bad or unsupported type declaration)"r�rr�r�r�r�r%r�r�r'�	ArrayDecl�dim�_parse_constantr�r�	ArrayTyper�r�rjr��ranger r&rr�coordrArrrrrr�_parse_function_type)r��typenoderEr�r�r�r��length�itemtype�	itemqualsr�r��prefixes�newnames�prefixr-�ident�tp0�quals0s                   rr�zParser._get_type_and_qualsUs$��
�x���!9�:�:�	��x�}�i�o�&D�E�E�	���
�#�$�$��)�)�
�(�-�-�a�0�
0�T�5G�G�G��*�:��
�8K�A�8N�+N�O�I�B���T�(�(��2�2�2�E��u�9���h�	�� 9�:�:�	6��|�#�����-�-��L�4E�.�G�G���*��U�?�?�?�6E�o�o�G�F�"%��"7���0�0���2C�0?�1�A�A�I�B���?�2�v�.�.��5�5��h�	�� 7�8�8�	�"&�":�":�8�=�"I�"I��H�i��'�'��)�d�'�K�K�B��'�'��1�1�E��u�9���h�	�� 8�9�9�1	!��'�'��1�1�E��=�D��$�	�� >�?�?�
-��T�Z�(�(���X�v�.�.�.�!�H��"�$�Q�x���#J�J�J�-5�\�\�$��-B�-B�Q�-F�H�T�N� %�a���!�
 �"� "�H�"?�4�4��!&�x�|�|�F�A�'>�'>�!?�!?�4�4�A�$�O�O�F�3�3�3�3�4� �(�!&������'�'�"�h�.�.�&�H�2D�2D�$&�E�$�u�,�E���������F�?�?� �?�E�1�1��O�+�+�"�#<�$�N�/�$0�1�1�1�1�$��>�>���V��U�V�^�,�,��$�	�� 6�7�7�
!��5�5�h��d�K�K���5�y� ��$�	�� 5�6�6�
!��5�5�g�t�T�J�J���5�y� ��$�	�� 4�5�5�
!��5�5�f�d�D�I�I���5�y� ��h�	�� 8�9�9�	@��,�,�X�t�<�<�a�?�?��h�	�� 6�7�7�	D��3�3�H�h��;?�4�A�A�BC�D�
D��h�	�� 5�6�6�	D��3�3�G�X�t�;?�4�A�A�BC�D�
D��A���#�$�%�%�	%rc�|��tt|jdg����}t|��D]>\}}t	|d��s)td|pd|dzt|dd��fz����?t
|��dkott|d	jtj
j��oJt|d	jjtj
j��o|d	jjj
d
gk}|r*|���|std|pdz����fd�|D��}|s|tjgkrg}��|j��\}}	d}
t	|jd
��r|jjdd�gd�krd}
tjt)|��|||
��S)Nrr�zt%s arg %d: unknown type '%s' (if you meant to use the old C syntax of giving untyped arguments, it is not supported)z
in expressionrrE�?r	r�r�z=%s: a function with only '(...)' as argument is not correct Cc�T��g|]$}�j��|j�����%Sr)�_as_func_argr�r�)�.0�argdeclnoder�s  �r�
<listcomp>z/Parser._parse_function_type.<locals>.<listcomp>�sD���+�+�+��"��!�4�#;�#;�K�<L�#M�#M�N�+�+�+rr����)r"r"r!�	__stdcall)rj�getattrr�rlrrr%r�r�rr�r�r�r��poprrr�r�r�tuple)r�r@�funcnamerr-�arg�ellipsisr��resultr��abis`          rr?zParser._parse_function_type�s����g�h�m�X�r�:�:�;�;����'�'�	3�	3�F�A�s��3��'�'�
3��!?� �2�?�A��E��s�F�C�0�0�2�!2�3�3�3�
3�
��K�K�!�O�
<��v�b�z��	��(@�A�A�
<��v�b�z��+� ��5�
7�
7�
<�
�2�J�O� �&�?�*;�;�	��	I��J�J�L�L�L��
I��(�+3�+F��H�I�I�I�+�+�+�+�#)�+�+�+���	�D�U�_�$5�5�5��D��0�0���?�?�
������8�=�'�*�*�	"��}�"�2�3�3�'�+L�+L�+L�L�L�!���$�U�4�[�[�&�(�C�H�H�Hrc���t|tj��rtj|j|��St|tj��r|���S|Sr)r�rr<r/�itemrr*r&s   rrMzParser._as_func_arg�sW���d�E�O�,�,�	��$�T�Y��6�6�6�
��e�3�
4�
4�	��+�+�-�-�-��Krc��	|j|S#t$rYnwxYw|}|j}|�%|�d|z}n|xjdz
c_d|jz}d}n'|}|�d|��}|j�|d��\}}	|��|dkrt
j|ddd��}ng|dkrt
j|ddd��}nI|dkr1|d	krtd
���|�
||j��}ntd|�����|�|�
||��n|dkr|j�td|z���|js|�|��|jr'd
|jvr|�
d|jz|��||j|<|dkr|S|j�|S|j�td|z���g}
g}g}g}
|jD�]Z}t'|jt*jj��r:d�|jj��d	kr|�||���a|j�d}n|�|j��}d|_|�|jd���\}}|jr|�||��t'|tj��r|jr|�||��|
� |jpd��|� |��|� |��|
� |����\tC|
��|_tC|��|_"tC|��|_#tC|
��|_$|dgtK|��zkr3t'|tj��r|jrt|�d����|j&�d��|_'|j(r!d|_(|j)� |��|S)Nz$%srz$%drZ)NNr�r�r�r�z!Enums cannot be declared with ...zkind = z^enum %s: the '{}' declaration should appear on the first time the enum is mentioned, not laterr)zanonymous %sz"duplicate declaration of struct %srr�FTr�z!: using both bitfields and '...;'r�r	)*r��KeyErrorrEr�r�r�r�
StructType�	UnionTyper�_build_enum_type�valuesrTr�r7r-�force_the_name�decls�fldnamesr�r�rr�r�r&r��
_make_partial�bitsizer;�_partial_lengthr��partialr rU�fldtypes�
fldbitsize�fldqualsr%r�r��	completedr�)r��kindr�rEr8�
force_name�
explicit_namer�r��_rerjrkrlrFrg�fquals                 rrz"Parser._get_struct_union_enum_type�sr��	��(��.�.���	�	�	��D�	�����
��y���<��%� %�
� 2�
�
��'�'�1�,�'�'� %��(?� ?�
��B�B� �M�!�T�T�4�4�(�C��&�*�*�3��=�=�E�B��
�:��x����%�m�T�4��F�F��������_�]�D�$��E�E������� �O�3�3�#�$G�H�H�H��*�*�=�$�+�F�F���$�n�D�D�%:�;�;�;����
�
�c�2�&�&�&���v�~�~�$�+�"9�)�<�>K�L�M�M�M��|�	*����j�)�)�)�
�<�	=�C�2�7�N�N��M�M�.�2�<�7��<�<�<�&(���d�#��6�>�>��I�
�:���I�
�;�"��@�4�G�H�H�H������
����J�	#�	#�D��4�9�i�o�&D�E�E�
��G�G�D�I�O�,�,��?�?��"�"�2�v�.�.�.���|�#�����.�.�t�|�<�<��#(�D� ��2�2�4�9�EI�3�K�K�K�D�%��#�
/��"�"�2�v�.�.�.��$�� 0�1�1�
/�d�l�
/��"�"�2�v�.�.�.��O�O�D�I�O��,�,�,��O�O�D�!�!�!����g�&�&�&��O�O�E�"�"�"�"��H�o�o����H�o�o����j�)�)��
��H�o�o����"���J���/�/�/��"�e�.�/�/�
3�B�J�
3�)�-/�R�R�+2�3�3�3��M�%�%�h�/�/��	�
�<�	(��B�L���#�#�B�'�'�'��	s��
�c��t|tj��st|�d����|���s|st|�d����d|_dS)Nz cannot be partialz is partial but has no C nameT)r�r�
StructOrUnionr�
has_c_namer7ri)r�r�r8s   rrfzParser._make_partial_se���"�e�1�2�2�	<��b�b�b�:�;�;�;��}�}���	P�v�	P�%�"�"�"�&N�O�O�O���
�
�
rc���t|tjj���rr|j}d|dcxkrdkr�nn�|�d��}	|�d��rt|d��St|d��S#t$rzt|��dkrd|�
��dd�d	krt|d
��cYS|�
��dd�dkrt|d��cYSYnwxYwtd|�����|dd
krS|dd
krGt|��dkst|��dkr!|ddkrt|d��Std|�����t|tjj
��r%|jdkr|�|j��St|tjj
��r&|jdkr|�|j��St|tjj��r |j|jvr|j|jSt|tjj��r2|jdkr'|r	d|_dSt+d|jjz���t|tjj��r�|�|j��}|�|j��}|jdkr||zS|jdkr||z
S|jdkr||zS|jdkr|�||��S|jdkr||�||��|zz
S|jdkr||zS|jdkr||z	S|jdkr||zS|jdkr||zS|jd kr||zSt+d!|jjz���)"Nr�r	�9�uUlLr�r�rrr���0bzinvalid constant rr�r
��\����+r��__dotdotdotarray__Tr_zT:%d: unsupported '[...]' here, cannot derive the actual array length in this contextr�/�%z<<z>>�&�|�^z?:%d: unsupported expression: expected a simple numeric constant)r�rr��Constantr�r�r$rUr�r%r�r�ordr	r
r;rrrEr�rhrr>rA�BinaryOp�left�right�_c_div)r�rr�rVr�r�s      rr;zParser._parse_constantfs���h�	�� 8�9�9�	>���A��a��d�!�!�!�!�c�!�!�!�!�!��H�H�V�$�$��
-��|�|�C�(�(�*�"�1�a�y�y�(�"�1�b�z�z�)��!�-�-�-��1�v�v��z�z��7�7�9�9�Q�q�S�>�T�1�1�#&�q�"�:�:�-�-�-��W�W�Y�Y�q��s�^�t�3�3�#&�q�!�9�9�,�,�,���-���� �i��� <�=�=�=��1������2��#�����F�F�a�K�K�C��F�F�a�K�K�A�a�D�D�L�L��1�R�5�z�z�!��i��� <�=�=�=��x���!8�9�9�	7���s�"�"��'�'��
�6�6�6��x���!8�9�9�	8���s�"�"��(�(���7�7�7�7��x���!3�4�4�	6��
��!4�4�4��&�x�}�5�5��x���!3�4�4�	2��M�%9�9�9� �
�'+��$��u��E�%�^�0�1�2�2�
2��h�	�� 8�9�9�	$��'�'��
�6�6�D��(�(���8�8�E��{�c�!�!��e�|�#����#�#��e�|�#����#�#��e�|�#����#�#��{�{�4��/�/�/����#�#��d�k�k�$��6�6��>�>�>����$�$��u�}�$����$�$��u�}�$����#�#��e�|�#����#�#��e�|�#����#�#��e�|�#��1�3;�>�3F�G�H�H�	Hs�$B	�9B	�	A
D
�0D
�D
c�F�||z}|dk|dkzr||zdkr|dz
}|S)Nr	rr)r��a�brYs    rr�z
Parser._c_div�s:���a���
��U�q�1�u��	�A��E�a�<�<��a�K�F��
rc��|��d}g}g}d}|jD]�}t�|j��rd}�$|j�|�|j��}|�|j��|�|��|�|j|��|dz
}��t|��}t|��}tj
|||��}||_ntj
|dd��}|S)NFr	Trr)�enumerators�_r_enum_dotdotdotr)rEr�r;r r�rUr�EnumTyperi)	r�rprdrir��
enumvalues�
nextenumvaluer�r�s	         rrazParser._build_enum_type�s�����G��K��J��M��)�	
#�	
#��$�*�*�4�9�5�5��"�G���:�)�$(�$8�$8���$D�$D�M��"�"�4�9�-�-�-��!�!�-�0�0�0��#�#�D�I�}�=�=�=���"�
�
���,�,�K��z�*�*�J���
�{�J�G�G�B� �B�J�J���
�r�2�6�6�B��	rc�R�|j���D]W\}\}}|�d��r�|�dd��d}|dvr|�||d|����X|j���D]\}}|�||���dS)Nzanonymous $enum_$rZrr	)r�r�r��	anonymousrzT)rr�)r�r�r$rr�r�r�)r��otherrEr�r�rn�k�vs        r�includezParser.include�s���!&�!4�!:�!:�!<�!<�	D�	D��D�+�2�u����2�3�3�
���:�:�c�1�%�%�a�(�D��J�J�J��
�
�d�B��U�
�C�C�C���(�.�.�0�0�	&�	&�D�A�q�����1�%�%�%�%�	&�	&rc�t�|jjj}|dgkrtj|j��S|dgkr/|j�d|jz|_tj|j��S|dgkr/|j�d|jz|_tj|j��Std|j	j
z���)Nr��__dotdotdotint__z'typedef int... %s'�__dotdotdotfloat__z'typedef float... %s'�*:%d: unsupported usage of "..." in typedef)r�r�r�unknown_typerEr��UnknownIntegerType�UnknownFloatTyperr>rA)r�rFr�s   rr�zParser._get_unknown_type�s����I�N�(�	���)�)�)��%�d�i�0�0�0��+�,�,�,��%�-�)>���)J��&��+�D�I�6�6�6��-�.�.�.��%�-�)@�4�9�)L��&��)�$�)�4�4�4��C����)�*�*�	*rc��|jjjjdgkrtj|j��Std|jjz���)Nr�r�)r�r�r�unknown_ptr_typerErr>rA)r�rFs  rr�zParser._get_unknown_ptr_type�sN���9�>��$��(9�9�9��)�$�)�4�4�4��C����)�*�*�	*r)FFNF)Fr	r)NFN)NF)F)r��
__module__�__qualname__r�r�r�r�r�r�r�r�r�r�r�rrr�r'r�r�r?rMrrfr;r�rar�r�r�rrrr�r�'s�������&�&�&�$$�$$�$$�L������AE�#�)�)�)�)�05�5�5�n'�'�'�
0�
0�
0�.�.�.�"
+�
+�
+�1P�1P�1P�f3�3�3�7�7�7�1�1�1�1�
�
�
�.�.�.�.�JO�,0�g%�g%�g%�g%�R!I�!I�!I�!I�F���t�t�t�t�l���GH�GH�GH�GH�R������0&�&�&�*�*�*�&*�*�*�*�*rr�)4rr�commontypesrr�errorrrrr�ImportErrorr�r��sys�version_info�thread�_thread�
allocate_lockr�rr��compile�DOTALL�	MULTILINEr`rarNrkr�rir}r�
IGNORECASEr�rgrfrhr5rrnrorr/r9rBrGrPrWrwr��objectr�rrr�<module>r�sM��������:�:�:�:�:�:�:�:�&�&�&�&�&�&�&�&��)�)�)�)�)�)�)�����������������������������
��$��� � � � � ����� �7� �"�"�D�D�������D�D�D��������,��
�R�Z�7��	�B�L�0�2�2�
�
�R�Z�2��	�B�L�0�2�2�	��B�J�A�2�<�P�P���"�*�=�>�>���B�J�3�4�4���2�:�1�2�2���2�:�i� � ���
����4�b�m�D�D���b�j�2�3�3���b�j�6�7�7���2�:�n�%�%���2�:�O�P�P�� �b�j�.�0�0���2�:�(�)�)���R�Z� <�=�=�����(�(�(�T0�0�0�d
�
�
�;�;�;�$�$�$�3�3�3�@�@�@�D%�%�%�PG*�G*�G*�G*�G*�V�G*�G*�G*�G*�G*s��	+�+�#A�A)�(A)