
    	hэ                       % S r SSKJr  SSKrSSKr " S S\5      r " S S\5      rSrSr	 " S S	5      r
 " S
 S\
5      r " S S\
5      r " S S\
5      r " S S\
5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S  S!\5      r " S" S#\5      r " S$ S%\5      r " S& S'\5      r " S( S)\5      r " S* S+\5      r0 S,S-_S.S/_S0S1_S2S3_S4S5_S6S7_S8S9_S:S;_S<S=_S>S?_S@SA_SBS=_SCS=_SDS=_SES=_SFS=_SGS=_S=S=S=S=SH.Er " SI SJ\
5      r0 SK\SSL4_SM\SSL4_SN\SSL4_SO\SLSL4_SP\SLSL4_SQ\SLSL4_SR\SLSL4_SS\SLSL4_ST\SLSL4_SU\SLSL4_SV\S4_SW\SLS4_SX\S4_SY\S4_SZ\S4_S[\S4_S\\S4_0 SX\S4_S]\S4_S^\S4_S_\S4_S`\S4_Sa\S4_Sb\SLSL4_Sc\SLSL4_Sd\S4_Se\S4_Sf\S4_Sg\S4_Sh\S4_Si\S4_Sj\S4_Sk\S4_Sl\S4_E0 Sm\S4_Sn\S4_So\SL4_Sp\SL4_Sq\SL4_Sr\SL4_Ss\SL4_St\SL4_Su\SL4_Sv\SL4_S.\S4_Sw\S4_Sx\SSL4_Sy\SSL4_Sz\SSL4_S{\SSL4_S|\SSL4_E\SSL4\S}S}4\SS4\SSL4\SSL4\SSL4\SL4\S4\S4\SL4\S4\S4\S}4\S}4S~.E\R?                  \\S45      Er S\!S'   S r" " S S5      r# " S S5      r$ " S S5      r%S r&S r'S r(S r)g)a  Utilities for makegw - Parse a header file to build an interface

This module contains the core code for parsing a header file describing a
COM interface, and building it into an "Interface" structure.

Each Interface has methods, and each method has arguments.

Each argument knows how to use Py_BuildValue or Py_ParseTuple to
exchange itself with Python.

See the @win32com.makegw@ module for information in building a COM
interface
    )annotationsNc                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )error_not_found   c                $   > [         TU ]  U5        g Nsuper__init__selfmsg	__class__s     nC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\win32com/makegw/makegwparse.pyr   error_not_found.__init__            )z%The requested item could not be found__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__r   s   @r   r   r           r   r   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )error_not_supported   c                $   > [         TU ]  U5        g r   r	   r   s     r   r   error_not_supported.__init__   r   r   r   )z+The required functionality is not supportedr   r   s   @r   r   r      r   r   r   c                      \ rS 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g)ArgFormatter'   zHAn instance for a specific type of argument. Knows how to convert itselfc                6    Xl         X l        X0l        SU l        g Nr   argbuiltinIndirectiondeclaredIndirectiongatewayModer   r)   r*   r+   s       r   r   ArgFormatter.__init__*   s    "4#6 r   c                @    X-
  nUS:X  a  gUS:X  a  gUS:X  a  gSU4-  $ )a  Given the indirection level I was declared at (0=Normal, 1=*, 2=**)
return a string prefix so I can pass to a function with the
required indirection (where the default is the indirection of the method's param.

eg, assuming my arg has indirection level of 2, if this function was passed 1
it would return "&", so that a variable declared with indirection of 1
can be prefixed with this to turn it into the indirection level required of 2
r    &   *z?? (%d))r   )r   indirectionFromindirectionTodifs       r   _IndirectPrefixArgFormatter._IndirectPrefix1   s7     -!8BYAXv%%r   c                    Uc  U R                  5       U R                  -   nU R                  X5      U R                  R                  -   $ r   )_GetDeclaredIndirectionr*   r8   r)   name)r   indirectFromr6   s      r   GetIndirectedArgName!ArgFormatter.GetIndirectedArgNameE   sC       779D<S<SSL##L@488==PPr   c                .    U R                   R                  $ )z.Get the argument to be passes to Py_BuildValuer)   r<   r   s    r   GetBuildValueArgArgFormatter.GetBuildValueArgV   s    xx}}r   c                    U R                   (       a  U R                  SS5      $ U R                  U R                  S5      $ )z1Get the argument to be passed to PyArg_ParseTupleNr3   )r,   r>   r*   rB   s    r   GetParseTupleArgArgFormatter.GetParseTupleArgZ   s7    ,,T155(()@)@!DDr   c                    U R                  U R                  U R                  R                  U R                  -   5      U R	                  5        SU R                  R
                   34$ )al  Provide information about the C++ object used.

Simple variables (such as integers) can declare their type (eg an integer)
and use it as the target of both PyArg_ParseTuple and the COM function itself.

More complex types require a PyObject * declared as the target of PyArg_ParseTuple,
then some conversion routine to the C++ object which is actually passed to COM.

This method provides the name, and optionally the type of that C++ variable.
If the type if provided, the caller will likely generate a variable declaration.
The name must always be returned.

Result is a tuple of (variableName, [DeclareType|None|""])
 )r>   r*   r)   indirectionLevelGetUnconstTyper<   rB   s    r   GetInterfaceCppObjectInfo&ArgFormatter.GetInterfaceCppObjectInfob   s_    0 %%''))D,C,CC ""$%Qtxx}}o6
 	
r   c                L    [         (       a  SU R                  R                  -  $ g)z@Return cleanup code for C++ args passed to the interface method.z2/* GetInterfaceArgCleanup output goes here: %s */
r0   DEBUGr)   r<   rB   s    r   GetInterfaceArgCleanup#ArgFormatter.GetInterfaceArgCleanup   s    5H488==XXr   c                L    [         (       a  SU R                  R                  -  $ g)zgReturn cleanup code for C++ args passed to the interface
method that must be executed with the GIL heldz=/* GetInterfaceArgCleanup (GIL held) output goes here: %s */
r0   rO   rB   s    r   GetInterfaceArgCleanupGIL&ArgFormatter.GetInterfaceArgCleanupGIL   s&     5P((-- 
 r   c                .    U R                   R                  $ r   )r)   unc_typerB   s    r   rK   ArgFormatter.GetUnconstType   s    xx   r   c                    SU l         g Nr3   )r,   rB   s    r   SetGatewayModeArgFormatter.SetGatewayMode   s
    r   c                .    U R                   R                  $ r   )r)   rJ   printr<   r,   r+   rB   s    r   r;   $ArgFormatter._GetDeclaredIndirection   s    xx(((r   c                L    [         (       a  SU R                  R                  -  $ g)zEDeclare the variable used as the PyArg_ParseTuple param for a gatewayz8/* Declare ParseArgTupleInputConverter goes here: %s */
r0   rO   rB   s    r   "DeclareParseArgTupleInputConverter/ArgFormatter.DeclareParseArgTupleInputConverter   s&     5K((-- 
 r   c                L    [         (       a  SU R                  R                  -  $ g)z_Get a string of C++ code to be executed after (ie, to finalise) the PyArg_ParseTuple conversionz*/* GetParsePostCode code goes here: %s */
r0   rO   rB   s    r   GetParsePostCodeArgFormatter.GetParsePostCode   s    5@488==PPr   c                L    [         (       a  SU R                  R                  -  $ g)znGet a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Interfacesz0/* GetBuildForInterfacePreCode goes here: %s */
r0   rO   rB   s    r   GetBuildForInterfacePreCode(ArgFormatter.GetBuildForInterfacePreCode   s    5FVVr   c                    U R                  5       n[        (       a"  USS S:X  a  SU R                  R                  -  nU$ )zlGet a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for GatewaysN   /* Gz./* GetBuildForGatewayPreCode goes here: %s */
)rg   rP   r)   r<   r   ss     r   GetBuildForGatewayPreCode&ArgFormatter.GetBuildForGatewayPreCode   s9    ,,.5!uEUr   c                L    [         (       a  SU R                  R                  -  $ g)zkGet a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Interfacesz1/* GetBuildForInterfacePostCode goes here: %s */
r0   rO   rB   s    r   GetBuildForInterfacePostCode)ArgFormatter.GetBuildForInterfacePostCode   s    5G$((--WWr   c                    U R                  5       n[        (       a"  USS S:X  a  SU R                  R                  -  nU$ )ziGet a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for GatewaysNrj   rk   z//* GetBuildForGatewayPostCode goes here: %s */
)rq   rP   r)   r<   rl   s     r   GetBuildForGatewayPostCode'ArgFormatter.GetBuildForGatewayPostCode   s9    --/5!uFVr   c                    SR                  U R                  5       U R                  R                  U R                  R                  5      $ )Nz$// @pyparm {}|{}||Description for {})format_GetPythonTypeDescr)   r<   rB   s    r   GetAutoduckStringArgFormatter.GetAutoduckString   s7    5<<##%HHMMHHMM
 	
r   c                    g)zIReturns a string with the description of the type. Used for doco purposesNr   rB   s    r   rx   ArgFormatter._GetPythonTypeDesc   s    r   c                    g)z5Determines if this arg forces a USES_CONVERSION macror   r   rB   s    r   NeedUSES_CONVERSION ArgFormatter.NeedUSES_CONVERSION   s    r   r(   Nr   )r   r   r   r   __doc__r   r8   r>   rC   rF   rL   rQ   rT   rK   r[   r;   ra   rd   rg   rn   rq   rt   ry   rx   r~   r   r   r   r   r$   r$   '   sl    RU(Q"E
>	!,
r   r$   c                  D    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
rg)ArgFormatterFloat   c                    g)Nfr   rB   s    r   GetFormatCharArgFormatterFloat.GetFormatChar       r   c                4    SU R                   R                  -  $ )Nz	double dbl%s;
rA   rB   s    r   ra   4ArgFormatterFloat.DeclareParseArgTupleInputConverter   s    "TXX]]22r   c                4    SU R                   R                  -   $ Nz&dblrA   rB   s    r   rF   "ArgFormatterFloat.GetParseTupleArg       %%r   c                    g)Nfloatr   rB   s    r   rx   $ArgFormatterFloat._GetPythonTypeDesc   s    r   c                4    SU R                   R                  -   $ r   rA   rB   s    r   rC   "ArgFormatterFloat.GetBuildValueArg   r   r   c                n    SU R                   R                  -   S-   U R                   R                  -   S-   $ )Nz	dbl = ;
rA   rB   s    r   rg   -ArgFormatterFloat.GetBuildForInterfacePreCode   s,    &.>FFr   c                    SU R                   R                  -  U R                  U R                  5       S5      -   U R                   R                  -   S-   $ )Nz		dbl%s = r   r   r)   r<   r8   r;   rB   s    r   rn   +ArgFormatterFloat.GetBuildForGatewayPreCode   sP    488==(""4#?#?#A1EFhhmm 	
r   c                    SnU R                   (       a"  XR                  U R                  5       S5      -  nXR                  R                  -  nUSU R                  R                  -  -  nU$ )N	r   z = (float)dbl%s;
r,   r8   r;   r)   r<   rl   s     r   rd   "ArgFormatterFloat.GetParsePostCode   s[    %%d&B&B&DaHHA	XX]]	!DHHMM11r   r   Nr   r   r   r   r   ra   rF   rx   rC   rg   rn   rd   r   r   r   r   r   r      s+    3&&G
r   r   c                  D    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
rg)ArgFormatterShorti  c                    g)Nir   rB   s    r   r   ArgFormatterShort.GetFormatChar  r   r   c                4    SU R                   R                  -  $ )Nz
	INT i%s;
rA   rB   s    r   ra   4ArgFormatterShort.DeclareParseArgTupleInputConverter  s    --r   c                4    SU R                   R                  -   $ Nz&irA   rB   s    r   rF   "ArgFormatterShort.GetParseTupleArg      dhhmm##r   c                    g)Nintr   rB   s    r   rx   $ArgFormatterShort._GetPythonTypeDesc  s    r   c                4    SU R                   R                  -   $ r   rA   rB   s    r   rC   "ArgFormatterShort.GetBuildValueArg  r   r   c                n    SU R                   R                  -   S-   U R                   R                  -   S-   $ )Nz	ir   r   rA   rB   s    r   rg   -ArgFormatterShort.GetBuildForInterfacePreCode  s,    txx}}$u,txx}}<uDDr   c                    SU R                   R                  -  U R                  U R                  5       S5      -   U R                   R                  -   S-   $ )Nz	i%s = r   r   r   rB   s    r   rn   +ArgFormatterShort.GetBuildForGatewayPreCode  sP    &""4#?#?#A1EFhhmm 	
r   c                    SnU R                   (       a"  XR                  U R                  5       S5      -  nXR                  R                  -  nUSU R                  R                  -  -  nU$ )Nr   r   z = i%s;
r   rl   s     r   rd   "ArgFormatterShort.GetParsePostCode'  sZ    %%d&B&B&DaHHA	XX]]	[488==((r   r   Nr   r   r   r   r   r     s+    .$$E
r   r   c                  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g)ArgFormatterLONG_PTRi1  c                    gNOr   rB   s    r   r   "ArgFormatterLONG_PTR.GetFormatChar2  r   r   c                4    SU R                   R                  -  $ Nz	PyObject *ob%s;
rA   rB   s    r   ra   7ArgFormatterLONG_PTR.DeclareParseArgTupleInputConverter5      $txx}}44r   c                4    SU R                   R                  -   $ Nz&obrA   rB   s    r   rF   %ArgFormatterLONG_PTR.GetParseTupleArg9      txx}}$$r   c                    g)Nzint/longr   rB   s    r   rx   'ArgFormatterLONG_PTR._GetPythonTypeDesc<  s    r   c                4    SU R                   R                  -   $ NobrA   rB   s    r   rC   %ArgFormatterLONG_PTR.GetBuildValueArg?  r   r   c                4    SU R                   R                  -  $ Nz	Py_XDECREF(ob%s);
rA   rB   s    r   rq   1ArgFormatterLONG_PTR.GetBuildForInterfacePostCodeB      &66r   c                n    SR                  U R                  R                  U R                  S S5      5      $ )Nz^	if (bPythonIsHappy && !PyWinLong_AsULONG_PTR(ob{}, (ULONG_PTR *){})) bPythonIsHappy = FALSE;
   rw   r)   r<   r>   rB   s    r   rd   %ArgFormatterLONG_PTR.GetParsePostCodeE  s/    qxxHHMM444T1=
 	
r   c                `    U R                  S S5      nSU R                  R                   SU S3$ )Nr3   	obz = PyWinObject_FromULONG_PTR();
r>   r)   r<   r   notdirecteds     r   rg   0ArgFormatterLONG_PTR.GetBuildForInterfacePreCodeJ  2    //a8dhhmm_$A+dSSr   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rt   /ArgFormatterLONG_PTR.GetBuildForGatewayPostCodeN  r   r   r   N)r   r   r   r   r   ra   rF   rx   rC   rq   rd   rg   rt   r   r   r   r   r   r   1  s0    5%$7

T7r   r   c                  <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ArgFormatterPythonCOMiR  z:An arg formatter for types exposed in the PythonCOM modulec                    gr   r   rB   s    r   r   #ArgFormatterPythonCOM.GetFormatCharU  r   r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   ra   8ArgFormatterPythonCOM.DeclareParseArgTupleInputConverter[  r   r   c                4    SU R                   R                  -   $ r   rA   rB   s    r   rF   &ArgFormatterPythonCOM.GetParseTupleArg_  r   r   c                4    SU R                   R                  -  $ )Nz<o Py%s>r)   typerB   s    r   rx   (ArgFormatterPythonCOM._GetPythonTypeDescb  s    DHHMM))r   c                4    SU R                   R                  -   $ r   rA   rB   s    r   rC   &ArgFormatterPythonCOM.GetBuildValueArge  r   r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rq   2ArgFormatterPythonCOM.GetBuildForInterfacePostCodeh  r   r   r   N)r   r   r   r   r   r   ra   rF   rx   rC   rq   r   r   r   r   r   r   R  s#    D5%*$7r   r   c                  2    \ rS rSrS rS rS rS rS rSr	g)	ArgFormatterBSTRil  c                    gNz<o unicode>r   rB   s    r   rx   #ArgFormatterBSTR._GetPythonTypeDescm      r   c                n    SR                  U R                  R                  U R                  S S5      5      $ NzN	if (bPythonIsHappy && !PyWinObject_AsBstr(ob{}, {})) bPythonIsHappy = FALSE;
r   r   rB   s    r   rd   !ArgFormatterBSTR.GetParsePostCodep  /    ahhHHMM444T1=
 	
r   c                `    U R                  S S5      nSU R                  R                   SU S3$ )Nr3   r   z = MakeBstrToObj(r   r   r   s     r   rg   ,ArgFormatterBSTR.GetBuildForInterfacePreCodeu  s2    //a8dhhmm_$5k]$GGr   c                b    SU R                   R                   S3[        R                  U 5      -   $ )Nz	SysFreeString(r   r)   r<   r   rq   rB   s    r   rq   -ArgFormatterBSTR.GetBuildForInterfacePostCodey  s/    txx}}oT2#@@FG	
r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rt   +ArgFormatterBSTR.GetBuildForGatewayPostCode  r   r   r   N)
r   r   r   r   rx   rd   rg   rq   rt   r   r   r   r   r   r   l  s    

H
7r   r   c                  >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)ArgFormatterOLECHARi  c                    gr   r   rB   s    r   rx   &ArgFormatterOLECHAR._GetPythonTypeDesc  r   r   c                    U R                   R                  S S S:X  a3  U R                   R                  S S U R                   R                  SS  -   $ U R                   R                  $ N   LPCr   r)   r   rW   rB   s    r   rK   "ArgFormatterOLECHAR.GetUnconstType  R    88==!%88==!$txx}}QR'88888$$$r   c                n    SR                  U R                  R                  U R                  S S5      5      $ r   r   rB   s    r   rd   $ArgFormatterOLECHAR.GetParsePostCode  r   r   c                ,    SU R                  S S5      -  $ )Nz	SysFreeString(%s);
r3   r>   rB   s    r   rQ   *ArgFormatterOLECHAR.GetInterfaceArgCleanup  s    '$*C*CD!*LLLr   c                t    U R                  U R                  S5      nSU R                  R                   SU S3$ )Nr3   r   z = MakeOLECHARToObj(r   r>   r*   r)   r<   r   s     r   rg   /ArgFormatterOLECHAR.GetBuildForInterfacePreCode  s8    //0G0GKdhhmm_$8TJJr   c                b    SU R                   R                   S3[        R                  U 5      -   $ )Nz	CoTaskMemFree(r   r   rB   s    r   rq   0ArgFormatterOLECHAR.GetBuildForInterfacePostCode  s1     txx}}oT2#@@FG	
r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rt   .ArgFormatterOLECHAR.GetBuildForGatewayPostCode  r   r   r   Nr   r   r   r   rx   rK   rd   rQ   rg   rq   rt   r   r   r   r   r   r     s'    %

MK

7r   r   c                  >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)ArgFormatterTCHARi  c                    g)Nzstring/<o unicode>r   rB   s    r   rx   $ArgFormatterTCHAR._GetPythonTypeDesc  s    #r   c                    U R                   R                  S S S:X  a3  U R                   R                  S S U R                   R                  SS  -   $ U R                   R                  $ r  r  rB   s    r   rK    ArgFormatterTCHAR.GetUnconstType  r  r   c                n    SR                  U R                  R                  U R                  S S5      5      $ )NzO	if (bPythonIsHappy && !PyWinObject_AsTCHAR(ob{}, {})) bPythonIsHappy = FALSE;
r   r   rB   s    r   rd   "ArgFormatterTCHAR.GetParsePostCode  s/    biiHHMM444T1=
 	
r   c                ,    SU R                  S S5      -  $ )Nz	PyWinObject_FreeTCHAR(%s);
r3   r  rB   s    r   rQ   (ArgFormatterTCHAR.GetInterfaceArgCleanup  s    /$2K2KDRS2TTTr   c                t    U R                  U R                  S5      nSU R                  R                   SU S3$ )Nr3   r   z = PyWinObject_FromTCHAR(r   r  r   s     r   rg   -ArgFormatterTCHAR.GetBuildForInterfacePreCode  s8    //0G0GKdhhmm_$=k]$OOr   c                    g)Nz// ??? - TCHAR post code
r   rB   s    r   rq   .ArgFormatterTCHAR.GetBuildForInterfacePostCode  s    +r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rt   ,ArgFormatterTCHAR.GetBuildForGatewayPostCode  r   r   r   Nr  r   r   r   r  r    s'    $%

UP
,7r   r  c                  ,    \ rS rSrS rS rS rS rSrg)ArgFormatterIIDi  c                    g)Nz	<o PyIID>r   rB   s    r   rx   "ArgFormatterIID._GetPythonTypeDesc      r   c                v    SR                  U R                  R                  U R                  R                  5      $ )Nz<	if (!PyWinObject_AsIID(ob{}, &{})) bPythonIsHappy = FALSE;
)rw   r)   r<   rB   s    r   rd    ArgFormatterIID.GetParsePostCode  s+    OVVHHMMHHMM
 	
r   c                `    U R                  S S5      nSU R                  R                   SU S3$ )Nr   r   z = PyWinObject_FromIID(r   r   r   s     r   rg   +ArgFormatterIID.GetBuildForInterfacePreCode  s2    //a8dhhmm_$;K=MMr   c                `    U R                   R                  SU R                   R                  -  4$ )NzIID %srA   rB   s    r   rL   )ArgFormatterIID.GetInterfaceCppObjectInfo  s"    xx}}h$((--888r   r   N)	r   r   r   r   rx   rd   rg   rL   r   r   r   r   r'  r'    s    
N
9r   r'  c                  6    \ rS rSrS	S jrS rS rS rS rSr	g)
ArgFormatterTimei  c                    UR                   S:X  a>  UR                  S S S:X  a+  UR                  SS  Ul        U=R                   S-  sl         Sn[        R                  XX#5        g )Nr   r   LPr3   )rJ   rW   r   r   r-   s       r   r   ArgFormatterTime.__init__  s_    1$bq)9T)A<<+CL  A% !"&&)	
r   c                    g)Nz<o PyDateTime>r   rB   s    r   rx   #ArgFormatterTime._GetPythonTypeDesc      r   c                    SR                  U R                  R                  U R                  R                  U R                  U R                  S5      5      $ )Nz	if (!PyTime_Check(ob{})) {{
		PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object");
		bPythonIsHappy = FALSE;
	}}
	if (!((PyTime *)ob{})->GetTime({})) bPythonIsHappy = FALSE;
r3   )rw   r)   r<   r>   r*   rB   s    r   rd   !ArgFormatterTime.GetParsePostCode  sJ     b  i  iHHMMHHMM%%d&=&=qA
 	
r   c                t    U R                  U R                  S5      nSU R                  R                   SU S3$ )Nr   r   z = new PyTime(r   r  r   s     r   rg   ,ArgFormatterTime.GetBuildForInterfacePreCode  s7    //0G0GKdhhmm_N;-tDDr   c                    SnU R                   U R                  R                  -   S:  a  SU R                  R                  -  nU[        R                  U 5      -   $ )Nr0   r3   z	CoTaskMemFree(%s);
)r*   r)   rJ   r<   r   rq   r   rets     r   rq   -ArgFormatterTime.GetBuildForInterfacePostCode  sM    ""TXX%>%>>B*TXX]]:C*GGMMMr   r   Nr   )
r   r   r   r   r   rx   rd   rg   rq   r   r   r   r   r2  r2    s    	
 
E
Nr   r2  c                  &    \ rS rSrS rS rS rSrg)ArgFormatterSTATSTGi  c                    g)Nz<o STATSTG>r   rB   s    r   rx   &ArgFormatterSTATSTG._GetPythonTypeDesc  r   r   c                n    SR                  U R                  R                  U R                  S S5      5      $ )NzM	if (!PyCom_PyObjectAsSTATSTG(ob{}, {}, 0/*flags*/)) bPythonIsHappy = FALSE;
r3   r   rB   s    r   rd   $ArgFormatterSTATSTG.GetParsePostCode   s/    `ggHHMM444T1=
 	
r   c                    U R                  S S5      nSR                  U R                  R                  U R                  S S5      UU5      $ )Nr3   z	ob{} = PyCom_PyObjectFromSTATSTG({});
	// STATSTG doco says our responsibility to free
	if (({}).pwcsName) CoTaskMemFree(({}).pwcsName);
r>   rw   r)   r<   r   s     r   rg   /ArgFormatterSTATSTG.GetBuildForInterfacePreCode  sQ    //a8 b  i  iHHMM%%dA.	
 	
r   r   Nr   r   r   r   rx   rd   rg   r   r   r   r   rB  rB    s    


r   rB  c                  ,    \ rS rSrS rS rS rS rSrg)ArgFormatterGenerici  c                4    SU R                   R                  -  $ Nz<o %s>r   rB   s    r   rx   &ArgFormatterGeneric._GetPythonTypeDesc  s    $((--''r   c                    SR                  U R                  R                  U R                  R                  U R	                  S S5      5      $ )Nz7	if (!PyObject_As{}(ob{}, &{}) bPythonIsHappy = FALSE;
r3   )rw   r)   r   r<   r>   rB   s    r   rd   $ArgFormatterGeneric.GetParsePostCode  s;    JQQHHMMHHMM%%dA.
 	
r   c                d    SU R                   R                   SU R                   R                   S3$ )Nz	PyObject_Free(r   )r)   r   r<   rB   s    r   rQ   *ArgFormatterGeneric.GetInterfaceArgCleanup  s'     qtDDr   c                    U R                  S S5      nSR                  U R                  R                  U R                  R                  U R                  S S5      5      $ )Nr3   z	ob{} = PyObject_From{}({});
)r>   rw   r)   r<   r   r   s     r   rg   /ArgFormatterGeneric.GetBuildForInterfacePreCode  sM    //a8077HHMMHHMM%%dA.
 	
r   r   N	r   r   r   r   rx   rd   rQ   rg   r   r   r   r   rL  rL    s    (
E
r   rL  c                  ,    \ rS rSrS rS rS rS rSrg)ArgFormatterIDLISTi&  c                    g)Nz	<o PyIDL>r   rB   s    r   rx   %ArgFormatterIDLIST._GetPythonTypeDesc'  r*  r   c                n    SR                  U R                  R                  U R                  S S5      5      $ )NzL	if (bPythonIsHappy && !PyObject_AsPIDL(ob{}, &{})) bPythonIsHappy = FALSE;
r3   r   rB   s    r   rd   #ArgFormatterIDLIST.GetParsePostCode*  s/    _ffHHMM444T1=
 	
r   c                6    SU R                   R                   S3$ )Nz	PyObject_FreePIDL(r   rA   rB   s    r   rQ   )ArgFormatterIDLIST.GetInterfaceArgCleanup/  s    %dhhmm_D99r   c                    U R                  S S5      nSR                  U R                  R                  U R                  S S5      5      $ )Nr3   z	ob{} = PyObject_FromPIDL({});
rH  r   s     r   rg   .ArgFormatterIDLIST.GetBuildForInterfacePreCode2  sB    //a8299HHMM%%dA.
 	
r   r   NrW  r   r   r   rY  rY  &  s    

:
r   rY  c                  &    \ rS rSrS rS rS rSrg)ArgFormatterHANDLEi:  c                    g)Nz<o PyHANDLE>r   rB   s    r   rx   %ArgFormatterHANDLE._GetPythonTypeDesc;  s    r   c                n    SR                  U R                  R                  U R                  S S5      5      $ )NzE	if (!PyWinObject_AsHANDLE(ob{}, &{}, FALSE) bPythonIsHappy = FALSE;
r3   r   rB   s    r   rd   #ArgFormatterHANDLE.GetParsePostCode>  s/    X__HHMM444T1=
 	
r   c                    U R                  S S5      nSR                  U R                  R                  U R                  S S5      5      $ )Nr3   z$	ob{} = PyWinObject_FromHANDLE({});
r   rH  r   s     r   rg   .ArgFormatterHANDLE.GetBuildForInterfacePreCodeC  sB    //a87>>HHMM%%dA.
 	
r   r   NrJ  r   r   r   rc  rc  :  s    


r   rc  c                  ,    \ rS rSrS rS rS rS rSrg)ArgFormatterLARGE_INTEGERiK  c                    g)NLARGE_INTEGERr   rB   s    r   
GetKeyName$ArgFormatterLARGE_INTEGER.GetKeyNameL  s    r   c                (    SU R                  5       -  $ rN  )rn  rB   s    r   rx   ,ArgFormatterLARGE_INTEGER._GetPythonTypeDescO  s    $//+++r   c                    SR                  U R                  5       U R                  R                  U R	                  S S5      5      $ )Nz:	if (!PyWinObject_As{}(ob{}, {})) bPythonIsHappy = FALSE;
r3   )rw   rn  r)   r<   r>   rB   s    r   rd   *ArgFormatterLARGE_INTEGER.GetParsePostCodeR  s:    MTTOOHHMM%%dA.
 	
r   c                    U R                  S S5      nSR                  U R                  R                  U R	                  5       U5      $ )Nr   z 	ob{} = PyWinObject_From{}({});
)r>   rw   r)   r<   rn  r   s     r   rg   5ArgFormatterLARGE_INTEGER.GetBuildForInterfacePreCodeY  s?    //a83::HHMMOO
 	
r   r   N)	r   r   r   r   rn  rx   rd   rg   r   r   r   r   rk  rk  K  s    ,

r   rk  c                      \ rS rSrS rSrg)ArgFormatterULARGE_INTEGERib  c                    g)NULARGE_INTEGERr   rB   s    r   rn  %ArgFormatterULARGE_INTEGER.GetKeyNamec  r8  r   r   N)r   r   r   r   rn  r   r   r   r   rw  rw  b  s     r   rw  c                  2    \ rS rSrS rS rS rS rS rSr	g)	ArgFormatterInterfaceig  c                    U R                  SU R                  R                  5      SR                  U R	                  5       U R                  R
                  5      4$ )Nr3   z{} * {})r>   r)   rJ   rw   rK   r<   rB   s    r   rL   /ArgFormatterInterface.GetInterfaceCppObjectInfoh  sN    ((txx((
!HHMM

 	
r   c                    U R                   (       a  U R                  S S5      nOU R                  SS5      nSR                  U R                  R                  U R                  R
                  U5      $ )Nr   r3   z	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(ob{}, IID_{}, (void **){}, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
)r,   r>   rw   r)   r<   r   )r   sArgs     r   rd   &ArgFormatterInterface.GetParsePostCodep  sd    ,,T15D ,,Q2D `  g  gHHMM488==$
 	
r   c                    SR                  U R                  R                  U R                  R                  U R                  R                  5      $ )Nz7	ob{} = PyCom_PyObjectFromIUnknown({}, IID_{}, FALSE);
)rw   r)   r<   r   rB   s    r   rg   1ArgFormatterInterface.GetBuildForInterfacePreCode{  s6    JQQHHMMHHMMHHMM
 	
r   c                    U R                  U R                  5       S5      nSR                  U R                  R                  UU R                  R                  U R                  R
                  5      $ )Nr3   z8	ob{} = PyCom_PyObjectFromIUnknown({}{}, IID_{}, TRUE);
)r8   r;   rw   r)   r<   r   )r   sPrefixs     r   rn   /ArgFormatterInterface.GetBuildForGatewayPreCode  sT    &&t'C'C'EqIKRRHHMMHHMMHHMM	
 	
r   c                d    SU R                   R                   SU R                   R                   S3$ )Nz	if (z) z->Release();
rA   rB   s    r   rQ   ,ArgFormatterInterface.GetInterfaceArgCleanup  s'    b~FFr   r   N)
r   r   r   r   rL   rd   rg   rn   rQ   r   r   r   r   r|  r|  g  s    
	


Gr   r|  c                  &    \ rS rSrS rS rS rSrg)ArgFormatterVARIANTi  c                n    SR                  U R                  R                  U R                  S S5      5      $ )NzG	if ( !PyCom_VariantFromPyObject(ob{}, {}) )
		bPythonIsHappy = FALSE;
