
    %
iэ                    ,   U d Z ddlmZ ddlZddlZ G d de          Z G d de          ZdZdZ	 G d d	          Z
 G d
 de
          Z G d de
          Z G d de
          Z G d de
          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          Z G d( d)e          Z G d* d+e          Zi d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBd=dCd=dDd=dEd=dFd=dGd=d=d=d=d=dHZ G dI dJe
          Zi dKeddLfdMeddLfdNeddLfdOedLdLfdPedLdLfdQedLdLfdRedLdLfdSedLdLfdTedLdLfdUedLdLfdVedfdWedLdfdXedfdYedfdZedfd[edfd\edfi dXedfd]edfd^edfd_edfd`edfdaedfdbedLdLfdcedLdLfddedfdeedfdfedfdgedfdhedfdiedfdjedfdkedfdledfi dmedfdnedfdoedLfdpedLfdqedLfdredLfdsedLfdtedLfduedLfdvedLfd.edfdwedfdxeddLfdyeddLfdzeddLfd{eddLfd|eddLfeddLfed}d}feddfeddLfeddLfeddLfedLfedfedfedLfedfedfed}fed}fd~e                    eedf          Z de!d<   d Z" G d d          Z# G d d          Z$ G d d          Z%d Z&d Z'd Z(d Z)dS )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                        e Zd Zd fd	Z xZS )error_not_found%The requested item could not be foundc                J    t                                          |           d S Nsuper__init__selfmsg	__class__s     C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\win32com/makegw/makegwparse.pyr   zerror_not_found.__init__   !        )r   __name__
__module____qualname__r   __classcell__r   s   @r   r   r      =                 r   r   c                        e Zd Zd fd	Z xZS )error_not_supported+The required functionality is not supportedc                J    t                                          |           d S r   r	   r   s     r   r   zerror_not_supported.__init__   r   r   )r   r   r   s   @r   r   r      r   r   r   c                      e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )ArgFormatterzHAn instance for a specific type of argument. Knows how to convert itselfr   c                >    || _         || _        || _        d| _        d S Nr   )argbuiltinIndirectiondeclaredIndirectiongatewayModer   r"   r#   r$   s       r   r   zArgFormatter.__init__*   s'    "4#6 r   c                H    ||z
  }|dk    rdS |dk    rdS |dk    rdS d|fz  S )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   _IndirectPrefixzArgFormatter._IndirectPrefix1   sE     -!882BYY3AXX3v%%r   c                    ||                                  | j        z   }|                     ||          | j        j        z   S r   )_GetDeclaredIndirectionr#   r0   r"   name)r   indirectFromr.   s      r   GetIndirectedArgNamez!ArgFormatter.GetIndirectedArgNameE   sD       7799D<SSL##L-@@48=PPr   c                    | j         j        S )z.Get the argument to be passes to Py_BuildValuer"   r3   r   s    r   GetBuildValueArgzArgFormatter.GetBuildValueArgV   s    x}r   c                r    | j         r|                     dd          S |                     | j        d          S )z1Get the argument to be passed to PyArg_ParseTupleNr+   )r%   r5   r#   r8   s    r   GetParseTupleArgzArgFormatter.GetParseTupleArgZ   s<     	6,,T1555(()@!DDDr   c                    |                      | j        | j        j        | j        z             |                                  d| j        j         fS )a  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|""])
         )r5   r#   r"   indirectionLevelGetUnconstTyper3   r8   s    r   GetInterfaceCppObjectInfoz&ArgFormatter.GetInterfaceCppObjectInfob   sZ    0 %%')D,CC  ""$$66tx}66
 	
r   c                2    t           rd| j        j        z  S dS )z@Return cleanup code for C++ args passed to the interface method.z2/* GetInterfaceArgCleanup output goes here: %s */
r(   DEBUGr"   r3   r8   s    r   GetInterfaceArgCleanupz#ArgFormatter.GetInterfaceArgCleanup   s     	H48=XX2r   c                2    t           rd| j        j        z  S dS )zoReturn 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 */
r(   rB   r8   s    r   GetInterfaceArgCleanupGILz&ArgFormatter.GetInterfaceArgCleanupGIL   s'      	P(- 
 2r   c                    | j         j        S r   )r"   unc_typer8   s    r   r?   zArgFormatter.GetUnconstType   s    x  r   c                    d| _         d S Nr+   )r%   r8   s    r   SetGatewayModezArgFormatter.SetGatewayMode   s    r   c                    | j         j        S r   )r"   r>   printr3   r%   r$   r8   s    r   r2   z$ArgFormatter._GetDeclaredIndirection   s    x((r   c                2    t           rd| j        j        z  S dS )zEDeclare the variable used as the PyArg_ParseTuple param for a gatewayz8/* Declare ParseArgTupleInputConverter goes here: %s */
r(   rB   r8   s    r   "DeclareParseArgTupleInputConverterz/ArgFormatter.DeclareParseArgTupleInputConverter   s'      	K(- 
 2r   c                2    t           rd| j        j        z  S dS )z_Get a string of C++ code to be executed after (ie, to finalise) the PyArg_ParseTuple conversionz*/* GetParsePostCode code goes here: %s */
r(   rB   r8   s    r   GetParsePostCodezArgFormatter.GetParsePostCode   s     	@48=PP2r   c                2    t           rd| j        j        z  S dS )znGet a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Interfacesz0/* GetBuildForInterfacePreCode goes here: %s */
r(   rB   r8   s    r   GetBuildForInterfacePreCodez(ArgFormatter.GetBuildForInterfacePreCode   s     	FVV2r   c                v    |                                  }t          r|dd         dk    rd| j        j        z  }|S )zlGet a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for GatewaysN   /* Gz./* GetBuildForGatewayPreCode goes here: %s */
)rS   rC   r"   r3   r   ss     r   GetBuildForGatewayPreCodez&ArgFormatter.GetBuildForGatewayPreCode   s@    ,,.. 	V!uEUr   c                2    t           rd| j        j        z  S dS )zkGet a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Interfacesz1/* GetBuildForInterfacePostCode goes here: %s */
r(   rB   r8   s    r   GetBuildForInterfacePostCodez)ArgFormatter.GetBuildForInterfacePostCode   s     	XG$(-WWrr   c                v    |                                  }t          r|dd         dk    rd| j        j        z  }|S )ziGet a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for GatewaysNrU   rV   z//* GetBuildForGatewayPostCode goes here: %s */
)r[   rC   r"   r3   rW   s     r   GetBuildForGatewayPostCodez'ArgFormatter.GetBuildForGatewayPostCode   s@    --// 	W!uFVr   c                |    d                     |                                 | j        j        | j        j                  S )Nz$// @pyparm {}|{}||Description for {})format_GetPythonTypeDescr"   r3   r8   s    r   GetAutoduckStringzArgFormatter.GetAutoduckString   s7    5<<##%%HMHM
 
 	
r   c                    dS )zIReturns a string with the description of the type. Used for doco purposesN r8   s    r   r`   zArgFormatter._GetPythonTypeDesc   s    tr   c                    dS )z5Determines if this arg forces a USES_CONVERSION macror   rc   r8   s    r   NeedUSES_CONVERSIONz ArgFormatter.NeedUSES_CONVERSION   s    qr   Nr   )r   r   r   __doc__r   r0   r5   r9   r;   r@   rD   rF   r?   rK   r2   rO   rQ   rS   rY   r[   r]   ra   r`   re   rc   r   r   r   r   '   sT       RR   U U U(Q Q Q"  E E E
 
 
>  	 	 	! ! !  , , ,            
 
 
      r   r   c                  >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ArgFormatterFloatc                    dS )Nfrc   r8   s    r   GetFormatCharzArgFormatterFloat.GetFormatChar       sr   c                     d| j         j        z  S )Nz	double dbl%s;
r7   r8   s    r   rO   z4ArgFormatterFloat.DeclareParseArgTupleInputConverter   s    "TX]22r   c                     d| j         j        z   S Nz&dblr7   r8   s    r   r;   z"ArgFormatterFloat.GetParseTupleArg       %%r   c                    dS )Nfloatrc   r8   s    r   r`   z$ArgFormatterFloat._GetPythonTypeDesc   s    wr   c                     d| j         j        z   S rp   r7   r8   s    r   r9   z"ArgFormatterFloat.GetBuildValueArg   rq   r   c                F    d| j         j        z   dz   | j         j        z   dz   S )Nz	dbl = ;
r7   r8   s    r   rS   z-ArgFormatterFloat.GetBuildForInterfacePreCode   s$    &.>FFr   c                    d| j         j        z  |                     |                                 d          z   | j         j        z   dz   S )Nz		dbl%s = r   rw   r"   r3   r0   r2   r8   s    r   rY   z+ArgFormatterFloat.GetBuildForGatewayPreCode   sN    48=(""4#?#?#A#A1EEFhm 	
r   c                    d}| j         r+||                     |                                 d          z  }|| j        j        z  }|d| j        j        z  z  }|S )N	r   z = (float)dbl%s;
r%   r0   r2   r"   r3   rW   s     r   rQ   z"ArgFormatterFloat.GetParsePostCode   s`     	I%%d&B&B&D&DaHHHA	TX]	!DHM11r   Nr   r   r   rl   rO   r;   r`   r9   rS   rY   rQ   rc   r   r   ri   ri      s          3 3 3& & &  & & &G G G
 
 
    r   ri   c                  >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ArgFormatterShortc                    dS )Nirc   r8   s    r   rl   zArgFormatterShort.GetFormatChar  rm   r   c                     d| j         j        z  S )Nz
	INT i%s;
