MarkAsConstructor() public method

public MarkAsConstructor ( Scriptable prototypeProperty ) : void
prototypeProperty Scriptable
return void
示例#1
0
		internal static void Init(Scriptable scope, bool @sealed)
		{
			Rhino.NativeWith obj = new Rhino.NativeWith();
			obj.SetParentScope(scope);
			obj.SetPrototype(ScriptableObject.GetObjectPrototype(scope));
			IdFunctionObject ctor = new IdFunctionObject(obj, FTAG, Id_constructor, "With", 0, scope);
			ctor.MarkAsConstructor(obj);
			if (@sealed)
			{
				ctor.SealObject();
			}
			ctor.ExportAsScopeProperty();
		}
示例#2
0
		public static void Init(Context cx, Scriptable scope, bool @sealed)
		{
			NativeGlobal obj = new NativeGlobal();
			for (int id = 1; id <= LAST_SCOPE_FUNCTION_ID; ++id)
			{
				string name;
				int arity = 1;
				switch (id)
				{
					case Id_decodeURI:
					{
						name = "decodeURI";
						break;
					}

					case Id_decodeURIComponent:
					{
						name = "decodeURIComponent";
						break;
					}

					case Id_encodeURI:
					{
						name = "encodeURI";
						break;
					}

					case Id_encodeURIComponent:
					{
						name = "encodeURIComponent";
						break;
					}

					case Id_escape:
					{
						name = "escape";
						break;
					}

					case Id_eval:
					{
						name = "eval";
						break;
					}

					case Id_isFinite:
					{
						name = "isFinite";
						break;
					}

					case Id_isNaN:
					{
						name = "isNaN";
						break;
					}

					case Id_isXMLName:
					{
						name = "isXMLName";
						break;
					}

					case Id_parseFloat:
					{
						name = "parseFloat";
						break;
					}

					case Id_parseInt:
					{
						name = "parseInt";
						arity = 2;
						break;
					}

					case Id_unescape:
					{
						name = "unescape";
						break;
					}

					case Id_uneval:
					{
						name = "uneval";
						break;
					}

					default:
					{
						throw Kit.CodeBug();
					}
				}
				IdFunctionObject f = new IdFunctionObject(obj, FTAG, id, name, arity, scope);
				if (@sealed)
				{
					f.SealObject();
				}
				f.ExportAsScopeProperty();
			}
			ScriptableObject.DefineProperty(scope, "NaN", ScriptRuntime.NaNobj, ScriptableObject.READONLY | ScriptableObject.DONTENUM | ScriptableObject.PERMANENT);
			ScriptableObject.DefineProperty(scope, "Infinity", ScriptRuntime.WrapNumber(double.PositiveInfinity), ScriptableObject.READONLY | ScriptableObject.DONTENUM | ScriptableObject.PERMANENT);
			ScriptableObject.DefineProperty(scope, "undefined", Undefined.instance, ScriptableObject.READONLY | ScriptableObject.DONTENUM | ScriptableObject.PERMANENT);
			string[] errorMethods = new string[] { "ConversionError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "InternalError", "JavaException" };
			for (int i = 0; i < errorMethods.Length; i++)
			{
				string name = errorMethods[i];
				ScriptableObject errorProto = (ScriptableObject)ScriptRuntime.NewObject(cx, scope, "Error", ScriptRuntime.emptyArgs);
				errorProto.Put("name", errorProto, name);
				errorProto.Put("message", errorProto, string.Empty);
				IdFunctionObject ctor = new IdFunctionObject(obj, FTAG, Id_new_CommonError, name, 1, scope);
				ctor.MarkAsConstructor(errorProto);
				errorProto.Put("constructor", errorProto, ctor);
				errorProto.SetAttributes("constructor", ScriptableObject.DONTENUM);
				if (@sealed)
				{
					errorProto.SealObject();
					ctor.SealObject();
				}
				ctor.ExportAsScopeProperty();
			}
		}