New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tojson unconditionally serializes #26054
Changes from 1 commit
80b2a87
096f3d7
f7d4a37
fa8afbb
d8c1dc6
74995a5
File filter...
Jump to…
| @@ -2968,12 +2968,19 @@ def __init__(self, descriptor, toJSONMethod): | ||
| def definition_body(self): | ||
| ret = '' | ||
| interface = self.descriptor.interface | ||
|
|
||
| for m in interface.members: | ||
| if m.isAttr() and not m.isStatic() and m.type.isJSONType(): | ||
| name = m.identifier.name | ||
| conditions = MemberCondition(None, None, m.exposureSet) | ||
| ret_conditions = 'vec![' + ",".join(conditions) + "]" | ||
|
||
| ret += fill( | ||
| """ | ||
| rooted!(in(cx) let mut temp = UndefinedValue()); | ||
| let conditions = ${conditions}; | ||
| if !conditions.iter().any(|c| c.is_satisfied(SafeJSContext::from_ptr(cx), HandleObject::from_raw(obj), HandleObject::from_raw(obj))) { | ||
| return false; | ||
jdm
Member
|
||
| } | ||
| rooted!(in(cx) let mut temp = UndefinedValue()); | ||
| if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { | ||
| return false; | ||
| } | ||
| @@ -2983,7 +2990,7 @@ def definition_body(self): | ||
| return false; | ||
| } | ||
| """, | ||
| name=name, nameAsArray=str_to_const_array(name)) | ||
| name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions) | ||
| ret += 'return true;\n' | ||
| return CGGeneric(ret) | ||
|
|
||
Let's use
&[instead ofvec![to avoid allocating a bunch of memory needlessly. Also use", "when joining to make the resulting code a bit easier to read.