Beispiel #1
0
 static void valueAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
   INC_STATS("DOM.HTMLLIElement.value._set");
   HTMLLIElement* imp = V8HTMLLIElement::toNative(info.Holder());
   int v = toInt32(value);
   imp->setValue(v);
   return;
 }
v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Document.evaluate()");

    RefPtr<Document> document = V8Document::toNative(args.Holder());
    ExceptionCode ec = 0;
    String expression = toWebCoreString(args[0]);
    RefPtr<Node> contextNode;
    if (V8Node::HasInstance(args[1]))
        contextNode = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[1]));

    RefPtr<XPathNSResolver> resolver = V8DOMWrapper::getXPathNSResolver(args[2]);
    if (!resolver && !args[2]->IsNull() && !args[2]->IsUndefined())
        return throwError(TYPE_MISMATCH_ERR);

    int type = toInt32(args[3]);
    RefPtr<XPathResult> inResult;
    if (V8XPathResult::HasInstance(args[4]))
        inResult = V8XPathResult::toNative(v8::Handle<v8::Object>::Cast(args[4]));

    v8::TryCatch exceptionCatcher;
    RefPtr<XPathResult> result = document->evaluate(expression, contextNode.get(), resolver.get(), type, inResult.get(), ec);
    if (exceptionCatcher.HasCaught())
        return throwError(exceptionCatcher.Exception());

    if (ec)
        return throwError(ec);

    return toV8(result.release());
}
Beispiel #3
0
NITFPRIV(NITF_BOOL) toInt(nitf_Field * field,
                          NITF_DATA * outData,
                          size_t length, nitf_Error * error)
{
    /*  First we have to figure out what we are storing...
       See, its okay to convert a BCS-N to an int, and...
       its also okay to maintain a binary int...          */
    NITF_BOOL status = NITF_FAILURE;
    if (field->type == NITF_BINARY)
    {
        switch (field->length)
        {
            case 2:
                status = toInt16(field, (nitf_Int16 *) outData, error);
                break;
            case 4:
                status = toInt32(field, (nitf_Int32 *) outData, error);
                break;
            case 8:
                status = toInt64(field, (nitf_Int64 *) outData, error);
                break;
            default:
                nitf_Error_initf(error, NITF_CTXT,
                                 NITF_ERR_INVALID_PARAMETER,
                                 "Unexpected field size for int [%d]",
                                 field->length);
        }
    }
    else
    {
        status = fromStringToInt(field, outData, length, error);
    }
    return status;
}
static void heightAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setHeight(v);
    return;
}
static void widthAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    HTMLPreElement* imp = V8HTMLPreElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setIntegralAttribute(WebCore::HTMLNames::widthAttr, v);
    return;
}
static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), info.GetIsolate());
    TestInterfaceEmpty* testInterfaceEmptyArg;
    int longArg;
    V8StringResource<> defaultUndefinedOptionalStringArg;
    V8StringResource<> defaultNullStringOptionalStringArg;
    Dictionary defaultUndefinedOptionalDictionaryArg;
    V8StringResource<> optionalStringArg;
    {
        int numArgsPassed = info.Length();
        while (numArgsPassed > 0) {
            if (!info[numArgsPassed - 1]->IsUndefined())
                break;
            --numArgsPassed;
        }
        testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]);
        if (!testInterfaceEmptyArg) {
            exceptionState.throwTypeError("parameter 1 is not of type 'TestInterfaceEmpty'.");
            exceptionState.throwIfNeeded();
            return;
        }
        longArg = toInt32(info.GetIsolate(), info[1], NormalConversion, exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        defaultUndefinedOptionalStringArg = info[2];
        if (!defaultUndefinedOptionalStringArg.prepare())
            return;
        if (!info[3]->IsUndefined()) {
            defaultNullStringOptionalStringArg = info[3];
            if (!defaultNullStringOptionalStringArg.prepare())
                return;
        } else {
            defaultNullStringOptionalStringArg = nullptr;
        }
        if (!isUndefinedOrNull(info[4]) && !info[4]->IsObject()) {
            exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
            exceptionState.throwIfNeeded();
            return;
        }
        defaultUndefinedOptionalDictionaryArg = Dictionary(info[4], info.GetIsolate(), exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        if (UNLIKELY(numArgsPassed <= 5)) {
            RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
            v8::Local<v8::Object> wrapper = info.Holder();
            wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper);
            v8SetReturnValue(info, wrapper);
            return;
        }
        optionalStringArg = info[5];
        if (!optionalStringArg.prepare())
            return;
    }
    RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg);
    v8::Local<v8::Object> wrapper = info.Holder();
    wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper);
    v8SetReturnValue(info, wrapper);
}
Beispiel #7
0
static void selectionEndAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLTextAreaElement.selectionEnd._set");
    HTMLTextAreaElement* imp = V8HTMLTextAreaElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setSelectionEnd(v);
    return;
}
static void rowSpanAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLTableCellElement.rowSpan._set");
    HTMLTableCellElement* imp = V8HTMLTableCellElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setRowSpan(v);
    return;
}
static void vspaceAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLImageElement.vspace._set");
    HTMLImageElement* imp = V8HTMLImageElement::toNative(info.Holder());
    int v = toInt32(value);
    imp->setIntegralAttribute(WebCore::HTMLNames::vspaceAttr, v);
    return;
}
Beispiel #10
0
int32_t toInt32(double d, bool &ok)
{
    ok = true;
    if (isNaN(d) || isInf(d)) {
        ok = false;
        return 0;
    }
    return toInt32(d);
}
static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.HTMLImageElement.Contructor");

    if (!args.IsConstructCall())
        return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);

    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
        return args.Holder();

    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
    if (!frame)
        return throwError("Image constructor associated frame is unavailable", V8Proxy::ReferenceError);

    Document* document = frame->document();
    if (!document)
        return throwError("Image constructor associated document is unavailable", V8Proxy::ReferenceError);

    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
    // may end up being the only node in the map and get garbage-ccollected prematurely.
    // FIXME: The correct way to do this would be to make HTMLImageElement derive from
    // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would
    // remove this code and the special case in isObservableThroughDOM.
    toV8(document);

    int width;
    int height;
    int* optionalWidth = 0;
    int* optionalHeight = 0;
    if (args.Length() > 0) {
        width = toInt32(args[0]);
        optionalWidth = &width;
    }
    if (args.Length() > 1) {
        height = toInt32(args[1]);
        optionalHeight = &height;
    }

    RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight);
    V8DOMWrapper::setDOMWrapper(args.Holder(), &V8HTMLImageElementConstructor::info, image.get());
    image->ref();
    V8DOMWrapper::setJSWrapperForDOMNode(image.get(), v8::Persistent<v8::Object>::New(args.Holder()));
    return args.Holder();
}
Beispiel #12
0
 static v8::Handle<v8::Value> initTouchEventCallback(const v8::Arguments& args) {
   INC_STATS("DOM.TouchEvent.initTouchEvent");
   TouchEvent* imp = V8TouchEvent::toNative(args.Holder());
   TouchList* touches = V8TouchList::HasInstance(args[0]) ? V8TouchList::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
   TouchList* targetTouches = V8TouchList::HasInstance(args[1]) ? V8TouchList::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0;
   TouchList* changedTouches = V8TouchList::HasInstance(args[2]) ? V8TouchList::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
   V8Parameter<> type = args[3];
   DOMWindow* view = V8DOMWindow::HasInstance(args[4]) ? V8DOMWindow::toNative(v8::Handle<v8::Object>::Cast(args[4])) : 0;
   int screenX = toInt32(args[5]);
   int screenY = toInt32(args[6]);
   int clientX = toInt32(args[7]);
   int clientY = toInt32(args[8]);
   bool ctrlKey = args[9]->BooleanValue();
   bool altKey = args[10]->BooleanValue();
   bool shiftKey = args[11]->BooleanValue();
   bool metaKey = args[12]->BooleanValue();
   imp->initTouchEvent(touches, targetTouches, changedTouches, type, view, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey);
   return v8::Handle<v8::Value>();
 }
static void baseValAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    SVGAnimatedInteger* imp = V8SVGAnimatedInteger::toNative(info.Holder());
    int v = toInt32(value);
    ExceptionCode ec = 0;
    imp->setBaseVal(v, ec);
    if (UNLIKELY(ec))
        setDOMException(ec, info.GetIsolate());
    return;
}
Beispiel #14
0
void V8Custom::ClearTimeoutImpl(const v8::Arguments& args)
{
    v8::Handle<v8::Value> holder = args.Holder();
    DOMWindow* imp = V8Proxy::ToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
    if (!V8Proxy::CanAccessFrame(imp->frame(), true))
        return;
    ScriptExecutionContext* context = static_cast<ScriptExecutionContext*>(imp->frame()->document());
    int handle = toInt32(args[0]);
    DOMTimer::removeById(context, handle);
}
static void exposeJSAccessorAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "exposeJSAccessorAttribute", "TestInterfaceOwnPropertiesDerived", holder, info.GetIsolate());
    TestInterfaceOwnPropertiesDerived* impl = V8TestInterfaceOwnPropertiesDerived::toImpl(holder);
    int cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setExposeJSAccessorAttribute(cppValue);
}
Beispiel #16
0
static void maxLengthAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    INC_STATS("DOM.HTMLTextAreaElement.maxLength._set");
    HTMLTextAreaElement* imp = V8HTMLTextAreaElement::toNative(info.Holder());
    int v = toInt32(value);
    ExceptionCode ec = 0;
    imp->setMaxLength(v, ec);
    if (UNLIKELY(ec))
        V8Proxy::setDOMException(ec);
    return;
}
v8::Handle<v8::Value> removeElement(HTMLSelectElement* imp, const v8::Arguments& args) 
{
    if (V8HTMLOptionElement::HasInstance(args[0])) {
        HTMLOptionElement* element = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>::Cast(args[0]));
        imp->remove(element->index());
        return v8::Undefined();
    }

    imp->remove(toInt32(args[0]));
    return v8::Undefined();
}
Beispiel #18
0
 static v8::Handle<v8::Value> initErrorEventCallback(const v8::Arguments& args) {
   INC_STATS("DOM.ErrorEvent.initErrorEvent");
   ErrorEvent* imp = V8ErrorEvent::toNative(args.Holder());
   V8Parameter<> typeArg = args[0];
   bool canBubbleArg = args[1]->BooleanValue();
   bool cancelableArg = args[2]->BooleanValue();
   V8Parameter<> messageArg = args[3];
   V8Parameter<> filenameArg = args[4];
   unsigned linenoArg = toInt32(args[5]);
   imp->initErrorEvent(typeArg, canBubbleArg, cancelableArg, messageArg, filenameArg, linenoArg);
   return v8::Handle<v8::Value>();
 }
