a „oe˜!ã@sddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZddlmZddlmZmZddlmZddlmZddlmZdd lmZzejd dZWneyÌdZYn0d d „ZGd d„dƒZGdd„deƒZ Gdd„de j!ƒZ!Gdd„dƒZ"dS)éN)ÚadbÚaxdebugÚcontextsÚ documentsÚgatewaysÚ stackframe)ÚSourceCodeContainer)Ú_wrapÚ _wrap_remove)Ú Enumerator)Ú COMException)ÚIIDToInterfaceNameé©ÚtraceZ DEBUG_AXDEBUGcGs8tsdStt ¡dd�|D]}t|dd�qtƒdS)z8A function used instead of "print" for debugging output.Nú )Úend)ÚdebuggingTraceÚprintÚwin32apiZGetCurrentThreadId)ÚargsÚarg©rúBC:\Program Files\Certbot\pkgs\win32comext\axscript\client\debug.pyrs rc@s\eZdZejgZdd„Zdd„Zdd„Zdd„Z d d „Z d d „Z d d„Z dd„Z dd„ZdS)Ú DebugManagercCs0||_t ¡|_d|_d|_t ¡|_z| t j ¡|_ Wn"t j yZtdƒd|_ Yn0d|_|j dur¤z|j  ¡|_|j  ¡|_Wnt j y¢d|_Yn0|jdurÚt  t jdt jt j¡}| ¡|_|j ¡|_|jdusìJdƒ‚d|_|jdu�r|j |j|j¡i|_tt||jƒt jƒ|_dS)Nz(Scripting site has no debugger interfacez.Need to have a DebugApplication object by now!)Ú scriptEnginerZDebuggerÚrootNodeÚdebugApplicationrZCodeContainerProviderÚ ccProviderZ GetScriptSiterZIID_IActiveScriptSiteDebugÚscriptSiteDebugÚ pythoncomZ com_errorrZGetApplicationZGetRootApplicationNodeZCoCreateInstanceZCLSID_ProcessDebugManagerZ CLSCTX_ALLZIID_IProcessDebugManagerZGetDefaultApplicationZ GetRootNodeÚactiveScriptDebugZ AttachAppÚcodeContainersr ÚActiveScriptDebugÚIID_IActiveScriptDebug)ÚselfrZpdmrrrÚ__init__(sN  ÿ      ü  ÿþ ÿzDebugManager.__init__cCsl|jdurt|jƒd|_d|_d|_d|_d|_|jdurL|j ¡d|_i|_|j rh|j   ¡d|_ dS©N) r!r rrrrrÚCloser"rZCloseApp©r%rrrr(Zs     zDebugManager.ClosecCs |jduS)z0Do we have _any_ debugging interfaces installed?N)rr)rrrÚ IsAnyHostmszDebugManager.IsAnyHostcCs |jduSr')rr)rrrÚ IsSimpleHostqszDebugManager.IsSimpleHostcCstdƒd}|S)zçCalled by the engine when a runtime error occurs. If we have a debugger, we let it know. The result is a boolean which indicates if the error handler should call IActiveScriptSite::OnScriptError() ÚHandleRuntimeErrorrr)r%Z fCallOnErrorrrrr,ts zDebugManager.HandleRuntimeErrorcCs||jvr|jStd|ƒdS)NzDebugManager QI - unknown IIDr)Ú_debugger_interfaces_r!r©r%ZiidrrrÚ_query_interface_for_debugger_„s  z+DebugManager._query_interface_for_debugger_cCsBtdƒz ddWnt ¡djj}Yn0|j |¡dS)NÚ OnEnterScriptrré)rÚsysÚexc_infoÚtb_frameÚf_backrZSetupAXDebugging)r%Z baseFramerrrr0Šs  zDebugManager.OnEnterScriptcCstdƒ|j ¡dS)NÚ OnLeaveScript)rrZResetAXDebuggingr)rrrr6“szDebugManager.OnLeaveScriptcCsŠt||jƒ}| ¡rht |¡}t|tjƒ}t |¡}t|tj ƒ}||_ |j   ¡}|  |¡| |j¡nd}||j|j<|j ||¡dSr')ÚDebugCodeBlockContainerrr+rZDebugDocumentTextr rZIID_IDebugDocumentZDebugDocumentProviderZIID_IDebugDocumentProviderZ debugDocumentrZCreateApplicationNodeZSetDocumentProviderZAttachrr"Z sourceContextrZAddCodeContainer)r%Ú codeBlockZccZdocumentZproviderZnewNoderrrÚAddScriptBlock—s        zDebugManager.AddScriptBlockN)Ú__name__Ú __module__Ú __qualname__rr$r-r&r(r*r+r,r/r0r6r9rrrrr%s2 rc@seZdZdd„Zdd„ZdS)r7cCs(||_t ||j| ¡|j|j|¡dSr')r8rr&ZcodeTextZ GetFileNameZsourceContextCookieZstartLineNumber)r%r8Zsiterrrr&ªsúz DebugCodeBlockContainer.__init__cCs8|tjkr|j ¡S|tjkr(|j ¡Sttjd�‚dS)N©Zscode)rZDOCUMENTNAMETYPE_APPNODEr8ZGetDisplayNameZDOCUMENTNAMETYPE_TITLEr ÚwinerrorZS_FALSE)r%ZdntrrrÚGetNameµs     zDebugCodeBlockContainer.GetNameN)r:r;r<r&r?rrrrr7©s r7c@seZdZdd„ZdS)ÚEnumDebugCodeContextscCs|Sr'r)r%Úobrrrr ÁszEnumDebugCodeContexts._wrapN)r:r;r<r rrrrr@Àsr@c@sPeZdZdZgd¢ZejgZdd„Zdd„Z dd„Z d d „Z d d „Z d d„Z dS)r#z‚The class which implements the IActiveScriptDebug interface for the Active Script engine. Only ever used by smart hosts. )ÚGetScriptTextAttributesÚGetScriptletTextAttributesÚEnumCodeContextsOfPositioncCs||_|j|_||_dSr'©ÚdebugMgrrr")r%rFr"rrrr&ÒszActiveScriptDebug.__init__cCsd|_d|_i|_dSr'rEr)rrrÚ_Close×szActiveScriptDebug._ClosecCstd|ƒt|jj|ƒS)NzDebuggerQI with)rr rFrr.rrrÚ_query_interface_Üs z#ActiveScriptDebug._query_interface_cCst|dƒ}| ¡S)Nú)rÚGetSyntaxColorAttributes©r%ÚcodeÚdelimÚflagsÚ containerrrrrBàs z)ActiveScriptDebug.GetScriptTextAttributescCs td|||ƒt|dƒ}| ¡S)NrCrI)rrrJrKrrrrCäs z,ActiveScriptDebug.GetScriptletTextAttributescCsXtd|||ƒz|j| |¡}Wnty@ttjd�‚Yn0t|gƒ}t|t j ƒS)NrDr=) rr"ZGetCodeContextAtPositionÚKeyErrorr r>Z E_UNEXPECTEDr@r rZIID_IEnumDebugCodeContexts)r%ÚcontextZ charOffsetZnumCharsÚenumrrrrDés  z,ActiveScriptDebug.EnumCodeContextsOfPositionN)r:r;r<Ú__doc__Z_public_methods_rr$Z_com_interfaces_r&rGrHrBrCrDrrrrr#Åsr#)#Úosr2r rZwin32com.client.connectZwin32comZwin32com.server.utilr>Zwin32com.axdebugrrrrrrZwin32com.axdebug.codecontainerrZwin32com.axdebug.utilr r Zwin32com.client.utilr Zwin32com.server.exceptionr Z win32com.utilr Z frameworkrÚenvironrrPrr7r@r#rrrrÚs0