
    0hy                         S SK r S SKJr  S SKJr  SSKJr  SSKJr  SSK	J
r
  SrS	rS
rSrS rS rS rS r " S S\5      rg)    N)OrderedDict)parse   )ast)COMPATIBLE_GIR_VERSION)Positionz)http://www.gtk.org/introspection/core/1.0z&http://www.gtk.org/introspection/c/1.0z(http://www.gtk.org/introspection/doc/1.0z)http://www.gtk.org/introspection/glib/1.0c                     S[         < SU < 3$ N{})CORE_NStags    1/lib/gobject-introspection/giscanner/girparser.py_corensr   $       $$    c                     S[         < SU < 3$ r
   )GLIB_NSr   s    r   _glibnsr   (   r   r   c                     S[         < SU < 3$ r
   )C_NSr   s    r   _cnsr   ,   s    S!!r   c                     S[         < SU < 3$ r
   )DOC_NSr   s    r   _docnsr   0   s    s##r   c                       \ rS rSrS'S jrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS(S jrS rS rS'S jrS'S jrS rS rS r S  r!S! r"S" r#S# r$S$ r%S% r&S&r'g))	GIRParser4   c                 ,    Xl         S U l        / U l        g N)_types_only
_namespace_filename_stack)self
types_onlys     r   __init__GIRParser.__init__6   s    %!r   c                     [         R                  R                  U5      nU R                  R	                  U5        [        U5      nU R                  U5        U R                  R                  5         g r!   )ospathabspathr$   appendr   
parse_treepop)r%   filenametrees      r   r   GIRParser.parse=   sO    77??8,##H-X  "r   c                     S U l         [        5       U l        [        5       U l        [        5       U l        SU l        S U l        U R                  UR                  5       5        g )Nunknown)	r#   set_pkgconfig_packages	_includes_c_includes_doc_format	_c_prefix
_parse_apigetroot)r%   r1   s     r   r.   GIRParser.parse_treeD   sG    #&5 5$'r   c                     U R                   $ r!   )r#   )r%   s    r   get_namespaceGIRParser.get_namespaceM   s    r   c                     [        U[        5      (       a  U H  nUR                  U:X  d  M  Us  $    g U H  nUR                  U;   d  M  Us  $    g r!   )
isinstancestrr   )r%   nodename_or_nameschilds       r   _find_first_childGIRParser._find_first_childR   sQ    mS))99- L   99- L  r   c                 T    U Vs/ s H  o3R                   U:X  d  M  UPM     sn$ s  snf r!   r   )r%   rD   namerF   s       r   _find_childrenGIRParser._find_children]   s#    #'=4%99+<4===s   %%c                     U R                   (       d  g [        R                  " 5       [        R                  -   nU R                   S   nUR	                  U5      (       a  U[        U5      S  $ U$ )N)r$   r*   getcwdsep
startswithlen)r%   cwdcurfiles      r   _get_current_fileGIRParser._get_current_file`   sY    ##iikBFF"&&r*c""3s89%%r   c                    UR                   [        S5      :X  d   eUR                  S   nU[        :w  a)  [	        U R                  5       < SU< S[        < S35      eU H  nUR                   [        S5      :X  a  U R                  U5        M/  UR                   [        S5      :X  a  U R                  U5        M[  UR                   [        S5      :X  a  U R                  U5        M  UR                   [        S5      :X  d  M  U R                  U5        M     UR                  [        S	5      5      nUc   eUR                  R                  [        S
5      5      nU(       a  UR                  S5      nUR                  R                  [        S5      5      nU(       a  UR                  S5      n[        R                   " UR                  S   UR                  S   UUS9U l        SUR                  ;   a-  UR                  S   R                  S5      U R"                  l        U R&                  U R"                  l        U R*                  U R"                  l        U R.                  U R"                  l        U R2                  U R"                  l        [        S5      U R6                  [        S5      U R8                  [        S5      U R:                  [        S5      U R<                  [        S5      U R8                  [        S5      U R<                  [        S5      U R>                  [        S5      U R@                  [        S5      U RB                  [E        S5      U RF                  0
nU RH                  (       d`  U RJ                  U[        S5      '   U RL                  U[        S5      '   U RN                  U[        S5      '   U RP                  U[        S5      '   U H+  nUR                  UR                   5      nUc  M#  U" U5        M-     g )N
repositoryversionz: Incompatible version z (supported: )includepackageformat	namespacezidentifier-prefixes,zsymbol-prefixesrJ   )identifier_prefixessymbol_prefixeszshared-libraryaliasbitfieldcallbackclassenumeration	interfacerecordunion
docsectionboxedconstantzfunction-inlinezfunction-macrofunction))r   r   attribr   
SystemExitrU   _parse_include_parse_pkgconfig_packager   _parse_c_includer   _parse_doc_formatfindgetsplitr   	Namespacer#   shared_librariesr7   includesr8   
c_includesr9   
doc_formatr6   exported_packages_parse_alias_parse_enumeration_bitfield_parse_callback_parse_object_interface_parse_record_parse_union_parse_doc_sectionr   _parse_boxedr"   _parse_constant_parse_function_inline_parse_function_macro_parse_function)	r%   rootrY   rD   nsr`   ra   parser_methodsmethods	            r   r;   GIRParser._parse_apii   s-   xx7<0000++i(,,"446AWY Z Z Dxx79--##D)WY//--d3T)_,%%d+VH--&&t,  YYw{+,~~ iimmD1F,GH"5";";C"@))--->(?@-33C8O--		&(9(*		)(<<O8GI ryy(/1yy9I/J/P/PQT/UDOO,#'>> %)%5%5"%)%5%5",0,D,D) Gd//J!A!AJ!5!5Gd::M"D$D$DK $">">Ht11Gd//L!4#:#:Gd//
1 262F2FN7:./9=9T9TN7#4568<8R8RN7#345262F2FN7:./D#''1F!t r   c                     [         R                  " UR                  S   5      nU R                  X5        U R                  R                  U5        g NrJ   )r   
DocSectionrn   _parse_generic_attribsr#   r-   )r%   rD   rj   s      r   r   GIRParser._parse_doc_section   s9    ^^DKK$78
##D5z*r   c                     [         R                  " UR                  S   UR                  S   5      nU R                  R	                  U5        g )NrJ   rY   )r   Includern   r7   add)r%   rD   r[   s      r   rp   GIRParser._parse_include   s6    ++dkk&14;;y3IJ7#r   c                 T    U R                   R                  UR                  S   5        g r   )r6   r   rn   r%   rD   s     r   rq   "GIRParser._parse_pkgconfig_package   s      $$T[[%89r   c                 T    U R                   R                  UR                  S   5        g r   )r8   r   rn   r   s     r   rr   GIRParser._parse_c_include   s    T[[01r   c                 ,    UR                   S   U l        g r   )rn   r9   r   s     r   rs   GIRParser._parse_doc_format   s    ;;v.r   c           	      
   U R                  U5      n[        R                  " UR                  S   X!R                  R	                  [        S5      5      5      nU R                  X5        U R                  R                  U5        g )NrJ   type)	_parse_typer   Aliasrn   ru   r   r   r#   r-   )r%   rD   typevalrb   s       r   r}   GIRParser._parse_alias   s\    ""4(		$++f-wV8UV##D0u%r   c           
         [        U[        R                  5      (       d   eUR                  R	                  S5      nU(       a   [        U5      S:  Ul        UR                  R	                  S5      nU(       a   [        U5      S:  Ul        U R                  (       a  g UR                  [        S5      5      nUb  UR                  (       aq  UR                  Ul        [        UR                  R	                  SS5      UR                  R	                  SS 5      UR                  R	                  S	S 5      5      Ul        UR                  R	                  S
5      nU(       a  Xbl        UR                  [        S5      5      nUb"  UR                  (       a  UR                  Ul        UR                  R	                  S5      nU(       a  Xl        UR                  [        S5      5      n	U	b"  U	R                  (       a  U	R                  Ul        UR                  R	                  S5      n
U
(       a  Xl        UR                  [        S5      5      nUb"  UR                  (       a  UR                  Ul        UR-                  [        S5      5      nU(       aS  [/        5       nU H=  nUR                  R	                  S5      nUR                  R	                  S5      nUX'   M?     Xl        [3        US5      (       a  [5        UR-                  [        S5      5      S S9nU Hm  nS	UR                  ;   a  [        UR                  S	   5      nOS nUR7                  [        UR                  S   [        UR                  S   5      U5      5        Mo     g g ! [         a    SUl         GNMf = f! [         a    SUl         GN/f = f)Nskipr   Fintrospectabledocr0   z	<unknown>linecolumnrY   zdoc-versionzdeprecated-versionzdoc-deprecated	stabilityzdoc-stability	attributerJ   valueadd_file_positionzsource-positionc                 P    U R                   S   [        U R                   S   5      4$ )Nr0   r   )rn   int)xs    r   <lambda>2GIRParser._parse_generic_attribs.<locals>.<lambda>   s$    ahhz.B.1!((62B.C.Er   )key)rB   r   	Annotatedrn   ru   r   r   
ValueErrorr   r"   rt   r   textr   r   doc_positionrY   version_doc
deprecateddeprecated_docr   stability_docfindallr   
attributeshasattrsortedr   )r%   rD   objr   r   r   rY   r   r   r   r   r   r   attributes_r   rJ   r   	positionspositionr   s                       r   r    GIRParser._parse_generic_attribs   s   #s}}----{{v&!t9q= )9:+%(%81%<" ii'?xx((#+CJJNN:{,S,/JJNN64,H,/JJNN8T,J$L  ++//),!Kii 67""-"2"2[[__%9:
'N7+;#<=%""%3%8%8"KKOOK0	%M		'/":;$!!$1$6$6!\\'+"67
%-K'	 ''++F3!((,,W5$)! ( )N3+,,t||G4E,FG$EFI &x. !:;F!F%%hxz/J/28??63J/K/5'7 8 &	 -_  ! !  +%*"+s$   N ;N) N&%N&)N>=N>c           
         UR                   R                  S5      nU(       a  U R                  R                  U5      nOS nUR                   S   UUR                   [	        S5         UR                   [	        S5         UR                   R                  [        S5      5      UR                   R                  [        S5      5      S.nUR                  [        S5      :X  a  [        R                  nOUR                  [        S	5      :X  ak  [        R                  nUR                   R                  S
5      nU=(       a    US:g  nXdS'   UR                   R                  S5      nU=(       a    US:g  nXtS'   O[        U5      eU" S0 UD6nU R                  X5        UR                   R                  [	        S5      5      n	U	(       a   U R                  R                  U	5      Ul        U[        R                  :X  a  UR                   R                  [	        S5      5      n
U
(       a  U
S:w  a  SUl        S HE  nUR                   R                  [	        U5      5      nXR                  UR!                  SS5      '   MG     U R"                  (       a  U R                  R%                  U5        g U R'                  U[        S5      5       HD  nUR(                  R%                  U R                  R                  UR                   S   5      5        MF     U R'                  U[        S5      5       HD  nUR*                  R%                  U R                  R                  UR                   S   5      5        MF     U R'                  U[        S5      5       H?  nU R-                  U[        R.                  U5      nUR0                  R%                  U5        MA     U R'                  U[        S5      5       HF  nU R-                  U[        R.                  U5      nSUl        UR4                  R%                  U5        MH     U R'                  U[        S5      5       HM  nU R-                  U[        R.                  U5      nSUl        SUl        UR4                  R%                  U5        MO     U R'                  U[        S5      5       Hn  nU R-                  U[        R8                  U5      nU R                  UU5        SUl        UR                  S5      Ul        UR<                  R%                  U5        Mp     U R'                  U[        S5      5       HF  nU R-                  U[        R.                  U5      nSUl        UR@                  R%                  U5        MH     URB                  RE                  U RG                  X5      5        U R'                  U[        S5      5       H.  nURH                  R%                  U RK                  UU5      5        M0     U R'                  U[	        S5      5       H=  nURL                  R%                  U R-                  U[        RN                  U5      5        M?     U R                  R%                  U5        g ) NparentrJ   	type-nameget-typesymbol-prefixr   )rJ   parent_type
gtype_nameget_typec_symbol_prefixctyperg   re   abstract0is_abstractfinalis_finalztype-structfundamentalT)zref-funcz
unref-funczset-value-funczget-value-func-_
implementsprerequisiterm   r   method-inlinezvirtual-methodinvokerconstructorpropertysignal )(rn   ru   r#   type_from_namer   r   r   r   r   	InterfaceClassAssertionErrorr   glib_type_structr   __dict__replacer"   r-   rK   
interfacesprerequisites_parse_function_commonFunctionstatic_methods	is_methodmethods	is_inline	VFunctionr   virtual_methodsis_constructorconstructorsfieldsextend_parse_fields
properties_parse_propertysignalsSignal)r%   rD   r   r   ctor_kwargsklassr   r   r   type_structis_fundamentalfunc_id	func_nameiface	func_nodefuncr   ctorpropr   s                       r   r   !GIRParser._parse_object_interface   s   *//88@KK#{{62&1%)[[1E%F#';;wz/B#C*.++//$:O*P $V =? 88w{++MMEXX))IIE++//*5K%<+*<K)4&{{w/H3HOH&.
# &&"k"##D.kkoogm&<=#'??#A#A+#NC CII![[__W]-CDN.C"7"&@ KKOOGG,<=	:CW__S#67@
 OO""3'((w|/DEENN!!$//"@"@fAU"VW F((w~/FGE$$T__%C%CELLQWDX%YZ H,,T7:3FGI..y#,,LD%%d+ H ))$0ABF..vs||SID!DNKKt$ C ))$0HIF..vs||SID!DN!DNKKt$	 J
 ))$8H0IJF..vs}}cJD''5!DN!::i0DL&&t, K ''gm.DED..tS\\3GD"&D##D) F 	

$,,T78''gj.ABDNN!!$"6"6tS"AB C))$0ABFKKt::63::sST C 	s#r   c                 z    U R                  U[        R                  5      nU R                  R	                  U5        g r!   )r   r   Callbackr#   r-   )r%   rD   rd   s      r   r   GIRParser._parse_callbackM  *    ..tS\\Bx(r   c                 z    U R                  U[        R                  5      nU R                  R	                  U5        g r!   )r   r   r   r#   r-   r%   rD   rm   s      r   r   GIRParser._parse_functionQ  r  r   c                     U R                  U[        R                  5      nSUl        U R                  R                  U5        g )NT)r   r   r   r   r#   r-   r
  s      r   r    GIRParser._parse_function_inlineU  s2    ..tS\\B!x(r   c                 L   UR                   S   nUR                   R                  [        S5      5      n/ nUR                  [	        S5      5      nUbt  U R                  U[	        S5      5       HU  n[        R                  " UR                   R                  S5      S 5      nUR                  U5        U R                  Xg5        MW     [        R                  " X$U5      nU R                  X5        U R                  R                  U5        U R                  R                  U5        g )NrJ   
identifier
parameters	parameter)rn   ru   r   rt   r   rK   r   	Parameterr-   r   FunctionMacror#   track)	r%   rD   rJ   symbolr  parameters_node	paramnodeparamr  s	            r   r   GIRParser._parse_function_macroZ  s    {{6"l!34
))GL$9:'!00'+BVW	i&6&6&:&:6&BDI!!%(++I= X
   6:##D/d#t$r   c                 \   U R                  U5      n[        R                  " UR                  R	                  S5      UUR                  R	                  S5      =(       d    [        R
                  UR                  R	                  S5      UR                  R	                  S5      S:H  UR                  R	                  S5      S:H  UR                  R	                  S5      S:H  UR                  R	                  S5      UR                  R	                  S	5      S:H  5	      nU R                  X5        U$ )
NrJ   	directiontransfer-ownershipnullable1optionalz
allow-nonescopezcaller-allocates)r   r   r  rn   ru   PARAM_DIRECTION_INr   )r%   rD   r   r  s       r   _parse_parameterGIRParser._parse_parameterk  s    ""4(dkkoof5%"kkook:Tc>T>T"kkoo.BC"kkooj9S@"kkooj9S@"kkool;sB"kkoog6"kkoo.@ASHJ 	##D0r   Nc                 
   UR                   S   nUR                  [        S5      5      nU(       d  [        SU< S35      eUR                   R	                  S5      nUR                   R	                  S5      S:H  n[
        R                  " U R                  U5      USU5      nU R                  XX5        / n	UR                   R	                  S	5      S:H  n
U[
        R                  L a.  U" XHXUR                   R	                  [        S
5      5      5      nGO.U[
        R                  L a/  UR                   R	                  [        S5      5      nU" XHXU5      nOU[
        R                  L a
  U" XHX5      nOU[
        R                  L a  U" XHU	UR                   R	                  S5      UR                   R	                  SS5      S:H  UR                   R	                  SS5      S:H  UR                   R	                  SS5      S:H  UR                   R	                  SS5      S:H  S9nUR                   R	                  S5      Ul        O eUR                   R	                  [        S5      S 5      Ul        UR                   R	                  [        S5      S 5      Ul        UR                   R	                  SS 5      Ul        UR                   R	                  SS 5      Ul        UR                   R	                  SS 5      Ul        UR                   R	                  [        S5      S 5      Ul        UR                   R	                  [        S5      S 5      Ul        UR                   R	                  [        S5      S 5      Ul        X;l        UR                  [        S5      5      nUGb  U R3                  U[        S5      5      nU(       a  U R5                  U5      Ul        U R9                  U[        S5      5       H#  nU	R;                  U R5                  U5      5        M%     [=        U R9                  U[        S5      5      5       H  u  pX   nU R?                  XUR@                  5        UR                   R	                  S5      nU(       aC  [C        U5      nU[E        U	5      :  d   S U[E        U	5      4-  5       eU	U   RF                  Ul$        UR                   R	                  S!5      nU(       d  M  [C        U5      nU[E        U	5      :  d   S U[E        U	5      4-  5       eU	U   RF                  Ul%        M     U R?                  XUR@                  5        Xl&        U R                  X5        U RN                  RQ                  U5        U$ )"NrJ   zreturn-valueznode z has no return-valuer  r  r  Fthrowsr   r  whenz
no-recurser   detailedactionzno-hooks)r&  
no_recurser'  r(  no_hooksemitterzset-propertyzget-propertyshadowszshadowed-byzmoved-tozfinish-funcz	sync-funcz
async-funcr  zinstance-parameterr  closurez%d >= %ddestroy))rn   rt   r   r   ru   r   Returnr   r   r  r   r   r   r   r+  r   set_propertyget_propertyr,  shadowed_bymoved_tofinish_func	sync_func
async_funcr   rG   r"  instance_parameterrK   r-   	enumerate_parse_type_array_lengthr   r   rR   argnameclosure_namedestroy_namer  r#   r  )r%   rD   r   r   rJ   
returnnodetransferr  retvalr  r%  r  r  r  r  ir  r-  idxr.  s                       r   r    GIRParser._parse_function_commony  sS   {{6"YYw~67
dEFF$$(()=>$$((4;D,,Z8(E8T##J7
++//(+s2CLL zf68Dcll"l);<Jz:FDcmm#z:Dcjj z"kkoof5$(KKOOL#$F#$M"&++//*c"Bc"I $# ># E"&++//*c"Bc"IKD  ;;??95DL5 KKOOGN,CTJ KKOOGN,CTJ{{y$7;;??=$?
D9;;??7=+A4H)=tD++//',*?F))GL$9:'..H\@]^I*.*?*?	*J'!00'+BVW	!!$"7"7	"BC X )$*=*=o>Ek>R+T !U"--jUZZP#**..y9g,CZ0U*S_?U2UU0)3C)@)@E&#**..y97g,CZ0U*S_?U2UU0)3C)@)@E&!U 	%%jfkkJ %##D/d#r   c                     / n[        S5      [        S5      [        S5      [        S5      4nU H7  nUR                  U;   d  M  U R                  XR5      nUR                  U5        M9     U$ )Nfieldrh   ri   rd   )r   r   _parse_fieldr-   )r%   rD   r   resnamesrF   fieldobjs          r   r   GIRParser._parse_fields  sc    !78#4gg6FPZH[\EyyE!,,U8

8$  
r   c                    U" UR                   R                  S5      UR                   R                  [        S5      5      UR                   R                  S5      S:H  UR                   R                  S5      S:H  UR                   R                  S5      S:H  UR                   R                  [        S5      5      UR                   R                  [        S5      5      UR                   R                  [        S	5      5      S
9nUR                   R                  S5      S:X  a  SUl        U R                  X#5        U R                  (       Gd  UR                  R                  U R                  X#5      5        U R                  U[        S5      5       HF  nU R                  U[        R                  U5      nSUl        UR                   R#                  U5        MH     U R                  U[        S5      5       HM  nU R                  U[        R                  U5      nSUl        SUl        UR                   R#                  U5        MO     ['        U R                  U[        S5      5      5       H:  u  pgUR                  U   nU R)                  UR                  XxR*                  5        M<     U R                  U[        S5      5       H=  nUR,                  R#                  U R                  U[        R                  U5      5        M?     U R                  U[        S5      5       HF  n	U R                  U	[        R                  U5      nSUl        UR0                  R#                  U5        MH     U$ )NrJ   r   	disguisedr  opaquepointerr   r   r   )r   rK  rL  rM  r   r   r   foreignTr   r   rD  rm   r   )rn   ru   r   r   rN  r   r"   r   r   r   rK   r   r   r   r   r   r   r-   r   r8  r9  r   r   r   r   )
r%   clsrD   compoundr   r  r@  	fieldnoderD  r  s
             r   _parse_compoundGIRParser._parse_compound  s   t{{v.![[__T&\:!%!=!D"kkooh73>#{{y9S@"&++//'+2F"G $
0C D'+{{tO7L'MO ;;??9%,#H##D3OO""4#5#5d#EF--dGH4EF2263<<R!%  ''- G --dGO4LM2263<<R!%!%  ''-	 N
 !*$*=*=dGGDT*U V *--hooy**U !W ++D'*2EF''..//cllHMO G ++D'-2HI224xP&*#%%,,T2 J r   c                    U R                  [        R                  U5      nUR                  R	                  [        S5      5      nUR                  R	                  S5      nUR                  R	                  S5      nUb   U R                  R                  U5      Ul        XSl	        Xcl
        U(       d  U R                  R                  U5        U$ )Nzis-gtype-struct-forcopy-functionfree-function)rR  r   Recordrn   ru   r   r#   r   is_gtype_struct_for	copy_func	free_funcr-   )r%   rD   	anonymousstructrX  rY  rZ  s          r   r   GIRParser._parse_record  s    %%cjj$7"kkoog6K.LMKKOOO4	KKOOO4	*)-)G)GH[)\F&$$OO""6*r   c                 
   U R                  [        R                  U5      nUR                  R	                  S5      Ul        UR                  R	                  S5      Ul        U(       d  U R                  R                  U5        U$ )NrU  rV  )	rR  r   Unionrn   ru   rY  rZ  r#   r-   )r%   rD   r[  ri   s       r   r   GIRParser._parse_union  sZ    $$SYY5++///:++///:OO""5)r   c           	      T   UR                   [        S5      :X  aS  U R                  R                  UR                  S   5      nUR                  R                  [        S5      5      Ul        U$ UR                   [        S5      :X  a  UR                  R                  S5      nU R                  U5      nUR                  R                  [        S5      5      n[        R                  " X4US9nUR                  R                  S5      nU(       a  US:X  a  SUl        UR                  R                  S	5      nU(       a  [        U5      Ul        U$ UR                   [        S
5      :X  a  [        R                  " 5       $ UR                   [        S5      :X  Ga  UR                  R                  S5      n	UR                  R                  [        S5      5      n
U	c,  U
c  [        R                  " 5       $ [        R                   " U
S9$ U	S;   ac  U R#                  U[%        ['        [        S5      5      5      nUb  U R                  U5      nO[        R(                  n[        R*                  " XU
S9$ U	S:X  a  U R-                  U[        S5      5      n[%        ['        U R.                  U5      5      n[1        U5      S:  a0  UR3                  [        R(                  5        [1        U5      S:  a  M0  [        R4                  " US   US   U
S9$ U R                  R                  X5      $  S5       e)Nrd   rJ   r   array)r   zzero-terminatedr   Fz
fixed-sizevarargs)z	GLib.Listz
GLib.SList)rd   rb  z    varargsr   zGLib.HashTable   r   r   zFailed to parse inner type)r   r   r#   r   rn   ru   r   r   r   r   Arrayzeroterminatedr   sizeVarargsTypeUnknownTyperG   listmapTYPE_ANYListrK   _parse_type_simplerR   r-   Map)r%   typenoder   
array_typeelement_typearray_ctyperetzero
fixed_sizerJ   r   subchildsubchildrensubchildren_typess                 r   ro  GIRParser._parse_type_simple  s   <<7:..oo44X__V5LMG$OO//V=GMN\\WW--!,,V4J++H5L"//--d6l;K))JKHC??&&'89D%*"!,,\:Jz?J\\WY//;;= \\WV_,??&&v.DOO''V5E|=??,,xxe,,4411(26s7 EW 8X 3YZ '#'#3#3H#=L#&<<Lxx%@@))"11(GFOL$(T-D-Dk)R$S!+,q0%,,S\\: +,q0ww035Fq5IQVWW55dBB6665r   c                     [        [        S5       H*  nUR                  U5      nUc  M  U R                  U5      s  $     S5       e)N)rd   rb  rc  r   zFailed to parse toplevel type)rl  r   rt   ro  )r%   rD   rJ   rq  s       r   r   GIRParser._parse_type6  sF    !IJDyyH#..x88 K 	655ur   c                 l   UR                  [        S5      5      nUc  gUR                  R                  S5      nUbx  [	        U5      nU[        U5      :  d   SX[        U5      4-  5       e[        X   [        R                  5      (       a  X   R                  Ul
        gX   R                  Ul
        gg)zNA hack necessary to handle the integer parameter/field indexes on
array types.rb  Nlengthz%r %d >= %d)rt   r   rn   ru   r   rR   rB   r   FieldrJ   length_param_namer:  )r%   siblingsrD   r   rq  lenidxrA  s          r   r9  "GIRParser._parse_type_array_length=  s     99WW-.$$X.f+CX&VH8V(VV&(-33,4M,>,>),4M,A,A) r   c           
         [         R                  " UR                  [        S5         UR                  [        S5         UR                  [        S5         UR                  R	                  [        S5      5      S9nU R                  X5        U R                  (       a  U R                  R                  U5        g U R                  U[        S5      5       HF  nU R                  U[         R                  U5      nSUl        UR                  R                  U5        MH     U R                  U[        S5      5       HM  nU R                  U[         R                  U5      nSUl        SUl        UR                  R                  U5        MO     U R                  U[        S	5      5       H=  nUR"                  R                  U R                  U[         R                  U5      5        M?     U R                  U[        S
5      5       H=  nUR$                  R                  U R                  U[         R&                  U5      5        M?     U R                  R                  U5        g )NrJ   r   r   r   )r   r   r   r   Tr   r   rd   )r   Boxedrn   r   ru   r   r   r"   r#   r-   rK   r   r   r   r   r   r   r   r   r  )r%   rD   r   r   r  r  rd   s          r   r   GIRParser._parse_boxedL  s   iiGFO4#';;w{/C#D!%WZ-@!A(,_8M(NP 	##D.OO""3'))$0ABF..vs||SID!DNKKt$ C ))$0HIF..vs||SID!DN!DNKKt$	 J
 ''gm.DED##++D#,,DF F ++D'*2EFHJJ++HcllCHJ G 	s#r   c           	         S nS nUR                   [        [        S5      ;   a  UnOU R                  U[        S5      5      nUb  UR                   [        S5      :X  a!  U R	                  U[
        R                  5      nOUR                   [        S5      :X  a  U R                  USS9nOvUR                   [        S5      :X  a  U R                  USS9nOL UR                   5       eUR                   [        S5      :X  d   UR                   5       eU R                  U5      n[
        R                  " UR                  R                  S5      UUR                  R                  S	5      S
:g  UR                  R                  S5      S:H  UR                  R                  S5      US9nUR                  R                  S5      S:H  Ul        X&l        U R                  X5        U$ )N)rd   rh   ri   rd   rh   T)r[  ri   rD  rJ   readabler   writabler  bits)anonymous_nodeprivate)r   rl  r   rG   r   r   r  r   r   r   r  rn   ru   r  r   r   )r%   rD   r   	type_noder  anonymous_eltrD  s          r   rE  GIRParser._parse_fieldh  s   	88s7$CDD M 2249LMM$  GJ$77!%!<!<]CLL!Y""gh&77!%!3!3MT!3!R""gg&66!%!2!2=D!2!Q/m///u88ww//99/((.I		$++//&1#++//*5<++//*5<++//&1)79 	2c9##D0r   c                 v   [         R                  " UR                  S   U R                  U5      UR                  R	                  S5      S:g  UR                  R	                  S5      S:H  UR                  R	                  S5      S:H  UR                  R	                  S5      S:H  UR                  R	                  S5      5      nUR                  R	                  S	5      Ul        UR                  R	                  S
5      Ul        UR                  R	                  S5      Ul        X#l        U R                  X5        U$ )NrJ   r  r   r  r  	constructzconstruct-onlyr  settergetterzdefault-value)
r   Propertyrn   r   ru   r  r  default_valuer   r   )r%   rD   r   r  s       r   r   GIRParser._parse_property  s    ||DKK/ ,,T2 KKOOJ73> KKOOJ73> KKOOK8C? KKOO,<=D KKOO,@AC kkooh/kkooh/![[___=##D/r   c                 \   [         R                  " UR                  S   UR                  S   UR                  R                  [	        S5      5      UR                  R                  [        S5      5      UR                  R                  [        S5      5      5      nU R                  X5        U$ )NrJ   r   r  nick)r   Memberrn   ru   r   r   r   )r%   rD   members      r   _parse_memberGIRParser._parse_member  sy    DKK/ KK0 KKOOD,>? KKOOGFO< KKOOGFO<	>
 	##D1r   c           
      (   U R                  U5      n[        R                  " UR                  S   UUR                  S   UR                  R	                  [        S5      5      5      nU R                  X5        U R                  R                  U5        g )NrJ   r   r   )	r   r   Constantrn   ru   r   r   r#   r-   )r%   rD   r  rl   s       r   r   GIRParser._parse_constant  sp    $$T*	<<F 3 ) $G 4 $V =? 	##D3x(r   c                    UR                   R                  S5      nUR                   R                  [        S5      5      nUR                   R                  [        S5      5      nUR                   R                  [        S5      5      nUR                   R                  [        S5      5      nUR                  [        S5      :X  a  [        R                  nO[        R                  n/ nU" X#UUUS9n	Xil	        X9l
        U R                  X5        U R                  (       a  U R                  R                  U	5        g U R                  U[        S5      5       H+  n
U R!                  U
5      nXl        UR                  U5        M-     U R                  U[        S	5      5       HD  nU R%                  U[        R&                  5      nXl        U	R(                  R                  U5        MF     U R                  R                  U	5        g )
NrJ   r   r   r   zerror-domainrc   )membersr   r   r  rm   )rn   ru   r   r   r   r   r   BitfieldEnumerror_domainr   r   r"   r#   r-   rK   r  r   r   r   r   )r%   rD   rJ   r   r   	type_nameglib_error_domainr   r  r   member_noder  r   r  s                 r   r~   %GIRParser._parse_enumeration_bitfield  s   {{v&V-;;??7:#67KKOOGK$89	 KKOOGN,CD88wz**LLEHHED#(%' -	##D.OO""3'..tWX5FGK''4FMNN6" H ,,T7:3FGI..y#,,GDK%%d+ H 	s#r   )r8   r:   r9   r$   r7   r#   r6   r"   )Fr!   )(__name__
__module____qualname____firstlineno__r'   r   r.   r?   rG   rK   rU   r;   r   rp   rq   rr   rs   r}   r   r   r   r   r   r   r"  r   r   rR  r   r   ro  r   r9  r   rE  r   r  r   r~   __static_attributes__r   r   r   r   r   4   s    "#(
	>9v+
$:2/&A8FL$\)))
%"HT!F07d6B$8<)$r   r   )r*   collectionsr   xml.etree.ElementTreer    r   	girwriterr   messager   r   r   r   r   r   r   r   r   objectr   r   r   r   <module>r     sO   * 
 # '  - 
5/	3
5%%"$R
$ R
$r   