static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info) { switch (info.getType()) { case WebGLGetInfo::kTypeBool: return jsBoolean(info.getBool()); case WebGLGetInfo::kTypeBoolArray: { MarkedArgumentBuffer list; const auto& values = info.getBoolArray(); for (const auto& value : values) list.append(jsBoolean(value)); return constructArray(exec, 0, globalObject, list); } case WebGLGetInfo::kTypeFloat: return jsNumber(info.getFloat()); case WebGLGetInfo::kTypeInt: return jsNumber(info.getInt()); case WebGLGetInfo::kTypeNull: return jsNull(); case WebGLGetInfo::kTypeString: return jsStringWithCache(exec, info.getString()); case WebGLGetInfo::kTypeUnsignedInt: return jsNumber(info.getUnsignedInt()); case WebGLGetInfo::kTypeInt64: return jsNumber(info.getInt64()); default: notImplemented(); return jsUndefined(); } }
static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebGLGetInfo& info) { switch (info.getType()) { case WebGLGetInfo::kTypeBool: return jsBoolean(info.getBool()); case WebGLGetInfo::kTypeBoolArray: { MarkedArgumentBuffer list; const Vector<bool>& value = info.getBoolArray(); for (size_t ii = 0; ii < value.size(); ++ii) list.append(jsBoolean(value[ii])); return constructArray(exec, 0, globalObject, list); } case WebGLGetInfo::kTypeFloat: return jsNumber(info.getFloat()); case WebGLGetInfo::kTypeInt: return jsNumber(info.getInt()); case WebGLGetInfo::kTypeNull: return jsNull(); case WebGLGetInfo::kTypeString: return jsStringWithCache(exec, info.getString()); case WebGLGetInfo::kTypeUnsignedInt: return jsNumber(info.getUnsignedInt()); case WebGLGetInfo::kTypeWebGLBuffer: return toJS(exec, globalObject, info.getWebGLBuffer()); case WebGLGetInfo::kTypeWebGLFloatArray: return toJS(exec, globalObject, info.getWebGLFloatArray()); case WebGLGetInfo::kTypeWebGLFramebuffer: return toJS(exec, globalObject, info.getWebGLFramebuffer()); case WebGLGetInfo::kTypeWebGLIntArray: return toJS(exec, globalObject, info.getWebGLIntArray()); // FIXME: implement WebGLObjectArray // case WebGLGetInfo::kTypeWebGLObjectArray: case WebGLGetInfo::kTypeWebGLProgram: return toJS(exec, globalObject, info.getWebGLProgram()); case WebGLGetInfo::kTypeWebGLRenderbuffer: return toJS(exec, globalObject, info.getWebGLRenderbuffer()); case WebGLGetInfo::kTypeWebGLTexture: return toJS(exec, globalObject, info.getWebGLTexture()); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: return toJS(exec, globalObject, info.getWebGLUnsignedByteArray()); case WebGLGetInfo::kTypeWebGLUnsignedIntArray: return toJS(exec, globalObject, info.getWebGLUnsignedIntArray()); #if ENABLE(WEBGL2) case WebGLGetInfo::kTypeWebGLVertexArrayObject: return toJS(exec, globalObject, info.getWebGLVertexArrayObject()); #endif case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES()); default: notImplemented(); return jsUndefined(); } }
static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) { switch (info.getType()) { case WebGLGetInfo::kTypeBool: return v8::Boolean::New(info.getBool()); case WebGLGetInfo::kTypeBoolArray: { const Vector<bool>& value = info.getBoolArray(); v8::Local<v8::Array> array = v8::Array::New(value.size()); for (size_t ii = 0; ii < value.size(); ++ii) array->Set(v8::Integer::New(ii), v8::Boolean::New(value[ii])); return array; } case WebGLGetInfo::kTypeFloat: return v8::Number::New(info.getFloat()); case WebGLGetInfo::kTypeInt: return v8::Integer::New(info.getInt()); case WebGLGetInfo::kTypeNull: return v8::Null(); case WebGLGetInfo::kTypeString: return v8::String::New(fromWebCoreString(info.getString()), info.getString().length()); case WebGLGetInfo::kTypeUnsignedInt: return v8::Integer::NewFromUnsigned(info.getUnsignedInt()); case WebGLGetInfo::kTypeWebGLBuffer: return toV8(info.getWebGLBuffer()); case WebGLGetInfo::kTypeWebGLFloatArray: return toV8(info.getWebGLFloatArray()); case WebGLGetInfo::kTypeWebGLFramebuffer: return toV8(info.getWebGLFramebuffer()); case WebGLGetInfo::kTypeWebGLIntArray: return toV8(info.getWebGLIntArray()); // FIXME: implement WebGLObjectArray // case WebGLGetInfo::kTypeWebGLObjectArray: case WebGLGetInfo::kTypeWebGLProgram: return toV8(info.getWebGLProgram()); case WebGLGetInfo::kTypeWebGLRenderbuffer: return toV8(info.getWebGLRenderbuffer()); case WebGLGetInfo::kTypeWebGLTexture: return toV8(info.getWebGLTexture()); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: return toV8(info.getWebGLUnsignedByteArray()); case WebGLGetInfo::kTypeWebGLUnsignedIntArray: return toV8(info.getWebGLUnsignedIntArray()); case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: return toV8(info.getWebGLVertexArrayObjectOES()); default: notImplemented(); return v8::Undefined(); } }