Bug 769872 - Add C++ core of Intl object and constructors Collator, NumberFormat, DateTimeFormat. However, disable initialization of Intl object and its constructors while functionality is incomplete. r=jwalden

This commit is contained in:
Norbert Lindenberg 2012-11-12 13:23:01 -08:00
parent 90413ff7a4
commit a4217d92b5
12 changed files with 595 additions and 5 deletions

View File

@ -123,6 +123,7 @@ CPPSRCS = \
BytecodeCompiler.cpp \
BytecodeEmitter.cpp \
FoldConstants.cpp \
Intl.cpp \
NameFunctions.cpp \
ParallelArray.cpp \
ParseMaps.cpp \

517
js/src/builtin/Intl.cpp Normal file
View File

@ -0,0 +1,517 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The Intl module specified by standard ECMA-402,
* ECMAScript Internationalization API Specification.
*/
#include "jsapi.h"
#include "jsatom.h"
#include "jscntxt.h"
#include "jsobj.h"
#include "builtin/Intl.h"
#include "vm/GlobalObject.h"
#include "jsobjinlines.h"
using namespace js;
/******************** Common to Intl constructors ********************/
static bool
IntlInitialize(JSContext *cx, HandleObject obj, Handle<PropertyName*> initializer,
HandleValue locales, HandleValue options)
{
// ??? stub - initializer to be implemented as self-hosted function
return true;
}
/******************** Collator ********************/
static Class CollatorClass = {
js_Object_str,
0,
JS_PropertyStub, /* addProperty */
JS_PropertyStub, /* delProperty */
JS_PropertyStub, /* getProperty */
JS_StrictPropertyStub, /* setProperty */
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub
};
#if JS_HAS_TOSOURCE
static JSBool
collator_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->names().Collator);
return true;
}
#endif
static JSFunctionSpec collator_static_methods[] = {
JS_FS_END
};
static JSFunctionSpec collator_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, collator_toSource, 0, 0),
#endif
JS_FS_END
};
/**
* Collator constructor.
* Spec: ECMAScript Internationalization API Specification, 10.1
*/
static JSBool
Collator(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx);
bool construct = IsConstructing(args);
if (!construct) {
// 10.1.2.1 step 3
JSObject *intl = cx->global()->getOrCreateIntlObject(cx);
if (!intl)
return false;
RootedValue self(cx, args.thisv());
if (!self.isUndefined() && (!self.isObject() || self.toObject() != *intl)) {
// 10.1.2.1 step 4
obj = ToObject(cx, self);
if (!obj)
return false;
// 10.1.2.1 step 5
if (!obj->isExtensible())
return Throw(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE);
} else {
// 10.1.2.1 step 3.a
construct = true;
}
}
if (construct) {
// 10.1.3.1 paragraph 2
RootedObject proto(cx, cx->global()->getOrCreateCollatorPrototype(cx));
if (!proto)
return false;
obj = NewObjectWithGivenProto(cx, &CollatorClass, proto, cx->global());
if (!obj)
return false;
}
// 10.1.2.1 steps 1 and 2; 10.1.3.1 steps 1 and 2
RootedValue locales(cx, args.length() > 0 ? args[0] : UndefinedValue());
RootedValue options(cx, args.length() > 1 ? args[1] : UndefinedValue());
// 10.1.2.1 step 6; 10.1.3.1 step 3
if (!IntlInitialize(cx, obj, cx->names().InitializeCollator, locales, options))
return false;
// 10.1.2.1 steps 3.a and 7
args.rval().setObject(*obj);
return true;
}
static JSObject *
InitCollatorClass(JSContext *cx, HandleObject Intl, Handle<GlobalObject*> global)
{
RootedFunction ctor(cx, global->createConstructor(cx, &Collator, cx->names().Collator, 0));
if (!ctor)
return NULL;
RootedObject proto(cx, global->asGlobal().getOrCreateCollatorPrototype(cx));
if (!proto)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, proto))
return NULL;
// 10.2.2
if (!JS_DefineFunctions(cx, ctor, collator_static_methods))
return NULL;
// 10.3.2 and 10.3.3
if (!JS_DefineFunctions(cx, proto, collator_methods))
return NULL;
// 10.2.1 and 10.3
RootedValue locales(cx, UndefinedValue());
RootedValue options(cx, UndefinedValue());
if (!IntlInitialize(cx, proto, cx->names().InitializeCollator, locales, options))
return NULL;
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!JSObject::defineProperty(cx, Intl, cx->names().Collator, ctorValue,
JS_PropertyStub, JS_StrictPropertyStub, 0)) {
return NULL;
}
return ctor;
}
bool
GlobalObject::initCollatorProto(JSContext *cx, Handle<GlobalObject*> global)
{
RootedObject proto(cx, global->createBlankPrototype(cx, &CollatorClass));
if (!proto)
return false;
global->setReservedSlot(COLLATOR_PROTO, ObjectValue(*proto));
return true;
}
/******************** NumberFormat ********************/
static Class NumberFormatClass = {
js_Object_str,
0,
JS_PropertyStub, /* addProperty */
JS_PropertyStub, /* delProperty */
JS_PropertyStub, /* getProperty */
JS_StrictPropertyStub, /* setProperty */
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub
};
#if JS_HAS_TOSOURCE
static JSBool
numberFormat_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->names().NumberFormat);
return true;
}
#endif
static JSFunctionSpec numberFormat_static_methods[] = {
JS_FS_END
};
static JSFunctionSpec numberFormat_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, numberFormat_toSource, 0, 0),
#endif
JS_FS_END
};
/**
* NumberFormat constructor.
* Spec: ECMAScript Internationalization API Specification, 11.1
*/
static JSBool
NumberFormat(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx);
bool construct = IsConstructing(args);
if (!construct) {
// 11.1.2.1 step 3
JSObject *intl = cx->global()->getOrCreateIntlObject(cx);
if (!intl)
return false;
RootedValue self(cx, args.thisv());
if (!self.isUndefined() && (!self.isObject() || self.toObject() != *intl)) {
// 11.1.2.1 step 4
obj = ToObject(cx, self);
if (!obj)
return false;
// 11.1.2.1 step 5
if (!obj->isExtensible())
return Throw(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE);
} else {
// 11.1.2.1 step 3.a
construct = true;
}
}
if (construct) {
// 11.1.3.1 paragraph 2
RootedObject proto(cx, cx->global()->getOrCreateNumberFormatPrototype(cx));
if (!proto)
return false;
obj = NewObjectWithGivenProto(cx, &NumberFormatClass, proto, cx->global());
if (!obj)
return false;
}
// 11.1.2.1 steps 1 and 2; 11.1.3.1 steps 1 and 2
RootedValue locales(cx, args.length() > 0 ? args[0] : UndefinedValue());
RootedValue options(cx, args.length() > 1 ? args[1] : UndefinedValue());
// 11.1.2.1 step 6; 11.1.3.1 step 3
if (!IntlInitialize(cx, obj, cx->names().InitializeNumberFormat, locales, options))
return false;
// 11.1.2.1 steps 3.a and 7
args.rval().setObject(*obj);
return true;
}
static JSObject *
InitNumberFormatClass(JSContext *cx, HandleObject Intl, Handle<GlobalObject*> global)
{
RootedFunction ctor(cx, global->createConstructor(cx, &NumberFormat, cx->names().NumberFormat, 0));
if (!ctor)
return NULL;
RootedObject proto(cx, global->asGlobal().getOrCreateNumberFormatPrototype(cx));
if (!proto)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, proto))
return NULL;
// 11.2.2
if (!JS_DefineFunctions(cx, ctor, numberFormat_static_methods))
return NULL;
// 11.3.2 and 11.3.3
if (!JS_DefineFunctions(cx, proto, numberFormat_methods))
return NULL;
// 11.2.1 and 11.3
RootedValue locales(cx, UndefinedValue());
RootedValue options(cx, UndefinedValue());
if (!IntlInitialize(cx, proto, cx->names().InitializeNumberFormat, locales, options))
return NULL;
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!JSObject::defineProperty(cx, Intl, cx->names().NumberFormat, ctorValue,
JS_PropertyStub, JS_StrictPropertyStub, 0)) {
return NULL;
}
return ctor;
}
bool
GlobalObject::initNumberFormatProto(JSContext *cx, Handle<GlobalObject*> global)
{
RootedObject proto(cx, global->createBlankPrototype(cx, &NumberFormatClass));
if (!proto)
return false;
global->setReservedSlot(NUMBER_FORMAT_PROTO, ObjectValue(*proto));
return true;
}
/******************** DateTimeFormat ********************/
static Class DateTimeFormatClass = {
js_Object_str,
0,
JS_PropertyStub, /* addProperty */
JS_PropertyStub, /* delProperty */
JS_PropertyStub, /* getProperty */
JS_StrictPropertyStub, /* setProperty */
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub
};
#if JS_HAS_TOSOURCE
static JSBool
dateTimeFormat_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->names().DateTimeFormat);
return true;
}
#endif
static JSFunctionSpec dateTimeFormat_static_methods[] = {
JS_FS_END
};
static JSFunctionSpec dateTimeFormat_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, dateTimeFormat_toSource, 0, 0),
#endif
JS_FS_END
};
/**
* DateTimeFormat constructor.
* Spec: ECMAScript Internationalization API Specification, 12.1
*/
static JSBool
DateTimeFormat(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
RootedObject obj(cx);
bool construct = IsConstructing(args);
if (!construct) {
// 12.1.2.1 step 3
JSObject *intl = cx->global()->getOrCreateIntlObject(cx);
if (!intl)
return false;
RootedValue self(cx, args.thisv());
if (!self.isUndefined() && (!self.isObject() || self.toObject() != *intl)) {
// 12.1.2.1 step 4
obj = ToObject(cx, self);
if (!obj)
return false;
// 12.1.2.1 step 5
if (!obj->isExtensible())
return Throw(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE);
} else {
// 12.1.2.1 step 3.a
construct = true;
}
}
if (construct) {
// 12.1.3.1 paragraph 2
RootedObject proto(cx, cx->global()->getOrCreateDateTimeFormatPrototype(cx));
if (!proto)
return false;
obj = NewObjectWithGivenProto(cx, &DateTimeFormatClass, proto, cx->global());
if (!obj)
return false;
}
// 12.1.2.1 steps 1 and 2; 12.1.3.1 steps 1 and 2
RootedValue locales(cx, args.length() > 0 ? args[0] : UndefinedValue());
RootedValue options(cx, args.length() > 1 ? args[1] : UndefinedValue());
// 12.1.2.1 step 6; 12.1.3.1 step 3
if (!IntlInitialize(cx, obj, cx->names().InitializeDateTimeFormat, locales, options))
return false;
// 12.1.2.1 steps 3.a and 7
args.rval().setObject(*obj);
return true;
}
static JSObject *
InitDateTimeFormatClass(JSContext *cx, HandleObject Intl, Handle<GlobalObject*> global)
{
RootedFunction ctor(cx, global->createConstructor(cx, &DateTimeFormat, cx->names().DateTimeFormat, 0));
if (!ctor)
return NULL;
RootedObject proto(cx, global->asGlobal().getOrCreateDateTimeFormatPrototype(cx));
if (!proto)
return NULL;
if (!LinkConstructorAndPrototype(cx, ctor, proto))
return NULL;
// 12.2.2
if (!JS_DefineFunctions(cx, ctor, dateTimeFormat_static_methods))
return NULL;
// 12.3.2 and 12.3.3
if (!JS_DefineFunctions(cx, proto, dateTimeFormat_methods))
return NULL;
// 12.2.1 and 12.3
RootedValue locales(cx, UndefinedValue());
RootedValue options(cx, UndefinedValue());
if (!IntlInitialize(cx, proto, cx->names().InitializeDateTimeFormat, locales, options))
return NULL;
// 8.1
RootedValue ctorValue(cx, ObjectValue(*ctor));
if (!JSObject::defineProperty(cx, Intl, cx->names().DateTimeFormat, ctorValue,
JS_PropertyStub, JS_StrictPropertyStub, 0)) {
return NULL;
}
return ctor;
}
bool
GlobalObject::initDateTimeFormatProto(JSContext *cx, Handle<GlobalObject*> global)
{
RootedObject proto(cx, global->createBlankPrototype(cx, &DateTimeFormatClass));
if (!proto)
return false;
global->setReservedSlot(DATE_TIME_FORMAT_PROTO, ObjectValue(*proto));
return true;
}
/******************** Intl ********************/
Class js::IntlClass = {
js_Object_str,
JSCLASS_HAS_CACHED_PROTO(JSProto_Intl),
JS_PropertyStub, /* addProperty */
JS_PropertyStub, /* delProperty */
JS_PropertyStub, /* getProperty */
JS_StrictPropertyStub, /* setProperty */
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub
};
#if JS_HAS_TOSOURCE
static JSBool
intl_toSource(JSContext *cx, unsigned argc, Value *vp)
{
vp->setString(cx->names().Intl);
return true;
}
#endif
static JSFunctionSpec intl_static_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, intl_toSource, 0, 0),
#endif
JS_FS_END
};
/**
* Initializes the Intl Object and its standard built-in properties.
* Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
*/
JSObject *
js_InitIntlClass(JSContext *cx, HandleObject obj)
{
JS_ASSERT(obj->isGlobal());
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
// The constructors above need to be able to determine whether they've been
// called with this being "the standard built-in Intl object". The global
// object reserves slots to track standard built-in objects, but doesn't
// normally keep references to non-constructors. This makes sure there is one.
RootedObject Intl(cx, global->getOrCreateIntlObject(cx));
if (!Intl)
return NULL;
RootedValue IntlValue(cx, ObjectValue(*Intl));
if (!JSObject::defineProperty(cx, global, cx->names().Intl, IntlValue,
JS_PropertyStub, JS_StrictPropertyStub, 0)) {
return NULL;
}
if (!JS_DefineFunctions(cx, Intl, intl_static_methods))
return NULL;
if (!InitCollatorClass(cx, Intl, global))
return NULL;
if (!InitNumberFormatClass(cx, Intl, global))
return NULL;
if (!InitDateTimeFormatClass(cx, Intl, global))
return NULL;
MarkStandardClassInitializedNoProto(global, &IntlClass);
return Intl;
}
bool
GlobalObject::initIntlObject(JSContext *cx, Handle<GlobalObject*> global)
{
RootedObject Intl(cx, NewObjectWithClassProto(cx, &IntlClass, NULL, global));
if (!Intl || !JSObject::setSingletonType(cx, Intl))
return false;
global->setReservedSlot(JSProto_Intl, ObjectValue(*Intl));
return true;
}

27
js/src/builtin/Intl.h Normal file
View File

@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef Intl_h___
#define Intl_h___
#include "gc/Root.h"
struct JSContext;
struct JSObject;
/*
* The Intl module specified by standard ECMA-402,
* ECMAScript Internationalization API Specification.
*/
/**
* Initializes the Intl Object and its standard built-in properties.
* Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
*/
extern JSObject *
js_InitIntlClass(JSContext *cx, js::HandleObject obj);
#endif /* Intl_h___ */

View File

@ -55,6 +55,7 @@
#include "jsxml.h"
#include "builtin/Eval.h"
#include "builtin/Intl.h"
#include "builtin/MapObject.h"
#include "builtin/RegExp.h"
#include "builtin/ParallelArray.h"
@ -1793,6 +1794,9 @@ static JSStdName standard_class_atoms[] = {
{js_InitSetClass, EAGER_CLASS_ATOM(Set), &js::SetObject::class_},
{js_InitParallelArrayClass, EAGER_CLASS_ATOM(ParallelArray), &js::ParallelArrayObject::class_},
{js_InitProxyClass, EAGER_ATOM_AND_CLASP(Proxy)},
#if ENABLE_INTL_API
{js_InitIntlClass, EAGER_ATOM_AND_CLASP(Intl)},
#endif
{NULL, 0, NULL}
};

