Inheritance: BaseFunction
コード例 #1
0
ファイル: NativeScript.cs プロジェクト: hazzik/Rhino.Net
		internal static void Init(Scriptable scope, bool @sealed)
		{
			Rhino.NativeScript obj = new Rhino.NativeScript(null);
			obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
		}
コード例 #2
0
ファイル: NativeScript.cs プロジェクト: hazzik/Rhino.Net
		public override object ExecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, object[] args)
		{
			if (!f.HasTag(SCRIPT_TAG))
			{
				return base.ExecIdCall(f, cx, scope, thisObj, args);
			}
			int id = f.MethodId();
			switch (id)
			{
				case Id_constructor:
				{
					string source = (args.Length == 0) ? string.Empty : ScriptRuntime.ToString(args[0]);
					Script script = Compile(cx, source);
					Rhino.NativeScript nscript = new Rhino.NativeScript(script);
					ScriptRuntime.SetObjectProtoAndParent(nscript, scope);
					return nscript;
				}

				case Id_toString:
				{
					Rhino.NativeScript real = RealThis(thisObj, f);
					Script realScript = real.script;
					if (realScript == null)
					{
						return string.Empty;
					}
					return cx.DecompileScript(realScript, 0);
				}

				case Id_exec:
				{
					throw Context.ReportRuntimeError1("msg.cant.call.indirect", "exec");
				}

				case Id_compile:
				{
					Rhino.NativeScript real = RealThis(thisObj, f);
					string source = ScriptRuntime.ToString(args, 0);
					real.script = Compile(cx, source);
					return real;
				}
			}
			throw new ArgumentException(id.ToString());
		}