Setting DONT_ENUM property on some methods. Conformance fixes.

git-svn-id: http://v8-i18n.googlecode.com/svn/trunk@187 24c52dca-d3ef-abce-e343-6dbe4d066545
diff --git a/src/break-iterator.js b/src/break-iterator.js
index 5d40d66..dc0f387 100644
--- a/src/break-iterator.js
+++ b/src/break-iterator.js
@@ -64,42 +64,46 @@
  *
  * @constructor
  */
-Intl.v8BreakIterator = function() {
-  var locales = arguments[0];
-  var options = arguments[1];
+%SetProperty(Intl, 'v8BreakIterator', function() {
+    var locales = arguments[0];
+    var options = arguments[1];
 
-  if (!this || this === Intl) {
-    // Constructor is called as a function.
-    return new Intl.v8BreakIterator(locales, options);
-  }
+    if (!this || this === Intl) {
+      // Constructor is called as a function.
+      return new Intl.v8BreakIterator(locales, options);
+    }
 
-  return initializeBreakIterator(toObject(this), locales, options);
-};
+    return initializeBreakIterator(toObject(this), locales, options);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 
 
 /**
  * BreakIterator resolvedOptions method.
  */
-Intl.v8BreakIterator.prototype.resolvedOptions = function() {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', function() {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  if (!this || typeof this !== 'object' ||
-      this.__initializedIntlObject !== 'breakiterator') {
-    throw new TypeError('resolvedOptions method called on a non-object or ' +
-        'on a object that is not Intl.v8BreakIterator.');
-  }
+    if (!this || typeof this !== 'object' ||
+        this.__initializedIntlObject !== 'breakiterator') {
+      throw new TypeError('resolvedOptions method called on a non-object or ' +
+          'on a object that is not Intl.v8BreakIterator.');
+    }
 
-  var segmenter = this;
-  var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale,
-                                     segmenter.resolved.locale);
+    var segmenter = this;
+    var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale,
+                                       segmenter.resolved.locale);
 
-  return {
-    locale: locale,
-    type: segmenter.resolved.type
-  };
-};
+    return {
+      locale: locale,
+      type: segmenter.resolved.type
+    };
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.v8BreakIterator.prototype.resolvedOptions);
 
 
@@ -109,13 +113,15 @@
  * order in the returned list as in the input list.
  * Options are optional parameter.
  */
-Intl.v8BreakIterator.supportedLocalesOf = function(locales) {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.v8BreakIterator, 'supportedLocalesOf', function(locales) {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  return supportedLocalesOf('breakiterator', locales, arguments[1]);
-};
+    return supportedLocalesOf('breakiterator', locales, arguments[1]);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf);
 
 
diff --git a/src/collator.js b/src/collator.js
index b4954a9..519635d 100644
--- a/src/collator.js
+++ b/src/collator.js
@@ -109,47 +109,51 @@
  *
  * @constructor
  */
-Intl.Collator = function() {
-  var locales = arguments[0];
-  var options = arguments[1];
+%SetProperty(Intl, 'Collator', function() {
+    var locales = arguments[0];
+    var options = arguments[1];
 
-  if (!this || this === Intl) {
-    // Constructor is called as a function.
-    return new Intl.Collator(locales, options);
-  }
+    if (!this || this === Intl) {
+      // Constructor is called as a function.
+      return new Intl.Collator(locales, options);
+    }
 
-  return initializeCollator(toObject(this), locales, options);
-};
+    return initializeCollator(toObject(this), locales, options);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 
 
 /**
  * Collator resolvedOptions method.
  */
-Intl.Collator.prototype.resolvedOptions = function() {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.Collator.prototype, 'resolvedOptions', function() {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  if (!this || typeof this !== 'object' ||
-      this.__initializedIntlObject !== 'collator') {
-    throw new TypeError('resolvedOptions method called on a non-object ' +
-        'or on a object that is not Intl.Collator.');
-  }
+    if (!this || typeof this !== 'object' ||
+        this.__initializedIntlObject !== 'collator') {
+      throw new TypeError('resolvedOptions method called on a non-object ' +
+                          'or on a object that is not Intl.Collator.');
+    }
 
-  var coll = this;
-  var locale = getOptimalLanguageTag(coll.resolved.requestedLocale,
-                                     coll.resolved.locale);
+    var coll = this;
+    var locale = getOptimalLanguageTag(coll.resolved.requestedLocale,
+                                       coll.resolved.locale);
 
-  return {
-    locale: locale,
-    usage: coll.resolved.usage,
-    sensitivity: coll.resolved.sensitivity,
-    ignorePunctuation: coll.resolved.ignorePunctuation,
-    numeric: coll.resolved.numeric,
-    caseFirst: coll.resolved.caseFirst,
-    collation: coll.resolved.collation
-  };
-};
+    return {
+      locale: locale,
+      usage: coll.resolved.usage,
+      sensitivity: coll.resolved.sensitivity,
+      ignorePunctuation: coll.resolved.ignorePunctuation,
+      numeric: coll.resolved.numeric,
+      caseFirst: coll.resolved.caseFirst,
+      collation: coll.resolved.collation
+    };
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.Collator.prototype.resolvedOptions);
 
 
@@ -159,13 +163,15 @@
  * order in the returned list as in the input list.
  * Options are optional parameter.
  */
-Intl.Collator.supportedLocalesOf = function(locales) {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.Collator, 'supportedLocalesOf', function(locales) {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  return supportedLocalesOf('collator', locales, arguments[1]);
-};
+    return supportedLocalesOf('collator', locales, arguments[1]);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf);
 
 
diff --git a/src/date-format.js b/src/date-format.js
index 8f2651b..5ec3781 100644
--- a/src/date-format.js
+++ b/src/date-format.js
@@ -300,65 +300,69 @@
  *
  * @constructor
  */
-Intl.DateTimeFormat = function() {
-  var locales = arguments[0];
-  var options = arguments[1];
+%SetProperty(Intl, 'DateTimeFormat', function() {
+    var locales = arguments[0];
+    var options = arguments[1];
 
-  if (!this || this === Intl) {
-    // Constructor is called as a function.
-    return new Intl.DateTimeFormat(locales, options);
-  }
+    if (!this || this === Intl) {
+      // Constructor is called as a function.
+      return new Intl.DateTimeFormat(locales, options);
+    }
 
-  return initializeDateTimeFormat(toObject(this), locales, options);
-};
+    return initializeDateTimeFormat(toObject(this), locales, options);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 
 
 /**
  * DateTimeFormat resolvedOptions method.
  */
-Intl.DateTimeFormat.prototype.resolvedOptions = function() {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  if (!this || typeof this !== 'object' ||
-      this.__initializedIntlObject !== 'dateformat') {
-    throw new TypeError('resolvedOptions method called on a non-object or ' +
-        'on a object that is not Intl.DateTimeFormat.');
-  }
+    if (!this || typeof this !== 'object' ||
+        this.__initializedIntlObject !== 'dateformat') {
+      throw new TypeError('resolvedOptions method called on a non-object or ' +
+          'on a object that is not Intl.DateTimeFormat.');
+    }
 
-  var format = this;
-  var fromPattern = fromLDMLString(format.resolved.pattern);
-  var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar];
-  if (userCalendar === undefined) {
-    // Use ICU name if we don't have a match. It shouldn't happen, but
-    // it would be too strict to throw for this.
-    userCalendar = format.resolved.calendar;
-  }
+    var format = this;
+    var fromPattern = fromLDMLString(format.resolved.pattern);
+    var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar];
+    if (userCalendar === undefined) {
+      // Use ICU name if we don't have a match. It shouldn't happen, but
+      // it would be too strict to throw for this.
+      userCalendar = format.resolved.calendar;
+    }
 
-  var locale = getOptimalLanguageTag(format.resolved.requestedLocale,
-                                     format.resolved.locale);
+    var locale = getOptimalLanguageTag(format.resolved.requestedLocale,
+                                       format.resolved.locale);
 
-  var result = {
-    locale: locale,
-    numberingSystem: format.resolved.numberingSystem,
-    calendar: userCalendar,
-    timeZone: format.resolved.timeZone
-  };
+    var result = {
+      locale: locale,
+      numberingSystem: format.resolved.numberingSystem,
+      calendar: userCalendar,
+      timeZone: format.resolved.timeZone
+    };
 
-  addWECPropertyIfDefined(result, 'timeZoneName', fromPattern.timeZoneName);
-  addWECPropertyIfDefined(result, 'era', fromPattern.era);
-  addWECPropertyIfDefined(result, 'year', fromPattern.year);
-  addWECPropertyIfDefined(result, 'month', fromPattern.month);
-  addWECPropertyIfDefined(result, 'day', fromPattern.day);
-  addWECPropertyIfDefined(result, 'weekday', fromPattern.weekday);
-  addWECPropertyIfDefined(result, 'hour12', fromPattern.hour12);
-  addWECPropertyIfDefined(result, 'hour', fromPattern.hour);
-  addWECPropertyIfDefined(result, 'minute', fromPattern.minute);
-  addWECPropertyIfDefined(result, 'second', fromPattern.second);
+    addWECPropertyIfDefined(result, 'timeZoneName', fromPattern.timeZoneName);
+    addWECPropertyIfDefined(result, 'era', fromPattern.era);
+    addWECPropertyIfDefined(result, 'year', fromPattern.year);
+    addWECPropertyIfDefined(result, 'month', fromPattern.month);
+    addWECPropertyIfDefined(result, 'day', fromPattern.day);
+    addWECPropertyIfDefined(result, 'weekday', fromPattern.weekday);
+    addWECPropertyIfDefined(result, 'hour12', fromPattern.hour12);
+    addWECPropertyIfDefined(result, 'hour', fromPattern.hour);
+    addWECPropertyIfDefined(result, 'minute', fromPattern.minute);
+    addWECPropertyIfDefined(result, 'second', fromPattern.second);
 
-  return result;
-};
+    return result;
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.DateTimeFormat.prototype.resolvedOptions);
 
 
@@ -368,13 +372,15 @@
  * order in the returned list as in the input list.
  * Options are optional parameter.
  */
-Intl.DateTimeFormat.supportedLocalesOf = function(locales) {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  return supportedLocalesOf('dateformat', locales, arguments[1]);
-};
+    return supportedLocalesOf('dateformat', locales, arguments[1]);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf);
 
 
diff --git a/src/globals.js b/src/globals.js
index 6aaa5e4..ab132f4 100644
--- a/src/globals.js
+++ b/src/globals.js
@@ -135,6 +135,18 @@
 ];
 
 /**
+ * Object attributes (configurable, writable, enumerable).
+ * To combine attributes, OR them.
+ * Values/names are copied from v8/include/v8.h:PropertyAttribute
+ */
+var ATTRIBUTES = {
+  'NONE': 0,
+  'READ_ONLY': 1,
+  'DONT_ENUM': 2,
+  'DONT_DELETE': 4
+};
+
+/**
  * Error message for when function object is created with new and it's not
  * a constructor.
  */
