V8 Project
v8::internal::NumberFormat Class Reference

#include <i18n.h>

+ Collaboration diagram for v8::internal::NumberFormat:

Static Public Member Functions

static icu::DecimalFormat * InitializeNumberFormat (Isolate *isolate, Handle< String > locale, Handle< JSObject > options, Handle< JSObject > resolved)
 
static icu::DecimalFormat * UnpackNumberFormat (Isolate *isolate, Handle< JSObject > obj)
 
static void DeleteNumberFormat (const v8::WeakCallbackData< v8::Value, void > &data)
 

Private Member Functions

 NumberFormat ()
 

Detailed Description

Definition at line 59 of file i18n.h.

Constructor & Destructor Documentation

◆ NumberFormat()

v8::internal::NumberFormat::NumberFormat ( )
private

Member Function Documentation

◆ DeleteNumberFormat()

void v8::internal::NumberFormat::DeleteNumberFormat ( const v8::WeakCallbackData< v8::Value, void > &  data)
static

Definition at line 807 of file i18n.cc.

808  {
809  DeleteNativeObjectAt<icu::DecimalFormat>(data, 0);
810  DestroyGlobalHandle(data);
811 }
static void DestroyGlobalHandle(const v8::WeakCallbackData< v8::Value, void > &data)
Definition: i18n.cc:740

References v8::internal::DestroyGlobalHandle().

+ Here is the call graph for this function:

◆ InitializeNumberFormat()

icu::DecimalFormat * v8::internal::NumberFormat::InitializeNumberFormat ( Isolate isolate,
Handle< String locale,
Handle< JSObject options,
Handle< JSObject resolved 
)
static

Definition at line 753 of file i18n.cc.

757  {
758  // Convert BCP47 into ICU locale format.
759  UErrorCode status = U_ZERO_ERROR;
760  icu::Locale icu_locale;
761  char icu_result[ULOC_FULLNAME_CAPACITY];
762  int icu_length = 0;
763  v8::String::Utf8Value bcp47_locale(v8::Utils::ToLocal(locale));
764  if (bcp47_locale.length() != 0) {
765  uloc_forLanguageTag(*bcp47_locale, icu_result, ULOC_FULLNAME_CAPACITY,
766  &icu_length, &status);
767  if (U_FAILURE(status) || icu_length == 0) {
768  return NULL;
769  }
770  icu_locale = icu::Locale(icu_result);
771  }
772 
773  icu::DecimalFormat* number_format =
774  CreateICUNumberFormat(isolate, icu_locale, options);
775  if (!number_format) {
776  // Remove extensions and try again.
777  icu::Locale no_extension_locale(icu_locale.getBaseName());
778  number_format = CreateICUNumberFormat(
779  isolate, no_extension_locale, options);
780 
781  // Set resolved settings (pattern, numbering system).
783  isolate, no_extension_locale, number_format, resolved);
784  } else {
785  SetResolvedNumberSettings(isolate, icu_locale, number_format, resolved);
786  }
787 
788  return number_format;
789 }
Converts an object to a UTF-8-encoded character array.
Definition: v8.h:2048
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
void SetResolvedNumberSettings(Isolate *isolate, const icu::Locale &icu_locale, icu::DecimalFormat *number_format, Handle< JSObject > resolved)
Definition: i18n.cc:331
icu::DecimalFormat * CreateICUNumberFormat(Isolate *isolate, const icu::Locale &icu_locale, Handle< JSObject > options)
Definition: i18n.cc:224

References v8::internal::anonymous_namespace{i18n.cc}::CreateICUNumberFormat(), v8::String::Utf8Value::length(), NULL, v8::internal::anonymous_namespace{i18n.cc}::SetResolvedNumberSettings(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ UnpackNumberFormat()

icu::DecimalFormat * v8::internal::NumberFormat::UnpackNumberFormat ( Isolate isolate,
Handle< JSObject obj 
)
static

Definition at line 792 of file i18n.cc.

794  {
795  Handle<String> key =
796  isolate->factory()->NewStringFromStaticChars("numberFormat");
797  Maybe<bool> maybe = JSReceiver::HasOwnProperty(obj, key);
798  CHECK(maybe.has_value);
799  if (maybe.value) {
800  return reinterpret_cast<icu::DecimalFormat*>(obj->GetInternalField(0));
801  }
802 
803  return NULL;
804 }
static MUST_USE_RESULT Maybe< bool > HasOwnProperty(Handle< JSReceiver >, Handle< Name > name)
Definition: objects-inl.h:6658
#define CHECK(condition)
Definition: logging.h:36
Maybe< T > maybe(T t)
Definition: v8.h:902

References CHECK, v8::internal::Isolate::factory(), v8::internal::JSReceiver::HasOwnProperty(), v8::maybe(), and NULL.

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: