
    	hā                     |   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJrJrJrJrJr  SSKJr  SrSr\R*                  \R,                     r\R*                  \R0                     rSrSrS	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#\!r$S r%S r&S r'g)a  Policies

Note that Dispatchers are now implemented in "dispatcher.py", but
are still documented here.

Policies

 A policy is an object which manages the interaction between a public
 Python object, and COM .  In simple terms, the policy object is the
 object which is actually called by COM, and it invokes the requested
 method, fetches/sets the requested property, etc.  See the
 @win32com.server.policy.CreateInstance@ method for a description of
 how a policy is specified or created.

 Exactly how a policy determines which underlying object method/property
 is obtained is up to the policy.  A few policies are provided, but you
 can build your own.  See each policy class for a description of how it
 implements its policy.

 There is a policy that allows the object to specify exactly which
 methods and properties will be exposed.  There is also a policy that
 will dynamically expose all Python methods and properties - even those
 added after the object has been instantiated.

Dispatchers

 A Dispatcher is a level in front of a Policy.  A dispatcher is the
 thing which actually receives the COM calls, and passes them to the
 policy object (which in turn somehow does something with the wrapped
 object).

 It is important to note that a policy does not need to have a dispatcher.
 A dispatcher has the same interface as a policy, and simply steps in its
 place, delegating to the real policy.  The primary use for a Dispatcher
 is to support debugging when necessary, but without imposing overheads
 when not (ie, by not using a dispatcher at all).

 There are a few dispatchers provided - "tracing" dispatchers which simply
 prints calls and args (including a variation which uses
 win32api.OutputDebugString), and a "debugger" dispatcher, which can
 invoke the debugger when necessary.

