/MeScript/src/uAXScriptInf.pas

http://meaop.googlecode.com/ · Pascal · 1382 lines · 639 code · 201 blank · 542 comment · 0 complexity · d3e02514b6c20c961c4de82f84ac2a4e MD5 · raw file

  1. { Summary: the AX Script Interface Declaration
  2. License:
  3. * The contents of this file are released under a dual \license, and
  4. * you may choose to use it under either the Mozilla Public License
  5. * 1.1 (MPL 1.1, available from http://www.mozilla.org/MPL/MPL-1.1.html)
  6. * or the GNU Lesser General Public License 2.1 (LGPL 2.1, available from
  7. * http://www.opensource.org/licenses/lgpl-license.php).
  8. * Software distributed under the License is distributed on an "AS
  9. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing
  11. * rights and limitations under the \license.
  12. * The Original Code is $RCSfile: uAXScriptInf.pas,v $.
  13. * The Initial Developers of the Original Code are Riceball LEE.
  14. * Portions created by Serhiy Perevoznyk is Copyright (C) 2001-2004
  15. * Portions created by Riceball LEE is Copyright (C) 2007-2008
  16. * All rights reserved.
  17. * Contributor(s):
  18. }
  19. (*
  20. The following information on IBindEventHandler might be useful to you.
  21. I've just discovered, IBindEventHandler has no appication with IE (at least
  22. IE5). Even more, all IE objects that support
  23. function <object>.<event>() { .. }
  24. binding don't expose IBindEventHandler. Still note, complex things like this
  25. <script>
  26. function window.document.onkeydown() { alert("Blah") }
  27. </script>
  28. do work!
  29. My IBindEventHandler was never being queried for. It turns out, when JScript
  30. sees
  31. function <object>.<event>() { alert("Blah") }
  32. syntax, it understands it and merely assigns object.event, which is much the
  33. same as:
  34. <object>.<event> = function() { alert("Blah") }
  35. I implemented a special property per event (like IE does):
  36. [propput] HRESULT event([in] IDispatch* handler)
  37. [propget] HRESULT event([out, retval] IDispatch** handler)
  38. and it works perfectly. You should call Invoke(DISPID_VALUE,...) on passed
  39. IDispatch when the corresponding event occurs. Some time it's even easier and
  40. more efficient than implementing standard IConnectionPointContainer schema. It
  41. allows you to sink events from children objects as easy as:
  42. function <root>.<child1>.<child2>.<event>() { alert("Blah") }
  43. with VBScript, you can do the same with
  44. sub handler
  45. end sub
  46. <root>.<child1>.<child2>.<event> = GetRef(handler);
  47. Eric please, should IBindEventHandler be consdered as legacy interface?
  48. Btw, new cool features are here for engines V5. Look:
  49. ****************
  50. interface IActiveScriptProperty : IUnknown
  51. {
  52. // NOTES:
  53. // * This is a generic information passing interface to allow
  54. // the host to get and set pre-defined properties of the engine
  55. // * dwProperty must be a SCRIPTPROP_* value
  56. // * pvarIndex (when used) further identifies the dwProperty
  57. // * pvarValue is the value of the property, can be any VARIANT including
  58. // binary data in a VT_BSTR, most common is VT_BOOL
  59. HRESULT GetProperty(
  60. [in] DWORD dwProperty,
  61. [in] VARIANT *pvarIndex,
  62. [out] VARIANT *pvarValue
  63. );
  64. HRESULT SetProperty(
  65. [in] DWORD dwProperty,
  66. [in] VARIANT *pvarIndex,
  67. [in] VARIANT *pvarValue
  68. );
  69. }
  70. /* Properties for IActiveScriptProperty */
  71. #define SCRIPTPROP_NAME 0x00000000
  72. #define SCRIPTPROP_MAJORVERSION 0x00000001
  73. #define SCRIPTPROP_MINORVERSION 0x00000002
  74. #define SCRIPTPROP_BUILDNUMBER 0x00000003
  75. #define SCRIPTPROP_DELAYEDEVENTSINKING 0x00001000
  76. #define SCRIPTPROP_CATCHEXCEPTION 0x00001001
  77. #define SCRIPTPROP_DEBUGGER 0x00001100
  78. #define SCRIPTPROP_JITDEBUG 0x00001101
  79. // These properties are defined and available, but are not
  80. // officially supported.
  81. #define SCRIPTPROP_HACK_FIBERSUPPORT 0x70000000
  82. #define SCRIPTPROP_HACK_TRIDENTEVENTSINK 0x70000001
  83. ****************
  84. I'm especially interested at SCRIPTPROP_DEBUGGER, SCRIPTPROP_DEBUGGER,
  85. SCRIPTPROP_CATCHEXCEPTION.
  86. Note also this:
  87. ****************
  88. [
  89. object,
  90. uuid(1DC9CA50-06EF-11d2-8415-006008C3FBFC),
  91. pointer_default(unique)
  92. ]
  93. interface ITridentEventSink : IUnknown
  94. {
  95. HRESULT FireEvent(
  96. [in] LPCOLESTR pstrEvent,
  97. [in] DISPPARAMS *pdp,
  98. [out] VARIANT *pvarRes,
  99. [out] EXCEPINFO *pei
  100. );
  101. }
  102. These are NOT cool new features, these are hacks we added to the engine in
  103. order to get performance features into IE and ASP without re-writing the
  104. Windows Script Interfaces entirely. DO NOT USE THEM. As far as I know,
  105. they will NEVER be documented or supported. Their behaviour is entirely
  106. dependent on my whims, and you know how capricious I can be. ;-) If by
  107. some strange twist of fate we do decide to support these as public WSIs,
  108. we'll add them to the doc then. Until then, please don't muck with them as
  109. we cannot guarantee that future script engines will be forward compatible
  110. with any host that uses these interfaces.
  111. In particular, ITridentEventSink is a hack that we added which allows
  112. VBScript to walk the IE type info looking for events to bind much faster
  113. than the traditional type info walking code. We found that we had
  114. situations where there would be a table with a thousand entries, say, and
  115. we'd spend thirty, forty seconds just looking at every entry to see if there
  116. were any events bound on it. (JScript doesn't have this problem because
  117. JScript doesn't have automagic event hookup, events must be hooked up
  118. explicitly in the code or the HTML.) This interface is a PRIVATE interface
  119. between VBScript and the IE HTML rendering surface, DO NOT USE IT. Pay no
  120. attention to the man behind the curtain!
  121. *)
  122. unit uAXScriptInf;
  123. {$I Jedi.inc}
  124. interface
  125. uses
  126. Windows, ActiveX
  127. ;
  128. {$Z4}
  129. const
  130. SCATID_ActiveScript = '{F0B7A1A1-9847-11cf-8F20-00805F2CD064}';
  131. SCATID_ActiveScriptParse = '{F0B7A1A2-9847-11cf-8F20-00805F2CD064}';
  132. SCATID_VBScript = '{B54F3741-5B07-11CF-A4B0-00AA004A55E8}';
  133. SCATID_VBScriptEncode = '{B54F3743-5B07-11CF-A4B0-00AA004A55E8}';
  134. SCATID_JScript = '{F414C260-6AC0-11CF-B6D1-00AA00BBBB58}';
  135. SCATID_JScriptEncode = '{F414C262-6AC0-11CF-B6D1-00AA00BBBB58}';
  136. SCATID_PythonScript = '{DF630910-1C1D-11D0-AE36-8C0F5E000000}';
  137. SCATID_PerlScript = '{F8D77580-0F09-11D0-AA61-3C284E000000}';
  138. SCATID_CypressEnable = '{3C6F3220-4A4A-11D0-89EB-444553540001}';
  139. SCatID_JScriptNet = '{9888F5B2-0A2C-11D3-B354-00105A98B7CE}';
  140. SID_IActiveScript = '{BB1A2AE1-A4F9-11cf-8F20-00805F2CD064}';
  141. SID_IActiveScriptParse = '{BB1A2AE2-A4F9-11cf-8F20-00805F2CD064}';
  142. SID_IActiveScriptParseProcedureOld ='{1CFF0050-6FDD-11d0-9328-00A0C90DCAA9}';
  143. SID_IActiveScriptParseProcedure = '{AA5B6A80-B834-11d0-932F-00A0C90DCAA9}';
  144. SID_IActiveScriptSite = '{DB01A1E3-A42B-11cf-8F20-00805F2CD064}';
  145. SID_IActiveScriptSiteWindow = '{D10F6761-83E9-11cf-8F20-00805F2CD064}';
  146. SID_IActiveScriptSiteInterruptPoll ='{539698A0-CDCA-11CF-A5EB-00AA0047A063}';
  147. SID_IActiveScriptError = '{EAE1BA61-A4ED-11cf-8F20-00805F2CD064}';
  148. SID_IBindEventHandler = '{63CDBCB0-C1B1-11d0-9336-00A0C90DCAA9}';
  149. SID_IActiveScriptStats = '{B8DA6310-E19B-11d0-933C-00A0C90DCAA9}';
  150. SID_ProcessDebugManager = '{51973C2f-CB0C-11d0-B5C9-00A0244A0E7A}';
  151. SID_MachineDebugManager = '{51973C2c-CB0C-11d0-B5C9-00A0244A0E7A}';
  152. SCLSID_ProcessDebugManager = '{78a51822-51f4-11d0-8f20-00805f2cd064}';
  153. SCLSID_MachineDebugManager ='{0C0A3666-30C9-11D0-8F20-00805F2CD064}';
  154. CATID_ActiveScript: TGUID = SCATID_ActiveScript;
  155. CATID_ActiveScriptParse: TGUID = SCATID_ActiveScriptParse;
  156. IID_IActiveScript: TGUID = SID_IActiveScript;
  157. IID_IActiveScriptParse: TGUID = SID_IActiveScriptParse;
  158. IID_IActiveScriptParseProcedureOld: TGUID = SID_IActiveScriptParseProcedureOld;
  159. IID_IActiveScriptParseProcedure: TGUID = SID_IActiveScriptParseProcedure;
  160. IID_IActiveScriptSite: TGUID = SID_IActiveScriptSite;
  161. IID_IActiveScriptSiteWindow: TGUID = SID_IActiveScriptSiteWindow;
  162. IID_IActiveScriptSiteInterruptPoll: TGUID = SID_IActiveScriptSiteInterruptPoll;
  163. IID_IActiveScriptError: TGUID = SID_IActiveScriptError;
  164. IID_IBindEventHandler: TGUID = SID_IBindEventHandler;
  165. IID_IActiveScriptStats: TGUID = SID_IActiveScriptStats;
  166. IID_ProcessDebugManager: TGUID = SID_ProcessDebugManager;
  167. IID_MachineDebugManager: TGUID = SID_MachineDebugManager;
  168. CLSID_ProcessDebugManager: TGUID = SCLSID_ProcessDebugManager;
  169. CLSID_MachineDebugManager: TGUID = SCLSID_MachineDebugManager;
  170. // Constants used by ActiveX Scripting:
  171. //
  172. (* IActiveScript::AddNamedItem() input flags *)
  173. SCRIPTITEM_ISVISIBLE = $00000002;
  174. SCRIPTITEM_ISSOURCE = $00000004;
  175. SCRIPTITEM_GLOBALMEMBERS = $00000008;
  176. SCRIPTITEM_ISPERSISTENT = $00000040;
  177. SCRIPTITEM_CODEONLY = $00000200;
  178. SCRIPTITEM_NOCODE = $00000400;
  179. SCRIPTITEM_ALL_FLAGS =(SCRIPTITEM_ISSOURCE or
  180. SCRIPTITEM_ISVISIBLE or
  181. SCRIPTITEM_ISPERSISTENT or
  182. SCRIPTITEM_GLOBALMEMBERS or
  183. SCRIPTITEM_NOCODE or
  184. SCRIPTITEM_CODEONLY);
  185. (* IActiveScript::AddTypeLib() input flags *)
  186. SCRIPTTYPELIB_ISCONTROL = $00000010;
  187. SCRIPTTYPELIB_ISPERSISTENT = $00000040;
  188. SCRIPTTYPELIB_ALL_FLAGS = (SCRIPTTYPELIB_ISCONTROL or
  189. SCRIPTTYPELIB_ISPERSISTENT);
  190. (* IActiveScriptParse::AddScriptlet() and
  191. IActiveScriptParse::ParseScriptText() input flags *)
  192. SCRIPTTEXT_NULL = $00000000; { added for demo}
  193. {
  194. SCRIPTTEXT_DELAYEXECUTION will do nothing if you're evaluating an expression; if the SCRIPTTEST_ISEXPRESSION flag is set or the pvarResult parameter is non-NULL, the script code you pass in will be executed immediately if the script engine is at the very least initialized.
  195. The SCRIPTTEXT_DELAYEXECUTION flag causes the code you're
  196. adding to the engine to be placed in queue for execution. The code will not
  197. be executed until the script engine's state is shifted from
  198. SCRIPTSTATE_INITIALIZED to SCRIPTSTATE_STARTED. This means that if you add
  199. SCRIPTTEXT_DELAYEXECUTION code to a script engine in the SCRIPTSTATE_STARTED
  200. state, the code will be put into a queue for execution, but it will not
  201. immediatey execute. The code will not run until you revert the engine state
  202. to SCRIPTSTATE_INITIALIZED and back to SCRIPTSTATE_STARTED. Of course, the
  203. state switch to SCRIPTSTATE_INITIALIZED will reset the engine to a
  204. pre-running state, and the subsequent switch to SCRIPTSTATE_STARTED will
  205. cause all of the persistent code you've added so far to run from scratch.
  206. }
  207. SCRIPTTEXT_DELAYEXECUTION = $00000001;
  208. //Indicates that the script text should be visible (and, therefore, callable by name) as a global method in the name space of the script.
  209. SCRIPTTEXT_ISVISIBLE = $00000002;
  210. //If the distinction between a computational expression and a statement is important but syntactically ambiguous in the script language, this flag specifies that the scriptlet is to be interpreted as an expression, rather than as a statement or list of statements. By default, statements are assumed unless the correct choice can be determined from the syntax of the scriptlet text.
  211. SCRIPTTEXT_ISEXPRESSION = $00000020;
  212. //Indicates that the code added during this call should be saved if the scripting engine is saved (for example, through a call to IPersist*::Save), or if the scripting engine is reset by way of a transition back to the initialized state.
  213. SCRIPTTEXT_ISPERSISTENT = $00000040;
  214. SCRIPTTEXT_HOSTMANAGESSOURCE = $00000080;
  215. SCRIPTTEXT_ALL_FLAGS = (SCRIPTTEXT_DELAYEXECUTION or
  216. SCRIPTTEXT_ISVISIBLE or
  217. SCRIPTTEXT_ISEXPRESSION or
  218. SCRIPTTEXT_ISPERSISTENT or
  219. SCRIPTTEXT_HOSTMANAGESSOURCE);
  220. (* IActiveScriptParseProcedure::ParseProcedureText() input flags *)
  221. SCRIPTPROC_HOSTMANAGESSOURCE = $00000080;
  222. SCRIPTPROC_IMPLICIT_THIS = $00000100;
  223. SCRIPTPROC_IMPLICIT_PARENTS = $00000200;
  224. SCRIPTPROC_ALL_FLAGS = (SCRIPTPROC_HOSTMANAGESSOURCE or
  225. SCRIPTPROC_IMPLICIT_THIS or
  226. SCRIPTPROC_IMPLICIT_PARENTS);
  227. (* IActiveScriptSite::GetItemInfo() input flags *)
  228. SCRIPTINFO_IUNKNOWN = $00000001;
  229. SCRIPTINFO_ITYPEINFO = $00000002;
  230. SCRIPTINFO_ALL_FLAGS = (SCRIPTINFO_IUNKNOWN or
  231. SCRIPTINFO_ITYPEINFO);
  232. (* IActiveScript::Interrupt() Flags *)
  233. SCRIPTINTERRUPT_DEBUG = $00000001;
  234. SCRIPTINTERRUPT_RAISEEXCEPTION = $00000002;
  235. SCRIPTINTERRUPT_ALL_FLAGS = (SCRIPTINTERRUPT_DEBUG or
  236. SCRIPTINTERRUPT_RAISEEXCEPTION);
  237. (* IActiveScriptStats::GetStat() values *)
  238. SCRIPTSTAT_STATEMENT_COUNT = 1;
  239. SCRIPTSTAT_INSTRUCTION_COUNT = 2;
  240. SCRIPTSTAT_INTSTRUCTION_TIME = 3;
  241. SCRIPTSTAT_TOTAL_TIME = 4;
  242. const
  243. // Caller of interface may be untrusted
  244. INTERFACESAFE_FOR_UNTRUSTED_CALLER = $00000001;
  245. // Data passed into interface may be untrusted
  246. INTERFACESAFE_FOR_UNTRUSTED_DATA = $00000002;
  247. // Object knows to use IDispatchEx
  248. INTERFACE_USES_DISPEX = $00000004;
  249. // Object knows to use IInternetHostSecurityManager
  250. INTERFACE_USES_SECURITY_MANAGER = $00000008;
  251. (* script state values *)
  252. type
  253. tagSCRIPTSTATE = longword;
  254. SCRIPTSTATE = tagSCRIPTSTATE;
  255. const
  256. {
  257. ??????????
  258. Uninitialized?????? ????????????????????????????????????????????????
  259. Initialized?????? ?????????IPersist ????????????IActiveScriptSite???????????????????????????????????????????????????????????IActiveScriptParse.ParseScriptText()???????????
  260. Started?????????????????????IDispatch??????????????????????????????????????????????????????????????????????????????????????????
  261. Connected????? ?????????????????????????????????????
  262. Disconnected?????????????????????????????????????????????????????????????????????????????????????????????????????
  263. Closed???? ?????????????????????IActiveScript.Close()????????????
  264. }
  265. SCRIPTSTATE_UNINITIALIZED = $00000000;
  266. SCRIPTSTATE_INITIALIZED = $00000005;
  267. SCRIPTSTATE_STARTED = $00000001;
  268. SCRIPTSTATE_CONNECTED = $00000002;
  269. SCRIPTSTATE_DISCONNECTED = $00000003;
  270. SCRIPTSTATE_CLOSED = $00000004;
  271. (* script thread state values *)
  272. type
  273. tagSCRIPTTHREADSTATE = longword;
  274. SCRIPTTHREADSTATE = tagSCRIPTTHREADSTATE;
  275. const
  276. SCRIPTTHREADSTATE_NOTINSCRIPT = $00000000;
  277. SCRIPTTHREADSTATE_RUNNING = $00000001;
  278. (* Thread IDs *)
  279. type
  280. SCRIPTTHREADID = DWORD;
  281. const
  282. SCRIPTTHREADID_CURRENT = SCRIPTTHREADID(-1);
  283. SCRIPTTHREADID_BASE = SCRIPTTHREADID(-2);
  284. SCRIPTTHREADID_ALL = SCRIPTTHREADID(-3);
  285. // evaluate flags
  286. DEBUG_TEXT_ISEXPRESSION = $00000001;
  287. DEBUG_TEXT_RETURNVALUE = $00000002;
  288. DEBUG_TEXT_NOSIDEEFFECTS = $00000004;
  289. DEBUG_TEXT_ALLOWBREAKPOINTS = $00000008;
  290. DEBUG_TEXT_ALLOWERRORREPORT = $00000010;
  291. DBGPROP_INFO_NAME = $001;// init the bstrName field
  292. DBGPROP_INFO_TYPE = $002; // init the bstrType field
  293. DBGPROP_INFO_VALUE = $004; // init the bstrValue field
  294. DBGPROP_INFO_FULLNAME = $020; // init the full name field
  295. DBGPROP_INFO_ATTRIBUTES = $008; // init the dwAttrib field
  296. DBGPROP_INFO_DEBUGPROP = $010; // init the pDebugProp field
  297. DBGPROP_INFO_AUTOEXPAND = $8000000; // make the Value result auto-expand
  298. DBGPROP_INFO_STANDARD = DBGPROP_INFO_NAME or DBGPROP_INFO_TYPE or DBGPROP_INFO_VALUE or
  299. DBGPROP_INFO_ATTRIBUTES;
  300. DBGPROP_INFO_ALL = DBGPROP_INFO_NAME or DBGPROP_INFO_TYPE or DBGPROP_INFO_VALUE or
  301. DBGPROP_INFO_FULLNAME or DBGPROP_INFO_ATTRIBUTES or DBGPROP_INFO_DEBUGPROP;
  302. type
  303. TEXT_DOC_ATTR = DWORD;
  304. const
  305. // Indicates that the document is read-only.
  306. TEXT_DOC_ATTR_READONLY = $00000001;
  307. // DEBUGGER_BLOCK
  308. // languages should break immediately with BREAKREASON_DEBUGGER_BLOCK
  309. APPBREAKFLAG_DEBUGGER_BLOCK= $00000001;
  310. // DEBUGGER_HALT
  311. // languages should break immediately with BREAKREASON_DEBUGGER_HALT
  312. APPBREAKFLAG_DEBUGGER_HALT= $00000002;
  313. // STEP
  314. // languages should break immediately in the stepping thread with BREAKREASON_STEP
  315. APPBREAKFLAG_STEP= $00010000;
  316. // NESTED - the application is in nested execution on a breakpoint
  317. APPBREAKFLAG_NESTED= $00020000;
  318. // STEP TYPES - defines whether we are stepping at source, bytecode, or machine level.
  319. APPBREAKFLAG_STEPTYPE_SOURCE = $00000000;
  320. APPBREAKFLAG_STEPTYPE_BYTECODE = $00100000;
  321. APPBREAKFLAG_STEPTYPE_MACHINE = $00200000;
  322. APPBREAKFLAG_STEPTYPE_MASK = $00F00000;
  323. // BREAKPOINT IN_PROGRESS
  324. APPBREAKFLAG_IN_BREAKPOINT = $80000000;
  325. // -----------------------------------------------------------------------
  326. // OBJECT ATTRIBUTES
  327. DBGPROP_ATTRIB_NO_ATTRIB = $00000000;
  328. // ---------------------
  329. // Characteristics
  330. DBGPROP_ATTRIB_VALUE_IS_INVALID = $00000008; // the value in this slot is invalid
  331. DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE =$00000010; // the object has children
  332. DBGPROP_ATTRIB_VALUE_READONLY = $00000800; // the value is read-only
  333. // Attributes about a slot's type
  334. // ---------------------
  335. // Common attributes
  336. // field access control
  337. DBGPROP_ATTRIB_ACCESS_PUBLIC = $00001000;
  338. DBGPROP_ATTRIB_ACCESS_PRIVATE = $00002000;
  339. DBGPROP_ATTRIB_ACCESS_PROTECTED = $00004000;
  340. DBGPROP_ATTRIB_ACCESS_FINAL = $00008000;
  341. // storage types
  342. DBGPROP_ATTRIB_STORAGE_GLOBAL = $00010000;
  343. DBGPROP_ATTRIB_STORAGE_STATIC = $00020000;
  344. DBGPROP_ATTRIB_STORAGE_FIELD = $00040000;
  345. // type modifiers
  346. DBGPROP_ATTRIB_STORAGE_VIRTUAL = $00080000; // this slot is virtual
  347. DBGPROP_ATTRIB_TYPE_IS_CONSTANT = $00100000; // this slot is a constant value
  348. DBGPROP_ATTRIB_TYPE_IS_SYNCHRONIZED =$00200000; // this slot is thread synchronized
  349. DBGPROP_ATTRIB_TYPE_IS_VOLATILE = $00400000; // this slot is volatile storage
  350. DBGPROP_ATTRIB_HAS_EXTENDED_ATTRIBS =$00800000; // has more attributes
  351. THREAD_STATE_RUNNING = $00000001;
  352. THREAD_STATE_SUSPENDED = $00000002;
  353. THREAD_BLOCKED = $00000004;
  354. THREAD_OUT_OF_CONTEXT = $00000008;
  355. {
  356. Application break flags. Indicates the current debug state for the application
  357. and the current thread. When certain of these bits are set (some are per-thread
  358. and some are for all threads), language engines should break at the next
  359. opportunity.
  360. }
  361. type
  362. TAPPBREAKFLAGS = DWORD;
  363. TTextDocAttr = DWORD;
  364. TSourceTextAttr = WORD;
  365. type
  366. TDocumentNameType = (
  367. DOCUMENTNAMETYPE_APPNODE,// Gets the name as it appears in the app tree
  368. DOCUMENTNAMETYPE_TITLE,// Gets the name as it appears on the doc viewer title bar
  369. DOCUMENTNAMETYPE_FILE_TAIL,// Gets the filename without a path (for save as...)
  370. DOCUMENTNAMETYPE_URL// Gets the URL of the document, if any
  371. );
  372. TBreakPointState = (
  373. BREAKPOINT_DELETED,// The breakpoint no longer exists but there are still references
  374. BREAKPOINT_DISABLED,// The breakpoint exists but is disabled
  375. BREAKPOINT_ENABLED// The breakpoint exists and is enabled
  376. );
  377. TBreakResumeAction = (
  378. braAbort,// Abort the application
  379. braContinue,// Continue running
  380. braStepInto,// Step into a procedure
  381. braStepOver,// Step over a procedure
  382. braStepOut,// Step out of the current procedure
  383. braIgnore
  384. );
  385. TErrorResumeAction = (
  386. eraReexecute,// try executing the erroneous line again
  387. eraAbortAndReturnError,// let the language engine handle the error
  388. eraSkipError// resume execution from beyond the error
  389. );
  390. TBreakReason = (
  391. BREAKREASON_STEP,// Caused by the stepping mode
  392. BREAKREASON_BREAKPOINT,// Caused by an explicit breakpoint
  393. BREAKREASON_DEBUGGER_BLOCK,// Caused by another thread breaking
  394. BREAKREASON_HOST_INITIATED,// Caused by host requested break
  395. BREAKREASON_LANGUAGE_INITIATED,// Caused by a scripted break
  396. BREAKREASON_DEBUGGER_HALT,// Caused by debugger IDE requested break
  397. BREAKREASON_ERROR// Caused by an execution error
  398. );
  399. TDbgPropInfoFlags = DWORD; // Flags used to specify DebugPropertyInfo (and ExtendedDebugPropertyInfo) fields
  400. TDbgPropAttribFlags = DWORD;
  401. {$IFDEF Compiler4_Up}
  402. {$IFDEF BCB4_UP}
  403. type
  404. POleVariant = ^OleVariant;
  405. {$ENDIF}
  406. {$ELSE}
  407. type
  408. POleVariant = ^OleVariant;
  409. {$ENDIF}
  410. type
  411. IActiveScriptSite = interface;
  412. IActiveScriptSiteWindow = interface;
  413. IActiveScript = interface;
  414. IActiveScriptParse = interface;
  415. IActiveScriptParseProcedure = interface;
  416. IActiveScriptError = interface;
  417. LPCOLESTR = PWideChar;
  418. IActiveScriptSite = interface(IUnknown)
  419. [SID_IActiveScriptSite]
  420. function GetLCID(out plcid: LCID): HResult; stdcall;
  421. function GetItemInfo(
  422. pstrName: LPCOLESTR;
  423. dwReturnMask: DWORD;
  424. out ppiunkItem: IUnknown;
  425. out ppti: ITypeInfo): HResult; stdcall;
  426. function GetDocVersionString(out pbstrVersion: WideString): HResult; stdcall;
  427. function OnScriptTerminate(
  428. var pvarResult: OleVariant;
  429. var pexcepinfo: EXCEPINFO): HResult; stdcall;
  430. function OnStateChange(ssScriptState: SCRIPTSTATE): HResult; stdcall;
  431. function OnScriptError(
  432. const pscripterror: IActiveScriptError): HResult; stdcall;
  433. function OnEnterScript: HResult; stdcall;
  434. function OnLeaveScript: HResult; stdcall;
  435. end;
  436. IActiveScriptError = interface(IUnknown)
  437. [SID_IActiveScriptError]
  438. function GetExceptionInfo(out pexcepinfo: EXCEPINFO): HResult; stdcall;
  439. function GetSourcePosition(
  440. out pdwSourceContext: DWORD;
  441. out pulLineNumber: ULONG;
  442. out plCharacterPosition: Integer): HResult; stdcall;
  443. function GetSourceLineText(out pbstrSourceLine: WideString): HResult; stdcall;
  444. end;
  445. IActiveScriptSiteWindow = interface(IUnknown)
  446. [SID_IActiveScriptSiteWindow]
  447. function GetWindow(out phwnd: HWND): HResult; stdcall;
  448. function EnableModeless(fEnable: BOOL): HResult; stdcall;
  449. end;
  450. IActiveScriptSiteInterruptPoll = interface(IUnknown)
  451. [SID_IActiveScriptSiteInterruptPoll]
  452. function QueryContinue: HResult; stdcall;
  453. end;
  454. IActiveScript = interface(IUnknown)
  455. [SID_IActiveScript]
  456. function SetScriptSite(const pass: IActiveScriptSite): HResult; stdcall;
  457. function GetScriptSite(
  458. const riid: TGUID;
  459. out ppvObject: Pointer): HResult; stdcall;
  460. function SetScriptState(ss: SCRIPTSTATE): HResult; stdcall;
  461. function GetScriptState(out pssState: SCRIPTSTATE): HResult; stdcall;
  462. function Close: HResult; stdcall;
  463. function AddNamedItem(
  464. pstrName: LPCOLESTR;
  465. dwFlags: DWORD): HResult; stdcall;
  466. function AddTypeLib(
  467. const rguidTypeLib: TGUID;
  468. dwMajor: DWORD;
  469. dwMinor: DWORD;
  470. dwFlags: DWORD): HResult; stdcall;
  471. function GetScriptDispatch(
  472. pstrItemName: LPCOLESTR;
  473. out ppdisp: IDispatch): HResult; stdcall;
  474. function GetCurrentScriptThreadID(
  475. out pstidThread: SCRIPTTHREADID): HResult; stdcall;
  476. function GetScriptThreadID(dwWin32ThreadId: DWORD;
  477. out pstidThread: SCRIPTTHREADID): HResult; stdcall;
  478. function GetScriptThreadState(
  479. stidThread: SCRIPTTHREADID;
  480. out pstsState: SCRIPTTHREADSTATE): HResult; stdcall;
  481. function InterruptScriptThread(
  482. stidThread: SCRIPTTHREADID;
  483. var pexcepinfo: EXCEPINFO;
  484. dwFlags: DWORD): HResult; stdcall;
  485. function Clone(out ppscript: IActiveScript): HResult; stdcall;
  486. end;
  487. IActiveScriptParse = interface(IUnknown)
  488. [SID_IActiveScriptParse]
  489. function InitNew: HResult; stdcall;
  490. {
  491. What is the best way to add event-handling code to the script engine?
  492. Events can be synced from any object that has been added to IActiveScript::AddNamedItem with the SCRIPTITEM_ISSOURCE flag, and any immediate child object of such objects. So, for example, when
  493. IE adds the window object with the SCRIPTITEM_ISSOURCE flag, the OnClick event of a button on that window object can automatically be synced.
  494. To add an event handler for that child object, you use IActiveScriptParse::AddScriptlet like the following:
  495. pScriptEngineParse->AddScriptlet(
  496. NULL, /*pstrDefaultName*/
  497. L"MsgBox \"Hello\"", /*pstrCode*/
  498. L"window", /*pstrItemName*/
  499. L"button1", /*pstrSubItemName*/
  500. L"OnClick", /*pstrEventName*/
  501. NULL, /*pstrDelimiter*/
  502. 0, /*dwSourceContextCookie/*
  503. ulStartingLineNumber,
  504. SCRIPTTEXT_ISPERSTENT, /*dwFlags*/
  505. &bstrName,
  506. &excepInfo );
  507. When called like this, the script engine will call IActiveScriptSite::GetItemInfo() on the window object, and then IDispatch::GetIDsOfNames/Invoke on the button1 object. Then it will QI for IConnectionPointContainer and use Connection Points to sync the OnClick event.
  508. }
  509. function AddScriptlet(
  510. //a default name to associate with the scriptlet. If the scriptlet does not contain naming information (as in the ONCLICK example above), this name will be used to identify the scriptlet. If this parameter is NULL, the scripting engine manufactures a unique name, if necessary.
  511. pstrDefaultName: LPCOLESTR;
  512. //the scriptlet text
  513. pstrCode: LPCOLESTR;
  514. //a buffer that contains the item name associated with this scriptlet. This parameter, in addition to pstrSubItemName, identifies the object for which the scriptlet is an event handler.
  515. pstrItemName: LPCOLESTR;
  516. //a buffer that contains the name of a subobject of the named item with which this scriptlet is associated; this name must be found in the named item's type information. This parameter is NULL if the scriptlet is to be associated with the named item instead of a subitem. This parameter, in addition to pstrItemName, identifies the specific object for which the scriptlet is an event handler.
  517. pstrSubItemName: LPCOLESTR;
  518. //a buffer that contains the name of the event for which the scriptlet is an event handler.
  519. pstrEventName: LPCOLESTR;
  520. //the end-of-scriptlet delimiter. When the pstrCode parameter is parsed from a stream of text, the host typically uses a delimiter, such as two single quotation marks (''), to detect the end of the scriptlet. This parameter specifies the delimiter that the host used, allowing the scripting engine to provide some conditional primitive preprocessing (for example, replacing a single quotation mark ['] with two single quotation marks for use as a delimiter). Exactly how (and if) the scripting engine makes use of this information depends on the scripting engine. Set this parameter to NULL if the host did not use a delimiter to mark the end of the scriptlet.
  521. pstrDelimiter: LPCOLESTR;
  522. dwSourceContextCookie: DWORD;
  523. ulStartingLineNumber: ULONG;
  524. dwFlags: DWORD;
  525. //Actual name used to identify the scriptlet. This is to be in order of preference: a name explicitly specified in the scriptlet text, the default name provided in pstrDefaultName, or a unique name synthesized by the scripting engine.
  526. out pbstrName: WideString;
  527. out pexcepinfo: EXCEPINFO): HResult; stdcall;
  528. {
  529. Returns one of the following values:
  530. Return Value Meaning
  531. S_OK Success.
  532. DISP_E_EXCEPTION An exception occurred in the processing of the scriptlet. The pexcepinfo parameter contains information about the exception.
  533. E_INVALIDARG An argument was invalid.
  534. E_POINTER An invalid pointer was specified.
  535. E_NOTIMPL This method is not supported. The scripting engine does not support run-time evaluation of expressions or statements.
  536. E_UNEXPECTED The call was not expected (for example, the scripting engine is in the uninitialized or closed state, or the SCRIPTTEXT_ISEXPRESSION flag was set and the scripting engine is in the initialized state).
  537. OLESCRIPT_E_SYNTAX An unspecified syntax error occurred in the scriptlet.
  538. Remarks
  539. If the scripting engine is in the initialized state, no code will actually be evaluated during this call; rather, such code is queued and executed when the scripting engine is transitioned into (or through) the started state. Because execution is not allowed in the initialized state, it is an error to call this method with the SCRIPTTEXT_ISEXPRESSION flag when in the initialized state.
  540. The scriptlet can be an expression, a list of statements, or anything allowed by the script language. For example, this method is used in the evaluation of the HTML <SCRIPT> tag, which allows statements to be executed as the HTML page is being constructed, rather than just compiling them into the script state.
  541. The code passed to this method must be a valid, complete portion of code. For example, in VBScript it is illegal to call this method once with Sub Function(x) and then a second time with End Sub. The parser must not wait for the second call to complete the subroutine, but rather must generate a parse error because a subroutine declaration was started but not completed.
  542. }
  543. function ParseScriptText(
  544. //scriptlet text
  545. pstrCode: LPCOLESTR;
  546. //item name that gives the context in which the scriptlet is to be evaluated. If this parameter is NULL, the code is evaluated in the scripting engine's global context.
  547. pstrItemName: LPCOLESTR;
  548. //debugging context. This object is reserved for use in a debugging environment, where such a context may be provided by the debugger to represent an active run-time context. If this parameter is NULL, the engine uses pstrItemName to identify the context.
  549. const punkContext: IUnknown;
  550. //end-of-scriptlet delimiter. When pstrCode is parsed from a stream of text, the host typically uses a delimiter, such as two single quotation marks (''), to detect the end of the scriptlet. This parameter specifies the delimiter that the host used, allowing the scripting engine to provide some conditional primitive preprocessing (for example, replacing a single quotation mark ['] with two single quotation marks for use as a delimiter). Exactly how (and if) the scripting engine makes use of this information depends on the scripting engine. Set this parameter to NULL if the host did not use a delimiter to mark the end of the scriptlet.
  551. pstrDelimiter: LPCOLESTR;
  552. //Application-defined value that is used for debugging purposes.
  553. dwSourceContextCookie: DWORD;
  554. //starting line of the script. Zero-based value that specifies which line the parsing will begin at.
  555. ulStartingLineNumber: ULONG;
  556. //scriptlet flags. Flags associated with the scriptlet. Can be a combination of these values:SCRIPTTEXT_ISEXPRESSION,SCRIPTTEXT_ISPERSISTENT,SCRIPTTEXT_ISVISIBLE
  557. dwFlags: DWORD;
  558. //buffer for results. Address of a buffer that receives the results of scriptlet processing, or NULL if the caller expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set).
  559. out pvarResult: OleVariant;
  560. //buffer for error data. Address of a structure that receives exception information. This structure is filled if IActiveScriptParse::ParseScriptText returns DISP_E_EXCEPTION.
  561. out pexcepinfo: EXCEPINFO): HResult; stdcall;
  562. end;
  563. IActiveScriptParseProcedureOld = interface(IUnknown)
  564. [SID_IActiveScriptParseProcedureOld]
  565. function ParseProcedureText(
  566. pstrCode: LPCOLESTR;
  567. pstrFormalParams: LPCOLESTR;
  568. pstrItemName: LPCOLESTR;
  569. const punkContext: IUnknown;
  570. pstrDelimiter: LPCOLESTR;
  571. dwSourceContextCookie: DWORD;
  572. ulStartingLineNumber: ULONG;
  573. dwFlags: DWORD;
  574. out ppdisp: IDispatch): HResult; stdcall;
  575. end;
  576. IActiveScriptParseProcedure = interface(IUnknown)
  577. [SID_IActiveScriptParseProcedure]
  578. function ParseProcedureText(
  579. pstrCode: LPCOLESTR;
  580. pstrFormalParams: LPCOLESTR;
  581. pstrProcedureName: LPCOLESTR;
  582. pstrItemName: LPCOLESTR;
  583. const punkContext: IUnknown;
  584. pstrDelimiter: LPCOLESTR;
  585. dwSourceContextCookie: DWORD;
  586. ulStartingLineNumber: ULONG;
  587. dwFlags: DWORD;
  588. out ppdisp: IDispatch): HResult; stdcall;
  589. end;
  590. IBindEventHandler = interface(IUnknown)
  591. [SID_IBindEventHandler]
  592. function BindHandler(
  593. pstrEvent: LPCOLESTR;
  594. const pdisp: IDispatch): HResult; stdcall;
  595. end;
  596. IActiveScriptStats = interface(IUnknown)
  597. [SID_IActiveScriptStats]
  598. function GetStat(
  599. stid: DWORD;
  600. out pluHi: ULONG;
  601. out pluLo: ULONG): HResult; stdcall;
  602. function GetStatEx(
  603. const guid: TGUID;
  604. out pluHi: ULONG;
  605. out pluLo: ULONG): HResult; stdcall;
  606. function ResetStats: HResult; stdcall;
  607. end;
  608. IDebugApplication = interface;
  609. IDebugDocumentHost = interface;
  610. IDebugProperty = interface;
  611. IDebugApplicationNode = interface;
  612. IEnumDebugCodeContexts = interface;
  613. IDebugDocumentContext = interface;
  614. IDebugDocumentHelper = interface(IUnknown)
  615. ['{51973C26-CB0C-11d0-B5C9-00A0244A0E7A}']
  616. // Initialize a debug doc helper with the given name and
  617. // initial attributes.
  618. //
  619. // Note: The document will not actually appear in the tree
  620. // until Attach is called.
  621. function Init(const pda : IDebugApplication; const pszShortName : PWideChar;
  622. const pszLongName : PWideChar; const docAttr : TTextDocAttr) : HRESULT; stdcall;
  623. // Add the document to the doc tree, using pddhParent as the parent.
  624. // If the ppdhParent is NULL, the document will be top-level.
  625. function Attach(const pddhParent : IDebugDocumentHelper) : HRESULT; stdcall;
  626. // Remove the document from the doc tree.
  627. function Detach : HRESULT; stdcall;
  628. // Add the given set of unicode characters to end of the document.
  629. // (This will generate IDebugDocumentTextEvent notifications.)
  630. //
  631. // If this method is called after AddDeferredText has been called,
  632. // E_FAIL will be returned.
  633. function AddUnicodeText(const pszText : PWideChar) : HRESULT; stdcall;
  634. // Add the given set of DBCS characters to end of the document.
  635. // (This will generate IDebugDocumentTextEvent notifications.)
  636. //
  637. // If this method is called after AddDeferredText has been called,
  638. // E_FAIL will be returned.
  639. function AddDBCSText(const pszText : PWideChar): HRESULT; stdcall;
  640. // Set the DebugDocumentHost interface.
  641. // If provided, this interface will be used for
  642. // smart-host syntax coloring, fetching deferred text, and returning
  643. // controlling unknowns for newly created document contexts.
  644. function SetDebugDocumentHost(const pddh : IDebugDocumentHost) : HRESULT; stdcall;
  645. // Notify the helper that the given text is available, but don't actually
  646. // provide the characters.
  647. // This allows the host to defer providing the characters unless they
  648. // are actually needed, while still allowing the helper to generate
  649. // accurate notifications and size information.
  650. //
  651. // dwTextStartCookie is a cookie, defined by the host, that represents
  652. // the starting position of the text. (For example, in a host that
  653. // represents text in DBCS, the cookie could be a byte offset.)
  654. // This cookie will be provided in subsequent calls to GetText.
  655. //
  656. // NB: It is assumed that a single call to
  657. // GetText can get characters from multiple calls to AddDeferredText.
  658. // The helper classes may also ask for the same range of deferred
  659. // characters more than once.
  660. //
  661. // It is an error to mix calls to AddDeferredText with calls to
  662. // AddUnicodeText or AddDBCSText-- Doing so will cause E_FAIL to be
  663. // returned.
  664. function AddDeferredText(const cChars : ULONG;// number of (Unicode) characters to add
  665. const dwTextStartCookie : DWORD) : HRESULT; stdcall; // host-defined cookie representing the starting position of the text.
  666. // Notify the helper that a particular range of
  667. // characters is a script block handled by the given script engine.
  668. // All syntax coloring and code context lookups for that range will be
  669. // delegated to that script engine.
  670. //
  671. // This method would be used by a smart host whose documents contained
  672. // embedded script blocks, or by a language engine containing embedded
  673. // scripts for other languages.
  674. //
  675. // DefineScriptBlock should be called after the text has been
  676. // added (via AddDBCSText, etc) but before the script script block
  677. // has been parsed (via IActiveScriptParse).
  678. function DefineScriptBlock(const ulCharOffset, cChars : ULONG; const pas : IActiveScript;
  679. const fScriptlet : BOOL;out pdwSourceContext : DWORD) : HRESULT; stdcall;
  680. // Set the default attribute to use for text that is not in a
  681. // script block. (If not explicitly set, the default attributes for
  682. // text outside of a script block is SOURCETEXT_ATTR_NONSOURCE.)
  683. //
  684. // This would allow, for example, for text outside of script blocks
  685. // to be colored grey and marked read-only.
  686. function SetDefaultTextAttr(staTextAttr : TSourceTextAttr) : HRESULT; stdcall;
  687. // Explicilty set the attributes on a range of text, overriding any
  688. // other attributes on that text.
  689. //
  690. // It is an error to set the attributes on a text range that has not
  691. // yet been added using AddText.
  692. function SetTextAttributes(const ulCharOffset, cChars : ULONG; const pstaTextAttr : TSourceTextAttr) : HRESULT; stdcall;
  693. // Set a new long name for the document
  694. function SetLongName(const pszLongName : PWideChar) : HRESULT; stdcall;
  695. // Set a new short name for the document
  696. function SetShortName(const pszShortName : PWideChar) : HRESULT; stdcall;
  697. // Define a new set of document attributes
  698. function SetDocumentAttr(const pszAttributes : TTextDocAttr) : HRESULT; stdcall;
  699. // Return the debug application node corresponding to this document
  700. function GetDebugApplicationNode(out ppdan : IDebugApplicationNode) : HRESULT; stdcall;
  701. // Once a script block has been defined, this method allows the
  702. // associate range and script engine to be retrieved.
  703. function GetScriptBlockInfo(const dwSourceContext : DWORD;var ppasd : IActiveScript;
  704. var piCharPos : ULONG;var pcChars : ULONG) : HRESULT; stdcall;
  705. // Allows the host to create a new debug document context
  706. function CreateDebugDocumentContext(const iCharPos, cChars : ULONG;
  707. out ppddc : IDebugDocumentContext) : HRESULT; stdcall;
  708. // Bring this document to the top in the debugger UI.
  709. // If the debugger isn't started already, start it now.
  710. function BringDocumentToTop : HRESULT; stdcall;
  711. // Bring the given context in this document to the top
  712. // in the debugger UI.
  713. function BringDocumentContextToTop(pddc : IDebugDocumentContext) : HRESULT; stdcall;
  714. end;
  715. IProcessDebugManager = interface(IUnknown)
  716. ['{51973C2f-CB0C-11d0-B5C9-00A0244A0E7A}']
  717. // Creates a new debug application object. The new object is not added to the
  718. // running application list and has no name.
  719. function CreateApplication(out ppda : IDebugApplication) : HRESULT; stdcall;
  720. // Returns a default application object for the current process, creating one and adding
  721. // it to the running application list if necessary. Language engines should use this
  722. // application if they are running on a host that does not provide an application.
  723. function GetDefaultApplication(out ppda : IDebugApplication) : HRESULT; stdcall;
  724. // Adds an application to the running application list in the machine debug manager.
  725. function AddApplication(const pda : IDebugApplication;
  726. out pdwAppCookie : DWORD // Returns a cookie used to remove the application from the machine debug manager.
  727. ) : HRESULT; stdcall;
  728. // Removes an application from the running application list.
  729. function RemoveApplication(const dwAppCookie : DWORD) : HRESULT; stdcall;// The cookie provided by AddApplication.
  730. function CreateDebugDocumentHelper(const punkOuter : IUnknown; out pddh : IDebugDocumentHelper) : HRESULT; stdcall;
  731. end;
  732. TDebugPropertyInfo = packed record
  733. m_dwValidFields : TDbgPropInfoFlags; // which DebugPropertyInfo fields were successfully initialized
  734. m_bstrName : TBSTR; // property name
  735. m_bstrType : TBSTR; // property type, as formatted string
  736. m_bstrValue : TBSTR; // property value, as formatted string
  737. m_bstrFullName : TBSTR; // property's full name, like pObject->m_fFlag
  738. m_dwAttrib : TDbgPropAttribFlags; // property attributes
  739. m_pDebugProp : IDebugProperty; // IDebugProperty object corresponding to this DebugPropertyInfo
  740. end;
  741. PDebugPropertyInfo = ^TDebugPropertyInfo;
  742. IEnumDebugPropertyInfo = interface (IUnknown)
  743. ['{51973C51-CB0C-11d0-B5C9-00A0244A0E7A}']
  744. function Next(const celt : ULONG;
  745. out pi : TDebugPropertyInfo;
  746. out pceltFetched : ULONG) : HRESULT; stdcall;
  747. function Skip(const celt : ULONG) : HRESULT; stdcall;
  748. function Reset : HRESULT; stdcall;
  749. function Clone(out ppepi : IEnumDebugPropertyInfo) : HRESULT; stdcall;
  750. function GetCount(out pcelt : ULONG) : HRESULT; stdcall;
  751. end;
  752. IDebugProperty = interface(IUnknown)
  753. ['{51973C50-CB0C-11d0-B5C9-00A0244A0E7A}']
  754. // Get Information for this object
  755. // By setting various PROPERTY_INFO_FLAGS, any subset of the basic info
  756. // contained in DebugPropertyInfo can be fetched
  757. function GetPropertyInfo(const dwFieldSpec : TDBGPROPINFOFLAGS;
  758. const nRadix : UINT;out pPropertyInfo : TDebugPropertyInfo) : HRESULT; stdcall;
  759. // Get ExtendedInfo for this object. This API only exists for the purpose
  760. // of retrieving info that does not lend itself to being retrieved via the
  761. // standard means (i.e. using DebugPropertyInfo)
  762. //
  763. // An array of GUIDs and result VARIANTs is passed so that multiple items
  764. // of extended info can be fetched at the same time. If a variant cannot
  765. // be initialized for some reason, the vt field should be set to VT_ERROR.
  766. // The currently defined extended info guids are described below.
  767. // A QI is typically required to obtain interfaces on the right from
  768. // IUnknowns in the variant.
  769. // GUID VALUE
  770. //
  771. // guidDefinitionContext IDebugDocumentContext2
  772. // ISSUE: Add additional GUIDS, such as:
  773. // <guidSomeRandomBSTR> BSTR
  774. // <guidSomeRandomI4> I4
  775. function GetExtendedInfo(const cInfos : ULONG; const rgguidExtendedInfo : TGUID;
  776. out rgvar : POleVariant) : HRESULT; stdcall;
  777. // Set the value of this object as a string
  778. function SetValueAsString(const pszValue : PWideChar;const nRadix : UINT) : HRESULT; stdcall;
  779. // Get enumerator for props of members
  780. function EnumMembers(const dwFieldSpec : TDBGPROPINFOFLAGS; const nRadix : UINT;
  781. const refiid : TCLSID; out ppepi : IEnumDebugPropertyInfo) : HRESULT; stdcall;
  782. // Get the parent property
  783. function GetParent(out ppDebugProp : IDebugProperty) : HRESULT; stdcall;
  784. end;
  785. IDebugDocumentInfo = interface(IUnknown)
  786. ['{51973C1f-CB0C-11d0-B5C9-00A0244A0E7A}']
  787. // Returns the specified name for the document. If the indicated name is
  788. // not known, E_FAIL is returned.
  789. function GetName(const dnt : TDOCUMENTNAMETYPE; out pbstrName:WideString): HRESULT; stdcall;
  790. // Returns a CLSID describing the document type. This allows the debugger IDE
  791. // to host custom viewers for this document. returns CLSID_NULL if this document
  792. // does not have viewable data.
  793. function GetDocumentClassId(out pclsidDocument : TCLSID): HRESULT; stdcall;
  794. end;
  795. //The base interface to all debug documents.
  796. IDebugDocument = interface(IDebugDocumentInfo)
  797. ['{51973C21-CB0C-11d0-B5C9-00A0244A0E7A}']
  798. end;
  799. IDebugDocumentContext = interface (IUnknown)
  800. ['{51973C28-CB0C-11d0-B5C9-00A0244A0E7A}']
  801. // Returns the document that contains this context.
  802. function GetDocument(out ppsd : IDebugDocument) : HRESULT; stdcall;
  803. // Enumerates the code contexts associated with this document context. Generally there will
  804. // only be one code context but there are important exceptions, such as include file
  805. // or templates (in C++).
  806. function EnumCodeContexts(out ppescc : IEnumDebugCodeContexts) : HRESULT; stdcall;
  807. end;
  808. IDebugCodeContext = interface(IUnknown)
  809. ['{51973C13-CB0C-11d0-B5C9-00A0244A0E7A}']
  810. // Returns the document context associated with this code context.
  811. //
  812. // Note: For text documents, the character-position
  813. // range should include the text for the entire statement. This allows the debugger IDE
  814. // to hilight the current source statement.
  815. function GetDocumentContext(out ppsc : IDebugDocumentContext) : HRESULT; stdcall;
  816. // Sets or clears a breakpoint at this code context.
  817. function SetBreakPoint(const bps : TBreakPointState) : HRESULT; stdcall;
  818. end;
  819. IEnumDebugCodeContexts = interface (IUnknown)
  820. ['{51973C1d-CB0C-11d0-B5C9-00A0244A0E7A}']
  821. function Next(const celt : ULONG;
  822. out pscc : IDebugCodeContext;
  823. out pceltFetched : ULONG) : HRESULT; stdcall;
  824. function Skip(const celt : ULONG) : HRESULT; stdcall;
  825. function Reset : HRESULT; stdcall;
  826. function Clone(out ppescc : IEnumDebugCodeContexts) : HRESULT; stdcall;
  827. end;
  828. IRemoteDebugApplicationThread = interface;
  829. IActiveScriptErrorDebug = interface;
  830. IApplicationDebugger = interface(IUnknown)
  831. ['{51973C2a-CB0C-11d0-B5C9-00A0244A0E7A}']
  832. // Indicates if the debugger is alive. Should always return S_OK. If the debugger
  833. // has rudely shut down COM will return an error from the marshalling proxy.
  834. function QueryAlive : HRESULT; stdcall;
  835. // Provides a mechanism for hosts and language engines running out-of-process to the
  836. // debugger to create objects in the debugger process. This can be used for any purpose,
  837. // including extending the debugger UI. This method simply delegates to CoCreateInstance.
  838. function CreateInstanceAtDebugger(
  839. const rclsid : TCLSID;// Class identifier (CLSID) of the object
  840. const pUnkOuter : IUnknown; // Object is or isn't part of an aggregate
  841. const dwClsContext : DWORD; // Context for running executable code
  842. const riid : TIID; // Interface identifier
  843. out ppvObject : IUnknown) : HRESULT; stdcall;
  844. // Points to requested interface pointer
  845. // This method is called when IDebugApplication::DebugOutput is called. The debugger
  846. // can use this to display the string in an output window.
  847. function onDebugOutput(const pstr : PWideChar) : HRESULT; stdcall;
  848. // This method is called when a breakpoint is hit. The application will remain
  849. // suspended until the debugger IDE calls IDebugApplication::ResumeFromBreakPoint.
  850. function onHandleBreakPoint(
  851. // Indicates the thread in which the breakpoint occured.
  852. const prpt : IRemoteDebugApplicationThread;
  853. // Indicates the reason for the breakpoint.
  854. const br : TBreakReason;
  855. // optional runtime error info (for when br == BREAKREASON_ERROR)
  856. const pError : IActiveScriptErrorDebug) : HRESULT; stdcall;
  857. // This method is called when IDebugApplication::Close is called.
  858. function onClose : HRESULT; stdcall;
  859. // Handle a custom event.
  860. // The semantics of the GUID and IUnknown are entirely application/debugger defined
  861. // This method may return E_NOTIMPL.
  862. function onDebuggerEvent(const riid : TIID; const punk : IUnknown) : HRESULT; stdcall;
  863. end;
  864. IEnumRemoteDebugApplicationThreads = interface (IUnknown)
  865. ['{51973C3c-CB0C-11d0-B5C9-00A0244A0E7A}']
  866. function Next(const celt : ULONG; out pprdat : IRemoteDebugApplicationThread;
  867. out pceltFetched : ULONG) : HRESULT; stdcall;
  868. function Skip(const celt : ULONG) : HRESULT; stdcall;
  869. function Reset : HRESULT; stdcall;
  870. function Clone(out pperdat : IEnumRemoteDebugApplicationThreads) : HRESULT; stdcall;
  871. end;
  872. IDebugExpressionCallBack = interface (IUnknown)
  873. ['{51973C16-CB0C-11d0-B5C9-00A0244A0E7A}']
  874. // Indicates that the expression evaluation is complete. Note that
  875. // IDebugExpression::GetResultAsString can be called from within this event
  876. // handler.
  877. function onComplete : HRESULT; stdcall;
  878. end;
  879. IDebugExpression = interface(IUnknown)
  880. ['{51973C14-CB0C-11d0-B5C9-00A0244A0E7A}']
  881. // Begins the evaluation of the expression.
  882. function Start(
  883. // Provides an event driven means for indicating that the expression evaluation
  884. // is complete. If NULL, no events will be fired and the client will need to
  885. // poll the expression state using QueryIsComplete.
  886. const pdecb : IDebugExpressionCallBack) : HRESULT; stdcall;
  887. // Aborts the expression. Evaluation of an expression in progress will be stopped
  888. // at the earliest opportunity. If the expression is actually aborted, GetResultAsString
  889. // will return E_ABORT as phrResult.
  890. function Abort : HRESULT; stdcall;
  891. // Returns S_FALSE if the operation is still pending.
  892. // Returns S_OK if the operation is complete.
  893. function QueryIsComplete : HRESULT; stdcall;
  894. // Returns the result of the expression evaluation as a string and an HRESULT. Returns
  895. // E_PENDING if the operation is still pending. Returns S_OK and E_ABORT in phrResult
  896. // when the operation was aborted with Abort.
  897. function GetResultAsString(out phrResult : HRESULT; out pbstrResult : TBSTR) : HRESULT; stdcall;
  898. // Returns the result of the expression evaluation as an
  899. // IDebugProperty and an HRESULT. Returns
  900. // E_PENDING if the operation is still pending. Returns S_OK and E_ABORT in phrResult
  901. // when the operation was aborted with Abort.
  902. function GetResultAsDebugProperty(out phrResult : HRESULT; out ppdp : IDebugProperty) : HRESULT; stdcall;
  903. end;
  904. IDebugExpressionContext = interface(IUnknown)
  905. ['{51973C15-CB0C-11d0-B5C9-00A0244A0E7A}']
  906. // Creates an IDebugExpression for the specified text.
  907. function ParseLanguageText(
  908. // Provides the text of the expression or statement(s).
  909. const pstrCode : PWideChar;
  910. // Radix to use
  911. const nRadix : UINT;
  912. // See IActiveScriptParse::ParseScriptText
  913. const pstrDelimiter : PWideChar;
  914. // See above flags.
  915. const dwFlags : DWORD;
  916. // Returns the IDebugExpression for the given text.
  917. out ppe : IDebugExpression) : HRESULT; stdcall;
  918. end;
  919. IEnumDebugExpressionContexts = interface(IUnknown)
  920. ['{51973C40-CB0C-11d0-B5C9-00A0244A0E7A}']
  921. function Next(const celt : ULONG;out ppdec : IDebugExpressionContext;out pceltFetched : ULONG) : HRESULT; stdcall;
  922. function Skip(const celt : ULONG) : HRESULT; stdcall;
  923. function Reset : HRESULT; stdcall;
  924. function Clone(out ppedec : IEnumDebugExpressionContexts) : HRESULT; stdcall;
  925. end;
  926. IRemoteDebugApplication = interface(IUnknown)
  927. ['{51973C30-CB0C-11d0-B5C9-00A0244A0E7A}']
  928. // Continue an application which is currently in a breakpoint.
  929. function ResumeFromBreakPoint(
  930. // For stepping modes, the thread which is to be affected by the stepping mode.
  931. const prptFocus : IRemoteDebugApplicationThread;
  932. // The action to take (step mode, etc.) upon resuming the application
  933. const bra : TBreakResumeAction;
  934. // the action to take in the case that we stopped because of an error
  935. const era : TErrorResumeAction) : HRESULT; stdcall;
  936. // Causes the application to break into the debugger at the earliest opportunity. Note
  937. // that a long time may elapse before the application actually breaks, particularly if
  938. // the application is not currently executing script code.
  939. function CauseBreak : HRESULT; stdcall;
  940. // Connects a debugger to the application. Only one debugger may be connected at a
  941. // time; this method fails if there is already a debugger connected
  942. function ConnectDebugger(const pad : IApplicationDebugger) : HRESULT; stdcall;
  943. // Disconnects the current debugger from the application.
  944. function DisconnectDebugger : HRESULT; stdcall;
  945. // Returns the current debugger connected to the application.
  946. function GetDebugger(out pad : IApplicationDebugger) : HRESULT; stdcall;
  947. // Provides a mechanism for the debugger IDE, running out-of-process to the
  948. // application, to create objects in the application process.
  949. // This method simply delegates to CoCreateInstance.
  950. function CreateInstanceAtApplication(
  951. const rclsid : TCLSID;// Class identifier (CLSID) of the object
  952. // Note: This parameter may have to be removed.
  953. const pUnkOuter : IUnknown;// Object is or isn't part of an aggregate
  954. const dwClsContext : DWORD;// Context for running executable code
  955. const riid : TIID;// Interface identifier
  956. out ppvObject : IUnknown) : HRESULT; stdcall;
  957. // Points to requested interface pointer
  958. // Indicates if the application is alive. Should always return S_OK. If the application
  959. // process has rudely shut down COM will return an error from the marshalling proxy.
  960. function QueryAlive : HRESULT; stdcall;
  961. // Enumerates all threads known to be associated with the application.
  962. // New threads may be added at any time.
  963. function EnumThreads(out pperdat : IEnumRemoteDebugApplicationThreads) : HRESULT; stdcall;
  964. // Returns the application node under which all nodes associated with the
  965. // application are added.
  966. function GetName(out pbstrName:WideString) : HRESULT; stdcall;
  967. // Returns a node for the application
  968. function GetRootNode(out ppdanRoot : IDebugApplicationNode) : HRESULT; stdcall;
  969. // Returns an enumerator that lists the global expression
  970. // contexts for all languages running in this application
  971. function EnumGlobalExpressionContexts (out ppedec : IEnumDebugExpressionContexts) : HRESULT; stdcall;
  972. end;
  973. IDebugStackFrame = interface;
  974. TDebugStackFrameDescriptor = record
  975. pdsf : IDebugStackFrame;
  976. dwMin : DWORD;
  977. dwLim : DWORD;
  978. fFinal : BOOL;
  979. punkFinal : IUnknown;
  980. end;
  981. IEnumDebugStackFrames = interface;
  982. IRemoteDebugApplicationThread = interface(IUnknown)
  983. ['{51973C37-CB0C-11d0-B5C9-00A0244A0E7A}']
  984. // Returns an operating system dependent identifier associated with the thread.
  985. // Note: The returned value does not need to be unique across machines.
  986. function GetSystemThreadId(out dwThreadId : DWORD) : HRESULT; stdcall;
  987. // Returns the application object associated with the thread.
  988. function GetApplication(out pprda : IRemoteDebugApplication) : HRESULT; stdcall;
  989. // Returns an enumerator for the stack frames associated with the thread. Can only
  990. // be called when in a breakpoint. The stack frame enumerator enumerates stack frames
  991. // in the most recently called order.
  992. function EnumStackFrames(out ppedsf : IEnumDebugStackFrames) : HRESULT; stdcall;
  993. function GetDescription(out pbstrDescription, pbstrState : TBSTR) : HRESULT; stdcall;
  994. // Forces execution to continue as close as possible to the
  995. // given code context, in the context of the given frame.
  996. // Either of these arguments may be NULL, representing the
  997. // current frame or context.
  998. function SetNextStatement (const pStackFrame : IDebugStackFrame;
  999. const pCodeContext :IDebugCodeContext) : HRESULT; stdcall;
  1000. // returns the current state of the thread
  1001. function GetState (out pState : DWORD) : HRESULT; stdcall;
  1002. // suspends the thread (increments the suspend count)
  1003. function Suspend (out pdwCount : DWORD) : HRESULT; stdcall;
  1004. // resumes the thread (decrements the suspend count)
  1005. function Resume (out pdwCount : DWORD) : HRESULT; stdcall;
  1006. // returns the current suspend count of the thread
  1007. function GetSuspendCount (out pdwCount : DWORD) : HRESULT; stdcall;
  1008. end;
  1009. IDebugThreadCall = interface(IUnknown)
  1010. ['{51973C36-CB0C-11d0-B5C9-00A0244A0E7A}']
  1011. function ThreadCallHandler(const dwParam1, dwParam2, dwParam3 : DWORD) : HRESULT; stdcall;
  1012. end;
  1013. IDebugApplicationThread = interface(IRemoteDebugApplicationThread)
  1014. ['{51973C38-CB0C-11d0-B5C9-00A0244A0E7A}']
  1015. // Provides a mechanism for the caller to run code in another thread. This is generally
  1016. // used so that language engines and hosts can implement free threaded objects on top
  1017. // of their single threaded implementations.
  1018. function SynchronousCallIntoThread(
  1019. // The interface to be called back in the target thread.
  1020. const pstcb : IDebugThreadCall;
  1021. // Three arguments passed to the IDebugThreadCall.
  1022. const dwParam1 : DWORD;
  1023. const dwParam2 : DWORD;
  1024. const dwParam3 : DWORD) : HRESULT; stdcall;
  1025. // Returns S_OK when this is the currently running thread. Otherwise S_FALSE is returned.
  1026. function QueryIsCurrentThread : HRESULT; stdcall;
  1027. // Returns S_OK when this is the debugger thread. Otherwise, returns S_FALSE.
  1028. function QueryIsDebuggerThread : HRESULT; stdcall;
  1029. function SetDescription(const pstrDescription : PWideChar) : HRESULT; stdcall;
  1030. function SetStateString(const pstrState : PWideChar) : HRESULT; stdcall;
  1031. end;
  1032. IDebugStackFrame = interface (IUnknown)
  1033. ['{51973C17-CB0C-11d0-B5C9-00A0244A0E7A}']
  1034. // Returns the current code context associated with the stack frame.
  1035. function GetCodeContext(out ppcc : IDebugCodeContext) : HRESULT; stdcall;
  1036. // Returns a short or long textual description of the stack frame.
  1037. // Normally, when fLong if false, this will provide only the name of the
  1038. // function associated with the stack frame. When fLong is true it may
  1039. // also provide the parameter(s) to the function or whatever else is
  1040. // relevant.
  1041. function GetDescriptionString(const fLong : BOOL;out pbstrDescription : WideString) : HRESULT; stdcall;
  1042. // Returns a short or long textual description of the language. When fLong
  1043. // is false, just the language name should be provided, eg, "Pascal". When
  1044. // fLong is true a full product description may be provided, eg,
  1045. // "Gnat Software's Flaming Pascal v3.72".
  1046. function GetLanguageString(const fLong : BOOL;out pbstrLanguage : TBSTR) : HRESULT; stdcall;
  1047. // Returns the thread associated with this stack frame.
  1048. function GetThread(out ppat : IDebugApplicationThread) : HRESULT; stdcall;
  1049. // Returns a property browser for the current frame (locals, etc.)
  1050. function GetDebugProperty(out ppDebugProp : IDebugProperty) : HRESULT; stdcall;
  1051. end;
  1052. IActiveScriptErrorDebug = interface(IActiveScriptError)
  1053. ['{51973C12-CB0C-11d0-B5C9-00A0244A0E7A}']
  1054. // Provides the document context for the associated error. The character-position range
  1055. // should include the entire offending text.
  1056. function GetDocumentContext(out ppssc : IDebugDocumentContext) : HRESULT; stdcall;
  1057. // For runtime errors, provides the stack frame that is in effect.
  1058. function GetStackFrame(out ppdsf : IDebugStackFrame) : HRESULT; stdcall;
  1059. end;
  1060. IActiveScriptDebug = interface(IUnknown)
  1061. ['{51973C10-CB0C-11d0-B5C9-00A0244A0E7A}']
  1062. // Returns the text attributes for an arbitrary block of script text. Smart hosts
  1063. // use this call to delegate GetText calls made on their IDebugDocumentText.
  1064. function GetScriptTextAttributes(
  1065. // The script block text. This string need not be null terminated.
  1066. const Code : PWideChar;
  1067. // The number of characters in the script block text.
  1068. const NumCodeChars : ULONG;
  1069. // See IActiveScriptParse::ParseScriptText for a description of this argument.
  1070. const pstrDelimiter : PWideChar;
  1071. // See IActiveScriptParse::ParseScriptText for a description of this argument.
  1072. const dwFlags : DWORD;
  1073. // Buffer to contain the returned attributes.
  1074. var pattr) : HRESULT; stdcall;
  1075. // Returns the text attributes for an arbitrary scriptlet. Smart hosts
  1076. // use this call to delegate GetText calls made on their IDebugDocumentText.
  1077. // Note: this call is provided because scriptlets tend to be expressions and
  1078. // may have a different syntax than a script block. For many languages the implementation
  1079. // will be identical to GetScriptTextAttributes.
  1080. function GetScriptletTextAttributes(
  1081. // The script block text. This string need not be null terminated.
  1082. const Code : PWideChar;
  1083. // The number of characters in the script block text.
  1084. const NumCodeChars : ULONG;
  1085. // See IActiveScriptParse::AddScriptlet for a description of this argument.
  1086. const pstrDelimiter : PWideChar;
  1087. // See IActiveScriptParse::AddScriptlet for a description of this argument.
  1088. const dwFlags : DWORD;
  1089. // Buffer to contain the returned attributes.
  1090. out pattr) : HRESULT; stdcall;
  1091. // Used by the smart host to delegate IDebugDocumentContext::EnumDebugCodeContexts.
  1092. function EnumCodeContextsOfPosition(
  1093. // As provided to IActiveScriptParse::ParseScriptText
  1094. // or IActiveScriptParse::AddScriptlet
  1095. const dwSourceContext : DWORD;
  1096. // character offset relative
  1097. // to start of script text
  1098. const uCharacterOffset : ULONG;
  1099. // Number of characters in context
  1100. const NumChars : ULONG;
  1101. // Returns an enumerator of code contexts.
  1102. out ppescc : IEnumDebugCodeContexts) : HRESULT; stdcall;
  1103. end;
  1104. IEnumDebugApplicationNodes = interface (IUnknown)
  1105. ['{51973C3a-CB0C-11d0-B5C9-00A0244A0E7A}']
  1106. function Next(const celt : ULONG; out pprddp : IDebugApplicationNode;out pceltFetched : ULONG) : HRESULT; stdcall;
  1107. function Skip(const celt : ULONG) : HRESULT; stdcall;
  1108. function Reset : HRESULT; stdcall;
  1109. function Clone(out pperddp : IEnumDebugApplicationNodes) : HRESULT; stdcall;
  1110. end;
  1111. IEnumDebugStackFrames = interface(IUnknown)
  1112. ['{51973C1e-CB0C-11d0-B5C9-00A0244A0E7A}']
  1113. function Next(const celt : ULONG; out prgdsfd : TDebugStackFrameDescriptor; out pceltFetched : ULONG) : HRESULT; stdcall;
  1114. function Skip(const celt : ULONG) : HRESULT; stdcall;
  1115. function Reset : HRESULT; stdcall;
  1116. function Clone(out ppedsf : IEnumDebugStackFrames) : HRESULT; stdcall;
  1117. end;
  1118. IDebugDocumentProvider = interface (IDebugDocumentInfo)
  1119. ['{51973C20-CB0C-11d0-B5C9-00A0244A0E7A}']
  1120. // Causes the document to be instantiated if it does not already exist.
  1121. function GetDocument(out ppssd : IDebugDocument): HRESULT; stdcall;
  1122. end;
  1123. IDebugApplicationNode = interface (IDebugDocumentProvider)
  1124. ['{51973C34-CB0C-11d0-B5C9-00A0244A0E7A}']
  1125. function EnumChildren(out pperddp : IEnumDebugApplicationNodes) : HRESULT; stdcall;
  1126. function GetParent(out pprddp : IDebugApplicationNode) : HRESULT; stdcall;
  1127. function SetDocumentProvider(const pddp : IDebugDocumentProvider) : HRESULT; stdcall;
  1128. function Close : HRESULT; stdcall;
  1129. function Attach(const pdanParent : IDebugApplicationNode) : HRESULT; stdcall;
  1130. function Detach : HRESULT; stdcall;
  1131. end;
  1132. IDebugSyncOperation = interface(IUnknown)
  1133. ['{51973C1a-CB0C-11d0-B5C9-00A0244A0E7A}']
  1134. // Get TargetThread is called by PDM to determine what thread
  1135. // to call Evaluate() in
  1136. function GetTargetThread(out ppatTarget : IDebugApplicationThread): HRESULT; stdcall;
  1137. // Execute is called synchronously by the PDM in the target thread. It
  1138. // synchronously peforms the operation and returns. It returns E_ABORT if
  1139. // the operation was aborted with InProgressAbort();
  1140. function Execute(out ppunkResult : IUnknown) : HRESULT; stdcall;
  1141. // InProgressAbort() is called by the PDM, from within the debugger thread,
  1142. // to cancel an operation which is in progress in another thread. The
  1143. // op