3
h                 @   s   d dl mZ ddlmZ ddlT ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ G d
d deZdd Zdd ZeddZedZedZeddeegdZedZdS )    )absolute_import   )ModuleScope)*)CythonUtilityCode)error)StringSourceDescriptor)
MemoryView)EncodedStringc                   sj   e Zd ZdZdZdd Zdd Z fddZ fd	d
Zdd Z	dddZ
dd Zdd Zdd Z  ZS )CythonScoper   Fc             C   sV   t j| dd d  d| _| j  || _x,tttfD ]}| j|j	|d dd}d|_
q0W d S )NcythonTz<error>)cname)r   __init__pxd_file_loadedpopulate_cython_scopecontextZcy_integral_typeZcy_floating_typeZcy_numeric_typedeclare_typedefnameZin_cinclude)selfr   Z
fused_typeentry r   m/var/www/html/CrowdFlow/Picklecon/ble_analysis_env/lib/python3.6/site-packages/Cython/Compiler/CythonScope.pyr      s    zCythonScope.__init__c             C   s   | j jS )N)r   cpp)r   r   r   r   is_cpp   s    zCythonScope.is_cppc                s    t |}|r|S tt| j|S )N)Zparse_basic_typesuperr   lookup_type)r   r   type)	__class__r   r   r   "   s    zCythonScope.lookup_typec                s<   t t| j|}|d kr8| j r8| j  t t| j|}|S )N)r   r   lookup_cythonscope_initializedload_cythonscope)r   r   r   )r   r   r   r   *   s
    zCythonScope.lookupc             C   s   t d| | d S )Nzcython.%s is not available)r   )r   module_nameposr   r   r   find_module3   s    zCythonScope.find_modulec             C   sV   | j j|d }|s(| j  | j j|d }|r8|jr8|jS ttddddfd| d S )Nr    r   zcython.%s is not available)entriesgetr    	as_moduler   r   )r   r!   Z
as_packager   r   r   r   find_submodule6   s    
zCythonScope.find_submodulec             C   s\   |j d}| }xHt|dkrH|j|d }|r4|j}|d= |d krd S qW |j|d S d S )N.r   r   )splitlenZlookup_herer'   )r   qnameZ	name_pathZscoper   r   r   lookup_qualified_nameF   s    
z!CythonScope.lookup_qualified_namec          	   C   sT   | j dtd dd}d|_|j}| jdtttdtd tdt	|d gd ddd d S )	NZPyTypeObject)Z	base_typer"   r   TZPyObject_TypeCheckotr   )r"   Zdefiningr   )
r   Zc_void_typeZis_voidr   Zdeclare_cfunctionZ	CFuncTypeZc_bint_typeZCFuncTypeArgZpy_object_typeZ
c_ptr_type)r   Ztype_objectZtype_object_typer   r   r   r   T   s    z!CythonScope.populate_cython_scopec             C   s   | j r
dS d| _ tj| | d tj| | d td| d | _}|| jd|d_d|_d|_	t
j|| d tjj| j| tjd}dd |jj D }x|D ]
}d|_qW td	}t|| dd
}|| j||dd_d|_d|_	dS )zy
        Creates some entries for testing purposes and entries for
        cython.array() and for cython.view.*.
        NT)cython_scopeview)r0   Z	allowlistc             S   s   g | ]}|j jr|j qS r   )r   Zis_extension_type).0r   r   r   r   
<listcomp>   s   z0CythonScope.load_cythonscope.<locals>.<listcomp>r   Zdataclasses)r   )r"   )r   cython_testscope_utility_codeZdeclare_in_scope!cython_test_extclass_utility_coder   	viewscopeZdeclare_moduler'   is_cython_builtinr   !cythonview_testscope_utility_coder	   Zview_utility_codeZview_utility_allowlistr%   valuesZis_cython_builtin_typer
   )r   r6   Zview_utility_scopeZ	ext_typesZext_typeZdc_strZdataclassesscoper   r   r   r    f   s2    





zCythonScope.load_cythonscope)F)__name__
__module____qualname__r7   r   r   r   r   r   r#   r(   r-   r   r    __classcell__r   r   )r   r   r      s   	
r   c             C   s   t | S )N)r   )r   r   r   r   create_cython_scope   s    r>   c             K   s   t j| df|S )NzTestCythonScope.pyx)r   load)Zcy_util_namekwargsr   r   r   load_testscope_utility   s    rA   a  
    /* These methods are undecorated and have therefore no prototype */
    static PyObject *__pyx_TestClass_cdef_method(
            struct __pyx_TestClass_obj *self, int value);
    static PyObject *__pyx_TestClass_cpdef_method(
            struct __pyx_TestClass_obj *self, int value, int skip_dispatch);
    static PyObject *__pyx_TestClass_def_method(
            PyObject *self, PyObject *value);
)protoZ	TestScopeZTestDepZ	TestClass)r   requireszView.TestScopeN)
__future__r   ZSymtabr   Z
PyrexTypesZUtilityCoder   ZErrorsr   ZScanningr   r$   r	   ZStringEncodingr
   r   r>   rA   Zundecorated_methods_protosr4   Ztest_cython_utility_depr5   r8   r   r   r   r   <module>   s&    
