mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-09 16:28:41 +00:00
Add php.ini setting v8js.icudtl_dat_path
This commit is contained in:
parent
73e1f3c9a2
commit
989f0ae82c
@ -156,6 +156,9 @@ struct _v8js_process_globals {
|
||||
/* V8 command line flags */
|
||||
char *v8_flags;
|
||||
|
||||
/* Path to icudtl.dat file */
|
||||
char *icudtl_dat_path;
|
||||
|
||||
v8::Platform *v8_platform;
|
||||
};
|
||||
|
||||
|
28
v8js_main.cc
28
v8js_main.cc
@ -33,7 +33,7 @@ struct _v8js_process_globals v8js_process_globals;
|
||||
|
||||
/* {{{ INI Settings */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
static bool v8js_ini_string(char **field, const zend_string *new_value)/* {{{ */
|
||||
{
|
||||
bool immutable = false;
|
||||
|
||||
@ -56,18 +56,33 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
}
|
||||
|
||||
if (new_value) {
|
||||
if (v8js_process_globals.v8_flags) {
|
||||
free(v8js_process_globals.v8_flags);
|
||||
v8js_process_globals.v8_flags = NULL;
|
||||
if (*field) {
|
||||
free(*field);
|
||||
*field = NULL;
|
||||
}
|
||||
|
||||
if (!ZSTR_VAL(new_value)[0]) {
|
||||
return FAILURE;
|
||||
return SUCCESS;
|
||||
}
|
||||
v8js_process_globals.v8_flags = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
|
||||
*field = zend_strndup(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
|
||||
{
|
||||
return v8js_ini_string(&v8js_process_globals.v8_flags, new_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static ZEND_INI_MH(v8js_OnUpdateIcudatPath) /* {{{ */
|
||||
{
|
||||
return v8js_ini_string(&v8js_process_globals.icudtl_dat_path, new_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static bool v8js_ini_to_bool(const zend_string *new_value) /* {{{ */
|
||||
{
|
||||
@ -106,6 +121,7 @@ static ZEND_INI_MH(v8js_OnUpdateCompatExceptions) /* {{{ */
|
||||
|
||||
ZEND_INI_BEGIN() /* {{{ */
|
||||
ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
|
||||
ZEND_INI_ENTRY("v8js.icudtl_dat_path", NULL, ZEND_INI_ALL, v8js_OnUpdateIcudatPath)
|
||||
ZEND_INI_ENTRY("v8js.use_date", "0", ZEND_INI_ALL, v8js_OnUpdateUseDate)
|
||||
ZEND_INI_ENTRY("v8js.use_array_access", "0", ZEND_INI_ALL, v8js_OnUpdateUseArrayAccess)
|
||||
ZEND_INI_ENTRY("v8js.compat_php_exceptions", "0", ZEND_INI_ALL, v8js_OnUpdateCompatExceptions)
|
||||
|
13
v8js_v8.cc
13
v8js_v8.cc
@ -76,10 +76,17 @@ void v8js_v8_init() /* {{{ */
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PHP_V8_EXEC_PATH) && PHP_V8_API_VERSION >= 5003178
|
||||
/* Initialize ICU, call introduced in V8 5.3.178 */
|
||||
v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
|
||||
#if PHP_V8_API_VERSION >= 5003178
|
||||
/* Initialize ICU, call introduced in V8 5.3.178 */
|
||||
if (v8js_process_globals.icudtl_dat_path != NULL && v8js_process_globals.icudtl_dat_path[0] != 0) {
|
||||
v8::V8::InitializeICUDefaultLocation(nullptr, v8js_process_globals.icudtl_dat_path);
|
||||
}
|
||||
#ifdef PHP_V8_EXEC_PATH
|
||||
else {
|
||||
v8::V8::InitializeICUDefaultLocation(PHP_V8_EXEC_PATH, nullptr);
|
||||
}
|
||||
#endif
|
||||
#endif /* PHP_V8_API_VERSION >= 5003178 */
|
||||
|
||||
/* Initialize V8 */
|
||||
v8::V8::Initialize();
|
||||
|
Loading…
Reference in New Issue
Block a user