diff --git a/src/number-format.js b/src/number-format.js
index 7a40707..a5bd75f 100644
--- a/src/number-format.js
+++ b/src/number-format.js
@@ -171,65 +171,69 @@
  *
  * @constructor
  */
-Intl.NumberFormat = function() {
-  var locales = arguments[0];
-  var options = arguments[1];
+%SetProperty(Intl, 'NumberFormat', function() {
+    var locales = arguments[0];
+    var options = arguments[1];
 
-  if (!this || this === Intl) {
-    // Constructor is called as a function.
-    return new Intl.NumberFormat(locales, options);
-  }
+    if (!this || this === Intl) {
+      // Constructor is called as a function.
+      return new Intl.NumberFormat(locales, options);
+    }
 
-  return initializeNumberFormat(toObject(this), locales, options);
-};
+    return initializeNumberFormat(toObject(this), locales, options);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 
 
 /**
  * NumberFormat resolvedOptions method.
  */
-Intl.NumberFormat.prototype.resolvedOptions = function() {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  if (!this || typeof this !== 'object' ||
-      this.__initializedIntlObject !== 'numberformat') {
-    throw new TypeError('resolvedOptions method called on a non-object' +
-        ' or on a object that is not Intl.NumberFormat.');
-  }
+    if (!this || typeof this !== 'object' ||
+        this.__initializedIntlObject !== 'numberformat') {
+      throw new TypeError('resolvedOptions method called on a non-object' +
+          ' or on a object that is not Intl.NumberFormat.');
+    }
 
-  var format = this;
-  var locale = getOptimalLanguageTag(format.resolved.requestedLocale,
-                                     format.resolved.locale);
+    var format = this;
+    var locale = getOptimalLanguageTag(format.resolved.requestedLocale,
+                                       format.resolved.locale);
 
-  var result = {
-    locale: locale,
-    numberingSystem: format.resolved.numberingSystem,
-    style: format.resolved.style,
-    useGrouping: format.resolved.useGrouping,
-    minimumIntegerDigits: format.resolved.minimumIntegerDigits,
-    minimumFractionDigits: format.resolved.minimumFractionDigits,
-    maximumFractionDigits: format.resolved.maximumFractionDigits,
-  };
+    var result = {
+      locale: locale,
+      numberingSystem: format.resolved.numberingSystem,
+      style: format.resolved.style,
+      useGrouping: format.resolved.useGrouping,
+      minimumIntegerDigits: format.resolved.minimumIntegerDigits,
+      minimumFractionDigits: format.resolved.minimumFractionDigits,
+      maximumFractionDigits: format.resolved.maximumFractionDigits,
+    };
 
-  if (result.style === 'currency') {
-    defineWECProperty(result, 'currency', format.resolved.currency);
-    defineWECProperty(result, 'currencyDisplay',
-                      format.resolved.currencyDisplay);
-  }
+    if (result.style === 'currency') {
+      defineWECProperty(result, 'currency', format.resolved.currency);
+      defineWECProperty(result, 'currencyDisplay',
+                        format.resolved.currencyDisplay);
+    }
 
-  if (format.resolved.hasOwnProperty('minimumSignificantDigits')) {
-    defineWECProperty(result, 'minimumSignificantDigits',
-                      format.resolved.minimumSignificantDigits);
-  }
+    if (format.resolved.hasOwnProperty('minimumSignificantDigits')) {
+      defineWECProperty(result, 'minimumSignificantDigits',
+                        format.resolved.minimumSignificantDigits);
+    }
 
-  if (format.resolved.hasOwnProperty('maximumSignificantDigits')) {
-    defineWECProperty(result, 'maximumSignificantDigits',
-                      format.resolved.maximumSignificantDigits);
-  }
+    if (format.resolved.hasOwnProperty('maximumSignificantDigits')) {
+      defineWECProperty(result, 'maximumSignificantDigits',
+                        format.resolved.maximumSignificantDigits);
+    }
 
-  return result;
-};
+    return result;
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.NumberFormat.prototype.resolvedOptions);
 
 
@@ -239,13 +243,15 @@
  * order in the returned list as in the input list.
  * Options are optional parameter.
  */
-Intl.NumberFormat.supportedLocalesOf = function(locales) {
-  if (%_IsConstructCall()) {
-    throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
-  }
+%SetProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
+    if (%_IsConstructCall()) {
+      throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
+    }
 
-  return supportedLocalesOf('numberformat', locales, arguments[1]);
-};
+    return supportedLocalesOf('numberformat', locales, arguments[1]);
+  },
+  ATTRIBUTES.DONT_ENUM
+);
 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf);