private void Parse(string documentName, string code, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo, bool discard) { var formattedCode = FormatCode ? MiscHelpers.FormatCode(code) : code; DebugDocument debugDocument; var sourceContext = CreateDebugDocument(documentName, formattedCode, discard, out debugDocument); if (sourceContext != UIntPtr.Zero) { flags |= ScriptTextFlags.HostManagesSource; } try { activeScript.ParseScriptText(formattedCode, null, null, null, sourceContext, 0, flags, pVarResult, out excepInfo); } finally { if (discard && (sourceContext != UIntPtr.Zero)) { debugDocumentMap.Remove(sourceContext); debugDocument.Close(); } } }
/// <summary> /// Executes a script text /// </summary> /// <param name="code">Script text</param> /// <param name="documentName">Document name</param> /// <param name="isExpression">Flag that script text needs to run as an expression</param> /// <returns>Result of the execution</returns> private object InnerExecute(string code, string documentName, bool isExpression) { object result; DebugDocument debugDocument; UIntPtr sourceContext = CreateDebugDocument(documentName, code, out debugDocument); ScriptTextFlags flags = isExpression ? ScriptTextFlags.IsExpression : ScriptTextFlags.IsVisible; if (sourceContext != UIntPtr.Zero) { flags |= ScriptTextFlags.HostManagesSource; } try { result = _activeScriptWrapper.ParseScriptText(code, null, null, null, sourceContext, 0, flags); } catch { ThrowError(); throw; } // Check for parse error ThrowError(); return(result); }
private void Parse(DocumentInfo documentInfo, string code, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo) { var formattedCode = FormatCode ? MiscHelpers.FormatCode(code) : code; DebugDocument debugDocument; var sourceContext = CreateDebugDocument(documentInfo, formattedCode, out debugDocument); if (sourceContext != UIntPtr.Zero) { flags |= ScriptTextFlags.HostManagesSource; } try { activeScript.ParseScriptText(formattedCode, null, null, null, sourceContext, 0, flags, pVarResult, out excepInfo); } finally { if (documentInfo.Flags.GetValueOrDefault().HasFlag(DocumentFlags.IsTransient) && (sourceContext != UIntPtr.Zero)) { debugDocumentMap.Remove(sourceContext); debugDocument.Close(); } } }
internal override object Execute(string documentName, string code, bool evaluate, bool discard) { VerifyNotDisposed(); object result = null; ScriptInvoke(() => { EXCEPINFO excepInfo; if (!evaluate) { const ScriptTextFlags flags = ScriptTextFlags.IsVisible; Parse(documentName, code, flags, IntPtr.Zero, out excepInfo, discard); } else { var pVarResult = Marshal.AllocCoTaskMem(256); try { const ScriptTextFlags flags = ScriptTextFlags.IsExpression; Parse(documentName, code, flags, pVarResult, out excepInfo, discard); result = Marshal.GetObjectForNativeVariant(pVarResult); } finally { Marshal.FreeCoTaskMem(pVarResult); } } }); return(result); }
/// <summary> /// Adds a code scriptlet to the script. This method is used in environments where the /// persistent state of the script is intertwined with the host document and the host /// is responsible for restoring the script, rather than through an IPersist* interface. /// The primary examples are HTML scripting languages that allow scriptlets of code /// embedded in the HTML document to be attached to intrinsic events (for instance, /// ONCLICK="button1.text='Exit'"). /// </summary> /// <param name="defaultName">The 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.</param> /// <param name="code">The scriptlet text to add. The interpretation of this string /// depends on the scripting language.</param> /// <param name="itemName">The item name associated with this scriptlet. This parameter, /// in addition to pstrSubItemName, identifies the object for which the scriptlet is /// an event handler.</param> /// <param name="subItemName">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.</param> /// <param name="eventName">The name of the event for which the scriptlet is an event /// handler.</param> /// <param name="delimiter">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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes.</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at.</param> /// <param name="flags">Flags associated with the scriptlet.</param> /// <returns> /// 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. /// </returns> public string AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { string name; if (_parse32 != null) { _parse32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); } else if (_parse64 != null) { _parse64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); } else { throw new NotImplementedException(NeitherValidMessage); } return(name); }
internal sealed override object ExecuteRaw(UniqueDocumentInfo documentInfo, string code, bool evaluate) { if (!evaluate) { const ScriptTextFlags flags = ScriptTextFlags.IsVisible; Parse(documentInfo, code, flags, IntPtr.Zero, out _); return(null); } using (var resultVariantBlock = new CoTaskMemVariantBlock()) { const ScriptTextFlags flags = ScriptTextFlags.IsExpression; Parse(documentInfo, code, flags, resultVariantBlock.Addr, out _); return(Marshal.GetObjectForNativeVariant(resultVariantBlock.Addr)); } }
/// <summary> /// Adds a code scriptlet to the script. This method is used in environments where the /// persistent state of the script is intertwined with the host document and the host /// is responsible for restoring the script, rather than through an IPersist* interface. /// The primary examples are HTML scripting languages that allow scriptlets of code /// embedded in the HTML document to be attached to intrinsic events (for instance, /// ONCLICK="button1.text='Exit'"). /// </summary> /// <param name="defaultName">The 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.</param> /// <param name="code">The scriptlet text to add. The interpretation of this string /// depends on the scripting language.</param> /// <param name="itemName">The item name associated with this scriptlet. This parameter, /// in addition to pstrSubItemName, identifies the object for which the scriptlet is /// an event handler.</param> /// <param name="subItemName">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.</param> /// <param name="eventName">The name of the event for which the scriptlet is an event /// handler.</param> /// <param name="delimiter">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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// 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. /// </returns> public string AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { string name; if (_is64Bit) { _activeScriptParse64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _lastException); } else { _activeScriptParse32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _lastException); } return(name); }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language.</param> /// <param name="itemName">The 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.</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes.</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at.</param> /// <param name="flags">Flags associated with the scriptlet.</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_parse32 != null) { _parse32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else if (_parse64 != null) { _parse64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else { throw new NotImplementedException(NeitherValidMessage); } return(result); }
public void AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, ulong sourceContext, uint startingLineNumber, ScriptTextFlags flags, out string name, out EXCEPINFO excepInfo) { if (is64Bit) { activeScriptParse64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContext, startingLineNumber, flags, out name, out excepInfo); } else { activeScriptParse32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, (uint)sourceContext, startingLineNumber, flags, out name, out excepInfo); } }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language</param> /// <param name="itemName">The 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</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_parser32 != null) { _parser32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else if (_parser64 != null) { _parser64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else { throw new NotImplementedException(Strings.Runtime_InvalidParserImplementationError); } return(result); }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language</param> /// <param name="itemName">The 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</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_is64Bit) { _activeScriptParse64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _lastException); } else { _activeScriptParse32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _lastException); } return(result); }
internal override object Execute(string documentName, string code, bool evaluate, bool discard) { VerifyNotDisposed(); return(ScriptInvoke(() => { EXCEPINFO excepInfo; if (!evaluate) { const ScriptTextFlags flags = ScriptTextFlags.IsVisible; Parse(documentName, code, flags, IntPtr.Zero, out excepInfo, discard); return null; } using (var resultVariantBlock = new CoTaskMemVariantBlock()) { const ScriptTextFlags flags = ScriptTextFlags.IsExpression; Parse(documentName, code, flags, resultVariantBlock.Addr, out excepInfo, discard); return Marshal.GetObjectForNativeVariant(resultVariantBlock.Addr); } })); }
public void ParseScriptText( string code, string itemName, object context, string delimiter, ulong sourceContext, uint startingLineNumber, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo) { if (is64Bit) { activeScriptParse64.ParseScriptText( code, itemName, context, delimiter, sourceContext, startingLineNumber, flags, pVarResult, out excepInfo); } else { activeScriptParse32.ParseScriptText( code, itemName, context, delimiter, (uint)sourceContext, startingLineNumber, flags, pVarResult, out excepInfo); } }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language</param> /// <param name="itemName">The 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</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_parser32 != null) { _parser32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else if (_parser64 != null) { _parser64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); } else { throw new NotImplementedException(Strings.Runtime_InvalidParserImplementationError); } return result; }
public abstract void ParseScriptText(string code, string itemName, object context, string delimiter, UIntPtr sourceContext, uint startingLineNumber, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo);
public override void ParseScriptText(string code, string itemName, object context, string delimiter, UIntPtr sourceContext, uint startingLineNumber, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo) { activeScriptParse.ParseScriptText(code, itemName, context, delimiter, sourceContext.ToUInt64(), startingLineNumber, flags, pVarResult, out excepInfo); }
/// <summary> /// Adds a code scriptlet to the script. This method is used in environments where the /// persistent state of the script is intertwined with the host document and the host /// is responsible for restoring the script, rather than through an IPersist* interface. /// The primary examples are HTML scripting languages that allow scriptlets of code /// embedded in the HTML document to be attached to intrinsic events (for instance, /// ONCLICK="button1.text='Exit'"). /// </summary> /// <param name="defaultName">The 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.</param> /// <param name="code">The scriptlet text to add. The interpretation of this string /// depends on the scripting language.</param> /// <param name="itemName">The item name associated with this scriptlet. This parameter, /// in addition to pstrSubItemName, identifies the object for which the scriptlet is /// an event handler.</param> /// <param name="subItemName">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.</param> /// <param name="eventName">The name of the event for which the scriptlet is an event /// handler.</param> /// <param name="delimiter">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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// 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. /// </returns> public string AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { string name; if (_is64Bit) { _activeScriptParse64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _lastException); } else { _activeScriptParse32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _lastException); } return name; }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language</param> /// <param name="itemName">The 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</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_is64Bit) { _activeScriptParse64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _lastException); } else { _activeScriptParse32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _lastException); } return result; }
/// <summary> /// Adds a code scriptlet to the script. This method is used in environments where the /// persistent state of the script is intertwined with the host document and the host /// is responsible for restoring the script, rather than through an IPersist* interface. /// The primary examples are HTML scripting languages that allow scriptlets of code /// embedded in the HTML document to be attached to intrinsic events (for instance, /// ONCLICK="button1.text='Exit'"). /// </summary> /// <param name="defaultName">The 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.</param> /// <param name="code">The scriptlet text to add. The interpretation of this string /// depends on the scripting language.</param> /// <param name="itemName">The item name associated with this scriptlet. This parameter, /// in addition to pstrSubItemName, identifies the object for which the scriptlet is /// an event handler.</param> /// <param name="subItemName">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.</param> /// <param name="eventName">The name of the event for which the scriptlet is an event /// handler.</param> /// <param name="delimiter">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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes.</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at.</param> /// <param name="flags">Flags associated with the scriptlet.</param> /// <returns> /// 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. /// </returns> public string AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { string name; if (_parse32 != null) _parse32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); else if (_parse64 != null) _parse64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); else throw new NotImplementedException(NeitherValidMessage); return name; }
/// <summary> /// Parses the given code scriptlet, adding declarations into the namespace and /// evaluating code as appropriate. /// </summary> /// <param name="code">The scriptlet text to evaluate. The interpretation of this /// string depends on the scripting language.</param> /// <param name="itemName">The 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.</param> /// <param name="context">The context object. 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.</param> /// <param name="delimiter">The 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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes.</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at.</param> /// <param name="flags">Flags associated with the scriptlet.</param> /// <returns> /// The results of scriptlet processing, or NULL if the caller /// expects no result (that is, the SCRIPTTEXT_ISEXPRESSION value is not set). /// </returns> public object ParseScriptText( string code, string itemName, object context, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { object result; if (_parse32 != null) _parse32.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); else if (_parse64 != null) _parse64.ParseScriptText( code, itemName, context, delimiter, sourceContextCookie, startingLineNumber, flags, out result, out _exceptionInfo); else throw new NotImplementedException(NeitherValidMessage); return result; }
/// <summary> /// Adds a code scriptlet to the script. This method is used in environments where the /// persistent state of the script is intertwined with the host document and the host /// is responsible for restoring the script, rather than through an IPersist* interface. /// The primary examples are HTML scripting languages that allow scriptlets of code /// embedded in the HTML document to be attached to intrinsic events (for instance, /// ONCLICK="button1.text='Exit'"). /// </summary> /// <param name="defaultName">The 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.</param> /// <param name="code">The scriptlet text to add. The interpretation of this string /// depends on the scripting language.</param> /// <param name="itemName">The item name associated with this scriptlet. This parameter, /// in addition to pstrSubItemName, identifies the object for which the scriptlet is /// an event handler.</param> /// <param name="subItemName">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.</param> /// <param name="eventName">The name of the event for which the scriptlet is an event /// handler.</param> /// <param name="delimiter">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.</param> /// <param name="sourceContextCookie">Application-defined value that is used for /// debugging purposes</param> /// <param name="startingLineNumber">Zero-based value that specifies which line the /// parsing will begin at</param> /// <param name="flags">Flags associated with the scriptlet</param> /// <returns> /// 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. /// </returns> public string AddScriptlet( string defaultName, string code, string itemName, string subItemName, string eventName, string delimiter, IntPtr sourceContextCookie, uint startingLineNumber, ScriptTextFlags flags) { string name; if (_parser32 != null) { _parser32.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); } else if (_parser64 != null) { _parser64.AddScriptlet( defaultName, code, itemName, subItemName, eventName, delimiter, sourceContextCookie, startingLineNumber, flags, out name, out _exceptionInfo); } else { throw new NotImplementedException(Strings.Runtime_InvalidParserImplementationError); } return name; }