本文整理汇总了C#中IScriptable类的典型用法代码示例。如果您正苦于以下问题:C# IScriptable类的具体用法?C# IScriptable怎么用?C# IScriptable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IScriptable类属于命名空间,在下文中一共展示了IScriptable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuiltinCall
internal BuiltinCall(BuiltinFunction function, IScriptable scope, object [] args)
{
this.function = function;
ParentScope = scope;
// leave prototype null
this.originalArgs = (args == null) ? ScriptRuntime.EmptyArgs : args;
// initialize values of arguments
int paramAndVarCount = function.ParamAndVarCount;
int paramCount = function.ParamCount;
if (paramAndVarCount != 0) {
for (int i = 0; i != paramCount; ++i) {
string name = function.getParamOrVarName (i);
object val = i < args.Length ? args [i] : Undefined.Value;
DefineProperty (name, val, PERMANENT);
}
}
// initialize "arguments" property but only if it was not overriden by
// the parameter with the same name
if (!base.Has ("arguments", this)) {
DefineProperty ("arguments", new Arguments (this), PERMANENT);
}
if (paramAndVarCount != 0) {
for (int i = paramCount; i != paramAndVarCount; ++i) {
string name = function.getParamOrVarName (i);
if (!base.Has (name, this)) {
DefineProperty (name, Undefined.Value, PERMANENT);
}
}
}
}
示例2: Call
public override object Call (Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
if (script != null) {
return script.Exec (cx, scope);
}
return Undefined.Value;
}
示例3: ToObject
public static IScriptable ToObject (IScriptable scope, object val)
{
if (val is IScriptable) {
return (IScriptable)val;
}
return ToObject (null, scope, val);
}
示例4: ExecIdCall
public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
if (!f.HasTag (BOOLEAN_TAG)) {
return base.ExecIdCall (f, cx, scope, thisObj, args);
}
int id = f.MethodId;
if (id == Id_constructor) {
bool b = ScriptConvert.ToBoolean (args, 0);
if (thisObj == null) {
return new BuiltinBoolean (b);
}
return b;
}
// The rest of Boolean.prototype methods require thisObj to be Boolean
if (!(thisObj is BuiltinBoolean))
throw IncompatibleCallError (f);
bool value = ((BuiltinBoolean)thisObj).booleanValue;
switch (id) {
case Id_toString:
return value ? "true" : "false";
case Id_toSource:
return value ? "(new Boolean(true))" : "(new Boolean(false))";
case Id_valueOf:
return value;
}
throw new ArgumentException (Convert.ToString (id));
}
示例5: ImportTypes
public static void ImportTypes(IScriptable scope, string startsWith)
{
foreach (Assembly ass in Context.CurrentContext.AppDomain.GetAssemblies())
{
ImportAssembly(scope, ass, startsWith);
}
}
示例6: ImportAssembly
public static void ImportAssembly(IScriptable scope, Assembly ass, string startsWith)
{
foreach (Type type in ass.GetTypes ()) {
if (startsWith == null || type.FullName.StartsWith (startsWith))
ImportType (scope, type);
}
}
示例7: Put
public override object Put (string id, IScriptable start, object value)
{
// Ignore assignments to "length"--it's readonly.
if (!id.Equals ("length"))
return base.Put (id, start, value);
return Undefined.Value;
}
示例8: BuiltinString
internal static void Init
(IScriptable scope, bool zealed)
{
BuiltinString obj = new BuiltinString ("");
obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed,
ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
}
示例9: Call
public override object Call (Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
if (args.Length > 0 && args [0] is BuiltinRegExp && (args.Length == 1 || args [1] == Undefined.Value)) {
return args [0];
}
return Construct (cx, scope, args);
}
示例10: Construct
public override IScriptable Construct (Context cx, IScriptable scope, object [] args)
{
BuiltinRegExp re = new BuiltinRegExp ();
re.compile (cx, scope, args);
ScriptRuntime.setObjectProtoAndParent (re, scope);
return re;
}
示例11: ExecIdCall
public override System.Object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, System.Object [] args)
{
if (!f.HasTag (XMLCTOR_TAG)) {
return base.ExecIdCall (f, cx, scope, thisObj, args);
}
int id = f.MethodId;
switch (id) {
case Id_defaultSettings: {
lib.SetDefaultSettings ();
IScriptable obj = cx.NewObject (scope);
WriteSetting (obj);
return obj;
}
case Id_settings: {
IScriptable obj = cx.NewObject (scope);
WriteSetting (obj);
return obj;
}
case Id_setSettings: {
if (args.Length == 0 || args [0] == null || args [0] == Undefined.Value) {
lib.SetDefaultSettings ();
}
else if (args [0] is IScriptable) {
ReadSettings ((IScriptable)args [0]);
}
return Undefined.Value;
}
}
throw new System.ArgumentException (System.Convert.ToString (id));
}
示例12: PythonEngine
public PythonEngine(IScriptable callback)
{
_callback = callback;
_scriptHandler = new ScriptHandler(_callback);
_engines.Add(callback, this);
}
示例13: ExecIdCall
public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
{
int id = f.MethodId;
switch (id) {
case Id_print:
for (int i = 0; i < args.Length; i++) {
if (i > 0)
Console.Out.Write (" ");
Console.Out.Write (ScriptConvert.ToString (args [i]));
}
Console.Out.WriteLine ();
return Undefined.Value;
case Id_version:
if (args.Length > 0) {
if (CliHelper.IsNumber (args [0])) {
int newVer = (int)ScriptConvert.ToNumber (args [0]);
if (Context.IsValidLanguageVersion (newVer)) {
cx.Version = Context.ToValidLanguageVersion (newVer);
}
}
}
return (int)cx.Version;
case Id_options:
StringBuilder sb = new StringBuilder ();
if (cx.HasFeature (Context.Features.Strict))
sb.Append ("strict");
return sb.ToString ();
case Id_gc:
GC.Collect ();
return Undefined.Value;
}
throw f.Unknown ();
}
示例14: Put
public override object Put (int index, IScriptable start, object value)
{
if (0 <= index && index < length) {
((System.Array)array).SetValue (Context.JsToCli (value, cls), index);
return value;
}
return base.Put (index, start, value);
}
示例15: Get
public override object Get (int index, IScriptable start)
{
if (0 <= index && index < length) {
object obj = ((System.Array)array).GetValue (index);
return Context.CurrentContext.Wrap (this, obj, cls);
}
return Undefined.Value;
}