Your IP : 3.137.174.253


Current Path : /usr/lib64/python3.6/site-packages/cffi/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cffi/__pycache__/model.cpython-36.opt-1.pyc

3

M��Z0T�@s�ddlZddlZddlmZddlmZmZmZdZdZ	dZ
dd�ZGd	d
�d
e�Z
Gdd�de
�ZGd
d�de�Ze�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zee�Zdd �Zee�ZGd!d"�d"e�ZGd#d$�d$e�Zeed%�d�ZGd&d'�d'e
�ZGd(d)�d)e�Z Gd*d+�d+e �Z!Gd,d-�d-e �Z"Gd.d/�d/e�Z#d<d0d1�Z$d=d2d3�Z%e�Z&ej'�Z(d4d5�Z)d6d7�Z*d8d9�Z+d:d;�Z,dS)>�N�)�
allocate_lock)�	CDefError�VerificationError�VerificationMissing��cCs@|t@rd|j�}|t@r(d|j�}|t@r<d|j�}|S)Nz const z
 volatile z __restrict )�Q_CONST�lstrip�
Q_VOLATILE�
Q_RESTRICT)�quals�replace_with�r�/usr/lib64/python3.6/model.py�qualifysrc@sPeZdZdZdZddd�Zdd�Zd	d
�Zdd�Zdd
d�Z	dd�Z
dd�ZdS)�BaseTypeByIdentityF��a C filercCsx|j}|j�}|rB|jd�r.d|kr.d|}n|ddkrBd|}t||�}|jd|�}d|krttd	|j�|f��|S)
N�*z&[z(%s)rz[(� �&�$z-cannot generate '%s' in %s: unknown type name)�c_name_with_marker�strip�
startswithr�replacer�_get_c_name)�selfr�contextr
�resultrrr�
get_c_names

zBaseTypeByIdentity.get_c_namecCs|jjdd�S)Nrr)rr)rrrrr/szBaseTypeByIdentity._get_c_namecCsd|j�kS)Nr)r)rrrr�
has_c_name2szBaseTypeByIdentity.has_c_namecCsdS)NFr)rrrr�is_integer_type5sz"BaseTypeByIdentity.is_integer_typecCsBy|j|}Wn.tk
r<|j||�}|jj||�}YnX|S)N)�_cached_btypes�KeyError�build_backend_type�
setdefault)r�ffi�
finishlist�	can_delay�BTypeZBType2rrr�get_cached_btype8sz#BaseTypeByIdentity.get_cached_btypecCsd|j�fS)Nz<%s>)r)rrrr�__repr__AszBaseTypeByIdentity.__repr__cs�fdd��jD�S)Ncsg|]}|t�|�f�qSr)�getattr)�.0�name)rrr�
<listcomp>Esz1BaseTypeByIdentity._get_items.<locals>.<listcomp>)�_attrs_)rr)rr�
_get_itemsDszBaseTypeByIdentity._get_itemsN)rrr)F)�__name__�
__module__�__qualname__�
is_array_type�is_raw_functionr!rr"r#r,r-r3rrrrrs

	rc@s$eZdZdd�Zdd�Zdd�ZdS)�BaseTypecCs|j|jko|j�|j�kS)N)�	__class__r3)r�otherrrr�__eq__JszBaseType.__eq__cCs