v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Document.getCSSCanvasContext");
    v8::Handle<v8::Object> holder = args.Holder();
    Document* imp = V8Document::toNative(holder);
    String contextId = toWebCoreString(args[0]);
    String name = toWebCoreString(args[1]);
    int width = toInt32(args[2]);
    int height = toInt32(args[3]);
    CanvasRenderingContext* result = imp->getCSSCanvasContext(contextId, name, width, height);
    if (!result)
        return v8::Undefined();
    if (result->is2d())
        return toV8(static_cast<CanvasRenderingContext2D*>(result));
#if ENABLE(3D_CANVAS)
    else if (result->is3d())
        return toV8(static_cast<WebGLRenderingContext*>(result));
#endif // ENABLE(3D_CANVAS)
    ASSERT_NOT_REACHED();
    return v8::Undefined();
}
v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.WebGLRenderingContext.getFramebufferAttachmentParameter()");

    if (args.Length() != 3) {
        V8Proxy::setDOMException(SYNTAX_ERR);
        return notHandledByInterceptor();
    }

    ExceptionCode ec = 0;
    WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
    unsigned target = toInt32(args[0]);
    unsigned attachment = toInt32(args[1]);
    unsigned pname = toInt32(args[2]);
    WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attachment, pname, ec);
    if (ec) {
        V8Proxy::setDOMException(ec);
        return v8::Undefined();
    }
    return toV8Object(info);
}
static void v8HTMLImageElementConstructorMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    if (!args.IsConstructCall()) {
        throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
        return;
    }

    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
        v8SetReturnValue(args, args.Holder());
        return;
    }

    Document* document = currentDocument();
    ASSERT(document);

    // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance
    // may end up being the only node in the map and get garbage-collected prematurely.
    // FIXME: The correct way to do this would be to make HTMLImageElement derive from
    // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would
    // remove this code and the special case in isObservableThroughDOM.
    toV8(document, args.Holder(), args.GetIsolate());

    int width;
    int height;
    int* optionalWidth = 0;
    int* optionalHeight = 0;
    if (args.Length() > 0) {
        width = toInt32(args[0]);
        optionalWidth = &width;
    }
    if (args.Length() > 1) {
        height = toInt32(args[1]);
        optionalHeight = &height;
    }

    RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(*document, optionalWidth, optionalHeight);
    v8::Handle<v8::Object> wrapper = args.Holder();
    V8DOMWrapper::associateObjectWithWrapper<V8HTMLImageElement>(image.release(), &V8HTMLImageElementConstructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
    v8SetReturnValue(args, wrapper);
}
void V8WebCLKernel::getWorkGroupInfoMethodCustom(const v8::Arguments& args)
{
  
    if (args.Length() != 2)
        { throwNotEnoughArgumentsError(args.GetIsolate()); return; }

    ExceptionState es(args.GetIsolate());
    WebCLKernel* kernel = V8WebCLKernel::toNative(args.Holder());
    WebCLDevice* device = V8WebCLDevice::toNative(v8::Handle<v8::Object>::Cast(args[0]));
    int workgroup_index = toInt32(args[1]);
    WebCLGetInfo info = kernel->getWorkGroupInfo(device, workgroup_index, es);
    v8SetReturnValue(args, toV8Object(info,args.Holder(), args.GetIsolate()));
}
void V8WebCLKernel::getInfoMethodCustom(const v8::Arguments& args)
{
  
    if (args.Length() != 1)
        { throwNotEnoughArgumentsError(args.GetIsolate()); return; }

    ExceptionState es(args.GetIsolate());
    WebCLKernel* kernel = V8WebCLKernel::toNative(args.Holder()); 
    int kernel_index = toInt32(args[0]);
    WebCLGetInfo info = kernel->getInfo(kernel_index, es);

    v8SetReturnValue(args, toV8Object(info, args.Holder(),args.GetIsolate()));
}
Beispiel #24
0
static void conditionalLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Object> holder = info.Holder();
  TestInterfaceOriginTrialEnabled* impl = V8TestInterfaceOriginTrialEnabled::toImpl(holder);

  ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext, "TestInterfaceOriginTrialEnabled", "conditionalLongAttribute");

  // Prepare the value to be set.
  int cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
  if (exceptionState.hadException())
    return;

  impl->setConditionalLongAttribute(cppValue);
}
Beispiel #25
0
/* We may want to rethink this function a bit.
 * The NITF spec. has many fields with a BINARY_INTEGER type
 * This could mean that the field contains 3 8-bit binary integers
 * For that example, the length of the field is 3, which isn't an integer size
 * Thus, that wouldn't work here if we just assumed BINARY_INTEGER has ONE integer in the field
 */
