B
    dM              <   @   s  d dl mZ G dd deZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZedZdZdZdZd	d
 Zdddddddddddddddddddddddddddddddddddddddddddddddddddddddg g ddd;ZddddZdd Zdd Zeee eeeeedddddeee!e!ee"eddddeedZ#x,e$ D ] \Z%Z&e%e#krZe!e&e#e%< qZW dddddddddddddddddddddddddddddddd Z'd)d!d"Z(d*d#d$Z)d%d& Z*d+d'd(Z+dS ),    )absolute_importc               @   s:   e Zd Zg ZdddZdd Zdd Zd	d
 Zdd ZdS )ShouldBeFromDirectiveNFc             C   s&   || _ |p|| _|| _| j|  d S )N)options_namedirective_namedisallowknown_directivesappend)selfr   r   r    r
   d/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/Cython/Compiler/Options.py__init__   s    
zShouldBeFromDirective.__init__c             C   s   |    d S )N)_bad_access)r	   r
   r
   r   __nonzero__   s    z!ShouldBeFromDirective.__nonzero__c             C   s   |    d S )N)r   )r	   r
   r
   r   __int__   s    zShouldBeFromDirective.__int__c             C   s   t t| d S )N)RuntimeErrorrepr)r	   r
   r
   r   r      s    z!ShouldBeFromDirective._bad_accessc             C   s   d| j | jf S )NzEIllegal access of '%s' from Options module rather than directive '%s')r   r   )r	   r
   r
   r   __repr__   s    zShouldBeFromDirective.__repr__)NF)	__name__
__module____qualname__r   r   r   r   r   r   r
   r
   r
   r   r      s   
r   TFNold_style_globals   c              C   s`   xZt jD ]P} t | j}| jtks(tt|t s| j	rNt
d| j| jf q|t| j< qW tS )Nz+Option '%s' must be set from directive '%s')r   r   globalsgetr   r   _directive_defaultsAssertionError
isinstancer   r   option_name)Z
old_optionvaluer
   r
   r   get_directive_defaults   s    
r    bytes);ZboundscheckZ	nonecheckZinitializedcheckZembedsignatureZ
auto_cpdefauto_pickleZ	cdivisionZcdivision_warningsZc_api_binop_methodscpowZoverflowcheckzoverflowcheck.foldZalways_allow_keywordsZallow_none_for_extension_argsZ
wraparoundZccomplexZcallspecnogilZprofileZ	linetraceemit_code_commentsannotation_typinginfer_typeszinfer_types.verboseautotestdictzautotestdict.cdefzautotestdict.alllanguage_levelZfast_getattrZ
py2_importZpreliminary_late_includes_cy28iterable_coroutinec_string_typec_string_encodingtype_version_tagZunraisable_tracebacksr   
np_pythranfast_gilset_initial_pathwarnzwarn.undeclaredzwarn.unreachablezwarn.maybe_uninitializedzwarn.unusedzwarn.unused_argzwarn.unused_resultzwarn.multiple_declaratorszoptimize.inline_defnode_callszoptimize.unpack_method_callsz&optimize.unpack_method_calls_in_pyinitzoptimize.use_switchZremove_unreachablezcontrol_flow.dot_outputzcontrol_flow.dot_annotate_defstest_assert_path_existstest_fail_if_path_existsbindingZformal_grammar)zwarn.maybe_uninitializedzwarn.unreachablezwarn.unusedc                 s    fdd}|S )Nc                s$   | krt d|  |f n|S d S )Nz(%s directive must be one of %s, got '%s')
ValueError)namer   )argsr
   r   validate   s    zone_of.<locals>.validater
   )r7   r8   r
   )r7   r   one_of   s    r9   c             C   sl   |sdS |  dkr|  S ddl}y||}W n tk
rF   |S X xdD ]}|||krN|S qNW |S )a  
    >>> normalise_encoding_name('c_string_encoding', 'ascii')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'AsCIi')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'us-ascii')
    'ascii'
    >>> normalise_encoding_name('c_string_encoding', 'utF8')
    'utf8'
    >>> normalise_encoding_name('c_string_encoding', 'utF-8')
    'utf8'
    >>> normalise_encoding_name('c_string_encoding', 'deFAuLT')
    'default'
    >>> normalise_encoding_name('c_string_encoding', 'default')
    'default'
    >>> normalise_encoding_name('c_string_encoding', 'SeriousLyNoSuch--Encoding')
    'SeriousLyNoSuch--Encoding'
    r    )defaultasciiutf8r   N)r;   r<   )lowercodecs
getdecoderLookupError)r   encodingr>   decoderr6   r
   r
   r   normalise_encoding_name	  s    
rC   	bytearraystrunicode)r)   r"   localsfinalr$   internalr'   r4   cfuncccallinlinestaticmethodcclassno_gc_clearno_gcreturns	exceptvalr0   freelistr+   r,   r#   )modulerN   )rN   function)rU   zwith statement)rU   )rN   )classrN   zwith statement)rT   )rU   rV   rN   )rT   rU   )r"   rH   r$   rL   rJ   rK   rQ   rR   rG   rM   rO   rP   rI   rN   r(   zautotestdict.allzautotestdict.cdefr0   r2   r3   rS   r%   r&   r+   r,   r-   r)   r   r.   r/   r*   c             C   s   t | }|sdS |}|tkrtt|}|dkr2dS |dkr>dS |rb| }|dkrVdS |dkrbdS td| |f nb|tkryt|S  tk
r   td	| |f Y qX n*|tkrt|S t|r|| |S dstdS )
a  
    Parses value as an option value for the given name and returns
    the interpreted value. None is returned if the option does not exist.

    >>> print(parse_directive_value('nonexisting', 'asdf asdfd'))
    None
    >>> parse_directive_value('boundscheck', 'True')
    True
    >>> parse_directive_value('boundscheck', 'true')
    Traceback (most recent call last):
       ...
    ValueError: boundscheck directive must be set to True or False, got 'true'

    >>> parse_directive_value('c_string_encoding', 'us-ascii')
    'ascii'
    >>> parse_directive_value('c_string_type', 'str')
    'str'
    >>> parse_directive_value('c_string_type', 'bytes')
    'bytes'
    >>> parse_directive_value('c_string_type', 'bytearray')
    'bytearray'
    >>> parse_directive_value('c_string_type', 'unicode')
    'unicode'
    >>> parse_directive_value('c_string_type', 'unnicode')
    Traceback (most recent call last):
    ValueError: c_string_type directive must be one of ('bytes', 'bytearray', 'str', 'unicode'), got 'unnicode'
    NTrueTFalseF)trueyes)falsenoz3%s directive must be set to True or False, got '%s'z0%s directive must be set to an integer, got '%s')	directive_typesr   boolrE   r=   r5   intcallabler   )r6   r   relaxed_booltypeZ
orig_valuer
   r
   r   parse_directive_valuep  s:    

rc   c             C   s   |dkri }n|}x|  dD ]}| }|s0qd|krDtd| dd |  ddD \}}|tkrd}|d	r|dd
 }	x0tD ](}
|
|	rd}t|
||d}|||
< qW |s|std| qt|||d}|||< qW |S )aJ  
    Parses a comma-separated list of pragma options. Whitespace
    is not considered.

    >>> parse_directive_list('      ')
    {}
    >>> (parse_directive_list('boundscheck=True') ==
    ... {'boundscheck': True})
    True
    >>> parse_directive_list('  asdf')
    Traceback (most recent call last):
       ...
    ValueError: Expected "=" in option "asdf"
    >>> parse_directive_list('boundscheck=hey')
    Traceback (most recent call last):
       ...
    ValueError: boundscheck directive must be set to True or False, got 'hey'
    >>> parse_directive_list('unknown=True')
    Traceback (most recent call last):
       ...
    ValueError: Unknown option: "unknown"
    >>> warnings = parse_directive_list('warn.all=True')
    >>> len(warnings) > 1
    True
    >>> sum(warnings.values()) == len(warnings)  # all true.
    True
    N,=zExpected "=" in option "%s"c             S   s   g | ]}|  qS r
   )strip).0sr
   r
   r   
<listcomp>  s    z(parse_directive_list.<locals>.<listcomp>   Fz.allT)ra   zUnknown option: "%s")splitrf   r5   r   endswith
startswithrc   )rh   ra   Zignore_unknowncurrent_settingsresultitemr6   r   foundprefix	directiveZparsed_valuer
   r
   r   parse_directive_list  s0    


ru   c             C   s^   | dkrdS | dkrdS | dkr$dS |   r4t| S yt| } W n tk
rT   Y nX | S dS )a  
    Parses value as an option value for the given name and returns
    the interpreted value.

    >>> parse_variable_value('True')
    True
    >>> parse_variable_value('true')
    'true'
    >>> parse_variable_value('us-ascii')
    'us-ascii'
    >>> parse_variable_value('str')
    'str'
    >>> parse_variable_value('123')
    123
    >>> parse_variable_value('1.23')
    1.23

    rW   TrX   FNoneN)isdigitr_   float	Exception)r   r
   r
   r   parse_variable_value  s    rz   c             C   sr   |dkri }n|}xZ|  dD ]L}| }|s0qd|krDtd| dd | ddD \}}t|||< qW |S )a  
    Parses a comma-separated list of pragma options. Whitespace
    is not considered.

    >>> parse_compile_time_env('      ')
    {}
    >>> (parse_compile_time_env('HAVE_OPENMP=True') ==
    ... {'HAVE_OPENMP': True})
    True
    >>> parse_compile_time_env('  asdf')
    Traceback (most recent call last):
       ...
    ValueError: Expected "=" in option "asdf"
    >>> parse_compile_time_env('NUM_THREADS=4') == {'NUM_THREADS': 4}
    True
    >>> parse_compile_time_env('unknown=anything') == {'unknown': 'anything'}
    True
    Nrd   re   zExpected "=" in option "%s"c             S   s   g | ]}|  qS r
   )rf   )rg   rh   r
   r
   r   ri   &  s    z*parse_compile_time_env.<locals>.<listcomp>rj   )rl   rf   r5   rz   )rh   ro   rp   rq   r6   r   r
   r
   r   parse_compile_time_env	  s    r{   )F)FFN)N),
__future__r   objectr   Z
docstringsZembed_pos_in_docstringr%   Z
pre_importZgenerate_cleanup_codeZclear_to_noneZannotateZannotate_coverage_xmlZ	fast_failZwarning_errorsZerror_on_unknown_namesZerror_on_uninitializedZconvert_rangeZcache_builtinsZgcc_branch_hintsZlookup_module_cpdefZembedr   Zcimport_from_pyxZbuffer_max_dimsZclosure_freelist_sizer   r   Zextra_warningsr9   rC   rE   r^   dictrb   r_   r]   itemskeyvalZdirective_scopesrc   ru   rz   r{   r
   r
   r
   r   <module>   s(  &
	

$

< 
8$