diff options
author | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 00:41:27 +0000 |
---|---|---|
committer | abarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 00:41:27 +0000 |
commit | e87f312c1a96c95046034585561932bfa4aae2d4 (patch) | |
tree | 4b73e5ff782b9103ac9d282d8eda720c6f14adce /gin/arguments.cc | |
parent | 23cd38f16a09b542cb40f9d69f5ba86aca868c8b (diff) | |
download | chromium_src-e87f312c1a96c95046034585561932bfa4aae2d4.zip chromium_src-e87f312c1a96c95046034585561932bfa4aae2d4.tar.gz chromium_src-e87f312c1a96c95046034585561932bfa4aae2d4.tar.bz2 |
Begin implementing V8 bindings for Mojo
This CL contains the beginnings of JavaScript bindings for the core Mojo
system. The approach in this CL is to bind as close to the "metal" as possible
so as to self-host as much as possiblem in the VM. I've tried to avoid
retaining any state on the C++ side of the bindings, but I didn't quite succeed
because V8 requires embedders to retain state in order to access the memory
that backs ArrayBuffers.
In this CL, I've added some basic bindings for the symbols exported by core.h.
Specifically, I've created bindings for CreateMessagePipe, Close, Wait,
WaitMany, WriteMessage, and ReadMessage.
R=aa@chromium.org, darin@chromium.org
BUG=317398
Review URL: https://codereview.chromium.org/59153005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin/arguments.cc')
-rw-r--r-- | gin/arguments.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gin/arguments.cc b/gin/arguments.cc new file mode 100644 index 0000000..15802b8 --- /dev/null +++ b/gin/arguments.cc @@ -0,0 +1,36 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gin/arguments.h" + +#include <sstream> +#include "gin/converter.h" + +namespace gin { + +Arguments::Arguments(const v8::FunctionCallbackInfo<v8::Value>& info) + : isolate_(info.GetIsolate()), + info_(info), + next_(0), + insufficient_arguments_(false) { +} + +Arguments::~Arguments() { +} + +void Arguments::ThrowError() { + if (insufficient_arguments_) + return ThrowTypeError("Insufficient number of arguments."); + + std::stringstream stream; + stream << "Error processing argument " << next_ - 1 << "."; + ThrowTypeError(stream.str()); +} + +void Arguments::ThrowTypeError(const std::string& message) { + isolate_->ThrowException(v8::Exception::TypeError( + StringToV8(isolate_, message))); +} + +} // namespace gin |