a oe!@sddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZddlmZddlmZmZddlmZddlmZddlmZdd lmZzejd dZWneydZYn0d d ZGd ddZGdddeZ Gddde j!Z!GdddZ"dS)N)adbaxdebugcontexts documentsgateways stackframe)SourceCodeContainer)_wrap _wrap_remove) Enumerator) COMException)IIDToInterfaceNametraceZ DEBUG_AXDEBUGcGs8tsdSttdd|D]}t|ddqtdS)z8A function used instead of "print" for debugging output.N )end)debuggingTraceprintwin32apiZGetCurrentThreadId)argsargrBC:\Program Files\Certbot\pkgs\win32comext\axscript\client\debug.pyrs rc@s\eZdZejgZddZddZddZddZ d d Z d d Z d dZ ddZ ddZdS) DebugManagercCs0||_t|_d|_d|_t|_z|t j |_ Wn"t j yZtdd|_ Yn0d|_|j durz|j |_|j |_Wnt j yd|_Yn0|jdurt t jdt jt j}||_|j|_|jdusJdd|_|jdur|j|j|ji|_tt||jt j|_dS)Nz(Scripting site has no debugger interfacez.Need to have a DebugApplication object by now!) scriptEnginerZDebuggerrootNodedebugApplicationrZCodeContainerProvider ccProviderZ GetScriptSiterZIID_IActiveScriptSiteDebugscriptSiteDebug pythoncomZ com_errorrZGetApplicationZGetRootApplicationNodeZCoCreateInstanceZCLSID_ProcessDebugManagerZ CLSCTX_ALLZIID_IProcessDebugManagerZGetDefaultApplicationZ GetRootNodeactiveScriptDebugZ AttachAppcodeContainersr ActiveScriptDebugIID_IActiveScriptDebug)selfrZpdmrrr__init__(sN           zDebugManager.__init__cCsl|jdurt|jd|_d|_d|_d|_d|_|jdurL|jd|_i|_|j rh|j d|_ dSN) r!r rrrrrCloser"rZCloseAppr%rrrr(Zs     zDebugManager.ClosecCs |jduS)z0Do we have _any_ debugging interfaces installed?N)rr)rrr IsAnyHostmszDebugManager.IsAnyHostcCs |jduSr')rr)rrr IsSimpleHostqszDebugManager.IsSimpleHostcCstdd}|S)zCalled 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!rr%Ziidrrr_query_interface_for_debugger_s  z+DebugManager._query_interface_for_debugger_cCsBtdz ddWntdjj}Yn0|j|dS)N OnEnterScriptrr)rsysexc_infotb_framef_backrZSetupAXDebugging)r%Z baseFramerrrr0s  zDebugManager.OnEnterScriptcCstd|jdS)N OnLeaveScript)rrZResetAXDebuggingr)rrrr6szDebugManager.OnLeaveScriptcCst||j}|rht|}t|tj}t|}t|tj }||_ |j }| |||jnd}||j|j<|j||dSr')DebugCodeBlockContainerrr+rZDebugDocumentTextr rZIID_IDebugDocumentZDebugDocumentProviderZIID_IDebugDocumentProviderZ debugDocumentrZCreateApplicationNodeZSetDocumentProviderZAttachrr"Z sourceContextrZAddCodeContainer)r% codeBlockZccZdocumentZproviderZnewNoderrrAddScriptBlocks        zDebugManager.AddScriptBlockN)__name__ __module__ __qualname__rr$r-r&r(r*r+r,r/r0r6r9rrrrr%s2 rc@seZdZddZddZdS)r7cCs(||_t||j||j|j|dSr')r8rr&ZcodeTextZ GetFileNameZsourceContextCookieZstartLineNumber)r%r8Zsiterrrr&sz DebugCodeBlockContainer.__init__cCs8|tjkr|jS|tjkr(|jSttjddS)NZscode)rZDOCUMENTNAMETYPE_APPNODEr8ZGetDisplayNameZDOCUMENTNAMETYPE_TITLEr winerrorZS_FALSE)r%ZdntrrrGetNames     zDebugCodeBlockContainer.GetNameN)r:r;r<r&r?rrrrr7s r7c@seZdZddZdS)EnumDebugCodeContextscCs|Sr'r)r%obrrrr szEnumDebugCodeContexts._wrapN)r:r;r<r rrrrr@sr@c@sPeZdZdZgdZejgZddZddZ ddZ d d Z d d Z d dZ dS)r#zThe class which implements the IActiveScriptDebug interface for the Active Script engine. Only ever used by smart hosts. )GetScriptTextAttributesGetScriptletTextAttributesEnumCodeContextsOfPositioncCs||_|j|_||_dSr'debugMgrrr")r%rFr"rrrr&szActiveScriptDebug.__init__cCsd|_d|_i|_dSr'rEr)rrr_CloseszActiveScriptDebug._ClosecCstd|t|jj|S)NzDebuggerQI with)rr rFrr.rrr_query_interface_s z#ActiveScriptDebug._query_interface_cCst|d}|S)N)rGetSyntaxColorAttributesr%codedelimflags containerrrrrBs z)ActiveScriptDebug.GetScriptTextAttributescCs td|||t|d}|S)NrCrI)rrrJrKrrrrCs z,ActiveScriptDebug.GetScriptletTextAttributescCsXtd|||z|j||}Wnty@ttjdYn0t|g}t|t j S)NrDr=) rr"ZGetCodeContextAtPositionKeyErrorr r>Z E_UNEXPECTEDr@r rZIID_IEnumDebugCodeContexts)r%contextZ charOffsetZnumCharsenumrrrrDs  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 frameworkrenvironrrPrr7r@r#rrrrs0