static JSValue getObjectParameter(JSWebGLRenderingContext* obj, ExecState* exec, ObjectType objectType) { if (exec->argumentCount() != 2) return throwSyntaxError(exec); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(obj->impl()); unsigned target = exec->argument(0).toInt32(exec); if (exec->hadException()) return jsUndefined(); unsigned pname = exec->argument(1).toInt32(exec); if (exec->hadException()) return jsUndefined(); 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) { setDOMException(exec, ec); return jsUndefined(); } return toJS(exec, obj->globalObject(), info); }
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); }