r7   r8   s    r   rO   z4ArgFormatterShort.DeclareParseArgTupleInputConverter  s    --r   c                     d| j         j        z   S Nz&ir7   r8   s    r   r;   z"ArgFormatterShort.GetParseTupleArg      dhm##r   c                    dS )Nintrc   r8   s    r   r`   z$ArgFormatterShort._GetPythonTypeDesc  s    ur   c                     d| j         j        z   S r   r7   r8   s    r   r9   z"ArgFormatterShort.GetBuildValueArg  r   r   c                F    d| j         j        z   dz   | j         j        z   dz   S )Nz	irv   rw   r7   r8   s    r   rS   z-ArgFormatterShort.GetBuildForInterfacePreCode  s$    tx}$u,tx}<uDDr   c                    d| j         j        z  |                     |                                 d          z   | j         j        z   dz   S )Nz	i%s = r   rw   ry   r8   s    r   rY   z+ArgFormatterShort.GetBuildForGatewayPreCode  sN    &""4#?#?#A#A1EEFhm 	
r   c                    d}| j         r+||                     |                                 d          z  }|| j        j        z  }|d| j        j        z  z  }|S )Nr{   r   z = i%s;
r|   rW   s     r   rQ   z"ArgFormatterShort.GetParsePostCode'  s_     	I%%d&B&B&D&DaHHHA	TX]	[48=((r   Nr}   rc   r   r   r   r     s          . . .$ $ $  $ $ $E E E
 
 
    r   r   c                  D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )ArgFormatterLONG_PTRc                    dS NOrc   r8   s    r   rl   z"ArgFormatterLONG_PTR.GetFormatChar2  rm   r   c                     d| j         j        z  S Nz	PyObject *ob%s;
r7   r8   s    r   rO   z7ArgFormatterLONG_PTR.DeclareParseArgTupleInputConverter5      $tx}44r   c                     d| j         j        z   S Nz&obr7   r8   s    r   r;   z%ArgFormatterLONG_PTR.GetParseTupleArg9      tx}$$r   c                    dS )Nzint/longrc   r8   s    r   r`   z'ArgFormatterLONG_PTR._GetPythonTypeDesc<  s    zr   c                     d| j         j        z   S Nobr7   r8   s    r   r9   z%ArgFormatterLONG_PTR.GetBuildValueArg?  r   r   c                     d| j         j        z  S Nz	Py_XDECREF(ob%s);
r7   r8   s    r   r[   z1ArgFormatterLONG_PTR.GetBuildForInterfacePostCodeB      &66r   c                j    d                     | j        j        |                     d d                    S )Nz^	if (bPythonIsHappy && !PyWinLong_AsULONG_PTR(ob{}, (ULONG_PTR *){})) bPythonIsHappy = FALSE;
   r_   r"   r3   r5   r8   s    r   rQ   z%ArgFormatterLONG_PTR.GetParsePostCodeE  s3    qxxHM444T1==
 
 	
r   c                T    |                      d d          }d| j        j         d| dS )Nr+   	obz = PyWinObject_FromULONG_PTR();
r5   r"   r3   r   notdirecteds     r   rS   z0ArgFormatterLONG_PTR.GetBuildForInterfacePreCodeJ  4    //a88SdhmSS+SSSSr   c                     d| j         j        z  S r   r7   r8   s    r   r]   z/ArgFormatterLONG_PTR.GetBuildForGatewayPostCodeN  r   r   N)r   r   r   rl   rO   r;   r`   r9   r[   rQ   rS   r]   rc   r   r   r   r   1  s          5 5 5% % %  $ $ $7 7 7
 
 

