V8AudioNodeCustom.cpp [plain text]
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "V8AudioNode.h"
#include "AudioNode.h"
#include "ExceptionCode.h"
#include "NotImplemented.h"
#include "V8Binding.h"
#include "V8Proxy.h"
namespace WebCore {
v8::Handle<v8::Value> V8AudioNode::connectCallback(const v8::Arguments& args)
{
if (args.Length() < 1)
return throwError("Not enough arguments", V8Proxy::SyntaxError);
AudioNode* destinationNode = toNative(args[0]->ToObject());
if (!destinationNode)
return throwError("Invalid destination node", V8Proxy::SyntaxError);
unsigned output = 0;
unsigned input = 0;
bool ok = false;
if (args.Length() > 1) {
output = toInt32(args[1], ok);
if (!ok)
return throwError("Invalid index parameters", V8Proxy::SyntaxError);
}
if (args.Length() > 2) {
input = toInt32(args[2], ok);
if (!ok)
return throwError("Invalid index parameters", V8Proxy::SyntaxError);
}
AudioNode* audioNode = toNative(args.Holder());
bool success = audioNode->connect(destinationNode, output, input);
if (!success)
return throwError("Invalid index parameter", V8Proxy::SyntaxError);
return v8::Undefined();
}
v8::Handle<v8::Value> V8AudioNode::disconnectCallback(const v8::Arguments& args)
{
unsigned output = 0;
bool ok = false;
if (args.Length() > 0) {
output = toInt32(args[0], ok);
if (!ok)
return throwError("Invalid index parameters", V8Proxy::SyntaxError);
}
AudioNode* audioNode = toNative(args.Holder());
bool success = audioNode->disconnect(output);
if (!success)
return throwError("Invalid index parameter", V8Proxy::SyntaxError);
return v8::Undefined();
}
}
#endif // ENABLE(WEB_AUDIO)