mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 897185 - toJSON only deals with attributes whose types are serializable. r=bz
Now jsonifiers only include serializable attributes in their returned object, as per spec.
This commit is contained in:
parent
a6c83155aa
commit
a20effda55
@ -5241,7 +5241,7 @@ class CGJsonifierMethod(CGSpecializedMethod):
|
||||
' return false;\n'
|
||||
'}\n')
|
||||
for m in self.descriptor.interface.members:
|
||||
if m.isAttr() and not m.isStatic():
|
||||
if m.isAttr() and not m.isStatic() and m.type.isSerializable():
|
||||
ret += ('{ // scope for "temp"\n'
|
||||
' JS::Rooted<JS::Value> temp(cx);\n'
|
||||
' if (!get_%s(cx, obj, self, JSJitGetterCallArgs(&temp))) {\n'
|
||||
|
@ -1333,6 +1333,9 @@ class IDLType(IDLObject):
|
||||
# Should only call this on float types
|
||||
assert self.isFloat()
|
||||
|
||||
def isSerializable(self):
|
||||
return False
|
||||
|
||||
def tag(self):
|
||||
assert False # Override me!
|
||||
|
||||
@ -1468,6 +1471,9 @@ class IDLNullableType(IDLType):
|
||||
def isUnion(self):
|
||||
return self.inner.isUnion()
|
||||
|
||||
def isSerializable(self):
|
||||
return self.inner.isSerializable()
|
||||
|
||||
def tag(self):
|
||||
return self.inner.tag()
|
||||
|
||||
@ -1553,6 +1559,9 @@ class IDLSequenceType(IDLType):
|
||||
def isEnum(self):
|
||||
return False
|
||||
|
||||
def isSerializable(self):
|
||||
return self.inner.isSerializable()
|
||||
|
||||
def includesRestrictedFloat(self):
|
||||
return self.inner.includesRestrictedFloat()
|
||||
|
||||
@ -1602,6 +1611,9 @@ class IDLUnionType(IDLType):
|
||||
def isUnion(self):
|
||||
return True
|
||||
|
||||
def isSerializable(self):
|
||||
return all(m.isSerializable() for m in self.memberTypes)
|
||||
|
||||
def includesRestrictedFloat(self):
|
||||
return any(t.includesRestrictedFloat() for t in self.memberTypes)
|
||||
|
||||
@ -1932,6 +1944,19 @@ class IDLWrapperType(IDLType):
|
||||
def isEnum(self):
|
||||
return isinstance(self.inner, IDLEnum)
|
||||
|
||||
def isSerializable(self):
|
||||
if self.isInterface():
|
||||
if self.inner.isExternal():
|
||||
return False
|
||||
return any(m.isMethod() and m.isJsonifier() for m in self.inner.members)
|
||||
elif self.isEnum():
|
||||
return True
|
||||
elif self.isDictionary():
|
||||
return all(m.isSerializable() for m in self.inner.members)
|
||||
else:
|
||||
raise WebIDLError("IDLWrapperType wraps type %s that we don't know if "
|
||||
"is serializable" % type(self.inner), [self.location])
|
||||
|
||||
def resolveType(self, parentScope):
|
||||
assert isinstance(parentScope, IDLScope)
|
||||
self.inner.resolve(parentScope)
|
||||
@ -2130,6 +2155,9 @@ class IDLBuiltinType(IDLType):
|
||||
return self._typeTag == IDLBuiltinType.Types.unrestricted_float or \
|
||||
self._typeTag == IDLBuiltinType.Types.unrestricted_double
|
||||
|
||||
def isSerializable(self):
|
||||
return self.isPrimitive() or self.isDOMString() or self.isDate()
|
||||
|
||||
def includesRestrictedFloat(self):
|
||||
return self.isFloat() and not self.isUnrestricted()
|
||||
|
||||
|
@ -608,6 +608,12 @@ public:
|
||||
TestInterface* PutForwardsAttr();
|
||||
TestInterface* PutForwardsAttr2();
|
||||
TestInterface* PutForwardsAttr3();
|
||||
JS::Value JsonifierShouldSkipThis(JSContext*);
|
||||
void SetJsonifierShouldSkipThis(JSContext*, JS::Rooted<JS::Value>&);
|
||||
TestParentInterface* JsonifierShouldSkipThis2();
|
||||
void SetJsonifierShouldSkipThis2(TestParentInterface&);
|
||||
TestCallbackInterface* JsonifierShouldSkipThis3();
|
||||
void SetJsonifierShouldSkipThis3(TestCallbackInterface&);
|
||||
void ThrowingMethod(ErrorResult& aRv);
|
||||
bool GetThrowingAttr(ErrorResult& aRv) const;
|
||||
void SetThrowingAttr(bool arg, ErrorResult& aRv);
|
||||
|
@ -583,6 +583,10 @@ interface TestInterface {
|
||||
optional TestInterface? arg2 = null,
|
||||
optional Dict arg3, optional double arg4 = 5.0,
|
||||
optional float arg5);
|
||||
|
||||
attribute any jsonifierShouldSkipThis;
|
||||
attribute TestParentInterface jsonifierShouldSkipThis2;
|
||||
attribute TestCallbackInterface jsonifierShouldSkipThis3;
|
||||
jsonifier;
|
||||
|
||||
// If you add things here, add them to TestExampleGen and TestJSImplGen as well
|
||||
|
@ -480,6 +480,9 @@ interface TestExampleInterface {
|
||||
optional TestInterface? arg2 = null,
|
||||
optional Dict arg3, optional double arg4 = 5.0,
|
||||
optional float arg5);
|
||||
attribute any jsonifierShouldSkipThis;
|
||||
attribute TestParentInterface jsonifierShouldSkipThis2;
|
||||
attribute TestCallbackInterface jsonifierShouldSkipThis3;
|
||||
jsonifier;
|
||||
|
||||
// If you add things here, add them to TestCodeGen and TestJSImplGen as well
|
||||
|
@ -472,6 +472,9 @@ interface TestJSImplInterface {
|
||||
optional TestInterface? arg2 = null,
|
||||
optional Dict arg3, optional double arg4 = 5.0,
|
||||
optional float arg5);
|
||||
attribute any jsonifierShouldSkipThis;
|
||||
attribute TestParentInterface jsonifierShouldSkipThis2;
|
||||
attribute TestCallbackInterface jsonifierShouldSkipThis3;
|
||||
jsonifier;
|
||||
|
||||
// If you add things here, add them to TestCodeGen as well
|
||||
|
Loading…
Reference in New Issue
Block a user