View File

@ -3994,7 +3994,7 @@ struct JSClass {
* with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was
* prevously allowed, but is now an ES5 violation and thus unsupported.
*/
#define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 23)
#define JSCLASS_GLOBAL_SLOT_COUNT (JSProto_LIMIT * 3 + 26)
#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \
(JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n)))
#define JSCLASS_GLOBAL_FLAGS \

View File

@ -892,7 +892,7 @@ bool
GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, PropertyDescriptor *desc)
{
// FIXME: Call TrapGetOwnProperty directly once ScriptedIndirectProxies is removed
if (obj->isProxy())
if (obj->isProxy())
return Proxy::getOwnPropertyDescriptor(cx, obj, id, false, desc);
RootedObject pobj(cx);
@ -3513,7 +3513,7 @@ js_InitNullClass(JSContext *cx, HandleObject obj)
}
#define DECLARE_PROTOTYPE_CLASS_INIT(name,code,init) \
extern JSObject *init(JSContext *cx, JSObject *obj);
extern JSObject *init(JSContext *cx, Handle<JSObject*> obj);
JS_FOR_EACH_PROTOTYPE(DECLARE_PROTOTYPE_CLASS_INIT)
#undef DECLARE_PROTOTYPE_CLASS_INIT

View File

@ -208,6 +208,7 @@ extern Class DateClass;
extern Class ErrorClass;
extern Class ElementIteratorClass;
extern Class GeneratorClass;
extern Class IntlClass;
extern Class JSONClass;
extern Class MapIteratorClass;
extern Class MathClass;