||kS)Nr)rr;rrr�__ne__NszBaseType.__ne__cCst|jt|j��f�S)N)�hashr:�tupler3)rrrr�__hash__QszBaseType.__hash__N)r4r5r6r<r=r@rrrrr9Hsr9c@s eZdZfZdd�Zdd�ZdS)�VoidTypecCs
d|_dS)Nzvoid&)r)rrrr�__init__XszVoidType.__init__cCst||d�S)NZ
new_void_type)�global_cache)rr(r)rrrr&[szVoidType.build_backend_typeN)r4r5r6r2rBr&rrrrrAUsrAc@seZdZdd�ZdS)�BasePrimitiveTypecCsdS)NFr)rrrr�is_complex_typebsz!BasePrimitiveType.is_complex_typeN)r4r5r6rErrrrrDasrDc4@s�eZdZdZdddddddddddddddddddddddddddddddddddddddddddddddddddd�3Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dS)�
PrimitiveTyper0�c�i�f�j)3�charZshort�int�longz	long longzsigned charz
unsigned charzunsigned shortzunsigned intz
unsigned longzunsigned long long�floatZdoublezlong doublezfloat _Complexzdouble _ComplexZ_BoolZwchar_tZchar16_tZchar32_tZint8_tZuint8_tZint16_tZuint16_tZint32_tZuint32_tZint64_tZuint64_tZint_least8_tZ
uint_least8_tZ
int_least16_tZuint_least16_tZ
int_least32_tZuint_least32_tZ
int_least64_tZuint_least64_tZint_fast8_tZuint_fast8_tZint_fast16_tZ
uint_fast16_tZint_fast32_tZ
uint_fast32_tZint_fast64_tZ
uint_fast64_tZintptr_tZ	uintptr_tZintmax_tZ	uintmax_tZ	ptrdiff_tZsize_tZssize_tcCs||_|d|_dS)Nr)r0r)rr0rrrrB�szPrimitiveType.__init__cCs|j|jdkS)NrG)�ALL_PRIMITIVE_TYPESr0)rrrr�is_char_type�szPrimitiveType.is_char_typecCs|j|jdkS)NrH)rOr0)rrrrr#�szPrimitiveType.is_integer_typecCs|j|jdkS)NrI)rOr0)rrrr�
is_float_type�szPrimitiveType.is_float_typecCs|j|jdkS)NrJ)rOr0)rrrrrE�szPrimitiveType.is_complex_typecCst||d|j�S)NZnew_primitive_type)rCr0)rr(r)rrrr&�sz PrimitiveType.build_backend_typeN)r0)r4r5r6r2rOrBrPr#rQrEr&rrrrrFfstrFc@s(eZdZd	Zdd�Zdd�Zdd�ZdS)
�UnknownIntegerTyper0cCs||_|d|_dS)Nr)r0r)rr0rrrrB�szUnknownIntegerType.__init__cCsdS)NTr)rrrrr#�sz"UnknownIntegerType.is_integer_typecCstd|j��dS)Nz4integer type '%s' can only be used after compilation)�NotImplementedErrorr0)rr(r)rrrr&�sz%UnknownIntegerType.build_backend_typeN)r0)r4r5r6r2rBr#r&rrrrrR�srRc@s eZdZdZdd�Zdd�ZdS)�UnknownFloatTyper0cCs||_|d|_dS)Nr)r0r)rr0rrrrB�szUnknownFloatType.__init__cCstd|j��dS)Nz2float type '%s' can only be used after compilation)rSr0)rr(r)rrrr&�sz#UnknownFloatType.build_backend_typeN)r0)r4r5r6r2rBr&rrrrrT�srTc@seZdZdZd	dd�ZdS)
�BaseFunctionType�argsr �ellipsis�abiNcCs�||_||_||_||_dd�|jD�}|jr8|jd�|p@dg}|jdj|�f}|dk	r||dd�|d|dd�}|jjjd|�|_dS)	NcSsg|]}|j��qSr)r)r/�argrrrr1�sz-BaseFunctionType.__init__.<locals>.<listcomp>z...�voidz, rrr)	rVr rWrX�append�
_base_pattern�joinrr)rrVr rWrXZreprargsrrrrrB�s

 zBaseFunctionType.__init__)rVr rWrX)N)r4r5r6r2rBrrrrrU�srUc@s$eZdZdZdZdd�Zdd�ZdS)�RawFunctionTypez(&)(%s)TcCstd|f��dS)NzPcannot render the type %r: it is a function type, not a pointer-to-function type)r)rr(r)rrrr&�sz"RawFunctionType.build_backend_typecCst|j|j|j|j�S)N)�FunctionPtrTyperVr rWrX)rrrr�as_function_pointer�sz#RawFunctionType.as_function_pointerN)r4r5r6r\r8r&r`rrrrr^�sr^c@s eZdZdZdd�Zdd�ZdS)r_z(*&)(%s)cCs�|jj||�}g}x |jD]}|j|j||��qWf}|jdkrl|jsly|jjf}Wntk