NITFPRIV(NITF_BOOL) fromIntToString(nitf_Field * field, char *outValue,
                                    size_t length, nitf_Error * error)
{
    char buffer[256];
    size_t actualLength = 0;
    /*  These are all two-step processes 1) get native int 2) NITF_SNPRINTF */
    switch (field->length)
    {
        case 2:
        {
            nitf_Int16 int16;
            if (!toInt16(field, &int16, error))
                goto CATCH_ERROR;
            actualLength = NITF_SNPRINTF(buffer, 256, "%d", int16);
        }
        break;
        case 4:
        {
            nitf_Int32 int32;
            if (!toInt32(field, &int32, error))
                goto CATCH_ERROR;
            actualLength = NITF_SNPRINTF(buffer, 256, "%ld", (long) int32);
        }
        break;
        case 8:
        {
            nitf_Int64 int64;
            if (!toInt64(field, &int64, error))
                goto CATCH_ERROR;
            actualLength = NITF_SNPRINTF(buffer, 256, "%lld", int64);
        }
        break;
        default:
        {
            /* otherwise, it must not be an integer value */
            return fromStringToString(field, outValue, length, error);
        }
    }
    if (actualLength > length)
    {
        nitf_Error_initf(error, NITF_CTXT, NITF_ERR_INVALID_PARAMETER,
                         "Out value too small [%d] size required",
                         strlen(buffer));
        return NITF_FAILURE;
    }
    strcpy(outValue, buffer);
    return NITF_SUCCESS;

CATCH_ERROR:
    return NITF_FAILURE;
}
void V8WebCL::getImageInfoMethodCustom(const v8::Arguments& args)
{
   
    if (args.Length() != 2)
        { throwNotEnoughArgumentsError(args.GetIsolate()); return; }

    ExceptionState es(args.GetIsolate());
    WebCL* webcl = V8WebCL::toNative(args.Holder());
    WebCLImage* image = V8WebCLImage::toNative(v8::Handle<v8::Object>::Cast(args[0]));
    int image_index = toInt32(args[1]);
    WebCLGetInfo info = webcl->getImageInfo(image, image_index, es);

    v8SetReturnValue(args, toV8Object(info,args.Holder(), args.GetIsolate()));
}
v8::Handle<v8::Value> V8ArrayBufferView::sliceCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.ArrayBufferView.slice");
    // Forms:
    // * slice(long start, long end);

    ArrayBufferView* imp = V8ArrayBufferView::toNative(args.Holder());
    int start, end;
    switch (args.Length()) {
    case 0:
        start = 0;
        end = imp->length();
        break;
    case 1:
        start = toInt32(args[0]);
        end = imp->length();
        break;
    default:
        start = toInt32(args[0]);
        end = toInt32(args[1]);
    }
    return toV8(imp->slice(start, end));
}
Beispiel #28
0
void IdWrapper::toValue(JS::MutableHandleValue value) const {
    if (isInt()) {
        value.setInt32(toInt32());
        return;
    }

    if (isString()) {
        auto str = JSID_TO_STRING(_value);
        value.setString(str);
        return;
    }

    uasserted(ErrorCodes::BadValue, "Failed to toValue() non-string and non-integer jsid");
}
static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, ObjectType objectType)
{
    if (args.Length() != 2) {
        V8Proxy::setDOMException(SYNTAX_ERR);
        return notHandledByInterceptor();
    }

    ExceptionCode ec = 0;
    WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
    unsigned target = toInt32(args[0]);
    unsigned pname = toInt32(args[1]);
    WebGLGetInfo info;
    switch (objectType) {
    case kBuffer:
        info = context->getBufferParameter(target, pname, ec);
        break;
    case kRenderbuffer:
        info = context->getRenderbufferParameter(target, pname, ec);
        break;
    case kTexture:
        info = context->getTexParameter(target, pname, ec);
        break;
    case kVertexAttrib:
        // target => index
        info = context->getVertexAttrib(target, pname, ec);
        break;
    default:
        notImplemented();
        break;
    }
    if (ec) {
        V8Proxy::setDOMException(ec);
        return v8::Undefined();
    }
    return toV8Object(info);
}
Beispiel #30
0
v8::Handle<v8::Value> V8AudioNode::connectCallback(const v8::Arguments& args)
{    
    if (args.Length() < 1)
        return throwError("Not enough arguments", V8Proxy::SyntaxError);

    // CAPPFIX_WEB_HTML5: WEB_AUDIO
    AudioNode* destinationNode = 0;
    if (V8AudioNode::HasInstance(args[0]))
        destinationNode = toNative(args[0]->ToObject());
    // CAPPFIX_WEB_HTML5_END

    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();
}