本文整理汇总了C#中Scriptable类的典型用法代码示例。如果您正苦于以下问题:C# Scriptable类的具体用法?C# Scriptable怎么用?C# Scriptable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Scriptable类属于命名空间,在下文中一共展示了Scriptable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ModuleScope
public ModuleScope(Scriptable prototype, Uri uri, Uri @base)
{
this.uri = uri;
[email protected] = @base;
SetPrototype(prototype);
CacheBuiltins();
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:ModuleScope.cs
示例2: Action
public virtual object Action(Context cx, Scriptable scope, Scriptable thisObj, object[] args, int actionType)
{
GlobData data = new GlobData();
data.mode = actionType;
switch (actionType)
{
case RegExpProxyConstants.RA_MATCH:
{
object rval;
data.optarg = 1;
rval = MatchOrReplace(cx, scope, thisObj, args, this, data, false);
return data.arrayobj == null ? rval : data.arrayobj;
}
case RegExpProxyConstants.RA_SEARCH:
{
data.optarg = 1;
return MatchOrReplace(cx, scope, thisObj, args, this, data, false);
}
case RegExpProxyConstants.RA_REPLACE:
{
object arg1 = args.Length < 2 ? Undefined.instance : args[1];
string repstr = null;
Function lambda = null;
if (arg1 is Function)
{
lambda = (Function)arg1;
}
else
{
repstr = ScriptRuntime.ToString(arg1);
}
data.optarg = 2;
data.lambda = lambda;
data.repstr = repstr;
data.dollar = repstr == null ? -1 : repstr.IndexOf('$');
data.charBuf = null;
data.leftIndex = 0;
object val = MatchOrReplace(cx, scope, thisObj, args, this, data, true);
if (data.charBuf == null)
{
if (data.global || val == null || !val.Equals(true))
{
return data.str;
}
SubString lc = this.leftContext;
Replace_glob(data, cx, scope, this, lc.index, lc.length);
}
SubString rc = this.rightContext;
data.charBuf.AppendRange(rc.str, rc.index, rc.index + rc.length);
return data.charBuf.ToString();
}
default:
{
throw Kit.CodeBug();
}
}
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:60,代码来源:RegExpImpl.cs
示例3: CreateFunction
/// <summary>Create function compiled from Function(...) constructor.</summary>
/// <remarks>Create function compiled from Function(...) constructor.</remarks>
internal static Rhino.InterpretedFunction CreateFunction(Context cx, Scriptable scope, InterpreterData idata, object staticSecurityDomain)
{
Rhino.InterpretedFunction f;
f = new Rhino.InterpretedFunction(idata, staticSecurityDomain);
f.InitScriptFunction(cx, scope);
return f;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:InterpretedFunction.cs
示例4: Construct
public override Scriptable Construct(Context cx, Scriptable scope, object[] args)
{
NativeRegExp re = new NativeRegExp();
re.Compile(cx, scope, args);
ScriptRuntime.SetBuiltinProtoAndParent(re, scope, TopLevel.Builtins.RegExp);
return re;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:NativeRegExpCtor.cs
示例5: RunFileIfExists
private static void RunFileIfExists(Context cx, Scriptable global, FilePath f)
{
if (f.IsFile())
{
Main.ProcessFileNoThrow(cx, global, f.GetPath());
}
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:ShellTest.cs
示例6: LoadFromPathArray
/// <exception cref="System.IO.IOException"></exception>
private ModuleSource LoadFromPathArray(string moduleId, Scriptable paths, object validator)
{
long llength = ScriptRuntime.ToUint32(ScriptableObject.GetProperty(paths, "length"));
// Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me.
int ilength = llength > int.MaxValue ? int.MaxValue : (int)llength;
for (int i = 0; i < ilength; ++i)
{
string path = EnsureTrailingSlash(ScriptableObject.GetTypedProperty<string>(paths, i));
try
{
Uri uri = new Uri(path);
if (!uri.IsAbsoluteUri)
{
uri = new FilePath(path).ToURI().Resolve(string.Empty);
}
ModuleSource moduleSource = LoadFromUri(uri.Resolve(moduleId), uri, validator);
if (moduleSource != null)
{
return moduleSource;
}
}
catch (URISyntaxException e)
{
throw new UriFormatException(e.Message);
}
}
return null;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:29,代码来源:ModuleSourceProviderBase.cs
示例7: Init
internal static void Init(Scriptable scope, bool @sealed)
{
Rhino.BaseFunction obj = new Rhino.BaseFunction();
// Function.prototype attributes: see ECMA 15.3.3.1
obj.prototypePropertyAttributes = DONTENUM | READONLY | PERMANENT;
obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:BaseFunction.cs
示例8: Init
internal static void Init(Scriptable scope, bool @sealed)
{
Rhino.NativeDate obj = new Rhino.NativeDate();
// Set the value of the prototype Date to NaN ('invalid date');
obj.date = ScriptRuntime.NaN;
obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:NativeDate.cs
示例9: Initialize
internal void Initialize(XMLLibImpl lib, Scriptable scope, XMLObject prototype)
{
SetParentScope(scope);
SetPrototype(prototype);
prototypeFlag = (prototype == null);
this.lib = lib;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:XMLObjectImpl.cs
示例10: Call
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
if (args.Length > 0 && args[0] is NativeRegExp && (args.Length == 1 || args[1] == Undefined.instance))
{
return args[0];
}
return Construct(cx, scope, args);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:NativeRegExpCtor.cs
示例11: HasInstance
public override bool HasInstance(Scriptable instance)
{
if (targetFunction is Function)
{
return ((Function)targetFunction).HasInstance(instance);
}
throw ScriptRuntime.TypeError0("msg.not.ctor");
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:BoundFunction.cs
示例12: Construct
public override Scriptable Construct(Context cx, Scriptable scope, object[] extraArgs)
{
if (targetFunction is Function)
{
return ((Function)targetFunction).Construct(cx, scope, Concat(boundArgs, extraArgs));
}
throw ScriptRuntime.TypeError0("msg.not.ctor");
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:BoundFunction.cs
示例13: Call
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
if (script != null)
{
return script.Exec(cx, scope);
}
return Undefined.instance;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:NativeScript.cs
示例14: Get
public virtual object Get(string id, Scriptable start)
{
if (start == this)
{
start = prototype;
}
return prototype.Get(id, start);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:NativeWith.cs
示例15: Has
public override bool Has(string name, Scriptable start)
{
if (this == thePrototypeInstance)
{
return base.Has(name, start);
}
return (Runtime.GetProperty(name) != null);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:Environment.cs
示例16: Call
/// <seealso cref="Function.Call(Context, Scriptable, Scriptable, object[])">Function.Call(Context, Scriptable, Scriptable, object[])</seealso>
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
object sync = syncObject != null ? syncObject : thisObj;
lock (sync is Wrapper ? ((Wrapper)sync).Unwrap() : sync)
{
return ((Function)obj).Call(cx, scope, thisObj, args);
}
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:Synchronizer.cs
示例17: Get
/// <summary>Search for ClassCache object in the given scope.</summary>
/// <remarks>
/// Search for ClassCache object in the given scope.
/// The method first calls
/// <see cref="ScriptableObject.GetTopLevelScope(Scriptable)">ScriptableObject.GetTopLevelScope(Scriptable)</see>
/// to get the top most scope and then tries to locate associated
/// ClassCache object in the prototype chain of the top scope.
/// </remarks>
/// <param name="scope">scope to search for ClassCache object.</param>
/// <returns>
/// previously associated ClassCache object or a new instance of
/// ClassCache if no ClassCache object was found.
/// </returns>
/// <seealso cref="Associate(ScriptableObject)">Associate(ScriptableObject)</seealso>
public static ClassCache Get(Scriptable scope)
{
ClassCache cache = (ClassCache)ScriptableObject.GetTopScopeValue(scope, AKEY);
if (cache == null)
{
throw new Exception("Can't find top level scope for " + "ClassCache.get");
}
return cache;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:23,代码来源:ClassCache.cs
示例18: Init
internal static void Init(Scriptable scope, bool @sealed)
{
NativeError obj = new NativeError();
ScriptableObject.PutProperty(obj, "name", "Error");
ScriptableObject.PutProperty(obj, "message", string.Empty);
ScriptableObject.PutProperty(obj, "fileName", string.Empty);
ScriptableObject.PutProperty(obj, "lineNumber", Sharpen.Extensions.ValueOf(0));
obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:NativeError.cs
示例19: Create
internal static Rhino.Xmlimpl.Namespace Create(Scriptable scope, Rhino.Xmlimpl.Namespace prototype, Rhino.Xmlimpl.XmlNode.Namespace @namespace)
{
Rhino.Xmlimpl.Namespace rv = new Rhino.Xmlimpl.Namespace();
rv.SetParentScope(scope);
rv.prototype = prototype;
rv.SetPrototype(prototype);
rv.ns = @namespace;
return rv;
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:Namespace.cs
示例20: HasInstance
/// <summary>Implements the instanceof operator for JavaScript Function objects.</summary>
/// <remarks>
/// Implements the instanceof operator for JavaScript Function objects.
/// <p>
/// <code>
/// foo = new Foo();<br />
/// foo instanceof Foo; // true<br />
/// </code>
/// </remarks>
/// <param name="instance">
/// The value that appeared on the LHS of the instanceof
/// operator
/// </param>
/// <returns>
/// true if the "prototype" property of "this" appears in
/// value's prototype chain
/// </returns>
public override bool HasInstance(Scriptable instance)
{
object protoProp = ScriptableObject.GetProperty(this, "prototype");
if (protoProp is Scriptable)
{
return ScriptRuntime.JsDelegatesTo(instance, (Scriptable)protoProp);
}
throw ScriptRuntime.TypeError1("msg.instanceof.bad.prototype", GetFunctionName());
}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:26,代码来源:BaseFunction.cs
注:本文中的Scriptable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论