From e90a5882611c96fb3a4ef77f0120aa7f6d4c7ccc Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Sun, 3 Apr 2011 13:14:38 -0700 Subject: [PATCH] [INFER] Define static functions after defining the class for Number, String, bug 647537. --- js/src/jsnum.cpp | 7 ++++--- js/src/jsstr.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 67398f8a834..e45b148a8cd 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -1083,14 +1083,15 @@ js_InitNumberClass(JSContext *cx, JSObject *obj) /* 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; diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 88d0812c288..302fb22ce56 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -3589,10 +3589,6 @@ 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, @@ -3608,6 +3604,10 @@ js_InitStringClass(JSContext *cx, JSObject *obj) 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;