rjYnXt	||dt
|�||jf|��S)NZ	__stdcallZnew_function_type)r r,rVr[rXrW�_backendZFFI_STDCALL�AttributeErrorrCr?)rr(r)r rV�tpZabi_argsrrrr&�s
z"FunctionPtrType.build_backend_typecCst|j|j|j|j�S)N)r^rVr rWrX)rrrr�as_raw_functionszFunctionPtrType.as_raw_functionN)r4r5r6r\r&rdrrrrr_�sr_c@s"eZdZd	Zd
dd�Zdd�ZdS)�PointerType�totyper
rcCs>||_||_t|d�}|jr*d|j�f}|jjd|�|_dS)Nz *&z(%s)r)rfr
rr7r
rr)rrfr
ZextrarrrrBs
zPointerType.__init__cCs |jj||dd�}t||d|�S)NT)r*�new_pointer_type)rfr,rC)rr(r)ZBItemrrrr&szPointerType.build_backend_typeN)rfr
)r)r4r5r6r2rBr&rrrrres
recCs
t|t�S)N)rer	)rfrrr�ConstPointerTypesrhc@seZdZdZddd�ZdS)	�NamedPointerTyperfr0rcCs"tj|||�||_|d|_dS)Nr)rerBr0r)rrfr0r
rrrrBszNamedPointerType.__init__N)rfr0)r)r4r5r6r2rBrrrrrisric@s,eZdZdZdZdd�Zdd�Zdd	�Zd
S)�	ArrayType�item�lengthTcCsF||_||_|dkrd}n|dkr(d}nd|}|jjjd|�|_dS)Nz&[]z...z
&[/*...*/]z&[%s]r)rkrlrr)rrkrlZbracketsrrrrB)szArrayType.__init__cCst|j|�S)N)rjrk)rZ	newlengthrrr�resolve_length6szArrayType.resolve_lengthcCsJ|jdkrtd|f��|jj||�t|j�j||�}t||d||j�S)Nz...z)cannot render the type %r: unknown lengthZnew_array_type)rlrrkr,rerC)rr(r)ZBPtrItemrrrr&9s

zArrayType.build_backend_typeN)rkrl)r4r5r6r2r7rBrmr&rrrrrj%s

rjrKc@s,eZdZd	ZdZdd�Zdd�Zdd�ZdS)
�StructOrUnionOrEnumr0NcCs$|jpd|j|jf}|d|_dS)Nz%s %sr)�	forcename�kindr0r)rr0rrr�build_c_name_with_markerHsz,StructOrUnionOrEnum.build_c_name_with_markercCs||_|j�dS)N)rorq)rrorrr�force_the_nameLsz"StructOrUnionOrEnum.force_the_namecCs|jdd�S)Nr���)r)rrrr�get_official_namePsz%StructOrUnionOrEnum.get_official_name)r0)r4r5r6r2rorqrrrtrrrrrnDs
rnc@sjeZdZdZdZdZdZddd�Zdd�Zdd	d
�Z	dd�Z
dd
d�Zdd�Zdd�Z
dd�Zdd�ZdS)�
StructOrUnionNrFcCs*||_||_||_||_||_|j�dS)N)r0�fldnames�fldtypes�
fldbitsize�fldqualsrq)rr0rvrwrxryrrrrB[szStructOrUnion.__init__ccsB|jdk	r>x2t|j|j�D] \}}|dkrt|t�r|VqWdS)Nr)rw�ziprv�
isinstanceru)rr0�typerrr�anonymous_struct_fieldscs
z%StructOrUnion.anonymous_struct_fieldsTccs�|j}|dkrdt|j�}xbt|j|j|j|�D]J\}}}}|dkrnt|t�rn|rnx&|j�D]
}|Vq^Wq2||||fVq2WdS)Nrr)r)	ry�lenrvrzrwrxr{ru�
enumfields)rZexpand_anonymous_struct_unionryr0r|�bitsizer
r rrrriszStructOrUnion.enumfieldsc	Cs~g}g}g}g}x@|j�D]4\}}}}|j|�|j|�|j|�|j|�qWt|�|_t|�|_t|�|_t|�|_dS)N)rr[r?rvrwrxry)	r�names�typesZbitsizesryr0r|r�r
rrr�
force_flattenws





zStructOrUnion.force_flattencCs$tj||||�}|s |j||�|S)N)rnr,�finish_backend_type)rr(r)r*r+rrrr,�s

zStructOrUnion.get_cached_btypecs|jr$|jdkr td|jf��dS�j|}d|_|jdkrB�n�|jdkr���fdd�|jD�}tt|j||j	��}d}|j
r�d}�jj|||dd
|��nfg}|j\}}}	}
�x&t
t|j��D�]}||}|j|}
t|
t�o�|
jdk�rn|
jj���}t|�j|��\}}|dk�r<|jd	|j|j|�p4d
f�|
j|�}
|jd|�|
f|j|dd�|_|
j���}t|
t��r�|
jdk�r�n8�j|�}||k�r�|jd|j|j|�p�d
||f�|j|�q�Wtt|j||j	|��}�jj||||	|
�d|_dS)Nrz(recursive structure declaration for '%s'rcsg|]}|j����qSr)r,)r/rc)r(r)rrr1�sz5StructOrUnion.finish_backend_type.<locals>.<listcomp>r�z...zfield '%s.%s' has a bogus size?z{}z=field '%s.%s' is declared as %d bytes, but is really %d bytesrsrs)�	completedrSr0r$rw�fixedlayout�listrzrvrx�packedraZcomplete_struct_or_union�ranger~r{rjrlrkr,�divmod�sizeof�_verification_errorrmr[)rr(r)r+rwZlstZsflagsZfieldofsZ	fieldsizeZ	totalsizeZtotalalignmentrHZfsizeZftypeZ	BItemTypeZnlenZnrestZ
BFieldTypeZ	bitemsizer)r(r)rr��s`









z!StructOrUnion.finish_backend_typecCst|��dS)N)r)r�msgrrrr��sz!StructOrUnion._verification_errorcCs |jr|jdkrt|j���dS)N)�partialr�rr)rrrr�check_not_partial�szStructOrUnion.check_not_partialcCs.|j�|j|�t||d|j|j�|d�S)Nznew_%s_type)�key)r�r[rCrprt)rr(r)rrrr&�s
z StructOrUnion.build_backend_type)N)T)F)r4r5r6r�r�r�r�rBr}rr�r,r�r�r�r&rrrrruUs


<ruc@seZdZdZdS)�
StructType�structN)r4r5r6rprrrrr��sr�c@seZdZdZdS)�	UnionType�unionN)r4r5r6rprrrrr��sr�c@sBeZdZdZdZdZddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�EnumType�enumFNcCs$||_||_||_||_|j�dS)N)r0�enumerators�
enumvalues�baseinttyperq)rr0r�r�r�rrrrB�s
zEnumType.__init__cCs4tj||�|jdkr0|j�}d|jdd�|_dS)Nrr�_)rnrrrortr)rror0rrrrr�s
zEnumType.force_the_namecCs|jr|jrt|j���dS)N)r��partial_resolvedrr)rrrrr��szEnumType.check_not_partialc
Cs4|j�|j||�}t||d|j�|j|j||d�S)NZ
new_enum_type)r�)r��build_baseinttyperCrtr�r�)rr(r)Z
base_btyperrrr&�szEnumType.build_backend_typec
CsH|jdk	r|jj||�S|jr4t|j�}t|j�}nDddl}ytj�Wntk
r\YnX|j	d|j
��d}}|dkr�d}td�}td�}nd}td�}td�}|j||�}	|j||�}
|j|	�}|j|
�}|d
d|d>ko�|dd||>k�r|	S|dd|d>k�r4|dd||>k�r4|
St
d	|j
���dS)NrzU%r has no values explicitly defined; guessing that it is equivalent to 'unsigned int'rrLrMzunsigned intz
unsigned longr�z=%s values don't all fit into either 'long' or 'unsigned long'rsrs)r�r,r��min�max�warningsZ__warningregistry__�clear�	NameError�warnrrFr�r)
rr(r)Zsmallest_valueZ
largest_valuer�ZsignZ
candidate1Z
candidate2Zbtype1Zbtype2Zsize1Zsize2rrrr�s@




zEnumType.build_baseinttype)N)r4r5r6rpr�r�rBrrr�r&r�rrrrr��s
r�cCs2|dkrd|}t|ddd�}|j|�d|_|S)Nz$%s�unknown_type)r�rr�origin)r0�
structnamercrrrr�*s
r�cCs(|dkrd|}t|ddd�}t||�S)Nz$$%s)r�ri)r0r�rcrrr�unknown_ptr_type2sr�c
CsFt|tj�rtSt�(tt|�d�s2tj�t|�_	t|�j	SQRXdS)N�__typecache)
r{r��
ModuleType�_typecache_cffi_backend�global_lock�hasattrr|�weakref�WeakValueDictionaryr�)Zbackendrrr�
get_typecache<sr�c
 Os�|jd||f�}y
|j|Stk
r.YnXyt|j|�|�}Wn4tk
rx}ztd|||f��WYdd}~XnX|j}t�(|j|�}	|	dkr�|||<|S|	SWdQRXdS)Nr�z
%s: %r: %s)�popZ
_typecacher%r.rarSr��get)
Zsrctyper(�funcnamerV�kwdsr��res�e�cacheZres1rrrrCGs 
$
rCcCstd|d|�S)N�?rg)rC)r(r+rrr�
pointer_cache^sr�cCs@|jr<t|jd�tkr<d||jdff|jdd�|_dS)Nrz%s: %sr)rVr|�str)r�r0rrr�attach_exception_infoasr�)N)N)-r�r��lockr�errorrrrr	rrr�objectrr9rAZ	void_typerDrFrRrTrUr^r_reZ
voidp_typerhZconst_voidp_typerirjZchar_array_typernrur�r�r�r�r�r�r�r�r�rCr�r�rrrr�<module>sN
/
	L	G



?>