T T T7 7 7 7 7r   r   c                  6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	ArgFormatterPythonCOMz:An arg formatter for types exposed in the PythonCOM modulec                    dS r   rc   r8   s    r   rl   z#ArgFormatterPythonCOM.GetFormatCharU  rm   r   c                     d| j         j        z  S r   r7   r8   s    r   rO   z8ArgFormatterPythonCOM.DeclareParseArgTupleInputConverter[  r   r   c                     d| j         j        z   S r   r7   r8   s    r   r;   z&ArgFormatterPythonCOM.GetParseTupleArg_  r   r   c                     d| j         j        z  S )Nz<o Py%s>r"   typer8   s    r   r`   z(ArgFormatterPythonCOM._GetPythonTypeDescb  s    DHM))r   c                     d| j         j        z   S r   r7   r8   s    r   r9   z&ArgFormatterPythonCOM.GetBuildValueArge  r   r   c                     d| j         j        z  S r   r7   r8   s    r   r[   z2ArgFormatterPythonCOM.GetBuildForInterfacePostCodeh  r   r   N)
r   r   r   rg   rl   rO   r;   r`   r9   r[   rc   r   r   r   r   R  st        DD  5 5 5% % %* * *$ $ $7 7 7 7 7r   r   c                  ,    e Zd Zd Zd Zd Zd Zd ZdS )ArgFormatterBSTRc                    dS Nz<o unicode>rc   r8   s    r   r`   z#ArgFormatterBSTR._GetPythonTypeDescm      }r   c                j    d                     | j        j        |                     d d                    S NzN	if (bPythonIsHappy && !PyWinObject_AsBstr(ob{}, {})) bPythonIsHappy = FALSE;
r   r   r8   s    r   rQ   z!ArgFormatterBSTR.GetParsePostCodep  3    ahhHM444T1==
 
 	
r   c                T    |                      d d          }d| j        j         d| dS )Nr+   r   z = MakeBstrToObj(r   r   r   s     r   rS   z,ArgFormatterBSTR.GetBuildForInterfacePreCodeu  s4    //a88GdhmGGkGGGGr   c                X    d| j         j         dt                              |           z   S )Nz	SysFreeString(r   r"   r3   r   r[   r8   s    r   r[   z-ArgFormatterBSTR.GetBuildForInterfacePostCodey  s0    2tx}222#@@FFG	
r   c                     d| j         j        z  S r   r7   r8   s    r   r]   z+ArgFormatterBSTR.GetBuildForGatewayPostCode  r   r   N)r   r   r   r`   rQ   rS   r[   r]   rc   r   r   r   r   l  sb          
 
 

H H H
 
 
7 7 7 7 7r   r   c                  8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ArgFormatterOLECHARc                    dS r   rc   r8   s    r   r`   z&ArgFormatterOLECHAR._GetPythonTypeDesc  r   r   c                    | j         j        d d         dk    r)| j         j        d d         | j         j        dd          z   S | j         j        S N   LPCr   r"   r   rH   r8   s    r   r?   z"ArgFormatterOLECHAR.GetUnconstType  J    8=!%%8=!$tx}QRR'8888$$r   c                j    d                     | j        j        |                     d d                    S r   r   r8   s    r   rQ   z$ArgFormatterOLECHAR.GetParsePostCode  r   r   c                4    d|                      d d          z  S )Nz	SysFreeString(%s);
r+   r5   r8   s    r   rD   z*ArgFormatterOLECHAR.GetInterfaceArgCleanup  s    '$*C*CD!*L*LLLr   c                ^    |                      | j        d          }d| j        j         d| dS )Nr+   r   z = MakeOLECHARToObj(r   r5   r#   r"   r3   r   s     r   rS   z/ArgFormatterOLECHAR.GetBuildForInterfacePreCode  s7    //0GKKJdhmJJJJJJr   c                X    d| j         j         dt                              |           z   S )Nz	CoTaskMemFree(r   r   r8   s    r   r[   z0ArgFormatterOLECHAR.GetBuildForInterfacePostCode  s2     3tx}222#@@FFG	
r   c                     d| j         j        z  S r   r7   r8   s    r   r]   z.ArgFormatterOLECHAR.GetBuildForGatewayPostCode  r   r   N
r   r   r   r`   r?   rQ   rD   rS   r[   r]   rc   r   r   r   r     s          % % %
 
 

M M MK K K

 
 
7 7 7 7 7r   r   c                  8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ArgFormatterTCHARc                    dS )Nzstring/<o unicode>rc   r8   s    r   r`   z$ArgFormatterTCHAR._GetPythonTypeDesc  s    ##r   c                    | j         j        d d         dk    r)| j         j        d d         | j         j        dd          z   S | j         j        S r   r   r8   s    r   r?   z ArgFormatterTCHAR.GetUnconstType  r   r   c                j    d                     | j        j        |                     d d                    S )NzO	if (bPythonIsHappy && !PyWinObject_AsTCHAR(ob{}, {})) bPythonIsHappy = FALSE;
r   r   r8   s    r   rQ   z"ArgFormatterTCHAR.GetParsePostCode  s3    biiHM444T1==
 
 	
r   c                4    d|                      d d          z  S )Nz	PyWinObject_FreeTCHAR(%s);
r+   r   r8   s    r   rD   z(ArgFormatterTCHAR.GetInterfaceArgCleanup  s    /$2K2KDRS2T2TTTr   c                ^    |                      | j        d          }d| j        j         d| dS )Nr+   r   z = PyWinObject_FromTCHAR(r   r   r   s     r   rS   z-ArgFormatterTCHAR.GetBuildForInterfacePreCode  s7    //0GKKOdhmOOkOOOOr   c                    dS )Nz// ??? - TCHAR post code
rc   r8   s    r   r[   z.ArgFormatterTCHAR.GetBuildForInterfacePostCode  s    ++r   c                     d| j         j        z  S r   r7   r8   s    r   r]   z,ArgFormatterTCHAR.GetBuildForGatewayPostCode  r   r   Nr   rc   r   r   r   r     s        $ $ $% % %
 
 

U U UP P P
, , ,7 7 7 7 7r   r   c                  &    e Zd Zd Zd Zd Zd ZdS )ArgFormatterIIDc                    dS )Nz	<o PyIID>rc   r8   s    r   r`   z"ArgFormatterIID._GetPythonTypeDesc      {r   c                V    d                     | j        j        | j        j                  S )Nz<	if (!PyWinObject_AsIID(ob{}, &{})) bPythonIsHappy = FALSE;
)r_   r"   r3   r8   s    r   rQ   z ArgFormatterIID.GetParsePostCode  s(    OVVHMHM
 
 	
r   c                T    |                      d d          }d| j        j         d| dS )Nr   r   z = PyWinObject_FromIID(r   r   r   s     r   rS   z+ArgFormatterIID.GetBuildForInterfacePreCode  s4    //a88MdhmMMKMMMMr   c                8    | j         j        d| j         j        z  fS )NzIID %sr7   r8   s    r   r@   z)ArgFormatterIID.GetInterfaceCppObjectInfo  s    x}h$(-888r   N)r   r   r   r`   rQ   rS   r@   rc   r   r   r   r     sS          
 
 
N N N
9 9 9 9 9r   r   c                  .    e Zd ZddZd Zd Zd Zd ZdS )	ArgFormatterTimer   c                    |j         dk    r9|j        d d         dk    r&|j        dd          |_        |xj         dz  c_         d}t                              | |||           d S )Nr   r   LPr+   )r>   rH   r   r   r&   s       r   r   zArgFormatterTime.__init__  s~    1$$bqb)9T)A)A<+CL  A%  !"&&#)+>	
 	
 	
 	
 	
r   c                    dS )Nz<o PyDateTime>rc   r8   s    r   r`   z#ArgFormatterTime._GetPythonTypeDesc      r   c                    d                     | j        j        | j        j        |                     | j        d                    S )Nz	if (!PyTime_Check(ob{})) {{
		PyErr_SetString(PyExc_TypeError, "The argument must be a PyTime object");
		bPythonIsHappy = FALSE;
	}}
	if (!((PyTime *)ob{})->GetTime({})) bPythonIsHappy = FALSE;
r+   )r_   r"   r3   r5   r#   r8   s    r   rQ   z!ArgFormatterTime.GetParsePostCode  sG     b  i  iHMHM%%d&=qAA
 
 	
r   c                ^    |                      | j        d          }d| j        j         d| dS )Nr   r   z = new PyTime(r   r   r   s     r   rS   z,ArgFormatterTime.GetBuildForInterfacePreCode  s7    //0GKKDdhmDD;DDDDr   c                    d}| j         | j        j        z   dk    rd| j        j        z  }|t                              |           z   S )Nr(   r+   z	CoTaskMemFree(%s);
)r#   r"   r>   r3   r   r[   r   rets     r   r[   z-ArgFormatterTime.GetBuildForInterfacePostCode  sG    "TX%>>BB*TX]:C*GGMMMMr   Nrf   )r   r   r   r   r`   rQ   rS   r[   rc   r   r   r   r     sl        	
 	
 	
 	
     
 
 
E E E
N N N N Nr   r   c                       e Zd Zd Zd Zd ZdS )ArgFormatterSTATSTGc                    dS )Nz<o STATSTG>rc   r8   s    r   r`   z&ArgFormatterSTATSTG._GetPythonTypeDesc  r   r   c                j    d                     | j        j        |                     d d                    S )NzM	if (!PyCom_PyObjectAsSTATSTG(ob{}, {}, 0/*flags*/)) bPythonIsHappy = FALSE;
r+   r   r8   s    r   rQ   z$ArgFormatterSTATSTG.GetParsePostCode   s3    `ggHM444T1==
 
 	
r   c                    |                      d d          }d                    | j        j        |                      d d          ||          S )Nr+   z	ob{} = PyCom_PyObjectFromSTATSTG({});
	// STATSTG doco says our responsibility to free
	if (({}).pwcsName) CoTaskMemFree(({}).pwcsName);
