mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #13016 - servo:fromjsval-interface, r=jdm
Refactor some from_jsval implementations. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13016) <!-- Reviewable:end -->
This commit is contained in:
commit
77af4e26ce
2 changed files with 7 additions and 7 deletions
|
@ -3953,7 +3953,8 @@ class CGUnionConversionStruct(CGThing):
|
|||
method = CGWrapper(
|
||||
CGIndenter(CGList(conversions, "\n\n")),
|
||||
pre="unsafe fn from_jsval(cx: *mut JSContext,\n"
|
||||
" value: HandleValue, _option: ())"
|
||||
" value: HandleValue,\n"
|
||||
" _option: ())\n"
|
||||
" -> Result<ConversionResult<%s>, ()> {\n" % self.type,
|
||||
post="\n}")
|
||||
return CGWrapper(
|
||||
|
|
|
@ -104,15 +104,14 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite
|
|||
impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> {
|
||||
type Config = ();
|
||||
|
||||
unsafe fn from_jsval(cx: *mut JSContext,
|
||||
unsafe fn from_jsval(_cx: *mut JSContext,
|
||||
value: HandleValue,
|
||||
_config: Self::Config)
|
||||
-> Result<ConversionResult<Root<T>>, ()> {
|
||||
let result = root_from_handlevalue(value);
|
||||
if let Err(()) = result {
|
||||
throw_type_error(cx, "value is not an object");
|
||||
}
|
||||
result.map(ConversionResult::Success)
|
||||
Ok(match root_from_handlevalue(value) {
|
||||
Ok(result) => ConversionResult::Success(result),
|
||||
Err(()) => ConversionResult::Failure("value is not an object".into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue