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(); }
JSC::JSValue JSAudioNode::connect(JSC::ExecState* exec) { if (exec->argumentCount() < 1) return throwError(exec, createSyntaxError(exec, "Not enough arguments")); unsigned outputIndex = 0; unsigned inputIndex = 0; AudioNode* destinationNode = toAudioNode(exec->argument(0)); if (!destinationNode) return throwError(exec, createSyntaxError(exec, "Invalid destination node")); if (exec->argumentCount() > 1) outputIndex = exec->argument(1).toInt32(exec); if (exec->argumentCount() > 2) inputIndex = exec->argument(2).toInt32(exec); AudioNode* audioNode = static_cast<AudioNode*>(impl()); bool success = audioNode->connect(destinationNode, outputIndex, inputIndex); if (!success) return throwError(exec, createSyntaxError(exec, "Invalid index parameter")); return JSC::jsUndefined(); }