Error Handling

 It is important to realise that the caller of these interfaces may
 not be Python.  Therefore, general Python exceptions and tracebacks aren't
 much use.

 In general, there is an COMException class that should be raised, to allow
 the framework to extract rich COM type error information.

 The general rule is that the **only** exception returned from Python COM
 Server code should be an COMException instance.  Any other Python exception
 should be considered an implementation bug in the server (if not, it
 should be handled, and an appropriate COMException instance raised).  Any
 other exception is considered "unexpected", and a dispatcher may take
 special action (see Dispatchers above)

 Occasionally, the implementation will raise the policy.error error.
 This usually means there is a problem in the implementation that the
 Python programmer should fix.

 For example, if policy is asked to wrap an object which it can not
 support (because, eg, it does not provide _public_methods_ or _dynamic_)
 then policy.error will be raised, indicating it is a Python programmers
 problem, rather than a COM error.
    N)	DISPATCH_METHODDISPATCH_PROPERTYGETDISPATCH_PROPERTYPUTDISPATCH_PROPERTYPUTREFDISPID_EVALUATEDISPID_NEWENUMDISPID_PROPERTYPUTDISPID_STARTENUMDISPID_VALUE   )COMExceptionzGreg Stein and Mark HammondzCLSID\%s\PythonCOMzCLSID\%s\PythonCOMPolicyzCLSID\%s\PythonCOMDispatcherzCLSID\%s\PythonCOMPathc                     [         R                  " [        R                  [        U -  5      R                  S5      nU H9  nU[        R                  ;  d  M  [        R                  R                  SU5        M;      [         R                  " [        R                  [        U -  5      n[        U5      n [         R                  " [        R                  [        U -  5      nU(       a  [        U5      nU(       a
  U" US5      nOU" S5      nUR                  X5      $ ! [         R                   a     Nf = f! [         R                   a	    [        n Nf = f! [         R                   a    Sn N|f = f)a  Create a new instance of the specified IID

The COM framework **always** calls this function to create a new
instance for the specified CLSID.  This function looks up the
registry for the name of a policy, creates the policy, and asks the
policy to create the specified object by calling the _CreateInstance_ method.

Exactly how the policy creates the instance is up to the policy.  See the
specific policy documentation for more details.
;r   N)win32apiRegQueryValuewin32conHKEY_CLASSES_ROOTregAddnPathsplitsyspathinserterror	regPolicyresolve_funcDefaultPolicyregDispatcher_CreateInstance_)clsidreqIID	addnPathsnewPathpolicy
dispatcherretObjs          iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\win32com/server/policy.pyCreateInstancer'   l   s3   **&&e(;

%* 	 !Gchh&7+ !
''(B(BIPUDUVf%++&&(=

 %j1J FD)""511+ >> 
 >>  >> 
s<   AD $D =7D7 5>E D43D47EEE0/E0c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)BasicWrapPolicy   a  The base class of policies.

Normally not used directly (use a child class, instead)

This policy assumes we are wrapping another object
as the COM server.  This supports the delegation of the core COM entry points
to either the wrapped object, or to a child class.

This policy supports the following special attributes on the wrapped object

_query_interface_ -- A handler which can respond to the COM 'QueryInterface' call.
_com_interfaces_ -- An optional list of IIDs which the interface will assume are
    valid for the object.
_invoke_ -- A handler which can respond to the COM 'Invoke' call.  If this attribute
    is not provided, then the default policy implementation is used.  If this attribute
    does exist, it is responsible for providing all required functionality - ie, the
    policy _invoke_ method is not invoked at all (and nor are you able to call it!)
_getidsofnames_ -- A handler which can respond to the COM 'GetIDsOfNames' call.  If this attribute
    is not provided, then the default policy implementation is used.  If this attribute
    does exist, it is responsible for providing all required functionality - ie, the
    policy _getidsofnames_ method is not invoked at all (and nor are you able to call it!)

IDispatchEx functionality:

_invokeex_ -- Very similar to _invoke_, except slightly different arguments are used.
    And the result is just the _real_ result (rather than the (hresult, argErr, realResult)
    tuple that _invoke_ uses.
    This is the new, prefered handler (the default _invoke_ handler simply called _invokeex_)
_getdispid_ -- Very similar to _getidsofnames_, except slightly different arguments are used,
    and only 1 property at a time can be fetched (which is all we support in getidsofnames anyway!)
    This is the new, prefered handler (the default _invoke_ handler simply called _invokeex_)
_getnextdispid_- uses self._name_to_dispid_ to enumerate the DISPIDs
c                 .    Ub  U R                  U5        gg)zInitialise the policy object

Params:

object -- The object to wrap.  May be None *iff* @BasicWrapPolicy._CreateInstance_@ will be
called immediately after this to setup a brand new object
N)_wrap_selfobjects     r&   __init__BasicWrapPolicy.__init__   s     KK     c           	          [         R                  " [        R                  [        U-  5      n[        U5      nU R                  U5         [        R                  " X5      $ ! [         R
                   a    [        S[        U-   S35      ef = f! [        R                   aF  nUR                  u  pgpSSKJn
  SU< SU
" U5       SU SU 3n[        R                  " XgX5      eS	nAff = f)
zCreates a new instance of a **wrapped** object

This method looks up a "@win32com.server.policy.regSpec@" % clsid entry
in the registry (using @DefaultPolicy@)
z)The object is not correctly registered - z key can not be readr   )IIDToInterfaceNamezThe object 'z3' was created, but does not support the interface 'z'(z): N)r   r   r   r   regSpecr   
ValueError	call_funcr,   	pythoncom
WrapObject	com_errorargswin32com.utilr4   )r.   r   r    	classSpecmyobxxx_todo_changemehrdescexcargr4   s              r&   r    BasicWrapPolicy._CreateInstance_   s    	 ..**GeOI #D
	:''55 ~~ 	;GeO;LL`a 	 "" 	:#4#9#9 Rs8 th '089F83tfN  %%b99	:s$   ,A! B !+BC)#AC$$C)c                    0 U l         U=o l        [        US5      (       a  UR                  U l        [        US5      (       a  UR                  U l        [        US5      (       a  UR
                  U l        [        US5      (       a  UR                  U l        [        US5      (       a  UR                  U l        [        US5      (       a  / U l        UR                   Hp  n[        U[        R                  5      (       d3  US   S:w  a  [        R                  U   nO[        R                  " U5      nU R                  R                  U5        Mr     g	/ U l        g	)
zWraps up the specified object.

This function keeps a reference to the passed
object, and may interogate it to determine how to respond to COM requests, etc.
_query_interface__invoke_
_invokeex__getidsofnames__getdispid__com_interfaces_r   {N)_name_to_dispid__obj_hasattrrF   rG   rH   rI   rJ   rK   
isinstance
pywintypesIIDTyper8   InterfaceNamesIIDappend)r.   r/   obis       r&   r,   BasicWrapPolicy._wrap_   s    !#  Z2*++%'%9%9D"2z""KKDM2|$$ mmDO2())#%#5#5D 2}%%!~~D 2)**$&D!((!!Z%7%788ts{%44Q7&NN1-%%,,Q/ ) %'D!r2   c                 D    XR                   ;   a  gU R                  U5      $ )zThe main COM entry-point for QueryInterface.

This checks the _com_interfaces_ attribute and if the interface is not specified
there, it calls the derived helper _query_interface_
r   )rK   rF   r.   iids     r&   _QueryInterface_ BasicWrapPolicy._QueryInterface_
  s$     '''%%c**r2   c                     g)zCalled if the object does not provide the requested interface in _com_interfaces_,
and does not provide a _query_interface_ handler.

Returns a result to the COM framework indicating the interface is not supported.
r    rZ   s     r&   rF   !BasicWrapPolicy._query_interface_  s     r2   c                     [        U[        5      (       a   U R                  UR                  5          nU R                  XX45      $ ! [         a    [        [        R                  SS9ef = f)zFThe main COM entry-point for Invoke.

This calls the _invoke_ helper.
Member not foundscoderA   )	rP   strrM   lowerKeyErrorr   winerrorDISP_E_MEMBERNOTFOUNDrG   r.   dispidlcidwFlagsr;   s        r&   _Invoke_BasicWrapPolicy._Invoke_  si     fc""..v||~>
 }}V688	  ""88?Q s   A #A)c           
      8    [         SU R                  XX4S S 5      4$ NS_OKrH   rj   s        r&   rG   BasicWrapPolicy._invoke_,  s      RvT4PPPr2   c                 r    [        U5      S:  a  [        [        R                  SS9eU R	                  X5      $ )z~The main COM entry-point for GetIDsOfNames.

This checks the validity of the arguments, and calls the _getidsofnames_ helper.
r   z$Cannot support member argument namesrc   )lenr   rh   DISP_E_INVALIDrI   r.   namesrl   s      r&   _GetIDsOfNames_BasicWrapPolicy._GetIDsOfNames_2  s;    
 u:>--;  ##E00r2   c                 .    U R                  US   S5      4$ Nr   rJ   ry   s      r&   rI   BasicWrapPolicy._getidsofnames_>  s      q1-//r2   c                 $    U R                  X5      $ Nr   r.   namefdexs      r&   _GetDispID_BasicWrapPolicy._GetDispID_F  s    ++r2   c                      U R                   UR                  5          $ ! [         a    [        [        R
                  S9ef = fNrd   )rM   rf   rg   r   rh   DISP_E_UNKNOWNNAMEr   s      r&   rJ   BasicWrapPolicy._getdispid_I  sA    	B((66 	BX%@%@AA	Bs	    "Ac                     [        U[        5      (       a   U R                  UR                  5          nU R                  XX4XV5      $ ! [         a    [        [        R                  SS9ef = f)zJThe main COM entry-point for InvokeEx.

This calls the _invokeex_ helper.
rb   rc   )	rP   re   rM   rf   rg   r   rh   ri   rH   r.   rk   rl   rm   r;   kwargsserviceProviders          r&   
_InvokeEx_BasicWrapPolicy._InvokeEx_Q  sk     fc""..v||~>
 vV6SS	  ""88?Q s   A #A*c                     [        S5      e)zMA stub for _invokeex_ - should never be called.

Simply raises an exception.
z0This class does not provide _invokeex_ semantics)NotImplementedErrorr   s          r&   rH   BasicWrapPolicy._invokeex_`  s     ""TUUr2   c                 $    U R                  X5      $ r   )_deletememberbyname_r   s      r&   _DeleteMemberByName_$BasicWrapPolicy._DeleteMemberByName_h  s    ((44r2   c                 0    [        [        R                  S9er   r   rh   	E_NOTIMPLr   s      r&   r   $BasicWrapPolicy._deletememberbyname_k      !3!344r2   c                 $    U R                  U5      $ r   )_deletememberbydispidr.   ids     r&   _DeleteMemberByDispID_&BasicWrapPolicy._DeleteMemberByDispID_n  s    ))"--r2   c                 0    [        [        R                  S9er   r   r   s     r&   _deletememberbydispid_&BasicWrapPolicy._deletememberbydispid_q  r   r2   c                 $    U R                  X5      $ r   )_getmemberproperties_r.   r   r   s      r&   _GetMemberProperties_%BasicWrapPolicy._GetMemberProperties_t  s    ))"33r2   c                 0    [        [        R                  S9er   r   r   s      r&   r   %BasicWrapPolicy._getmemberproperties_w  r   r2   c                 $    U R                  U5      $ r   )_getmembername_r.   rk   s     r&   _GetMemberName_BasicWrapPolicy._GetMemberName_z  s    ##F++r2   c                 0    [        [        R                  S9er   r   r   s     r&   r   BasicWrapPolicy._getmembername_}  r   r2   c                 $    U R                  X5      $ r   )_getnextdispid_)r.   r   rk   s      r&   _GetNextDispID_BasicWrapPolicy._GetNextDispID_  s    ##D11r2   c                 l   U R                   R                  5        Vs/ s H  o3[        :w  d  M  UPM     nnUR                  5         U[        :X  a  US   $  XDR	                  U5      S-      $ s  snf ! [
         a    [        [        R                  S9e[         a    [        [        R                  S9ef = f)Nr   r   r   )rM   valuesr
   sortindexr6   r   rh   E_UNEXPECTED
IndexErrorS_FALSE)r.   r   rk   r   idss        r&   r   BasicWrapPolicy._getnextdispid_  s     1188:U:bDT>Tr:U
%%q6M;99V,q011 V  @")>)>?? ;")9)9::;s   A,A,A1 1AB3c                 "    U R                  5       $ r   )_getnamespaceparentr.   s    r&   _GetNameSpaceParent_$BasicWrapPolicy._GetNameSpaceParent_  s    ''))r2   c                 0    [        [        R                  S9er   r   r   s    r&   _getnamespaceparent_$BasicWrapPolicy._getnamespaceparent_  r   r2   )rK   rJ   rI   rG   rH   rM   rN   rF   N)__name__
__module____qualname____firstlineno____doc__r0   r   r,   r\   rF   rn   rG   r{   rI   r   rJ   r   rH   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__r_   r2   r&   r)   r)      s     D	 :8&'R+9Q
10,BTV55.545,52;*5r2   r)   c                   $    \ rS rSrSrS rS rSrg)MappedWrapPolicyi  a  Wraps an object using maps to do its magic

This policy wraps up a Python object, using a number of maps
which translate from a Dispatch ID and flags, into an object to call/getattr, etc.

It is the responsibility of derived classes to determine exactly how the
maps are filled (ie, the derived classes determine the map filling policy.

This policy supports the following special attributes on the wrapped object

_dispid_to_func_/_dispid_to_get_/_dispid_to_put_ -- These are dictionaries
  (keyed by integer dispid, values are string attribute names) which the COM
  implementation uses when it is processing COM requests.  Note that the implementation
  uses this dictionary for its own purposes - not a copy - which means the contents of
  these dictionaries will change as the object is used.

c                 B   [         R                  X5        U R                  n[        US5      (       a  UR                  U l        O0 U l        [        US5      (       a  UR
                  U l        O0 U l        [        US5      (       a  UR                  U l        g 0 U l        g )N_dispid_to_func__dispid_to_get__dispid_to_put_)r)   r,   rN   rO   r   r   r   )r.   r/   rV   s      r&   r,   MappedWrapPolicy._wrap_  s    t,ZZ2)**$&$7$7D!$&D!2())#%#5#5D #%D 2())#%#5#5D #%D r2   c                     XR                   ;   a  U R                   U   $ XR                  ;   a  U R                  U   $ XR                  ;   a  U R                  U   $ [        [        R
                  S9er   )r   r   r   r   rh   ri   r   s     r&   r    MappedWrapPolicy._getmembername_  sj    ***((00+++''//+++''//X%C%CDDr2   r   r   r   N)r   r   r   r   r   r,   r   r   r_   r2   r&   r   r     s    $& Er2   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)DesignatedWrapPolicyi  a  A policy which uses a mapping to link functions and dispid

 A MappedWrappedPolicy which allows the wrapped object to specify, via certain
 special named attributes, exactly which methods and properties are exposed.

 All a wrapped object need do is provide the special attributes, and the policy
 will handle everything else.

 Attributes:

 _public_methods_ -- Required, unless a typelib GUID is given -- A list
              of strings, which must be the names of methods the object
              provides.  These methods will be exposed and callable
              from other COM hosts.
 _public_attrs_ A list of strings, which must be the names of attributes on the object.
              These attributes will be exposed and readable and possibly writeable from other COM hosts.
 _readonly_attrs_ -- A list of strings, which must also appear in _public_attrs.  These
              attributes will be readable, but not writable, by other COM hosts.
 _value_ -- A method that will be called if the COM host requests the "default" method
              (ie, calls Invoke with dispid==DISPID_VALUE)
 _NewEnum -- A method that will be called if the COM host requests an enumerator on the
              object (ie, calls Invoke with dispid==DISPID_NEWENUM.)
              It is the responsibility of the method to ensure the returned
              object conforms to the required Enum interface.

_typelib_guid_ -- The GUID of the typelibrary with interface definitions we use.
_typelib_version_ -- A tuple of (major, minor) with a default of 1,1
_typelib_lcid_ -- The LCID of the typelib, default = LOCALE_USER_DEFAULT

 _Evaluate -- Dunno what this means, except the host has called Invoke with dispid==DISPID_EVALUATE!
              See the COM documentation for details.
c                 R   [        USS 5      nUb  [        USS5      u  p4[        USS5      nSSKJn  [        US/ 5       Vs/ s H>  n[        U[        R
                  5      (       a  M$  UR                  S5      (       a  M<  UPM@     nnUR                  X%X4U5      n	O/ n	[        R                  X5        [        US	5      (       d  [        US5      (       d  [        S
5      eU R                  R                  5        H!  u  pXR                  UR                  5       '   M#     U R                   R                  5        H!  u  pXR                  UR                  5       '   M#     U R"                  R                  5        H!  u  pXR                  UR                  5       '   M#     U	 H  u  pnXR                  UR                  5       '   U[$        :X  a  XR                  U
'   M<  U[&        [(        4;   a  XR"                  U
'   M\  U[*        :X  a  XR                   U
'   Mv  [        SX4-  5      e   [        US5      (       a&  SU R                   [,        '   SU R"                  [.        '   [        US5      (       a&  [0        U R                  S'   SU R                  [0        '   [        US5      (       a&  [2        U R                  S'   SU R                  [2        '   U R5                  S5      n[        US5      (       a  [        US5      (       a  UR6                  nO/ nUR8                   H  nU R                  R;                  UR                  5       5      n
U
c/  Un
XR                  UR                  5       '   U R5                  U5      nXR                   U
'   X;  d  Ms  XR"                  U
'   M     [        US	/ 5       Hl  nU R                  R;                  UR                  5       5      n
U
c/  Un
XR                  UR                  5       '   U R5                  U5      nXR                  U
'   Mn     S U l        g s  snf )N_typelib_guid__typelib_version_r   r   _typelib_lcid_r   )	universalrK   rL   _public_methods_zwObject does not support DesignatedWrapPolicy, as it does not have either _public_methods_ or _typelib_guid_ attributes.zunexpected invkind: %d (%s)_value__NewEnum_newenum	_Evaluate	_evaluatei  _public_attrs__readonly_attrs_)getattrwin32comr   rP   rQ   rR   
startswithRegisterInterfacesr   r,   rO   r6   r   itemsrM   rf   r   r   r   r   r   r   r   r	   r   r   _allocnextdispidr   r   get_typeinfos_)r.   rV   tlb_guid	tlb_major	tlb_minortlb_lcidr   rW   
interfacesuniversal_datark   r   invkindnext_dispidreadonlys                  r&   r,   DesignatedWrapPolicy._wrap_  s   2/6#*2/BF#K Ir#3Q7H* !%7<<A!!Z%7%78 ABcAR <  
 '99I*N  N)r-..wrCS7T7T^  !11779LF28!!$**,/ : 00668LF28!!$**,/ 9 00668LF28!!$**,/ 9 &4!FT28!!$**,//)04%%f-13JKK/3$$V,00/3$$V, !>'!PQQ &4 2y!!1:D  .7@D  !342z""0>D!!*-4>D!!.12{##1@D!!+.5@D!!/2++C02'((r-....))..224::<@>(F:@))$**,7"&"7"7"DK/3$$V,'37((0 * B 2B7D**..tzz|<F~$6<%%djjl3"33K@,0!!&) 8  Os   #P$)P$P$c                 f   [        U R                  SS 5      nUc  / $ [        U R                  SS5      u  p#[        R                  " XU5      nUR	                  5       nU R                  R
                   H  n UR                  U5      u  pxUb  U/s  $ M!     / $ ! [        R                   a     M<  f = f)Nr   r   r   )r   rN   r8   LoadRegTypeLibGetTypeComprK   BindTyper:   )	r.   r   r   r   tlbtypecompiname	type_info	type_comps	            r&   _build_typeinfos_&DesignatedWrapPolicy._build_typeinfos_;  s    4::'7>I&tzz3FO	&&xIF??$ ZZ00E'/'8'8'?$	(%;& ) 1 	 && s   7BB0/B0c                 p    U R                   c  U R                  5       U l         [        U R                   5      $ r   )r   r  rw   r   s    r&   _GetTypeInfoCount_'DesignatedWrapPolicy._GetTypeInfoCount_N  s0    ##557D4##$$r2   c                     U R                   c  U R                  5       U l         US:  d  U[        U R                   5      :  a  [        [        R
                  S9eSU R                   U   4$ )Nr   r   )r   r  rw   r   rh   DISP_E_BADINDEX)r.   r   rl   s      r&   _GetTypeInfo_"DesignatedWrapPolicy._GetTypeInfo_S  s_    ##557D19T%5%5!66X%=%=>>$""5)))r2   c                 p     US-  nXR                   ;  a   XR                  ;  a  XR                  ;  a  U$ M6  Nr   r   )r.   last_dispids     r&   r   %DesignatedWrapPolicy._allocnextdispidZ  s>    1K#8#88';';;';';;"" r2   c           
         U[         -  (       a-   U R                  U   n [        U R                  U5      n U" U6 $ U[        -  (       aL   U R                  U   n
[        U R                  U
5      n[        U[         R"                  5      (       a  U" U6 nU$ U[$        [&        -  -  (       a   U R(                  U   n
[        U R                  SU
-   S 5      n[        U[         R"                  5      (       a:  [        [        U R                  U
S 5      [         R"                  5      (       a  U" U6   g [+        U R                  XS   5        g [        [        R,                  S	S
9e! [         a    [        [        R                  S9ef = f! [         a;  n	[        U	5      R                  S5      S:  a  [        SU	 SU< SU< S35        e S n	A	ff = f! [         a)    U[        -  (       d  [        [        R                  S9e GNf = f! [         a    [        [        R                  S9ef = f! [         a    [        [        R                  S9ef = f)Nr   	argumentsr   z** TypeError z calling function ()Setzinvalid wFlagsrc   )r   r   r   rN   AttributeErrorr   rh   ri   	TypeErrorre   findprintrg   r   r   rP   types
MethodTyper   r   r   setattrE_INVALIDARG)r.   rk   rl   rm   r;   kwArgsr   funcnamefuncvr   retobfns                r&   rH   DesignatedWrapPolicy._invokeex_d  s0    O#008M"4::x8D
;& ((I++F3 DJJ-E%!1!122tL),CCDI++F3
 UT\48B"e..//J

D$/1A1A5 5 D	  

Dq'2!6!6=MNNQ & M&X-K-KLLM !  1v{{;/14aS0B4(!D8STUV   44&&<<  50  I")G)GHHI  I")G)GHHIsK   G E  F H ,H(  "F
G
6GG
/H ?H "H%("I
)r   N)r   r   r   r   r   r,   r  r	  r  r   rH   r   r_   r2   r&   r   r     s)    BR h&%
*#6Or2   r   c                   $    \ rS rSrSrS rS rSrg)EventHandlerPolicyi  a  The default policy used by event handlers in the win32com.client package.

In addition to the base policy, this provides argument conversion semantics for
params: dispatch params are converted to dispatch objects

NOTE: Later, we may allow the object to override this process??
c                    / nU H  n[        U[        5      (       a   SS Kn	U	R                  R	                  U5      nOR[        U[
        5      (       a=   SS Kn	U	R                  R	                  UR                  [        R                  5      5      nUR                  U5        M     [        U5      U4$ ! [        R                   a     N8f = fr~   )rP   IDispatchTypewin32com.clientclientDispatchIUnknownTypeQueryInterfacer8   IID_IDispatchr   rU   tuple)
r.   r;   r   rk   rl   rm   r   retrC   r   s
             r&   _transform_args_#EventHandlerPolicy._transform_args_  s    C#}--&oo..s3C..*"//22**9+B+BCC
 JJsO  Sz6!! ! s   <B11CCc           	      \    U R                  XEXX65      u  pE[        R                  XX#XEU5      $ r   )r3  r   rH   )r.   rk   rl   rm   r;   r   r   s          r&   rH   EventHandlerPolicy._invokeex_  s9    ,,&
 $..$o
 	
r2   r_   N)r   r   r   r   r   r3  rH   r   r_   r2   r&   r(  r(    s    "&
r2   r(  c                   0    \ rS rSrSrS rS rS rS rSr	g)	DynamicPolicyi  a  A policy which dynamically (ie, at run-time) determines public interfaces.

A dynamic policy is used to dynamically dispatch methods and properties to the
wrapped object.  The list of objects and properties does not need to be known in
advance, and methods or properties added to the wrapped object after construction
are also handled.

The wrapped object must provide the following attributes:

_dynamic_ -- A method that will be called whenever an invoke on the object
       is called.  The method is called with the name of the underlying method/property
       (ie, the mapping of dispid to/from name has been resolved.)  This name property
       may also be '_value_' to indicate the default, and '_NewEnum' to indicate a new
       enumerator is requested.

c                     [         R                  X5        [        U R                  S5      (       d  [	        S5      eS=U l        U l        [        S[        S0U l	        g )N	_dynamic_z*Object does not support Dynamic COM Policyi  r   r   )
r)   r,   rO   rN   r6   _next_dynamic__min_dynamic_r   r   _dyn_dispid_to_name_r-   s     r&   r,   DynamicPolicy._wrap_  sQ    t,tzz;//IJJ377d0)J%
!r2   c                     UR                  5       n U R                  U   $ ! [         a6    U R                  S-   =o@l        X@R                  U'   XR                  U'   Us $ f = fr  )rf   rM   rg   r;  r=  )r.   r   r   lnamerk   s        r&   rJ   DynamicPolicy._getdispid_  si    

	((// 	+/+>+>+BBF(+1!!%(04%%f-M		s   ! =A! A!c           
      8    [         SU R                  XX4S S 5      4$ rq   rs   rj   s        r&   rG   DynamicPolicy._invoke_  s    RvT4PPPr2   c                      U R                   U   nU R
                  R                  XrX45      $ ! [         a    [        [        R                  SS9ef = f)Nrb   rc   )r=  rg   r   rh   ri   rN   r:  )r.   rk   rl   rm   r;   r   r   r   s           r&   rH   DynamicPolicy._invokeex_  sZ    
	,,V4D
 zz##D==	  	44;M 	s	   - #A)r=  r<  r;  N)
r   r   r   r   r   r,   rJ   rG   rH   r   r_   r2   r&   r8  r8    s    "
	Q>r2   r8  c                      U R                  S5      nU SU nXS-   S n[        U5      n[        XC5      $ ! [         a    [	        5       U    s $ f = f)zResolve a function by name

Given a function specified by 'module.function', return a callable object
(ie, the function itself)
.Nr   )rindex_import_moduler   r6   globals)specidxmnamefnamemodules        r&   r   r     s_    
kk#Tc
1WY  &v%% ys   25 AAc                     [        U 5      " U6 $ )zjCall a function specified by name.

Call a function specified by 'module.function' and return the result.
)r   )rK  r;   s     r&   r7   r7     s     t$$r2   c                 >    [        U 5        [        R                  U    $ )zImport a module just like the 'import' statement.

Having this function is much nicer for importing arbitrary modules than
using the 'exec' keyword.  It is more efficient and obvious to the reader.
)
__import__r   modules)rM  s    r&   rI  rI    s     u ;;ur2   )(r   r   r  r8   rQ   r   r   rh   r   r   r   r   r   r   r	   r
   r   	exceptionr   
__author__rt   TypeIIDsr0  r*  IID_IUnknownr.  r5   r   r   r   r'   r)   r   r   r(  r8  r   r   r7   rI  r_   r2   r&   <module>rX     s   BH       
 
 
 $*
 ""9#:#:;!!)"8"89 !(	0((2V}5 }5@+E +E\UO+ UOp#
- #
L5>O 5>p %&%	r2   