0
0
mirror of https://github.com/phpv8/v8js.git synced 2025-01-03 11:21:51 +00:00

Fix output of var_dump on regexp (V8 > 4.8)

Newer V8 versions' toString() converts RegExp objects
just to [object RegExp] (instead of the actual regexp
as before).  Work-around by calling GetSource() on the
regexp and create former outhway that way.
This commit is contained in:
Stefan Siegl 2015-12-30 14:59:37 +01:00
parent d9e4ae5abe
commit 3108d3947d

View File

@ -92,10 +92,20 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
}
v8::TryCatch try_catch; /* object.toString() can throw an exception */
v8::Local<v8::String> details = var->ToDetailString();
if (try_catch.HasCaught()) {
details = V8JS_SYM("<toString threw exception>");
v8::Local<v8::String> details;
if(var->IsRegExp()) {
v8::RegExp *re = v8::RegExp::Cast(*var);
details = re->GetSource();
}
else {
details = var->ToDetailString();
if (try_catch.HasCaught()) {
details = V8JS_SYM("<toString threw exception>");
}
}
v8::String::Utf8Value str(details);
const char *valstr = ToCString(str);
size_t valstr_len = details->ToString()->Utf8Length();
@ -113,7 +123,7 @@ static void v8js_dumper(v8::Isolate *isolate, v8::Local<v8::Value> var, int leve
}
else if (var->IsRegExp())
{
php_printf("regexp(%s)\n", valstr);
php_printf("regexp(/%s/)\n", valstr);
}
else if (var->IsArray())
{