r3   r   rB   s    r   rd   $ArgFormatterVARIANT.GetParsePostCode  s/    ]ddHHMM444T1=
 	
r   c                `    U R                  S S5      nSU R                  R                   SU S3$ )Nr3   r   z = PyCom_PyObjectFromVariant(r   r   r   s     r   rn   -ArgFormatterVARIANT.GetBuildForGatewayPreCode  r   r   c                4    SU R                   R                  -  $ r   rA   rB   s    r   rt   .ArgFormatterVARIANT.GetBuildForGatewayPostCode  r   r   r   N)r   r   r   r   rd   rn   rt   r   r   r   r   r  r    s    

T7r   r  BOOL)r  r   r   UINT)r  r   r   BYTE)r  r   r   INT)r  r   r   DWORD)r  r   lHRESULT)r  r   r  ULONG)r  r   r  LONG)r  r   r  r   )r   r   r   long)r  r   r  DISPID)r  r  r  APPBREAKFLAGSBREAKRESUMEACTIONERRORRESUMEACTIONBREAKREASONBREAKPOINT_STATEBREAKRESUME_ACTION)SOURCE_TEXT_ATTRTEXT_DOC_ATTRQUERYOPTIONPARSEACTIONc                  $    \ rS rSrSrS rS rSrg)ArgFormatterSimplei  z-An arg formatter for simple integer etc typesc                B    [         U R                  R                     S   $ )Nr   ConvertSimpleTypesr)   r   rB   s    r   r    ArgFormatterSimple.GetFormatChar      !$((--033r   c                B    [         U R                  R                     S   $ rZ   r  rB   s    r   rx   %ArgFormatterSimple._GetPythonTypeDesc  r  r   r   N)r   r   r   r   r   r   rx   r   r   r   r   r  r    s    744r   r  zconst OLECHARr3   WCHAROLECHAR	LPCOLESTRLPOLESTRLPCWSTRLPWSTRLPCSTRLPTSTRLPCTSTRHANDLEBSTRz	const IIDCLSIDIIDGUIDz
const GUIDREFCLSIDREFIIDREFGUIDzconst FILETIMEzconst SYSTEMTIMEzconst LPSYSTEMTIMELPSYSTEMTIMEFILETIME
SYSTEMTIMESTATSTGrm  ry  VARIANTr   singleshortWORDVARIANT_BOOLHWNDHMENUHOLEMENUHICONHDCLPARAMWPARAMLRESULTSVSIFControl
DataObject_PropertyBag	AsyncProp
DataSourcer   )
DataFormatzvoid **
ITEMIDLISTLPITEMIDLISTLPCITEMIDLISTzconst ITEMIDLISTPITEMID_CHILDzconst PITEMID_CHILDPCITEMID_CHILDPUITEMID_CHILDPCUITEMID_CHILDzconst PUITEMID_CHILDPCUITEMID_CHILD_ARRAYzconst PCUITEMID_CHILD_ARRAYzOdict[str, tuple[type[ArgFormatter], int, int] | tuple[type[ArgFormatter], int]]AllConvertersc                    [         U R                     S   n[         U R                     S   nSn[        [         U R                     5      S:  a  [         U R                     S   nU" XU5      $ ! [         aI    U R                  S   S:X  a  [	        U SS5      s $ [        SU R                   SU R                   S35      ef = f)Nr   r3   r   Iz
The type 'z' (z) is unknown.)r  r   lenKeyErrorr|  r   r<   )r)   clzbindecls       r   make_arg_converterr    s    UCHH%a(CHH%a(}SXX&'!+ *1-D3T"" U88A;#(a33!JsxxjCHH:]"STT	Us   A,A/ /*C'Cc                  d    \ rS rSrSr\R                  " S5      r\S 5       r	S r
S rS rS rS	rg
)Argumenti  zA representation of an argument to a COM method

This class contains information about a specific argument to a method.
In addition, methods exist so that an argument knows how to convert itself
to/from Python arguments.
z6/\* \[([^\]]*.*?)] \*/[ \t](.*[* ]+)(\w+)(\[ *])?[\),]c                P    SR                  S UR                  S5       5       5      $ )NrI   c              3  T   #    U  H  oR                  S 5      (       a  M  Uv   M      g7f)__RPC_N)
startswith).0es     r   	<genexpr>-Argument.drop_rpc_metadata.<locals>.<genexpr>+  s     R#3a<<;Q#3s   (	()joinsplit)clstype_s     r   drop_rpc_metadataArgument.drop_rpc_metadata)  s     xxR5;;s#3RRRr   c                    Xl         S U l        S U l        S U l        S U l        S U l        SU l        SU l        SU l        g r'   )	good_interface_namesinoutr<   r   raw_typerW   const	arrayDeclrJ   r   r  s     r   r   Argument.__init__-  sA    $8!
		
 !r   c                   UR                  5       nU R                  R                  U5      nU(       d  [        eUR	                  S5      U l        UR	                  S5      R                  S5      U l        UR	                  S5      R                  5       nX@l	        UR	                  S5      (       a2  SU l
        U R                  U5      nXE:w  a  U =R                  S-  sl        U R                  U5      n  UR                  S5      nU =R                  S-  sl        USU R                  5       nM<  ! [         a     Of = fX@l        U R                  SS S	:X  a  U R                  SS U l        OU R                  U l        ["        (       aI  [%        S
R'                  U R
                  U R                  SU R                  -  U R                  5      5        gg)zParse and build my data from a file

Reads the next line in the file, and matches it as an argument
description.  If not a valid argument line, an error_not_found exception
is raised.
r  r3   z][r   rj   r4   N   zconst z       Arg {} of type {}{} ({}))readlineregexsearchr   groupr<   r  r  stripr  r  r  rJ   rindex
ValueErrorr   rW   VERBOSEr^   rw   )r   filelinemotyp
typ_no_rpcposs          r   BuildFromFileArgument.BuildFromFile8  s    }}ZZt$!!HHQK	XXa[&&t,
hhqk!88A;;DN//4J %%*%$$S)jjo%%*%$3ioo'	 
  	99Ra=H$ IIabMDM IIDM7188IItyy#0E0E*Etzz s   49D/ /
D<;D<c                    XR                   ;   $ )zDetermines if the argument has the specific attribute.

Argument attributes are specified in the header file, such as
"[in][out][retval]" etc.  You can pass a specific string (eg "out")
to find if this attribute was specified for the argument
)r  )r   r  s     r   HasAttributeArgument.HasAttributeb  s     jj  r   c                h    U R                    SU R                   3nU R                  (       a  US-  nU$ )NrI   z[])r  r<   r  r>  s     r   GetRawDeclarationArgument.GetRawDeclarationk  s/    q,>>4KC
r   )	r  r  r  rJ   r  r<   r  r   rW   N)r   r   r   r   r   recompiler  classmethodr  r   r  r  r  r   r   r   r   r  r    sA     JJPQES S	"(T!r   r  c                  H    \ rS rSrSr\R                  " S5      rS rS r	Sr
g)Methodir  zA representation of a C++ method on a COM interface

This class contains information about a specific method, as well as
a list of all @Argument@s
z+virtual (/\*.*?\*/ )?(.*?) (.*?) (.*?)\(\w?c                H    Xl         S =U l        =U l        U l        / U l        g r   )r  r<   resultcallconvargsr  s     r   r   Method.__init__}  s$    $8!266	6DK$-	r   c                H   UR                  5       nU R                  R                  U5      nU(       d  [        eUR	                  S5      U l        UR	                  S5      U l        U R                  S:w  aZ  U R                  S:X  a  [        S5        O[        SU R
                  -  5        [        SU R                   SU R
                   S	35         [        U R                  5      n UR                  U5        U R                  R                  U5        MD  ! [         a     g
f = f)zParse and build my data from a file

Reads the next line in the file, and matches it as a method
description.  If not a valid method line, an error_not_found exception
is raised.
rj   r   r  r  zBWarning: Old style interface detected - compilation errors likely!z4Method %s - Only HRESULT return types are supported.z     Method rI   rS  N)r  r  r  r   r  r<   r  r^   r  r  r  r!  append)r   r  r  r  r)   s        r   r  Method.BuildFromFile  s     }}ZZt$!!HHQK	hhqk;;)#{{g%X JTYYV LQtyyk;<4445C!!$'		  %	 
 # s   &,D 
D! D!)r!  r   r  r<   r  N)r   r   r   r   r   r  r  r  r   r  r   r   r   r   r  r  r  s"     JJEFE
r   r  c                  H    \ rS rSrSr\R                  " S5      rS rS r	Sr
g)	Interfacei  zA representation of a C++ COM Interface

This class contains information about a specific interface, as well as
a list of all @Method@s
z#(interface|) ([^ ]*) : public (.*)$c                    / U l         UR                  S5      U l        UR                  S5      U l        [        (       a&  [        SU R                   SU R                   35        g g )Nr   r  z
Interface z
 : public )methodsr  r<   baser
  r^   )r   r  s     r   r   Interface.__init__  sN    HHQK	HHQK	7JtyykDII;?@ r   c                    UR                  5         UR                  5           [        U R                  /5      nUR                  U5        U R                  R                  U5        ME  ! [         a     gf = f)z(Build all sub-methods for this interfaceN)r  r  r<   r  r)  r$  r   )r   r  methods      r   BuildMethodsInterface.BuildMethods  sg     	,$$T*##F+	 
 # s   AA' '
A43A4)r*  r)  r<   N)r   r   r   r   r   r  r  r  r   r.  r   r   r   r   r'  r'    s#     JJ=>EAr   r'  c                j   SnUR                  5       nU(       a  [        R                  R                  U5      nU(       aM  UR	                  S5      n[        U5        [        SS4[        U'   XP:X  a  [        U5      nUR                  U5        UR                  5       nU(       a  M  U(       a  U$ [        e)zFind and return an interface in a file

Given an interface name and file, search for the specified interface.

Upon return, the interface itself has been built,
but not the methods.
Nr   r   r3   )
r  r'  r  r  r  r^   r|  r  r.  r   )interfaceNamer  	interfacer  r  r<   s         r   find_interfacer3    s     I==?D
__##D)88A;D$K#8!Q"?M$$%bM	&&t,}} $ 
r   c                     [        X5      $ ! [        R                   a#    [        R                  " 5         [        S5         gf = f)zFind, parse and return an interface in a file

Given an interface name and file, search for the specified interface.

Upon return, the interface itself is fully built,
zCThe interface could not be built, as the regular expression failed!N)r3  r  error	traceback	print_excr^   )r1  r  s     r   parse_interface_infor8    s=    Um2288 USTUs   
 4AAc                 ~    [        S5      n  [        SU 5        U R                  5         g ! U R                  5         f = f)Nzd:\msdev\include\objidl.hIPersistStream)openr8  close)r   s    r   testr=    s0    +,A-q1			s   * <c           
         U R                  US5      nUS:X  a  [        S5        g [        SX R                  S5      U R                  S5      U R                  S5      U R                  S5      4-  5        g )	Nr   r1   z** Not foundz%d
%s
%s
%s
%sr3   r   r  rj   )r  r^   r  )rtextress      r   
test_regexrB    s[    
((4
C
byn CQWWQZQWWUVZ#XX	
r   )*r   
__future__r   r  r6  	Exceptionr   r   r
  rP   r$   r   r   r   r   r   r   r  r'  r2  rB  rL  rY  rc  rk  rw  r|  r  r  r  dictfromkeysr  __annotations__r  r  r  r'  r3  r8  r=  rB  r   r   r   <module>rH     s+   # 	 i 
) 
 	y yz" "N" "L7< 7B7L 747, 7.7/ 7D7- 7<9+ 9&#N, #NL
/ 
&
/ 
.
. 
(
. 
"
 5 
. !:  
%G1 %GP7/ 7 
 
    
	
 " & "   
   % ( , , &  +!" -#$ ,(&&+ 24 4D)1a0D!1a(D #Q*D %q!,	D
 $a+D #Q*D "Aq)D "Aq)D  !Q'D !1a(D !1%D q!$D /1%D oq!D 
OQD  _a !D" ?A&#D$ /1%%D& !$'D( ")D* #+D, '+-D. )1-/D0 +Q21D2 %q!,3D4 !1%5D6 #Q'7D8 #Q'9D: /3;D< 115=D> #Q'?D@ #ADB  !$CDD #EDF "GDH &*IDJ !1%KDL "A&MDN %q)ODP "A&QDR 
 !$SDT #Q'UDV #Q'WDX $a(YDZ "[D\ #]D^ %q!,_D` (!Q/aDb *Aq1cDd 'A.eDf (!Q/gDh )!Q/%q!,%q!,'A.(!Q/+Q2(!,.2)1-)1-*A./30!4$6#:CDF mm&);Q(?@GD   FRU$R Rj. .b @2U
r   