r5   r_   r"   r3   r   s     r   rS   z/ArgFormatterSTATSTG.GetBuildForInterfacePreCode  sX    //a88 b  i  iHM%%dA..	
 
 	
r   Nr   r   r   r`   rQ   rS   rc   r   r   r   r     sA          
 
 


 
 
 
 
r   r   c                  &    e Zd Zd Zd Zd Zd ZdS )ArgFormatterGenericc                     d| j         j        z  S Nz<o %s>r   r8   s    r   r`   z&ArgFormatterGeneric._GetPythonTypeDesc  s    $(-''r   c                    d                     | j        j        | j        j        |                     d d                    S )Nz7	if (!PyObject_As{}(ob{}, &{}) bPythonIsHappy = FALSE;
r+   )r_   r"   r   r3   r5   r8   s    r   rQ   z$ArgFormatterGeneric.GetParsePostCode  s;    JQQHMHM%%dA..
 
 	
r   c                <    d| j         j         d| j         j         dS )Nz	PyObject_Free(r   )r"   r   r3   r8   s    r   rD   z*ArgFormatterGeneric.GetInterfaceArgCleanup  s#    DDDDDDDr   c                    |                      d d          }d                    | j        j        | j        j        |                      d d                    S )Nr+   z	ob{} = PyObject_From{}({});
)r5   r_   r"   r3   r   r   s     r   rS   z/ArgFormatterGeneric.GetBuildForInterfacePreCode  sP    //a88077HMHM%%dA..
 
 	
r   Nr   r   r   r`   rQ   rD   rS   rc   r   r   r   r     sS        ( ( (
 
 
E E E
 
 
 
 
r   r   c                  &    e Zd Zd Zd Zd Zd ZdS )ArgFormatterIDLISTc                    dS )Nz	<o PyIDL>rc   r8   s    r   r`   z%ArgFormatterIDLIST._GetPythonTypeDesc'  r   r   c                j    d                     | j        j        |                     d d                    S )NzL	if (bPythonIsHappy && !PyObject_AsPIDL(ob{}, &{})) bPythonIsHappy = FALSE;
r+   r   r8   s    r   rQ   z#ArgFormatterIDLIST.GetParsePostCode*  s3    _ffHM444T1==
 
 	
r   c                "    d| j         j         dS )Nz	PyObject_FreePIDL(r   r7   r8   s    r   rD   z)ArgFormatterIDLIST.GetInterfaceArgCleanup/  s    9dhm9999r   c                    |                      d d          }d                    | j        j        |                      d d                    S )Nr+   z	ob{} = PyObject_FromPIDL({});
r   r   s     r   rS   z.ArgFormatterIDLIST.GetBuildForInterfacePreCode2  sI    //a88299HM%%dA..
 
 	
r   Nr   rc   r   r   r   r   &  sP          
 
 