View File

@ -60,5 +60,6 @@
macro(Set, 38, js_InitSetClass) \
macro(DataView, 39, js_InitTypedArrayClasses) \
macro(ParallelArray, 40, js_InitParallelArrayClass) \
macro(Intl, 41, js_InitIntlClass) \
#endif /* jsprototypes_h___ */

View File

@ -170,4 +170,7 @@
MOZ_NOT_REACHED("don't call this! to be used in the new object representation")
#endif
/* ECMAScript Internationalization API isn't fully implemented yet. */
#define ENABLE_INTL_API 0
#endif /* jsversion_h___ */

View File

@ -44,10 +44,12 @@
macro(caller, caller, "caller") \
macro(_CallFunction, _CallFunction, "_CallFunction") \
macro(classPrototype, classPrototype, "prototype") \
macro(Collator, Collator, "Collator") \
macro(columnNumber, columnNumber, "columnNumber") \
macro(configurable, configurable, "configurable") \
macro(construct, construct, "construct") \
macro(constructor, constructor, "constructor") \
macro(DateTimeFormat, DateTimeFormat, "DateTimeFormat") \
macro(decodeURI, decodeURI, "decodeURI") \
macro(decodeURIComponent, decodeURIComponent, "decodeURIComponent") \
macro(defineProperty, defineProperty, "defineProperty") \
@ -76,6 +78,9 @@
macro(hasOwnProperty, hasOwnProperty, "hasOwnProperty") \
macro(ignoreCase, ignoreCase, "ignoreCase") \
macro(index, index, "index") \
macro(InitializeCollator, InitializeCollator, "intl_InitializeCollator") \
macro(InitializeDateTimeFormat, InitializeDateTimeFormat, "intl_InitializeDateTimeFormat") \
macro(InitializeNumberFormat, InitializeNumberFormat, "intl_InitializeNumberFormat") \
macro(innermost, innermost, "innermost") \
macro(input, input, "input") \
macro(isFinite, isFinite, "isFinite") \
@ -101,6 +106,7 @@
macro(NaN, NaN, "NaN") \
macro(next, next, "next") \
macro(noSuchMethod, noSuchMethod, "__noSuchMethod__") \
macro(NumberFormat, NumberFormat, "NumberFormat") \
macro(objectNull, objectNull, "[object Null]") \
macro(objectUndefined, objectUndefined, "[object Undefined]") \
macro(of, of, "of") \

