Parsing ArrayBuffer from Script

61 views
Skip to first unread message

Michael Wielpütz

unread,
May 23, 2013, 6:32:46 PM5/23/13
to v8-u...@googlegroups.com
Hi,

currently I'm trying to read an ArrayBuffer, resulting from Javascript, inside a C++ application. For testing purposes I stripped the code down to the following:

v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope contextScope(context);

// the mini "script"
v8::Handle<v8::String> source = v8::String::New("new ArrayBuffer(3)");
v8::Handle<v8::Script> script = v8::Script::Compile(source);

v8::TryCatch trycatch;
v8::Handle<v8::Value>  result = script->Run();

if (result.IsEmpty())
{
  v8::Handle<v8::Value> excep = trycatch.Exception();
  v8::String::AsciiValue excepStr(excep);
  BOOST_REQUIRE_MESSAGE(false, *excepStr);
}

The result variable is always empty and I receive the following message:
ReferenceError: ArrayBuffer is not defined

If I replace the line 
v8::Handle<v8::String> source = v8::String::New("new ArrayBuffer(3)");
by
v8::Handle<v8::String> source = v8::String::New("new Array(3)");
the result variable holds the correct value.

Any ideas what I'm doing wrong here?

Thanks in advance,

Michael

Ben Noordhuis

unread,
May 23, 2013, 7:03:51 PM5/23/13
to v8-u...@googlegroups.com
Add --harmony_typed_arrays, they're not exposed by default.
Reply all
Reply to author
Forward
0 new messages