
    ?e$                     (    d Z dZ G d d          ZdS )    c                   .   e 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ed             Zed             Zed             Zed             Zd Zed             Zed             Zd ZddZed             Zd Zed             Zd ZdS )
ScopedNamez Encapsulate a scoped name. c                     t          |t                    r	|| _        dS t          |t                    rt          |j                  | _        dS |g| _        dS )z Initialise the scoped name. N)
isinstancelist_namer   selfnames     >lib/python3.11/site-packages/sipbuild/generator/scoped_name.py__init__zScopedName.__init__"   sW     dD!! 	 DJJJj)) 	 dj))DJJJ DJJJ    c                 Z    t          |t                    r| j        |j        k    S t          S )z0 Compare with another scoped name for equality. r   r   r	   NotImplementedr   others     r   __eq__zScopedName.__eq__/   s+     eZ(( 	-:,,r   c                 <    | j         |                     |          = dS )z Remove the requested name. Nr	   _normalised_indexr   indexs     r   __delitem__zScopedName.__delitem__7   s"     Jt--e44555r   c                 B    | j         |                     |                   S )z Get the requested name. r   r   s     r   __getitem__zScopedName.__getitem__<   s     z$007788r   c                 F    t          | j                  }| j        r|dz  }|S )zJ Return the length of the name, ie. the number of indivual names.
           )lenr	   is_absolute)r   nr_namess     r   __len__zScopedName.__len__A   s*     tz?? 	MHr   c                 Z    t          |t                    r| j        |j        k     S t          S )z? Compare with another scoped name to allow lists to be sorted. r   r   s     r   __lt__zScopedName.__lt__L   s+     eZ(( 	,:++r   c                 @    || j         |                     |          <   dS )z Set the requested name. Nr   )r   r   r   s      r   __setitem__zScopedName.__setitem__T   s$     59
4))%00111r   c                     g }| D ]3}|d                                          r n|                    |           4d                    |          S )z' Return the C++ string representation. r   ::)isdigitappendjoin)r   s_lss      r   __str__zScopedName.__str__Y   sR      	 	At||~~ JJqMMMMyy~~r   c                 p    | j         r| S  t          |           |           }|                                 |S )z# The absolute version of the name. )r!   typemake_absolute)r   copys     r   absolutezScopedName.absolutei   s@      	KtDzz$r   c                 :    | j                             |           dS )z Append a simple name. N)r	   r+   r
   s     r   r+   zScopedName.appendu   s      	
$r   c                 n    d                     | j                  }|                    d          rd|z   }|S )z% The C++ representation of the name. r)    )r,   r	   
startswith)r   cpps     r   as_cppzScopedName.as_cppz   s;     ii
## >>$ 	)C
r   c                 \    | j         rdnd}d                    | j        |d                   S )z( The Python representation of the name. r   r   .Nr!   r,   r	   r   starts     r   as_pyzScopedName.as_py   2     %,1xx
566*+++r   c                 \    | j         rdnd}d                    | j        |d                   S )z& The word representation of the name. r   r   _Nr=   r>   s     r   as_wordzScopedName.as_word   rA   r   c                     | j         d         S )z# The base name of the scoped name. r   r	   r   s    r   	base_namezScopedName.base_name   s     z"~r   c                     |t           k    rd}n| j        rdnd}|t          k    r||z  }d                    | j        |d                   S )zY Return the C++ representation of the name with leading scopes
        stripped.
        r   r   r)   N)
STRIP_NONEr!   STRIP_GLOBALr,   r	   )r   stripr?   s      r   cpp_strippedzScopedName.cpp_stripped   sX    
 JEE)0AAqE$$yyEFF+,,,r   c                 $    | j         d         dk    S )z& True if the scoped name is absolute. r    rF   rG   s    r   r!   zScopedName.is_absolute   s     z!}""r   c                 (    t          |           dk    S )z? Return True if the name is simple, ie. relative and unscoped. r   )r    rG   s    r   	is_simplezScopedName.is_simple   s     4yyA~r   c                 b    | j         d         dk    r| j                             dd           dS dS )z( Make sure the scoped name is absolute. r   rO   N)r	   insertrG   s    r   r2   zScopedName.make_absolute   s;     :a=BJa$$$$$ r   Nc                     | j         sJ |j         r| |k    S |It          |j        j                  }|j                            |j                   | |k    rdS |j        }|I| j        dd         |j        k    S )z Return True if a scoped name matches this taking account of an
        optional scope if the scoped name is relative.
        NTr   )r!   r   
iface_filefq_cpp_namer	   extendscope)r   scoped_namerX   fq_names       r   matcheszScopedName.matches   s    
  " 	';&&  !1!=>>GM  !2333wtKE  z!""~!222r   c                 >     | |                     d                    S )z5 Return a ScopedName object by parsing a raw string. r)   )split)clsraws     r   parsezScopedName.parse   s     s399T??###r   c                 p    t          |j                  }|                    | j                   || _        dS )z Prepend a scoped name. N)r   r	   rW   )r   rY   new_names      r   prependzScopedName.prepend   s3     )**
###


r   c                 v    t          |           dk    rdS  t          |           | j        dd                   S )zo The scoped name that is the enclosing scope of this one.  It will
        be None if there isn't one.
        r   Nr   )r    r1   r	   rG   s    r   rX   zScopedName.scope   s8     t99>>4tDzz$*SbS/***r   c                     t          |t                    s/t          d                    t	          |                              |dk    r| j        r|dz  }|S )z Return a normalised index. z'{}' is an invalid indexr   r   )r   int	TypeErrorformatr1   r!   r   s     r   r   zScopedName._normalised_index   sX     %%% 	L6==d5kkJJKKKA::$*:QJEr   )N)__name__
__module____qualname____doc__r   r   r   r   r#   r%   r'   r/   propertyr4   r+   r:   r@   rD   rH   rM   r!   rQ   r2   r[   classmethodr`   rc   rX   r    r   r   r   r      s       &&       6 6 6
9 9 9
	 	 	  9 9 9
    	 	 X	     
 	 	 X	 , , X, , , X,   X
- - - # # X#
   X
% % %3 3 3 30 $ $ [$
   + + X+	 	 	 	 	r   r   N)rJ   rK   r   ro   r   r   <module>rp      sM   6 
W W W W W W W W W Wr   