[INFER] Define static functions after defining the class for Number, String, bug 647537.
authorBrian Hackett <bhackett1024@gmail.com>
Sun, 03 Apr 2011 13:14:38 -0700
changeset 74891 17b68a623db15a36628980db468a4b0e75dda8bf
parent 74890 8c6e7d8864d742f2dfe21e81409bbf02fb0bb469
child 74892 74201cda4ce3839d683bdc12a475ec2deb683cee
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs647537
milestone2.2a1pre
[INFER] Define static functions after defining the class for Number, String, bug 647537.
js/src/jsnum.cpp
js/src/jsstr.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -1078,24 +1078,25 @@ JSObject *
 js_InitNumberClass(JSContext *cx, JSObject *obj)
 {
     JSObject *proto, *ctor;
     JSRuntime *rt;
 
     /* XXX must do at least once per new thread, so do it per JSContext... */
     FIX_FPU();
 
-    if (!JS_DefineFunctionsWithPrefix(cx, obj, number_functions, js_Number_str))
-        return NULL;
-
     proto = js_InitClass(cx, obj, NULL, &js_NumberClass, Number, 1, type_NewNumber,
                          NULL, number_methods, NULL, NULL);
     if (!proto || !(ctor = JS_GetConstructor(cx, proto)))
         return NULL;
     proto->setPrimitiveThis(Int32Value(0));
+
+    if (!JS_DefineFunctionsWithPrefix(cx, obj, number_functions, js_Number_str))
+        return NULL;
+
     if (!JS_DefineConstDoubles(cx, ctor, number_constants))
         return NULL;
 
     /* ECMA 15.1.1.1 */
     rt = cx->runtime;
     if (!JS_DefineProperty(cx, obj, js_NaN_str, Jsvalify(rt->NaNValue),
                            JS_PropertyStub, JS_StrictPropertyStub,
                            JSPROP_PERMANENT | JSPROP_READONLY)) {
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -3584,35 +3584,35 @@ static void type_NewString(JSContext *cx
         JS_TypeHandlerString(cx, jsfun, jssite);
 }
 
 JSObject *
 js_InitStringClass(JSContext *cx, JSObject *obj)
 {
     JSObject *proto;
 
-    /* Define the escape, unescape functions in the global object. */
-    if (!JS_DefineFunctionsWithPrefix(cx, obj, string_functions, js_String_str))
-        return NULL;
-
     proto = js_InitClass(cx, obj, NULL, &js_StringClass, js_String, 1,
                          type_NewString,
                          NULL, string_methods,
                          NULL, string_static_methods);
     if (!proto)
         return NULL;
     proto->setPrimitiveThis(StringValue(cx->runtime->emptyString));
     jsid lengthId = ATOM_TO_JSID(cx->runtime->atomState.lengthAtom);
     if (!js_DefineNativeProperty(cx, proto, lengthId,
                                  UndefinedValue(), NULL, NULL,
                                  JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED, 0, 0,
                                  NULL)) {
         return JS_FALSE;
     }
 
+    /* Define the escape, unescape functions in the global object. */
+    if (!JS_DefineFunctionsWithPrefix(cx, obj, string_functions, js_String_str))
+        return NULL;
+
     if (!cx->addTypePropertyId(proto->getType(), lengthId, TYPE_INT32))
         return NULL;
 
     TypeObject *objectType = proto->getNewType(cx);
     if (!objectType || !cx->addTypeProperty(objectType, NULL, TYPE_STRING))
         return NULL;
 
     return proto;