Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: src/icu_util.cc

Issue 209323014: Roll ICU 239289:258359 and add support for external ICU data tables (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/v8.h ('K') | « src/icu_util.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/icu_util.cc
diff --git a/src/icu_util.cc b/src/icu_util.cc
index b9bd65edc69ecb680a9cae4efc96ed3158543285..6441dbdd9f5fd98392a720d174fb7b4cebed7510 100644
--- a/src/icu_util.cc
+++ b/src/icu_util.cc
@@ -27,12 +27,20 @@
#include "icu_util.h"
-#if defined(_WIN32) && defined(V8_I18N_SUPPORT)
+#if defined(_WIN32)
#include <windows.h>
+#endif
+
+#if defined(V8_I18N_SUPPORT)
+#include <stdio.h>
#include "unicode/putil.h"
#include "unicode/udata.h"
+#define ICU_UTIL_DATA_FILE 0
+#define ICU_UTIL_DATA_SHARED 1
+#define ICU_UTIL_DATA_STATIC 2
+
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
#endif
@@ -41,8 +49,11 @@ namespace v8 {
namespace internal {
-bool InitializeICU() {
-#if defined(_WIN32) && defined(V8_I18N_SUPPORT)
+bool InitializeICU(const char* icu_data_file) {
+#if !defined(V8_I18N_SUPPORT)
+ return true;
+#else
+#if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED
// We expect to find the ICU data module alongside the current module.
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) return false;
@@ -53,9 +64,30 @@ bool InitializeICU() {
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
return err == U_ZERO_ERROR;
-#else
+#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC
// Mac/Linux bundle the ICU data in.
return true;
+#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
+ if (!icu_data_file) return false;
+
+ FILE* inf = fopen(icu_data_file, "rb");
+ if (!inf) return false;
+
+ fseek(inf, 0, SEEK_END);
+ size_t size = ftell(inf);
+ rewind(inf);
+
+ char* addr = new char[size];
+ if (fread(addr, 1, size, inf) != size) {
jungshik at Google 2014/03/26 05:53:15 Would it be a good idea to use memory map (I saw s
+ delete[] addr;
danno 2014/03/25 08:47:21 Not sure if we care about deleting this on V8 clea
jochen (gone - plz use gerrit) 2014/03/25 12:04:11 I don't think we run d8 when build in chromium und
Sven Panne 2014/03/25 12:10:57 Hmmm, d8 should really be valgrind-clean, and it w
+ fclose(inf);
+ return false;
+ }
+ fclose(inf);
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setCommonData(reinterpret_cast<void*>(addr), &err);
+ return err == U_ZERO_ERROR;
+#endif
#endif
}
« include/v8.h ('K') | « src/icu_util.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698