Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/Doc/tools/extensions/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/Doc/tools/extensions/__pycache__/c_annotations.cpython-35.pyc



��Yf��@s�dZddlmZddlmZddlmZddlmZddl	m
Z
Gdd�d�ZGd	d
�d
e�Z
dd�Zd
d�ZdS)a�
    c_annotations.py
    ~~~~~~~~~~~~~~~~

    Supports annotations for C API elements:

    * reference count annotations for C API functions.  Based on
      refcount.py and anno-api.py in the old Python documentation tools.

    * stable API annotations

    Usage: Set the `refcount_file` config value to the path to the reference
    count data file.

    :copyright: Copyright 2007-2014 by Georg Brandl.
    :license: Python license.
�)�path)�nodes)�
directives)�addnodes)�CObjectc@seZdZdd�ZdS)�RCEntrycCs(||_g|_d|_d|_dS)N�)�name�args�result_type�result_refs)�selfr	�r�G/opt/alt/python35/lib64/python3.5/Doc/tools/extensions/c_annotations.py�__init__s			zRCEntry.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@s.eZdZedd��Zdd�ZdS)�AnnotationscCs@|�}t|d�}zx|D]}|j�}|dd�d
krMq"|jdd�}t|�dkr�td|��|\}}}}	}
y||}Wn&tk
r�t|�}||<YnX|	s�|	d	kr�d}	nt|	�}	|r|jj	|||	f�q"||_
|	|_q"WWd|j�X|S)N�r�r�#�:��zWrong field count in %rZnull)rr)
�open�strip�split�len�
ValueError�KeyErrorr�intr
�appendrr�close)�cls�filename�d�fp�line�parts�function�type�arg�refcountZcomment�entryrrr�fromfile%s0	

		zAnnotations.fromfilecCsXxQ|jtj�D]=}|j}|ddkr5q|drd|jdtjddddg��|ddkrwq|djd	�s|dd	r�q|dd	d}|jd
�r�|dd�}|j	|�}|s�qn|j
dkr�q|jdkrd}n|jr%d}nd}|jdtj||ddg��qWdS)NZdomain�c�	stableabirz Part of the stable ABI.�classesZobjtyper*�nameszc.��	PyObject*�PyVarObject*zReturn value: Always NULL.zReturn value: New reference.z!Return value: Borrowed reference.r-)r5r6)ZtraverserZdesc_content�parent�insertrZemphasisZhas_key�
startswith�getrr)r
�appZdoctreeZnodeZparr	r.�rcrrr�add_annotationsGs4	

#			zAnnotations.add_annotationsN)rrr�classmethodr/r=rrrrr$s"rcCs;tjtj|j|jj��}|jd|j�dS)Nzdoctree-read)	rr/r�join�srcdir�config�
refcount_file�connectr=)r;Z	refcountsrrr�init_annotationsesrDcsr|jddd�|jdt�dtjdtjit_tj��fdd�}|t_d	d
ddiS)NrBrTzbuilder-initedZnoindexr1cs&d|jk|jd<�|||�S)Nr1)Zoptionsr7)r
ZsigZsignode)�old_handle_signaturerr�new_handle_signatureusz#setup.<locals>.new_handle_signature�versionz1.0Zparallel_read_safe)Zadd_config_valuerCrDrZflagrZoption_specZhandle_signature)r;rFr)rEr�setupks			rHN)�__doc__�osrZdocutilsrZdocutils.parsers.rstrZsphinxrZsphinx.domains.crr�dictrrDrHrrrr�<module>sA