: : :
 
 
 
 
r   r   c                       e Zd Zd Zd Zd ZdS )ArgFormatterHANDLEc                    dS )Nz<o PyHANDLE>rc   r8   s    r   r`   z%ArgFormatterHANDLE._GetPythonTypeDesc;  s    ~r   c                j    d                     | j        j        |                     d d                    S )NzE	if (!PyWinObject_AsHANDLE(ob{}, &{}, FALSE) bPythonIsHappy = FALSE;
r+   r   r8   s    r   rQ   z#ArgFormatterHANDLE.GetParsePostCode>  s3    X__HM444T1==
 
 	
r   c                    |                      d d          }d                    | j        j        |                      d d                    S )Nr+   z$	ob{} = PyWinObject_FromHANDLE({});
r   r   r   s     r   rS   z.ArgFormatterHANDLE.GetBuildForInterfacePreCodeC  sI    //a887>>HM%%dA..
 
 	
r   Nr   rc   r   r   r  r  :  sA          
 
 


 
 
 
 
r   r  c                  &    e Zd Zd Zd Zd Zd ZdS )ArgFormatterLARGE_INTEGERc                    dS )NLARGE_INTEGERrc   r8   s    r   
GetKeyNamez$ArgFormatterLARGE_INTEGER.GetKeyNameL  s    r   c                0    d|                                  z  S r   )r
  r8   s    r   r`   z,ArgFormatterLARGE_INTEGER._GetPythonTypeDescO  s    $//++++r   c                    d                     |                                 | j        j        |                     d d                    S )Nz:	if (!PyWinObject_As{}(ob{}, {})) bPythonIsHappy = FALSE;
r+   )r_   r
  r"   r3   r5   r8   s    r   rQ   z*ArgFormatterLARGE_INTEGER.GetParsePostCodeR  sA    MTTOOHM%%dA..
 
 	
r   c                    |                      d d          }d                    | j        j        |                                 |          S )Nr   z 	ob{} = PyWinObject_From{}({});
)r5   r_   r"   r3   r
  r   s     r   rS   z5ArgFormatterLARGE_INTEGER.GetBuildForInterfacePreCodeY  sF    //a883::HMOO
 
 	
r   N)r   r   r   r
  r`   rQ   rS   rc   r   r   r  r  K  sP          , , ,
 
 

 
 
 
 
r   r  c                      e Zd Zd ZdS )ArgFormatterULARGE_INTEGERc                    dS )NULARGE_INTEGERrc   r8   s    r   r
  z%ArgFormatterULARGE_INTEGER.GetKeyNamec  r   r   N)r   r   r   r
  rc   r   r   r  r  b  s#                 r   r  c                  ,    e Zd Zd Zd Zd Zd Zd ZdS )ArgFormatterInterfacec                    |                      d| j        j                  d                    |                                 | j        j                  fS )Nr+   z{} * {})r5   r"   r>   r_   r?   r3   r8   s    r   r@   z/ArgFormatterInterface.GetInterfaceCppObjectInfoh  sR    ((tx(
 
!!HM
 

 	
r   c                    | j         r|                     d d          }n|                     dd          }d                    | j        j        | j        j        |          S )Nr   r+   z	if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(ob{}, IID_{}, (void **){}, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
)r%   r5   r_   r"   r3   r   )r   sArgs     r   rQ   z&ArgFormatterInterface.GetParsePostCodep  sk     	3,,T155DD ,,Q22D `  g  gHM48=$
 
 	
r   c                l    d                     | j        j        | j        j        | j        j                  S )Nz7	ob{} = PyCom_PyObjectFromIUnknown({}, IID_{}, FALSE);
)r_   r"   r3   r   r8   s    r   rS   z1ArgFormatterInterface.GetBuildForInterfacePreCode{  s/    JQQHMHMHM
 
 	
r   c                    |                      |                                 d          }d                    | j        j        || j        j        | j        j                  S )Nr+   z8	ob{} = PyCom_PyObjectFromIUnknown({}{}, IID_{}, TRUE);
)r0   r2   r_   r"   r3   r   )r   sPrefixs     r   rY   z/ArgFormatterInterface.GetBuildForGatewayPreCode  sS    &&t'C'C'E'EqIIKRRHMHMHM	
 
 	
r   c                <    d| j         j         d| j         j         dS )Nz	if (z) z->Release();
r7   r8   s    r   rD   z,ArgFormatterInterface.GetInterfaceArgCleanup  s#    FFFFFFFr   N)r   r   r   r@   rQ   rS   rY   rD   rc   r   r   r  r  g  sd        
 
 
	
 	
 	

 
 

 
 
G G G G Gr   r  c                       e Zd Zd Zd Zd ZdS )ArgFormatterVARIANTc                j    d                     | j        j        |                     d d                    S )NzG	if ( !PyCom_VariantFromPyObject(ob{}, {}) )
		bPythonIsHappy = FALSE;
r+   r   r8   s    r   rQ   z$ArgFormatterVARIANT.GetParsePostCode  s3    ]ddHM444T1==
 
 	
r   c                T    |                      d d          }d| j        j         d| dS )Nr+   r   z = PyCom_PyObjectFromVariant(r   r   r   s     r   rY   z-ArgFormatterVARIANT.GetBuildForGatewayPreCode  r   r   c                     d| j         j        z  S r   r7   r8   s    r   r]   z.ArgFormatterVARIANT.GetBuildForGatewayPostCode  r   r   N)r   r   r   rQ   rY   r]   rc   r   r   r  r    sD        
 
 

T T T7 7 7 7 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                      e Zd ZdZd Zd ZdS )ArgFormatterSimplez-An arg formatter for simple integer etc typesc                <    t           | j        j                 d         S )Nr   ConvertSimpleTypesr"   r   r8   s    r   rl   z ArgFormatterSimple.GetFormatChar      !$(-033r   c                <    t           | j        j                 d         S rJ   r8  r8   s    r   r`   z%ArgFormatterSimple._GetPythonTypeDesc  r:  r   N)r   r   r   rg   rl   r`   rc   r   r   r6  r6    s8        774 4 44 4 4 4 4r   r6  zconst OLECHARr+   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STATSTGr	  r  VARIANTrs   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                   	 t           | j                 d         }t           | j                 d         }d}t          t           | j                           dk    rt           | j                 d         } || ||          S # t          $ rE | j        d         dk    rt	          | dd          cY S t          d| j         d| j         d          w xY w)Nr   r+   r   Iz
The type 'z' (z) is unknown.)rm  r   lenKeyErrorr  r   r3   )r"   clzbindecls       r   make_arg_converterru    s    UCH%a(CH%a(}SX&''!++ *1-Ds3T""" U U U8A;#(a33333!"Ssx"S"SCH"S"S"STTT	Us   A9A< <,C*!Cc                  `    e Zd ZdZ ej        d          Zed             Zd Z	d Z
d Zd ZdS )	ArgumentzA 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                f    d                     d |                    d          D                       S )Nr=   c              3  D   K   | ]}|                     d           |V  dS )__RPC_N)
startswith).0es     r   	<genexpr>z-Argument.drop_rpc_metadata.<locals>.<genexpr>+  s3      RRa1<<;Q;QRRRRRRRr   )joinsplit)clstype_s     r   drop_rpc_metadatazArgument.drop_rpc_metadata)  s/    xxRR5;;s#3#3RRRRRRr   c                    || _         d | _        d | _        d | _        d | _        d | _        d| _        d| _        d| _        d S r!   )	good_interface_namesinoutr3   r   raw_typerH   const	arrayDeclr>   r   r  s     r   r   zArgument.__init__-  sI    $8!
		
 !r   c                   |                                 }| j                            |          }|st          |                    d          | _        |                    d                              d          | _        |                    d                                          }|| _	        |                    d          r2d| _
        |                     |          }||k    r| xj        dz  c_        |                     |          }	 	 |                    d          }| xj        dz  c_        |d|                                         }n# t          $ r Y nw xY wT|| _        | j        dd         d	k    r| j        dd         | _        n| j        | _        t"          r>t%          d
                    | j        | j        d| j        z  | j                             dS dS )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   r+   z][r   rU   r,   N   zconst z       Arg {} of type {}{} ({}))readlineregexsearchr   groupr3   r  r  stripr  r  r  r>   rindex
