mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
servo: Merge #6581 - Remove unused files in 'script/dom/bindings/' (from frewsxcv:rm-unused-codegen-files); r=Ms2ger
As per this conversation: https://github.com/servo/servo/pull/6580 Source-Repo: https://github.com/servo/servo Source-Revision: fe17067d6a30b85a0346fd1ccb2b95e2081e6962
This commit is contained in:
parent
d599f5f1e4
commit
14eea70cbe
@ -1,633 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "BindingUtils.h"
|
||||
|
||||
#include "WrapperFactory.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
JSErrorFormatString ErrorFormatString[] = {
|
||||
#define MSG_DEF(_name, _argc, _str) \
|
||||
{ _str, _argc, JSEXN_TYPEERR },
|
||||
#include "mozilla/dom/Errors.msg"
|
||||
#undef MSG_DEF
|
||||
};
|
||||
|
||||
const JSErrorFormatString*
|
||||
GetErrorMessage(void* aUserRef, const char* aLocale,
|
||||
const unsigned aErrorNumber)
|
||||
{
|
||||
MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString));
|
||||
return &ErrorFormatString[aErrorNumber];
|
||||
}
|
||||
|
||||
bool
|
||||
ThrowErrorMessage(JSContext* aCx, const ErrNum aErrorNumber, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, aErrorNumber);
|
||||
JS_ReportErrorNumberVA(aCx, GetErrorMessage, NULL,
|
||||
static_cast<const unsigned>(aErrorNumber), ap);
|
||||
va_end(ap);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
DefineConstants(JSContext* cx, JSObject* obj, ConstantSpec* cs)
|
||||
{
|
||||
for (; cs->name; ++cs) {
|
||||
JSBool ok =
|
||||
JS_DefineProperty(cx, obj, cs->name, cs->value, NULL, NULL,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
Define(JSContext* cx, JSObject* obj, JSFunctionSpec* spec) {
|
||||
return JS_DefineFunctions(cx, obj, spec);
|
||||
}
|
||||
static inline bool
|
||||
Define(JSContext* cx, JSObject* obj, JSPropertySpec* spec) {
|
||||
return JS_DefineProperties(cx, obj, spec);
|
||||
}
|
||||
static inline bool
|
||||
Define(JSContext* cx, JSObject* obj, ConstantSpec* spec) {
|
||||
return DefineConstants(cx, obj, spec);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool
|
||||
DefinePrefable(JSContext* cx, JSObject* obj, Prefable<T>* props)
|
||||
{
|
||||
MOZ_ASSERT(props);
|
||||
MOZ_ASSERT(props->specs);
|
||||
do {
|
||||
// Define if enabled
|
||||
if (props->enabled) {
|
||||
if (!Define(cx, obj, props->specs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while ((++props)->specs);
|
||||
return true;
|
||||
}
|
||||
|
||||
// We should use JSFunction objects for interface objects, but we need a custom
|
||||
// hasInstance hook because we have new interface objects on prototype chains of
|
||||
// old (XPConnect-based) bindings. Because Function.prototype.toString throws if
|
||||
// passed a non-Function object we also need to provide our own toString method
|
||||
// for interface objects.
|
||||
|
||||
enum {
|
||||
TOSTRING_CLASS_RESERVED_SLOT = 0,
|
||||
TOSTRING_NAME_RESERVED_SLOT = 1
|
||||
};
|
||||
|
||||
JSBool
|
||||
InterfaceObjectToString(JSContext* cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
JSObject* callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
|
||||
|
||||
JSObject* obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CONVERT_TO,
|
||||
"null", "object");
|
||||
return false;
|
||||
}
|
||||
|
||||
jsval v = js::GetFunctionNativeReserved(callee, TOSTRING_CLASS_RESERVED_SLOT);
|
||||
JSClass* clasp = static_cast<JSClass*>(JSVAL_TO_PRIVATE(v));
|
||||
|
||||
v = js::GetFunctionNativeReserved(callee, TOSTRING_NAME_RESERVED_SLOT);
|
||||
JSString* jsname = static_cast<JSString*>(JSVAL_TO_STRING(v));
|
||||
size_t length;
|
||||
const jschar* name = JS_GetInternedStringCharsAndLength(jsname, &length);
|
||||
|
||||
if (js::GetObjectJSClass(obj) != clasp) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
|
||||
NS_ConvertUTF16toUTF8(name).get(), "toString",
|
||||
"object");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsString str;
|
||||
str.AppendLiteral("function ");
|
||||
str.Append(name, length);
|
||||
str.AppendLiteral("() {");
|
||||
str.Append('\n');
|
||||
str.AppendLiteral(" [native code]");
|
||||
str.Append('\n');
|
||||
str.AppendLiteral("}");
|
||||
|
||||
return xpc::NonVoidStringToJsval(cx, str, vp);
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
|
||||
JSClass* constructorClass, JSNative constructorNative,
|
||||
unsigned ctorNargs, JSObject* proto,
|
||||
Prefable<JSFunctionSpec>* staticMethods,
|
||||
Prefable<ConstantSpec>* constants,
|
||||
const char* name)
|
||||
{
|
||||
JSObject* constructor;
|
||||
if (constructorClass) {
|
||||
JSObject* functionProto = JS_GetFunctionPrototype(cx, global);
|
||||
if (!functionProto) {
|
||||
return NULL;
|
||||
}
|
||||
constructor = JS_NewObject(cx, constructorClass, functionProto, global);
|
||||
} else {
|
||||
MOZ_ASSERT(constructorNative);
|
||||
JSFunction* fun = JS_NewFunction(cx, constructorNative, ctorNargs,
|
||||
JSFUN_CONSTRUCTOR, global, name);
|
||||
if (!fun) {
|
||||
return NULL;
|
||||
}
|
||||
constructor = JS_GetFunctionObject(fun);
|
||||
}
|
||||
if (!constructor) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (staticMethods && !DefinePrefable(cx, constructor, staticMethods)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (constructorClass) {
|
||||
JSFunction* toString = js::DefineFunctionWithReserved(cx, constructor,
|
||||
"toString",
|
||||
InterfaceObjectToString,
|
||||
0, 0);
|
||||
if (!toString) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSObject* toStringObj = JS_GetFunctionObject(toString);
|
||||
js::SetFunctionNativeReserved(toStringObj, TOSTRING_CLASS_RESERVED_SLOT,
|
||||
PRIVATE_TO_JSVAL(constructorClass));
|
||||
|
||||
JSString *str = ::JS_InternString(cx, name);
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
js::SetFunctionNativeReserved(toStringObj, TOSTRING_NAME_RESERVED_SLOT,
|
||||
STRING_TO_JSVAL(str));
|
||||
}
|
||||
|
||||
if (constants && !DefinePrefable(cx, constructor, constants)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (proto && !JS_LinkConstructorAndPrototype(cx, constructor, proto)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSBool alreadyDefined;
|
||||
if (!JS_AlreadyHasOwnProperty(cx, receiver, name, &alreadyDefined)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This is Enumerable: False per spec.
|
||||
if (!alreadyDefined &&
|
||||
!JS_DefineProperty(cx, receiver, name, OBJECT_TO_JSVAL(constructor), NULL,
|
||||
NULL, 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return constructor;
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
CreateInterfacePrototypeObject(JSContext* cx, JSObject* global,
|
||||
JSObject* parentProto, JSClass* protoClass,
|
||||
Prefable<JSFunctionSpec>* methods,
|
||||
Prefable<JSPropertySpec>* properties,
|
||||
Prefable<ConstantSpec>* constants)
|
||||
{
|
||||
JSObject* ourProto = JS_NewObjectWithUniqueType(cx, protoClass, parentProto,
|
||||
global);
|
||||
if (!ourProto) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (methods && !DefinePrefable(cx, ourProto, methods)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (properties && !DefinePrefable(cx, ourProto, properties)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (constants && !DefinePrefable(cx, ourProto, constants)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ourProto;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject *receiver,
|
||||
JSObject* protoProto, JSClass* protoClass,
|
||||
JSClass* constructorClass, JSNative constructor,
|
||||
unsigned ctorNargs, const DOMClass* domClass,
|
||||
Prefable<JSFunctionSpec>* methods,
|
||||
Prefable<JSPropertySpec>* properties,
|
||||
Prefable<ConstantSpec>* constants,
|
||||
Prefable<JSFunctionSpec>* staticMethods, const char* name)
|
||||
{
|
||||
MOZ_ASSERT(protoClass || constructorClass || constructor,
|
||||
"Need at least one class or a constructor!");
|
||||
MOZ_ASSERT(!(methods || properties) || protoClass,
|
||||
"Methods or properties but no protoClass!");
|
||||
MOZ_ASSERT(!staticMethods || constructorClass || constructor,
|
||||
"Static methods but no constructorClass or constructor!");
|
||||
MOZ_ASSERT(bool(name) == bool(constructorClass || constructor),
|
||||
"Must have name precisely when we have an interface object");
|
||||
MOZ_ASSERT(!constructorClass || !constructor);
|
||||
|
||||
JSObject* proto;
|
||||
if (protoClass) {
|
||||
proto = CreateInterfacePrototypeObject(cx, global, protoProto, protoClass,
|
||||
methods, properties, constants);
|
||||
if (!proto) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
js::SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT,
|
||||
JS::PrivateValue(const_cast<DOMClass*>(domClass)));
|
||||
}
|
||||
else {
|
||||
proto = NULL;
|
||||
}
|
||||
|
||||
JSObject* interface;
|
||||
if (constructorClass || constructor) {
|
||||
interface = CreateInterfaceObject(cx, global, receiver, constructorClass,
|
||||
constructor, ctorNargs, proto,
|
||||
staticMethods, constants, name);
|
||||
if (!interface) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return protoClass ? proto : interface;
|
||||
}
|
||||
|
||||
static bool
|
||||
NativeInterface2JSObjectAndThrowIfFailed(XPCLazyCallContext& aLccx,
|
||||
JSContext* aCx,
|
||||
JS::Value* aRetval,
|
||||
xpcObjectHelper& aHelper,
|
||||
const nsIID* aIID,
|
||||
bool aAllowNativeWrapper)
|
||||
{
|
||||
nsresult rv;
|
||||
if (!XPCConvert::NativeInterface2JSObject(aLccx, aRetval, NULL, aHelper, aIID,
|
||||
NULL, aAllowNativeWrapper, &rv)) {
|
||||
// I can't tell if NativeInterface2JSObject throws JS exceptions
|
||||
// or not. This is a sloppy stab at the right semantics; the
|
||||
// method really ought to be fixed to behave consistently.
|
||||
if (!JS_IsExceptionPending(aCx)) {
|
||||
Throw<true>(aCx, NS_FAILED(rv) ? rv : NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DoHandleNewBindingWrappingFailure(JSContext* cx, JSObject* scope,
|
||||
nsISupports* value, JS::Value* vp)
|
||||
{
|
||||
if (JS_IsExceptionPending(cx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XPCLazyCallContext lccx(JS_CALLER, cx, scope);
|
||||
|
||||
if (value) {
|
||||
xpcObjectHelper helper(value);
|
||||
return NativeInterface2JSObjectAndThrowIfFailed(lccx, cx, vp, helper, NULL,
|
||||
true);
|
||||
}
|
||||
|
||||
return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
|
||||
// Can only be called with the immediate prototype of the instance object. Can
|
||||
// only be called on the prototype of an object known to be a DOM instance.
|
||||
JSBool
|
||||
InstanceClassHasProtoAtDepth(JSHandleObject protoObject, uint32_t protoID,
|
||||
uint32_t depth)
|
||||
{
|
||||
const DOMClass* domClass = static_cast<DOMClass*>(
|
||||
js::GetReservedSlot(protoObject, DOM_PROTO_INSTANCE_CLASS_SLOT).toPrivate());
|
||||
return (uint32_t)domClass->mInterfaceChain[depth] == protoID;
|
||||
}
|
||||
|
||||
// Only set allowNativeWrapper to false if you really know you need it, if in
|
||||
// doubt use true. Setting it to false disables security wrappers.
|
||||
bool
|
||||
XPCOMObjectToJsval(JSContext* cx, JSObject* scope, xpcObjectHelper &helper,
|
||||
const nsIID* iid, bool allowNativeWrapper, JS::Value* rval)
|
||||
{
|
||||
XPCLazyCallContext lccx(JS_CALLER, cx, scope);
|
||||
|
||||
if (!NativeInterface2JSObjectAndThrowIfFailed(lccx, cx, rval, helper, iid,
|
||||
allowNativeWrapper)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
JSObject* jsobj = JSVAL_TO_OBJECT(*rval);
|
||||
if (jsobj && !js::GetObjectParent(jsobj))
|
||||
NS_ASSERTION(js::GetObjectClass(jsobj)->flags & JSCLASS_IS_GLOBAL,
|
||||
"Why did we recreate this wrapper?");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool
|
||||
QueryInterface(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
JS::Value thisv = JS_THIS(cx, vp);
|
||||
if (thisv == JSVAL_NULL)
|
||||
return false;
|
||||
|
||||
// Get the object. It might be a security wrapper, in which case we do a checked
|
||||
// unwrap.
|
||||
JSObject* origObj = JSVAL_TO_OBJECT(thisv);
|
||||
JSObject* obj = js::UnwrapObjectChecked(cx, origObj);
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
nsISupports* native;
|
||||
if (!UnwrapDOMObjectToISupports(obj, native)) {
|
||||
return Throw<true>(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
if (argc < 1) {
|
||||
return Throw<true>(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
}
|
||||
|
||||
JS::Value* argv = JS_ARGV(cx, vp);
|
||||
if (!argv[0].isObject()) {
|
||||
return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
|
||||
nsIJSIID* iid;
|
||||
xpc_qsSelfRef iidRef;
|
||||
if (NS_FAILED(xpc_qsUnwrapArg<nsIJSIID>(cx, argv[0], &iid, &iidRef.ptr,
|
||||
&argv[0]))) {
|
||||
return Throw<true>(cx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
MOZ_ASSERT(iid);
|
||||
|
||||
if (iid->GetID()->Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(native, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw<true>(cx, rv);
|
||||
}
|
||||
|
||||
return WrapObject(cx, origObj, ci, &NS_GET_IID(nsIClassInfo), vp);
|
||||
}
|
||||
|
||||
// Lie, otherwise we need to check classinfo or QI
|
||||
*vp = thisv;
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool
|
||||
ThrowingConstructor(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
|
||||
}
|
||||
|
||||
bool
|
||||
XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
|
||||
JSPropertyDescriptor* desc,
|
||||
// And the things we need to determine the descriptor
|
||||
Prefable<JSFunctionSpec>* methods,
|
||||
jsid* methodIds,
|
||||
JSFunctionSpec* methodSpecs,
|
||||
size_t methodCount,
|
||||
Prefable<JSPropertySpec>* attributes,
|
||||
jsid* attributeIds,
|
||||
JSPropertySpec* attributeSpecs,
|
||||
size_t attributeCount,
|
||||
Prefable<ConstantSpec>* constants,
|
||||
jsid* constantIds,
|
||||
ConstantSpec* constantSpecs,
|
||||
size_t constantCount)
|
||||
{
|
||||
for (size_t prefIdx = 0; prefIdx < methodCount; ++prefIdx) {
|
||||
MOZ_ASSERT(methods[prefIdx].specs);
|
||||
if (methods[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = methods[prefIdx].specs - methodSpecs;
|
||||
for ( ; methodIds[i] != JSID_VOID; ++i) {
|
||||
if (id == methodIds[i]) {
|
||||
JSFunction *fun = JS_NewFunctionById(cx, methodSpecs[i].call.op,
|
||||
methodSpecs[i].nargs, 0,
|
||||
wrapper, id);
|
||||
if (!fun) {
|
||||
return false;
|
||||
}
|
||||
SET_JITINFO(fun, methodSpecs[i].call.info);
|
||||
JSObject *funobj = JS_GetFunctionObject(fun);
|
||||
desc->value.setObject(*funobj);
|
||||
desc->attrs = methodSpecs[i].flags;
|
||||
desc->obj = wrapper;
|
||||
desc->setter = nullptr;
|
||||
desc->getter = nullptr;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t prefIdx = 0; prefIdx < attributeCount; ++prefIdx) {
|
||||
MOZ_ASSERT(attributes[prefIdx].specs);
|
||||
if (attributes[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = attributes[prefIdx].specs - attributeSpecs;
|
||||
for ( ; attributeIds[i] != JSID_VOID; ++i) {
|
||||
if (id == attributeIds[i]) {
|
||||
// Because of centralization, we need to make sure we fault in the
|
||||
// JitInfos as well. At present, until the JSAPI changes, the easiest
|
||||
// way to do this is wrap them up as functions ourselves.
|
||||
desc->attrs = attributeSpecs[i].flags & ~JSPROP_NATIVE_ACCESSORS;
|
||||
// They all have getters, so we can just make it.
|
||||
JSObject *global = JS_GetGlobalForObject(cx, wrapper);
|
||||
JSFunction *fun = JS_NewFunction(cx, (JSNative)attributeSpecs[i].getter.op,
|
||||
0, 0, global, NULL);
|
||||
if (!fun)
|
||||
return false;
|
||||
SET_JITINFO(fun, attributeSpecs[i].getter.info);
|
||||
JSObject *funobj = JS_GetFunctionObject(fun);
|
||||
desc->getter = js::CastAsJSPropertyOp(funobj);
|
||||
desc->attrs |= JSPROP_GETTER;
|
||||
if (attributeSpecs[i].setter.op) {
|
||||
// We have a setter! Make it.
|
||||
fun = JS_NewFunction(cx, (JSNative)attributeSpecs[i].setter.op,
|
||||
1, 0, global, NULL);
|
||||
if (!fun)
|
||||
return false;
|
||||
SET_JITINFO(fun, attributeSpecs[i].setter.info);
|
||||
funobj = JS_GetFunctionObject(fun);
|
||||
desc->setter = js::CastAsJSStrictPropertyOp(funobj);
|
||||
desc->attrs |= JSPROP_SETTER;
|
||||
} else {
|
||||
desc->setter = NULL;
|
||||
}
|
||||
desc->obj = wrapper;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t prefIdx = 0; prefIdx < constantCount; ++prefIdx) {
|
||||
MOZ_ASSERT(constants[prefIdx].specs);
|
||||
if (constants[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = constants[prefIdx].specs - constantSpecs;
|
||||
for ( ; constantIds[i] != JSID_VOID; ++i) {
|
||||
if (id == constantIds[i]) {
|
||||
desc->attrs = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
|
||||
desc->obj = wrapper;
|
||||
desc->value = constantSpecs[i].value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
XrayEnumerateProperties(JS::AutoIdVector& props,
|
||||
Prefable<JSFunctionSpec>* methods,
|
||||
jsid* methodIds,
|
||||
JSFunctionSpec* methodSpecs,
|
||||
size_t methodCount,
|
||||
Prefable<JSPropertySpec>* attributes,
|
||||
jsid* attributeIds,
|
||||
JSPropertySpec* attributeSpecs,
|
||||
size_t attributeCount,
|
||||
Prefable<ConstantSpec>* constants,
|
||||
jsid* constantIds,
|
||||
ConstantSpec* constantSpecs,
|
||||
size_t constantCount)
|
||||
{
|
||||
for (size_t prefIdx = 0; prefIdx < methodCount; ++prefIdx) {
|
||||
MOZ_ASSERT(methods[prefIdx].specs);
|
||||
if (methods[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = methods[prefIdx].specs - methodSpecs;
|
||||
for ( ; methodIds[i] != JSID_VOID; ++i) {
|
||||
if ((methodSpecs[i].flags & JSPROP_ENUMERATE) &&
|
||||
!props.append(methodIds[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t prefIdx = 0; prefIdx < attributeCount; ++prefIdx) {
|
||||
MOZ_ASSERT(attributes[prefIdx].specs);
|
||||
if (attributes[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = attributes[prefIdx].specs - attributeSpecs;
|
||||
for ( ; attributeIds[i] != JSID_VOID; ++i) {
|
||||
if ((attributeSpecs[i].flags & JSPROP_ENUMERATE) &&
|
||||
!props.append(attributeIds[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t prefIdx = 0; prefIdx < constantCount; ++prefIdx) {
|
||||
MOZ_ASSERT(constants[prefIdx].specs);
|
||||
if (constants[prefIdx].enabled) {
|
||||
// Set i to be the index into our full list of ids/specs that we're
|
||||
// looking at now.
|
||||
size_t i = constants[prefIdx].specs - constantSpecs;
|
||||
for ( ; constantIds[i] != JSID_VOID; ++i) {
|
||||
if (!props.append(constantIds[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
GetPropertyOnPrototype(JSContext* cx, JSObject* proxy, jsid id, bool* found,
|
||||
JS::Value* vp)
|
||||
{
|
||||
JSObject* proto;
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
*found = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool hasProp;
|
||||
if (!JS_HasPropertyById(cx, proto, id, &hasProp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*found = hasProp;
|
||||
if (!hasProp || !vp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return JS_ForwardGetPropertyTo(cx, proto, id, proxy, vp);
|
||||
}
|
||||
|
||||
bool
|
||||
HasPropertyOnPrototype(JSContext* cx, JSObject* proxy, DOMProxyHandler* handler,
|
||||
jsid id)
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
|
||||
proxy = js::UnwrapObject(proxy);
|
||||
ac.construct(cx, proxy);
|
||||
}
|
||||
MOZ_ASSERT(js::IsProxy(proxy) && js::GetProxyHandler(proxy) == handler);
|
||||
|
||||
bool found;
|
||||
// We ignore an error from GetPropertyOnPrototype.
|
||||
return !GetPropertyOnPrototype(cx, proxy, id, &found, NULL) || found;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,114 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_DOMJSClass_h
|
||||
#define mozilla_dom_DOMJSClass_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "mozilla/dom/PrototypeList.h" // auto-generated
|
||||
|
||||
// We use slot 0 for holding the raw object. This is safe for both
|
||||
// globals and non-globals.
|
||||
#define DOM_OBJECT_SLOT 0
|
||||
|
||||
// All DOM globals must have a slot at DOM_PROTOTYPE_SLOT. We have to
|
||||
// start at 1 past JSCLASS_GLOBAL_SLOT_COUNT because XPConnect uses
|
||||
// that one.
|
||||
#define DOM_PROTOTYPE_SLOT (JSCLASS_GLOBAL_SLOT_COUNT + 1)
|
||||
|
||||
// We use these flag bits for the new bindings.
|
||||
#define JSCLASS_DOM_GLOBAL JSCLASS_USERBIT1
|
||||
|
||||
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
|
||||
// LSetDOMProperty. Those constants need to be changed accordingly if this value
|
||||
// changes.
|
||||
#define DOM_PROTO_INSTANCE_CLASS_SLOT 0
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
typedef bool
|
||||
(* ResolveProperty)(JSContext* cx, JSObject* wrapper, jsid id, bool set,
|
||||
JSPropertyDescriptor* desc);
|
||||
typedef bool
|
||||
(* EnumerateProperties)(JSContext* cx, JSObject* wrapper,
|
||||
JS::AutoIdVector& props);
|
||||
|
||||
struct NativePropertyHooks
|
||||
{
|
||||
ResolveProperty mResolveOwnProperty;
|
||||
ResolveProperty mResolveProperty;
|
||||
EnumerateProperties mEnumerateOwnProperties;
|
||||
EnumerateProperties mEnumerateProperties;
|
||||
|
||||
const NativePropertyHooks *mProtoHooks;
|
||||
};
|
||||
|
||||
struct DOMClass
|
||||
{
|
||||
// A list of interfaces that this object implements, in order of decreasing
|
||||
// derivedness.
|
||||
const prototypes::ID mInterfaceChain[prototypes::id::_ID_Count];
|
||||
|
||||
// We store the DOM object in reserved slot with index DOM_OBJECT_SLOT or in
|
||||
// the proxy private if we use a proxy object.
|
||||
// Sometimes it's an nsISupports and sometimes it's not; this class tells
|
||||
// us which it is.
|
||||
const bool mDOMObjectIsISupports;
|
||||
|
||||
const NativePropertyHooks* mNativeHooks;
|
||||
};
|
||||
|
||||
// Special JSClass for reflected DOM objects.
|
||||
struct DOMJSClass
|
||||
{
|
||||
// It would be nice to just inherit from JSClass, but that precludes pure
|
||||
// compile-time initialization of the form |DOMJSClass = {...};|, since C++
|
||||
// only allows brace initialization for aggregate/POD types.
|
||||
JSClass mBase;
|
||||
|
||||
DOMClass mClass;
|
||||
|
||||
static DOMJSClass* FromJSClass(JSClass* base) {
|
||||
MOZ_ASSERT(base->flags & JSCLASS_IS_DOMJSCLASS);
|
||||
return reinterpret_cast<DOMJSClass*>(base);
|
||||
}
|
||||
static const DOMJSClass* FromJSClass(const JSClass* base) {
|
||||
MOZ_ASSERT(base->flags & JSCLASS_IS_DOMJSCLASS);
|
||||
return reinterpret_cast<const DOMJSClass*>(base);
|
||||
}
|
||||
|
||||
static DOMJSClass* FromJSClass(js::Class* base) {
|
||||
return FromJSClass(Jsvalify(base));
|
||||
}
|
||||
static const DOMJSClass* FromJSClass(const js::Class* base) {
|
||||
return FromJSClass(Jsvalify(base));
|
||||
}
|
||||
|
||||
JSClass* ToJSClass() { return &mBase; }
|
||||
};
|
||||
|
||||
inline bool
|
||||
HasProtoOrIfaceArray(JSObject* global)
|
||||
{
|
||||
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
|
||||
// This can be undefined if we GC while creating the global
|
||||
return !js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).isUndefined();
|
||||
}
|
||||
|
||||
inline JSObject**
|
||||
GetProtoOrIfaceArray(JSObject* global)
|
||||
{
|
||||
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
|
||||
return static_cast<JSObject**>(
|
||||
js::GetReservedSlot(global, DOM_PROTOTYPE_SLOT).toPrivate());
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_DOMJSClass_h */
|
@ -1,247 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set ts=2 sw=2 et tw=99 ft=cpp: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "DOMJSProxyHandler.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "xpcprivate.h"
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
using namespace JS;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
jsid s_length_id = JSID_VOID;
|
||||
|
||||
bool
|
||||
DefineStaticJSVals(JSContext* cx)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
return InternJSString(cx, s_length_id, "length");
|
||||
}
|
||||
|
||||
|
||||
int HandlerFamily;
|
||||
|
||||
// Store the information for the specialized ICs.
|
||||
struct SetListBaseInformation
|
||||
{
|
||||
SetListBaseInformation() {
|
||||
js::SetListBaseInformation((void*) &HandlerFamily, js::JSSLOT_PROXY_EXTRA + JSPROXYSLOT_EXPANDO);
|
||||
}
|
||||
};
|
||||
|
||||
SetListBaseInformation gSetListBaseInformation;
|
||||
|
||||
|
||||
bool
|
||||
DefineConstructor(JSContext* cx, JSObject* obj, DefineInterface aDefine, nsresult* aResult)
|
||||
{
|
||||
bool enabled;
|
||||
bool defined = aDefine(cx, obj, &enabled);
|
||||
MOZ_ASSERT(!defined || enabled,
|
||||
"We defined a constructor but the new bindings are disabled?");
|
||||
*aResult = defined ? NS_OK : NS_ERROR_FAILURE;
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// static
|
||||
JSObject*
|
||||
DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
NS_ASSERTION(IsDOMProxy(obj), "expected a DOM proxy object");
|
||||
JSObject* expando = GetExpandoObject(obj);
|
||||
if (!expando) {
|
||||
expando = JS_NewObjectWithGivenProto(cx, nullptr, nullptr,
|
||||
js::GetObjectParent(obj));
|
||||
if (!expando) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xpc::CompartmentPrivate* priv = xpc::GetCompartmentPrivate(obj);
|
||||
if (!priv->RegisterDOMExpandoObject(obj)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsWrapperCache* cache;
|
||||
CallQueryInterface(UnwrapDOMObject<nsISupports>(obj, eProxyDOMObject), &cache);
|
||||
cache->SetPreservingWrapper(true);
|
||||
|
||||
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
|
||||
}
|
||||
return expando;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id, bool set,
|
||||
JSPropertyDescriptor* desc)
|
||||
{
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, set, desc)) {
|
||||
return false;
|
||||
}
|
||||
if (desc->obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject* proto;
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
desc->obj = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
return JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::defineProperty(JSContext* cx, JSObject* proxy, jsid id,
|
||||
JSPropertyDescriptor* desc)
|
||||
{
|
||||
if ((desc->attrs & JSPROP_GETTER) && desc->setter == JS_StrictPropertyStub) {
|
||||
return JS_ReportErrorFlagsAndNumber(cx,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT |
|
||||
JSREPORT_STRICT_MODE_ERROR,
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_GETTER_ONLY);
|
||||
}
|
||||
|
||||
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject* expando = EnsureExpandoObject(cx, proxy);
|
||||
if (!expando) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JS_DefinePropertyById(cx, expando, id, desc->value, desc->getter, desc->setter,
|
||||
desc->attrs);
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp)
|
||||
{
|
||||
JSBool b = true;
|
||||
|
||||
JSObject* expando;
|
||||
if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
||||
Value v;
|
||||
if (!JS_DeletePropertyById2(cx, expando, id, &v) || !JS_ValueToBoolean(cx, v, &b)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*bp = !!b;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::enumerate(JSContext* cx, JSObject* proxy, AutoIdVector& props)
|
||||
{
|
||||
JSObject* proto;
|
||||
if (!JS_GetPrototype(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
return getOwnPropertyNames(cx, proxy, props) &&
|
||||
(!proto || js::GetPropertyNames(cx, proto, 0, &props));
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::fix(JSContext* cx, JSObject* proxy, Value* vp)
|
||||
{
|
||||
vp->setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DOMProxyHandler::has(JSContext* cx, JSObject* proxy, jsid id, bool* bp)
|
||||
{
|
||||
if (!hasOwn(cx, proxy, id, bp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*bp) {
|
||||
// We have the property ourselves; no need to worry about our prototype
|
||||
// chain.
|
||||
return true;
|
||||
}
|
||||
|
||||
// OK, now we have to look at the proto
|
||||
JSObject *proto;
|
||||
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
||||
return false;
|
||||
}
|
||||
if (!proto) {
|
||||
return true;
|
||||
}
|
||||
JSBool protoHasProp;
|
||||
bool ok = JS_HasPropertyById(cx, proto, id, &protoHasProp);
|
||||
if (ok) {
|
||||
*bp = protoHasProp;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// static
|
||||
JSString*
|
||||
DOMProxyHandler::obj_toString(JSContext* cx, const char* className)
|
||||
{
|
||||
size_t nchars = sizeof("[object ]") - 1 + strlen(className);
|
||||
jschar* chars = static_cast<jschar*>(JS_malloc(cx, (nchars + 1) * sizeof(jschar)));
|
||||
if (!chars) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* prefix = "[object ";
|
||||
nchars = 0;
|
||||
while ((chars[nchars] = (jschar)*prefix) != 0) {
|
||||
nchars++, prefix++;
|
||||
}
|
||||
while ((chars[nchars] = (jschar)*className) != 0) {
|
||||
nchars++, className++;
|
||||
}
|
||||
chars[nchars++] = ']';
|
||||
chars[nchars] = 0;
|
||||
|
||||
JSString* str = JS_NewUCString(cx, chars, nchars);
|
||||
if (!str) {
|
||||
JS_free(cx, chars);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int32_t
|
||||
IdToInt32(JSContext* cx, jsid id)
|
||||
{
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
jsval idval;
|
||||
double array_index;
|
||||
int32_t i;
|
||||
if (!::JS_IdToValue(cx, id, &idval) ||
|
||||
!::JS_ValueToNumber(cx, idval, &array_index) ||
|
||||
!::JS_DoubleIsInt32(array_index, &i)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
@ -1,109 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_DOMJSProxyHandler_h
|
||||
#define mozilla_dom_DOMJSProxyHandler_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsproxy.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#define DOM_PROXY_OBJECT_SLOT js::JSSLOT_PROXY_PRIVATE
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
enum {
|
||||
JSPROXYSLOT_EXPANDO = 0
|
||||
};
|
||||
|
||||
template<typename T> struct Prefable;
|
||||
|
||||
class DOMProxyHandler : public DOMBaseProxyHandler
|
||||
{
|
||||
public:
|
||||
DOMProxyHandler(const DOMClass& aClass)
|
||||
: DOMBaseProxyHandler(true),
|
||||
mClass(aClass)
|
||||
{
|
||||
}
|
||||
|
||||
bool getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id, bool set,
|
||||
JSPropertyDescriptor* desc);
|
||||
bool defineProperty(JSContext* cx, JSObject* proxy, jsid id,
|
||||
JSPropertyDescriptor* desc);
|
||||
bool delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp);
|
||||
bool enumerate(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props);
|
||||
bool fix(JSContext* cx, JSObject* proxy, JS::Value* vp);
|
||||
bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp);
|
||||
using js::BaseProxyHandler::obj_toString;
|
||||
|
||||
static JSObject* GetExpandoObject(JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(IsDOMProxy(obj), "expected a DOM proxy object");
|
||||
JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
|
||||
return v.isUndefined() ? NULL : v.toObjectOrNull();
|
||||
}
|
||||
static JSObject* EnsureExpandoObject(JSContext* cx, JSObject* obj);
|
||||
|
||||
const DOMClass& mClass;
|
||||
|
||||
protected:
|
||||
static JSString* obj_toString(JSContext* cx, const char* className);
|
||||
};
|
||||
|
||||
extern jsid s_length_id;
|
||||
|
||||
int32_t IdToInt32(JSContext* cx, jsid id);
|
||||
|
||||
inline int32_t
|
||||
GetArrayIndexFromId(JSContext* cx, jsid id)
|
||||
{
|
||||
if (MOZ_LIKELY(JSID_IS_INT(id))) {
|
||||
return JSID_TO_INT(id);
|
||||
}
|
||||
if (MOZ_LIKELY(id == s_length_id)) {
|
||||
return -1;
|
||||
}
|
||||
if (MOZ_LIKELY(JSID_IS_ATOM(id))) {
|
||||
JSAtom* atom = JSID_TO_ATOM(id);
|
||||
jschar s = *js::GetAtomChars(atom);
|
||||
if (MOZ_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z'))
|
||||
return -1;
|
||||
|
||||
uint32_t i;
|
||||
JSLinearString* str = js::AtomToLinearString(JSID_TO_ATOM(id));
|
||||
return js::StringIsArrayIndex(str, &i) ? i : -1;
|
||||
}
|
||||
return IdToInt32(cx, id);
|
||||
}
|
||||
|
||||
inline void
|
||||
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, bool readonly)
|
||||
{
|
||||
desc->obj = obj;
|
||||
desc->attrs = (readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE;
|
||||
desc->getter = NULL;
|
||||
desc->setter = NULL;
|
||||
desc->shortid = 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, jsval v, bool readonly)
|
||||
{
|
||||
desc->value = v;
|
||||
FillPropertyDescriptor(desc, obj, readonly);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
EnsureExpandoObject(JSContext* cx, JSObject* obj);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_DOMProxyHandler_h */
|
@ -1,59 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* A struct for tracking exceptions that need to be thrown to JS.
|
||||
*/
|
||||
|
||||
#ifndef mozilla_ErrorResult_h
|
||||
#define mozilla_ErrorResult_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult {
|
||||
public:
|
||||
ErrorResult() {
|
||||
mResult = NS_OK;
|
||||
}
|
||||
|
||||
void Throw(nsresult rv) {
|
||||
MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
|
||||
mResult = rv;
|
||||
}
|
||||
|
||||
// In the future, we can add overloads of Throw that take more
|
||||
// interesting things, like strings or DOM exception types or
|
||||
// something if desired.
|
||||
|
||||
// Backwards-compat to make conversion simpler. We don't call
|
||||
// Throw() here because people can easily pass success codes to
|
||||
// this.
|
||||
void operator=(nsresult rv) {
|
||||
mResult = rv;
|
||||
}
|
||||
|
||||
bool Failed() const {
|
||||
return NS_FAILED(mResult);
|
||||
}
|
||||
|
||||
nsresult ErrorCode() const {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult mResult;
|
||||
|
||||
// Not to be implemented, to make sure people always pass this by
|
||||
// reference, not by value.
|
||||
ErrorResult(const ErrorResult&) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_ErrorResult_h */
|
@ -14,8 +14,6 @@ import WebIDL
|
||||
import cPickle
|
||||
from Configuration import *
|
||||
from CodegenRust import GlobalGenRoots, replaceFileIfChanged
|
||||
# import Codegen in general, so we can set a variable on it
|
||||
import Codegen
|
||||
|
||||
def generate_file(config, name, filename):
|
||||
root = getattr(GlobalGenRoots, name)(config)
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_Nullable_h
|
||||
#define mozilla_dom_Nullable_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// Support for nullable types
|
||||
template <typename T>
|
||||
struct Nullable
|
||||
{
|
||||
private:
|
||||
T mValue;
|
||||
bool mIsNull;
|
||||
|
||||
public:
|
||||
Nullable()
|
||||
: mIsNull(true)
|
||||
{}
|
||||
|
||||
Nullable(T aValue)
|
||||
: mValue(aValue)
|
||||
, mIsNull(false)
|
||||
{}
|
||||
|
||||
void SetValue(T aValue) {
|
||||
mValue = aValue;
|
||||
mIsNull = false;
|
||||
}
|
||||
|
||||
// For cases when |T| is some type with nontrivial copy behavior, we may want
|
||||
// to get a reference to our internal copy of T and work with it directly
|
||||
// instead of relying on the copying version of SetValue().
|
||||
T& SetValue() {
|
||||
mIsNull = false;
|
||||
return mValue;
|
||||
}
|
||||
|
||||
void SetNull() {
|
||||
mIsNull = true;
|
||||
}
|
||||
|
||||
const T& Value() const {
|
||||
MOZ_ASSERT(!mIsNull);
|
||||
return mValue;
|
||||
}
|
||||
|
||||
T& Value() {
|
||||
MOZ_ASSERT(!mIsNull);
|
||||
return mValue;
|
||||
}
|
||||
|
||||
bool IsNull() const {
|
||||
return mIsNull;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_Nullable_h */
|
@ -1,350 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Conversions from jsval to primitive values
|
||||
*/
|
||||
|
||||
#ifndef mozilla_dom_PrimitiveConversions_h
|
||||
#define mozilla_dom_PrimitiveConversions_h
|
||||
|
||||
#include <limits>
|
||||
#include <math.h>
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
template<typename T>
|
||||
struct TypeName {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct TypeName<int8_t> {
|
||||
static const char* value() {
|
||||
return "byte";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<uint8_t> {
|
||||
static const char* value() {
|
||||
return "octet";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<int16_t> {
|
||||
static const char* value() {
|
||||
return "short";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<uint16_t> {
|
||||
static const char* value() {
|
||||
return "unsigned short";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<int32_t> {
|
||||
static const char* value() {
|
||||
return "long";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<uint32_t> {
|
||||
static const char* value() {
|
||||
return "unsigned long";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<int64_t> {
|
||||
static const char* value() {
|
||||
return "long long";
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct TypeName<uint64_t> {
|
||||
static const char* value() {
|
||||
return "unsigned long long";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
enum ConversionBehavior {
|
||||
eDefault,
|
||||
eEnforceRange,
|
||||
eClamp
|
||||
};
|
||||
|
||||
template<typename T, ConversionBehavior B>
|
||||
struct PrimitiveConversionTraits {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct DisallowedConversion {
|
||||
typedef int jstype;
|
||||
typedef int intermediateType;
|
||||
|
||||
private:
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
MOZ_NOT_REACHED("This should never be instantiated!");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PrimitiveConversionTraits_smallInt {
|
||||
// The output of JS::ToInt32 is determined as follows:
|
||||
// 1) The value is converted to a double
|
||||
// 2) Anything that's not a finite double returns 0
|
||||
// 3) The double is rounded towards zero to the nearest integer
|
||||
// 4) The resulting integer is reduced mod 2^32. The output of this
|
||||
// operation is an integer in the range [0, 2^32).
|
||||
// 5) If the resulting number is >= 2^31, 2^32 is subtracted from it.
|
||||
//
|
||||
// The result of all this is a number in the range [-2^31, 2^31)
|
||||
//
|
||||
// WebIDL conversions for the 8-bit, 16-bit, and 32-bit integer types
|
||||
// are defined in the same way, except that step 4 uses reduction mod
|
||||
// 2^8 and 2^16 for the 8-bit and 16-bit types respectively, and step 5
|
||||
// is only done for the signed types.
|
||||
//
|
||||
// C/C++ define integer conversion semantics to unsigned types as taking
|
||||
// your input integer mod (1 + largest value representable in the
|
||||
// unsigned type). Since 2^32 is zero mod 2^8, 2^16, and 2^32,
|
||||
// converting to the unsigned int of the relevant width will correctly
|
||||
// perform step 4; in particular, the 2^32 possibly subtracted in step 5
|
||||
// will become 0.
|
||||
//
|
||||
// Once we have step 4 done, we're just going to assume 2s-complement
|
||||
// representation and cast directly to the type we really want.
|
||||
//
|
||||
// So we can cast directly for all unsigned types and for int32_t; for
|
||||
// the smaller-width signed types we need to cast through the
|
||||
// corresponding unsigned type.
|
||||
typedef int32_t jstype;
|
||||
typedef int32_t intermediateType;
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
return JS::ToInt32(cx, v, retval);
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<int8_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
typedef uint8_t intermediateType;
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<uint8_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<int16_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
typedef uint16_t intermediateType;
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<uint16_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<int32_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<uint32_t, eDefault> : PrimitiveConversionTraits_smallInt {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<int64_t, eDefault> {
|
||||
typedef int64_t jstype;
|
||||
typedef int64_t intermediateType;
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
return JS::ToInt64(cx, v, retval);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<uint64_t, eDefault> {
|
||||
typedef uint64_t jstype;
|
||||
typedef uint64_t intermediateType;
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
return JS::ToUint64(cx, v, retval);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct PrimitiveConversionTraits_Limits {
|
||||
static inline T min() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
static inline T max() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits_Limits<int64_t> {
|
||||
static inline int64_t min() {
|
||||
return -(1LL << 53) + 1;
|
||||
}
|
||||
static inline int64_t max() {
|
||||
return (1LL << 53) - 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits_Limits<uint64_t> {
|
||||
static inline uint64_t min() {
|
||||
return 0;
|
||||
}
|
||||
static inline uint64_t max() {
|
||||
return (1LL << 53) - 1;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, bool (*Enforce)(JSContext* cx, const double& d, T* retval)>
|
||||
struct PrimitiveConversionTraits_ToCheckedIntHelper {
|
||||
typedef T jstype;
|
||||
typedef T intermediateType;
|
||||
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
double intermediate;
|
||||
if (!JS::ToNumber(cx, v, &intermediate)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Enforce(cx, intermediate, retval);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool
|
||||
PrimitiveConversionTraits_EnforceRange(JSContext* cx, const double& d, T* retval)
|
||||
{
|
||||
MOZ_STATIC_ASSERT(std::numeric_limits<T>::is_integer,
|
||||
"This can only be applied to integers!");
|
||||
|
||||
if (!MOZ_DOUBLE_IS_FINITE(d)) {
|
||||
return ThrowErrorMessage(cx, MSG_ENFORCE_RANGE_NON_FINITE, TypeName<T>::value());
|
||||
}
|
||||
|
||||
bool neg = (d < 0);
|
||||
double rounded = floor(neg ? -d : d);
|
||||
rounded = neg ? -rounded : rounded;
|
||||
if (rounded < PrimitiveConversionTraits_Limits<T>::min() ||
|
||||
rounded > PrimitiveConversionTraits_Limits<T>::max()) {
|
||||
return ThrowErrorMessage(cx, MSG_ENFORCE_RANGE_OUT_OF_RANGE, TypeName<T>::value());
|
||||
}
|
||||
|
||||
*retval = static_cast<T>(rounded);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct PrimitiveConversionTraits<T, eEnforceRange> :
|
||||
public PrimitiveConversionTraits_ToCheckedIntHelper<T, PrimitiveConversionTraits_EnforceRange<T> > {
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool
|
||||
PrimitiveConversionTraits_Clamp(JSContext* cx, const double& d, T* retval)
|
||||
{
|
||||
MOZ_STATIC_ASSERT(std::numeric_limits<T>::is_integer,
|
||||
"This can only be applied to integers!");
|
||||
|
||||
if (MOZ_DOUBLE_IS_NaN(d)) {
|
||||
*retval = 0;
|
||||
return true;
|
||||
}
|
||||
if (d >= PrimitiveConversionTraits_Limits<T>::max()) {
|
||||
*retval = PrimitiveConversionTraits_Limits<T>::max();
|
||||
return true;
|
||||
}
|
||||
if (d <= PrimitiveConversionTraits_Limits<T>::min()) {
|
||||
*retval = PrimitiveConversionTraits_Limits<T>::min();
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(MOZ_DOUBLE_IS_FINITE(d));
|
||||
|
||||
// Banker's rounding (round ties towards even).
|
||||
// We move away from 0 by 0.5f and then truncate. That gets us the right
|
||||
// answer for any starting value except plus or minus N.5. With a starting
|
||||
// value of that form, we now have plus or minus N+1. If N is odd, this is
|
||||
// the correct result. If N is even, plus or minus N is the correct result.
|
||||
double toTruncate = (d < 0) ? d - 0.5 : d + 0.5;
|
||||
|
||||
T truncated(toTruncate);
|
||||
|
||||
if (truncated == toTruncate) {
|
||||
/*
|
||||
* It was a tie (since moving away from 0 by 0.5 gave us the exact integer
|
||||
* we want). Since we rounded away from 0, we either already have an even
|
||||
* number or we have an odd number but the number we want is one closer to
|
||||
* 0. So just unconditionally masking out the ones bit should do the trick
|
||||
* to get us the value we want.
|
||||
*/
|
||||
truncated &= ~1;
|
||||
}
|
||||
|
||||
*retval = truncated;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct PrimitiveConversionTraits<T, eClamp> :
|
||||
public PrimitiveConversionTraits_ToCheckedIntHelper<T, PrimitiveConversionTraits_Clamp<T> > {
|
||||
};
|
||||
|
||||
|
||||
template<ConversionBehavior B>
|
||||
struct PrimitiveConversionTraits<bool, B> : public DisallowedConversion<bool> {};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<bool, eDefault> {
|
||||
typedef JSBool jstype;
|
||||
typedef bool intermediateType;
|
||||
static inline bool converter(JSContext* /* unused */, JS::Value v, jstype* retval) {
|
||||
*retval = JS::ToBoolean(v);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<ConversionBehavior B>
|
||||
struct PrimitiveConversionTraits<float, B> : public DisallowedConversion<float> {};
|
||||
|
||||
template<ConversionBehavior B>
|
||||
struct PrimitiveConversionTraits<double, B> : public DisallowedConversion<double> {};
|
||||
|
||||
struct PrimitiveConversionTraits_float {
|
||||
typedef double jstype;
|
||||
typedef double intermediateType;
|
||||
static inline bool converter(JSContext* cx, JS::Value v, jstype* retval) {
|
||||
return JS::ToNumber(cx, v, retval);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<float, eDefault> : PrimitiveConversionTraits_float {
|
||||
};
|
||||
template<>
|
||||
struct PrimitiveConversionTraits<double, eDefault> : PrimitiveConversionTraits_float {
|
||||
};
|
||||
|
||||
|
||||
template<typename T, ConversionBehavior B>
|
||||
bool ValueToPrimitive(JSContext* cx, JS::Value v, T* retval)
|
||||
{
|
||||
typename PrimitiveConversionTraits<T, B>::jstype t;
|
||||
if (!PrimitiveConversionTraits<T, B>::converter(cx, v, &t))
|
||||
return false;
|
||||
|
||||
*retval =
|
||||
static_cast<typename PrimitiveConversionTraits<T, B>::intermediateType>(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_PrimitiveConversions_h */
|
@ -1,14 +0,0 @@
|
||||
#ifndef mozilla_dom_RegisterBindings_h__
|
||||
#define mozilla_dom_RegisterBindings_h__
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
void
|
||||
Register(nsScriptNameSpaceManager* aNameSpaceManager);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
#endif // mozilla_dom_RegisterBindings_h__
|
@ -1,121 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
||||
/* vim: set ts=2 sw=2 et tw=79: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_TypedArray_h
|
||||
#define mozilla_dom_TypedArray_h
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/*
|
||||
* Various typed array classes for argument conversion. We have a base class
|
||||
* that has a way of initializing a TypedArray from an existing typed array, and
|
||||
* a subclass of the base class that supports creation of a relevant typed array
|
||||
* or array buffer object.
|
||||
*/
|
||||
template<typename T,
|
||||
JSObject* UnboxArray(JSContext*, JSObject*, uint32_t*, T**)>
|
||||
struct TypedArray_base {
|
||||
TypedArray_base(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
mObj = UnboxArray(cx, obj, &mLength, &mData);
|
||||
}
|
||||
|
||||
private:
|
||||
T* mData;
|
||||
uint32_t mLength;
|
||||
JSObject* mObj;
|
||||
|
||||
public:
|
||||
inline bool inited() const {
|
||||
return !!mObj;
|
||||
}
|
||||
|
||||
inline T *Data() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mData;
|
||||
}
|
||||
|
||||
inline uint32_t Length() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mLength;
|
||||
}
|
||||
|
||||
inline JSObject *Obj() const {
|
||||
MOZ_ASSERT(inited());
|
||||
return mObj;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T,
|
||||
T* GetData(JSObject*, JSContext*),
|
||||
JSObject* UnboxArray(JSContext*, JSObject*, uint32_t*, T**),
|
||||
JSObject* CreateNew(JSContext*, uint32_t)>
|
||||
struct TypedArray : public TypedArray_base<T,UnboxArray> {
|
||||
TypedArray(JSContext* cx, JSObject* obj) :
|
||||
TypedArray_base<T,UnboxArray>(cx, obj)
|
||||
{}
|
||||
|
||||
static inline JSObject*
|
||||
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
|
||||
const T* data = NULL) {
|
||||
JSObject* creatorWrapper;
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
|
||||
ac.construct(cx, creatorWrapper);
|
||||
}
|
||||
JSObject* obj = CreateNew(cx, length);
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
}
|
||||
if (data) {
|
||||
T* buf = static_cast<T*>(GetData(obj, cx));
|
||||
memcpy(buf, data, length*sizeof(T));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
typedef TypedArray<int8_t, JS_GetInt8ArrayData, JS_GetObjectAsInt8Array,
|
||||
JS_NewInt8Array>
|
||||
Int8Array;
|
||||
typedef TypedArray<uint8_t, JS_GetUint8ArrayData,
|
||||
JS_GetObjectAsUint8Array, JS_NewUint8Array>
|
||||
Uint8Array;
|
||||
typedef TypedArray<uint8_t, JS_GetUint8ClampedArrayData,
|
||||
JS_GetObjectAsUint8ClampedArray, JS_NewUint8ClampedArray>
|
||||
Uint8ClampedArray;
|
||||
typedef TypedArray<int16_t, JS_GetInt16ArrayData,
|
||||
JS_GetObjectAsInt16Array, JS_NewInt16Array>
|
||||
Int16Array;
|
||||
typedef TypedArray<uint16_t, JS_GetUint16ArrayData,
|
||||
JS_GetObjectAsUint16Array, JS_NewUint16Array>
|
||||
Uint16Array;
|
||||
typedef TypedArray<int32_t, JS_GetInt32ArrayData,
|
||||
JS_GetObjectAsInt32Array, JS_NewInt32Array>
|
||||
Int32Array;
|
||||
typedef TypedArray<uint32_t, JS_GetUint32ArrayData,
|
||||
JS_GetObjectAsUint32Array, JS_NewUint32Array>
|
||||
Uint32Array;
|
||||
typedef TypedArray<float, JS_GetFloat32ArrayData,
|
||||
JS_GetObjectAsFloat32Array, JS_NewFloat32Array>
|
||||
Float32Array;
|
||||
typedef TypedArray<double, JS_GetFloat64ArrayData,
|
||||
JS_GetObjectAsFloat64Array, JS_NewFloat64Array>
|
||||
Float64Array;
|
||||
typedef TypedArray_base<uint8_t, JS_GetObjectAsArrayBufferView>
|
||||
ArrayBufferView;
|
||||
typedef TypedArray<uint8_t, JS_GetArrayBufferData,
|
||||
JS_GetObjectAsArrayBuffer, JS_NewArrayBuffer>
|
||||
ArrayBuffer;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* mozilla_dom_TypedArray_h */
|
Loading…
Reference in New Issue
Block a user