View File

@ -16,6 +16,7 @@
#include "jsweakmap.h"
#include "builtin/Eval.h"
#include "builtin/Intl.h"
#include "builtin/MapObject.h"
#include "builtin/RegExp.h"
#include "frontend/BytecodeEmitter.h"
@ -470,7 +471,11 @@ GlobalObject::initStandardClasses(JSContext *cx, Handle<GlobalObject*> global)
js_InitMapClass(cx, global) &&
GlobalObject::initMapIteratorProto(cx, global) &&
js_InitSetClass(cx, global) &&
GlobalObject::initSetIteratorProto(cx, global);
GlobalObject::initSetIteratorProto(cx, global) &&
#if ENABLE_INTL_API
js_InitIntlClass(cx, global) &&
#endif
true;
}
bool

View File

@ -95,7 +95,10 @@ class GlobalObject : public JSObject
static const unsigned GENERATOR_PROTO = ELEMENT_ITERATOR_PROTO + 1;
static const unsigned MAP_ITERATOR_PROTO = GENERATOR_PROTO + 1;
static const unsigned SET_ITERATOR_PROTO = MAP_ITERATOR_PROTO + 1;
static const unsigned REGEXP_STATICS = SET_ITERATOR_PROTO + 1;
static const unsigned COLLATOR_PROTO = SET_ITERATOR_PROTO + 1;
static const unsigned NUMBER_FORMAT_PROTO = COLLATOR_PROTO + 1;
static const unsigned DATE_TIME_FORMAT_PROTO = NUMBER_FORMAT_PROTO + 1;
static const unsigned REGEXP_STATICS = DATE_TIME_FORMAT_PROTO + 1;
static const unsigned FUNCTION_NS = REGEXP_STATICS + 1;
static const unsigned RUNTIME_CODEGEN_ENABLED = FUNCTION_NS + 1;
static const unsigned DEBUGGERS = RUNTIME_CODEGEN_ENABLED + 1;
@ -310,6 +313,22 @@ class GlobalObject : public JSObject
return &self->getPrototype(key).toObject();
}
JSObject *getOrCreateIntlObject(JSContext *cx) {
return getOrCreateObject(cx, JSProto_Intl, initIntlObject);
}
JSObject *getOrCreateCollatorPrototype(JSContext *cx) {
return getOrCreateObject(cx, COLLATOR_PROTO, initCollatorProto);
}
JSObject *getOrCreateNumberFormatPrototype(JSContext *cx) {
return getOrCreateObject(cx, NUMBER_FORMAT_PROTO, initNumberFormatProto);
}
JSObject *getOrCreateDateTimeFormatPrototype(JSContext *cx) {
return getOrCreateObject(cx, DATE_TIME_FORMAT_PROTO, initDateTimeFormatProto);
}
JSObject *getIteratorPrototype() {
return &getPrototype(JSProto_Iterator).toObject();
}
@ -423,6 +442,12 @@ class GlobalObject : public JSObject
static bool initMapIteratorProto(JSContext *cx, Handle<GlobalObject*> global);
static bool initSetIteratorProto(JSContext *cx, Handle<GlobalObject*> global);
// Implemented in Intl.cpp.
static bool initIntlObject(JSContext *cx, Handle<GlobalObject*> global);
static bool initCollatorProto(JSContext *cx, Handle<GlobalObject*> global);
static bool initNumberFormatProto(JSContext *cx, Handle<GlobalObject*> global);
static bool initDateTimeFormatProto(JSContext *cx, Handle<GlobalObject*> global);
static bool initStandardClasses(JSContext *cx, Handle<GlobalObject*> global);
typedef js::Vector<js::Debugger *, 0, js::SystemAllocPolicy> DebuggerVector;