ValueErrorr   rH   VERBOSErM   r_   )r   filelinemotyp
typ_no_rpcposs          r   BuildFromFilezArgument.BuildFromFile8  s    }}Zt$$ 	"!!HHQKK	XXa[[&&t,,
hhqkk!!88A;; 	+DN//44Jj  %%*%%$$S))	jjoo%%*%%$3$ioo''   	 	9RaR=H$$ IabbMDMM IDM 	188Ity#0E*Etz     	 	s   AE 
EEc                    || j         v S )a  Determines 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   HasAttributezArgument.HasAttributeb  s     dj  r   c                @    | j          d| j         }| j        r|dz  }|S )Nr=   z[])r  r3   r  r   s     r   GetRawDeclarationzArgument.GetRawDeclarationk  s1    ,,,,> 	4KC
r   N)r   r   r   rg   recompiler  classmethodr  r   r  r  r  rc   r   r   rw  rw    s          BJPQQES S [S	" 	" 	"( ( (T! ! !    r   rw  c                  >    e Zd ZdZ ej        d          Zd Zd ZdS )MethodzA 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                L    || _         d x| _        x| _        | _        g | _        d S r   )r  r3   resultcallconvargsr  s     r   r   zMethod.__init__}  s*    $8!266	6DK$-			r   c                B   |                                 }| j                            |          }|st          |                    d          | _        |                    d          | _        | j        dk    rR| j        dk    rt          d           nt          d| j        z             t          d| j         d| j         d	           	 t          | j	                  }	 |
                    |           | j                            |           n# t          $ r Y dS w xY wW)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.
        rU   r   r&  r$  zBWarning: Old style interface detected - compilation errors likely!z4Method %s - Only HRESULT return types are supported.z     Method r=   r   r+   N)r  r  r  r   r  r3   r  rM   rw  r  r  r  append)r   r  r  r  r"   s        r   r  zMethod.BuildFromFile  s>    }}Zt$$ 	"!!HHQKK	hhqkk;)##{g%%X    JTYV   ;;;ty;;;<<<	4455C!!$'''	  %%%%"   	s   /D 
DDN)	r   r   r   rg   r  r  r  r   r  rc   r   r   r  r  r  sP          BJEFFE  
    r   r  c                  >    e Zd ZdZ ej        d          Zd Zd ZdS )	InterfacezA 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                    g | _         |                    d          | _        |                    d          | _        t          r!t          d| j         d| j                    d S d S )Nr   r   z
Interface z
 : public )methodsr  r3   baser  rM   )r   r  s     r   r   zInterface.__init__  si    HHQKK	HHQKK	 	A?ty??DI??@@@@@	A 	Ar   c                   |                                  |                                  	 	 t          | j        g          }|                    |           | j                            |           n# t          $ r Y dS w xY wX)z(Build all sub-methods for this interfacer+   N)r  r  r3   r  r  r  r   )r   r  methods      r   BuildMethodszInterface.BuildMethods  s     		,,$$T***##F++++"   	s   AA0 0
A>=A>N)	r   r   r   rg   r  r  r  r   r  rc   r   r   r  r    sS          BJ=>>EA A A    r   r  c                v   d}|                                 }|rt          j                            |          }|r`|                    d          }t          |           t          ddft          |<   || k    r$t          |          }|                    |           |                                 }||r|S t          )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   r+   )
r  r  r  r  r  rM   r  rm  r  r   )interfaceNamer  	interfacer  r  r3   s         r   find_interfacer    s     I==??D
 	_##D)) 	-88A;;D$KKK#8!Q"?M$}$$%bMM	&&t,,,}}  	  
r   c                    	 t          | |          S # t          j        $ r& t          j                     t          d           Y dS w xY w)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)r  r  error	traceback	print_excrM   )r  r  s     r   parse_interface_infor    s`    UmT2228 U U USTTTTTTUs    1AAc                     t          d          } 	 t          d|            |                                  d S # |                                  w xY w)Nzd:\msdev\include\objidl.hIPersistStream)openr  close)rk   s    r   testr    sI    +,,A-q111										s	   7 Ac           
     &   |                      |d          }|dk    rt          d           d S t          d||                     d          |                     d          |                     d          |                     d          fz             d S )	Nr   r)   z** Not foundz%d
%s
%s
%s
%sr+   r   r   rU   )r  rM   r  )rtextress      r   
test_regexr    s    
((4

C
byyn CQWWQZZQWWUVZZ#XX	
 	
 	
 	
 	
r   )*rg   
__future__r   r  r  	Exceptionr   r   r  rC   r   ri   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r9  r6  dictfromkeysrm  __annotations__ru  rw  r  r  r  r  r  r  rc   r   r   <module>r     s
     # " " " " " 				        i   
    )   
 	y y y y y y y yz" " " " " " " "N" " " " " " " "L7 7 7 7 7< 7 7 7B7 7 7 7 7L 7 7 747 7 7 7 7, 7 7 7.7 7 7 7 7/ 7 7 7D7 7 7 7 7- 7 7 7<9 9 9 9 9+ 9 9 9&#N #N #N #N #N, #N #N #NL
 
 
 
 
/ 
 
 
&
 
 
 
 
/ 
 
 
.
 
 
 
 
. 
 
 
(
 
 
 
 
. 
 
 
"
 
 
 
 
 5 
 
 
.         !:      
%G %G %G %G %G1 %G %G %GP7 7 7 7 7/ 7 7 7 
 
    
	
 " & "   
   % ( , , &  +!" -#$ ,(&&+   24 4 4 4 4 4 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 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 D 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 Dh )!Q/%q!,%q!,'A.(!Q/+Q2(!,.2)1-)1-*A./30!4$6#:CD D DF mm&);Q(?@@GD  F F F FRU U U$R R R R R R R Rj. . . . . . . .b       @  2U U U  
 
 
 
 
r   