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
Merged
bors-servo
merged 6 commits into
servo:master
from
shnmorimoto:fix_tojson_unconditionally_serializes
Mar 31, 2020
+23
−18
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
80b2a87
fixed #25281
shnmorimoto 096f3d7
updated test
shnmorimoto f7d4a37
fixed fmt
shnmorimoto fa8afbb
remove unnecessary condition
shnmorimoto d8c1dc6
fixed is_satisfied condition
shnmorimoto 74995a5
fixed CGCollectJSONAttributesMethod
shnmorimoto File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
fixed is_satisfied condition
- Loading branch information
commit d8c1dc60e8f48f05ecd3ec01fbc91d7743734460
| @@ -2976,22 +2976,24 @@ def definition_body(self): | ||
| ret_conditions = 'vec![' + ",".join(conditions) + "]" | ||
|
||
| ret += fill( | ||
| """ | ||
| let incumbent_global = GlobalScope::incumbent().expect("no incumbent global"); | ||
| let global = incumbent_global.reflector().get_jsobject(); | ||
|
Comment on lines
+2979
to
+2980
jdm
Member
|
||
| let conditions = ${conditions}; | ||
| if !conditions.iter().any(|c| | ||
| let is_satisfied = conditions.iter().any(|c| | ||
| c.is_satisfied( | ||
| SafeJSContext::from_ptr(cx), | ||
| HandleObject::from_raw(obj), | ||
| HandleObject::from_raw(obj))) { | ||
| return false; | ||
| } | ||
| rooted!(in(cx) let mut temp = UndefinedValue()); | ||
| if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { | ||
| return false; | ||
| } | ||
| if !JS_DefineProperty(cx, result.handle().into(), | ||
| ${nameAsArray} as *const u8 as *const libc::c_char, | ||
| temp.handle(), JSPROP_ENUMERATE as u32) { | ||
| return false; | ||
| global)); | ||
| if is_satisfied { | ||
| rooted!(in(cx) let mut temp = UndefinedValue()); | ||
| if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) { | ||
| return false; | ||
| } | ||
| if !JS_DefineProperty(cx, result.handle().into(), | ||
| ${nameAsArray} as *const u8 as *const libc::c_char, | ||
| temp.handle(), JSPROP_ENUMERATE as u32) { | ||
| return false; | ||
| } | ||
| } | ||
| """, | ||
| name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions) | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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.