Exemplo n.º 1
0
JSC::JSValue  WebCore::JSNavigator::isApplicationInstalled(JSC::ExecState* exec, JSC::ArgList const& args)
{
    if (args.size() < 2) {
        setDOMException(exec, SYNTAX_ERR);
        return jsUndefined();
    }

    if (!args.at(1).inherits(&InternalFunction::info)) {
        setDOMException(exec, TYPE_MISMATCH_ERR);
        return jsUndefined();
    }

    String appName = args.at(0).toString(exec);

    JSObject* object;
    if (!(object = args.at(1).getObject())) {
        setDOMException(exec, TYPE_MISMATCH_ERR);
        return jsUndefined();
    }

    RefPtr<ApplicationInstalledCallback> callback(JSCustomApplicationInstalledCallback::create(
            object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())));

    if (!m_impl->isApplicationInstalled(appName, callback.release()))
        setDOMException(exec, INVALID_STATE_ERR);
    return jsUndefined();
}
JSValue JSCanvasRenderingContext3D::bufferSubData(JSC::ExecState* exec, JSC::ArgList const& args)
{
    if (args.size() != 3)
        return throwError(exec, SyntaxError);

    unsigned target = args.at(0).toInt32(exec);
    unsigned offset = args.at(1).toInt32(exec);
    
    CanvasArray* array = toCanvasArray(args.at(2));
    
    static_cast<CanvasRenderingContext3D*>(impl())->bufferSubData(target, offset, array);
    return jsUndefined();
}
JSC::JSValue JSWebGLShortArray::set(JSC::ExecState* exec, JSC::ArgList const& args)
{
    if (args.size() > 2)
        return throwError(exec, SyntaxError);

    if (args.size() == 2 && args.at(0).isInt32()) {
        // void set(in unsigned long index, in long value);
        unsigned index = args.at(0).toUInt32(exec);
        impl()->set(index, static_cast<signed short>(args.at(1).toInt32(exec)));
        return jsUndefined();
    }

    WebGLShortArray* shortArray = toWebGLShortArray(args.at(0));
    if (shortArray) {
        // void set(in WebGLShortArray array, [Optional] in unsigned long offset);
        unsigned offset = 0;
        if (args.size() == 2)
            offset = args.at(1).toInt32(exec);
        ExceptionCode ec = 0;
        impl()->set(shortArray, offset, ec);
        setDOMException(exec, ec);
        return jsUndefined();
    }

    return setWebGLArrayFromArray(exec, impl(), args);
}
static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, const JSC::ArgList& args, CanvasRenderingContext3D* context)
{
    if (args.size() != 2)
        return throwError(exec, SyntaxError);

    long location = args.at(0).toInt32(exec);
    if (exec->hadException())    
        return jsUndefined();
        
    RefPtr<CanvasFloatArray> canvasArray = toCanvasFloatArray(args.at(1));
    if (exec->hadException())    
        return jsUndefined();
        
    if (canvasArray) {
        switch(f) {
            case f_uniform1v: context->uniform1fv(location, canvasArray.get()); break;
            case f_uniform2v: context->uniform2fv(location, canvasArray.get()); break;
            case f_uniform3v: context->uniform3fv(location, canvasArray.get()); break;
            case f_uniform4v: context->uniform4fv(location, canvasArray.get()); break;
            case f_vertexAttrib1v: context->vertexAttrib1fv(location, canvasArray.get()); break;
            case f_vertexAttrib2v: context->vertexAttrib2fv(location, canvasArray.get()); break;
            case f_vertexAttrib3v: context->vertexAttrib3fv(location, canvasArray.get()); break;
            case f_vertexAttrib4v: context->vertexAttrib4fv(location, canvasArray.get()); break;
        }
        return jsUndefined();
    }
    
    float* array;
    int size;
    toArray<float>(exec, args.at(1), array, size);
    
    if (!array)
        return throwError(exec, TypeError);

    switch(f) {
        case f_uniform1v: context->uniform1fv(location, array, size); break;
        case f_uniform2v: context->uniform2fv(location, array, size); break;
        case f_uniform3v: context->uniform3fv(location, array, size); break;
        case f_uniform4v: context->uniform4fv(location, array, size); break;
        case f_vertexAttrib1v: context->vertexAttrib1fv(location, array, size); break;
        case f_vertexAttrib2v: context->vertexAttrib2fv(location, array, size); break;
        case f_vertexAttrib3v: context->vertexAttrib3fv(location, array, size); break;
        case f_vertexAttrib4v: context->vertexAttrib4fv(location, array, size); break;
    }
    return jsUndefined();
}
static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, const JSC::ArgList& args, CanvasRenderingContext3D* context)
{
    if (args.size() != 3)
        return throwError(exec, SyntaxError);

    long location = args.at(0).toInt32(exec);
    if (exec->hadException())    
        return jsUndefined();
        
    bool transpose = args.at(1).toBoolean(exec);
    if (exec->hadException())    
        return jsUndefined();
        
    RefPtr<CanvasFloatArray> canvasArray = toCanvasFloatArray(args.at(2));
    if (exec->hadException())    
        return jsUndefined();
        
    if (canvasArray) {
        switch(f) {
            case f_uniformMatrix2fv: context->uniformMatrix2fv(location, transpose, canvasArray.get()); break;
            case f_uniformMatrix3fv: context->uniformMatrix3fv(location, transpose, canvasArray.get()); break;
            case f_uniformMatrix4fv: context->uniformMatrix4fv(location, transpose, canvasArray.get()); break;
        }
        return jsUndefined();
    }
    
    float* array;
    int size;
    toArray<float>(exec, args.at(2), array, size);
    
    if (!array)
        return throwError(exec, TypeError);

    switch(f) {
        case f_uniformMatrix2fv: context->uniformMatrix2fv(location, transpose, array, size); break;
        case f_uniformMatrix3fv: context->uniformMatrix3fv(location, transpose, array, size); break;
        case f_uniformMatrix4fv: context->uniformMatrix4fv(location, transpose, array, size); break;
    }
    return jsUndefined();
}
Exemplo n.º 6
0
JSC::JSValue JSMessageEvent::initMessageEvent(JSC::ExecState* exec, const JSC::ArgList& args)
{
    const UString& typeArg = args.at(0).toString(exec);
    bool canBubbleArg = args.at(1).toBoolean(exec);
    bool cancelableArg = args.at(2).toBoolean(exec);
    PassRefPtr<SerializedScriptValue> dataArg = SerializedScriptValue::create(exec, args.at(3));
    const UString& originArg = args.at(4).toString(exec);
    const UString& lastEventIdArg = args.at(5).toString(exec);
    DOMWindow* sourceArg = toDOMWindow(args.at(6));
    OwnPtr<MessagePortArray> messagePorts;
    if (!args.at(7).isUndefinedOrNull()) {
        messagePorts = new MessagePortArray();
        fillMessagePortArray(exec, args.at(7), *messagePorts);
        if (exec->hadException())
            return jsUndefined();
    }

    MessageEvent* event = static_cast<MessageEvent*>(this->impl());
    event->initMessageEvent(ustringToAtomicString(typeArg), canBubbleArg, cancelableArg, dataArg, ustringToString(originArg), ustringToString(lastEventIdArg), sourceArg, messagePorts.release());
    return jsUndefined();
}
JSValue JSCanvasRenderingContext3D::bufferData(JSC::ExecState* exec, JSC::ArgList const& args)
{
    if (args.size() != 3)
        return throwError(exec, SyntaxError);

    unsigned target = args.at(0).toInt32(exec);
    unsigned usage = args.at(2).toInt32(exec);

    // If argument 1 is a number, we are initializing this buffer to that size
    if (!args.at(1).isObject()) {
        unsigned int count = args.at(1).toInt32(exec);
        static_cast<CanvasRenderingContext3D*>(impl())->bufferData(target, count, usage);
        return jsUndefined();
    }

    CanvasArray* array = toCanvasArray(args.at(1));
    
    static_cast<CanvasRenderingContext3D*>(impl())->bufferData(target, array, usage);
    return jsUndefined();
}