コード例 #1
0
ファイル: ImporterTopLevel.cs プロジェクト: hazzik/Rhino.Net
		public static void Init(Context cx, Scriptable scope, bool @sealed)
		{
			Rhino.ImporterTopLevel obj = new Rhino.ImporterTopLevel();
			obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
		}
コード例 #2
0
ファイル: Dim.cs プロジェクト: hazzik/Rhino.Net
			// ContextAction
			/// <summary>
			/// Performs the action given by
			/// <see cref="type">type</see>
			/// .
			/// </summary>
			public virtual object Run(Context cx)
			{
				switch (type)
				{
					case IPROXY_COMPILE_SCRIPT:
					{
						cx.CompileString(text, url, 1, null);
						break;
					}

					case IPROXY_EVAL_SCRIPT:
					{
						Scriptable scope = null;
						if (dim.scopeProvider != null)
						{
							scope = dim.scopeProvider.GetScope();
						}
						if (scope == null)
						{
							scope = new ImporterTopLevel(cx);
						}
						cx.EvaluateString(scope, text, url, 1, null);
						break;
					}

					case IPROXY_STRING_IS_COMPILABLE:
					{
						booleanResult = cx.StringIsCompilableUnit(text);
						break;
					}

					case IPROXY_OBJECT_TO_STRING:
					{
						if (@object == Undefined.instance)
						{
							stringResult = "undefined";
						}
						else
						{
							if (@object == null)
							{
								stringResult = "null";
							}
							else
							{
								if (@object is NativeCall)
								{
									stringResult = "[object Call]";
								}
								else
								{
									stringResult = Context.ToString(@object);
								}
							}
						}
						break;
					}

					case IPROXY_OBJECT_PROPERTY:
					{
						objectResult = dim.GetObjectPropertyImpl(cx, @object, id);
						break;
					}

					case IPROXY_OBJECT_IDS:
					{
						objectArrayResult = dim.GetObjectIdsImpl(cx, @object);
						break;
					}

					default:
					{
						throw Kit.CodeBug();
					}
				}
				return null;
			}
コード例 #3
0
ファイル: ImporterTopLevel.cs プロジェクト: hazzik/Rhino.Net
		private object Js_construct(Scriptable scope, object[] args)
		{
			Rhino.ImporterTopLevel result = new Rhino.ImporterTopLevel();
			for (int i = 0; i != args.Length; ++i)
			{
				object arg = args[i];
				if (arg is NativeJavaClass)
				{
					result.ImportClass((NativeJavaClass)arg);
				}
				else
				{
					if (arg is NativeJavaPackage)
					{
						result.ImportPackage((NativeJavaPackage)arg);
					}
					else
					{
						throw Context.ReportRuntimeError1("msg.not.class.not.pkg", Context.ToString(arg));
					}
				}
			}
			// set explicitly prototype and scope
			// as otherwise in top scope mode BaseFunction.construct
			// would keep them set to null. It also allow to use
			// JavaImporter without new and still get properly
			// initialized object.
			result.SetParentScope(scope);
			result.SetPrototype(this);
			return result;
		}