Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/Doc/tools/extensions/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/Doc/tools/extensions/__pycache__/c_annotations.cpython-36.pyc

3

� f��@srdZddlmZddlmZddlmZddlmZddl	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/python36/lib64/python3.6/Doc/tools/extensions/c_annotations.py�__init__szRCEntry.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@s eZdZedd��Zdd�ZdS)�AnnotationscCs�|�}t|d�}z�x�|D]�}|j�}|dd�d
kr6q|jdd�}t|�dkrZtd|��|\}}}}	}
y||}Wn$tk
r�t|�}||<YnX|	s�|	d	kr�d}	nt|	�}	|r�|jj	|||	f�q||_
|	|_qWWd|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.fromfilecCs�x�|jtj�D]�}|j}|ddkr&q|drH|jdtjdddgd��|ddkrVq|djd	�s|dd	rvq|dd	d}|jd
�r�|dd�}|j	|�}|s�qn|j
dkr�q|jdkr�d}n|jr�d}nd}|jdtj||dgd��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.Zrcrrr�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_annotationsesrCcsL|jddd�|jdt�tjtjd�t_tj��fdd�}|t_ddd	�S)
NrArTzbuilder-inited)Znoindexr1csd|jk|jd<�|||�S)Nr1)Zoptionsr7)r
ZsigZsignode)�old_handle_signaturerr�new_handle_signatureusz#setup.<locals>.new_handle_signaturez1.0)�versionZparallel_read_safe)Zadd_config_valuerBrCr�flagrZoption_specZhandle_signature)r;rEr)rDr�setupksrHN)�__doc__�osrZdocutilsrZdocutils.parsers.rstrZsphinxrZsphinx.domains.crr�dictrrCrHrrrr�<module>sA