static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContextBase& context) { if (exec->argumentCount() != 2) return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec)); WebGLUniformLocation* location = 0; long index = -1; if (functionForUniform(f)) { location = JSWebGLUniformLocation::toWrapped(exec->uncheckedArgument(0)); if (!location && !exec->uncheckedArgument(0).isUndefinedOrNull()) return throwTypeError(exec); } else index = exec->uncheckedArgument(0).toInt32(exec); if (exec->hadException()) return jsUndefined(); RefPtr<Float32Array> webGLArray = toFloat32Array(exec->uncheckedArgument(1)); if (exec->hadException()) return jsUndefined(); ExceptionCode ec = 0; if (webGLArray) { switch (f) { case f_uniform1v: context.uniform1fv(location, webGLArray.get(), ec); break; case f_uniform2v: context.uniform2fv(location, webGLArray.get(), ec); break; case f_uniform3v: context.uniform3fv(location, webGLArray.get(), ec); break; case f_uniform4v: context.uniform4fv(location, webGLArray.get(), ec); break; case f_vertexAttrib1v: context.vertexAttrib1fv(index, webGLArray.get()); break; case f_vertexAttrib2v: context.vertexAttrib2fv(index, webGLArray.get()); break; case f_vertexAttrib3v: context.vertexAttrib3fv(index, webGLArray.get()); break; case f_vertexAttrib4v: context.vertexAttrib4fv(index, webGLArray.get()); break; } setDOMException(exec, ec); return jsUndefined(); } Vector<float, 64> array; if (!toVector(exec, exec->uncheckedArgument(1), array)) return throwTypeError(exec); switch (f) { case f_uniform1v: context.uniform1fv(location, array.data(), array.size(), ec); break; case f_uniform2v: context.uniform2fv(location, array.data(), array.size(), ec); break; case f_uniform3v: context.uniform3fv(location, array.data(), array.size(), ec); break; case f_uniform4v: context.uniform4fv(location, array.data(), array.size(), ec); break; case f_vertexAttrib1v: context.vertexAttrib1fv(index, array.data(), array.size()); break; case f_vertexAttrib2v: context.vertexAttrib2fv(index, array.data(), array.size()); break; case f_vertexAttrib3v: context.vertexAttrib3fv(index, array.data(), array.size()); break; case f_vertexAttrib4v: context.vertexAttrib4fv(index, array.data(), array.size()); break; } setDOMException(exec, ec); return jsUndefined(); }
static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context) { if (exec->argumentCount() != 2) return throwSyntaxError(exec); WebGLUniformLocation* location = 0; long index = -1; if (functionForUniform(f)) { if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSWebGLUniformLocation::s_info)) return throwTypeError(exec); location = toWebGLUniformLocation(exec->argument(0)); } else index = exec->argument(0).toInt32(exec); if (exec->hadException()) return jsUndefined(); RefPtr<Float32Array> float32Array = toFloat32Array(exec->argument(1)); if (exec->hadException()) return jsUndefined(); ExceptionCode ec = 0; if (float32Array) { switch (f) { case f_uniform1v: context->uniform1fv(location, float32Array.get(), ec); break; case f_uniform2v: context->uniform2fv(location, float32Array.get(), ec); break; case f_uniform3v: context->uniform3fv(location, float32Array.get(), ec); break; case f_uniform4v: context->uniform4fv(location, float32Array.get(), ec); break; case f_vertexAttrib1v: context->vertexAttrib1fv(index, float32Array.get()); break; case f_vertexAttrib2v: context->vertexAttrib2fv(index, float32Array.get()); break; case f_vertexAttrib3v: context->vertexAttrib3fv(index, float32Array.get()); break; case f_vertexAttrib4v: context->vertexAttrib4fv(index, float32Array.get()); break; } setDOMException(exec, ec); return jsUndefined(); } Vector<float, 64> array; if (!toVector(exec, exec->argument(1), array)) return throwTypeError(exec); switch (f) { case f_uniform1v: context->uniform1fv(location, array.data(), array.size(), ec); break; case f_uniform2v: context->uniform2fv(location, array.data(), array.size(), ec); break; case f_uniform3v: context->uniform3fv(location, array.data(), array.size(), ec); break; case f_uniform4v: context->uniform4fv(location, array.data(), array.size(), ec); break; case f_vertexAttrib1v: context->vertexAttrib1fv(index, array.data(), array.size()); break; case f_vertexAttrib2v: context->vertexAttrib2fv(index, array.data(), array.size()); break; case f_vertexAttrib3v: context->vertexAttrib3fv(index, array.data(), array.size()); break; case f_vertexAttrib4v: context->vertexAttrib4fv(index, array.data(), array.size()); break; } setDOMException(exec, ec); return jsUndefined(); }