mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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(
|
method = CGWrapper(
|
||||||
CGIndenter(CGList(conversions, "\n\n")),
|
CGIndenter(CGList(conversions, "\n\n")),
|
||||||
pre="unsafe fn from_jsval(cx: *mut JSContext,\n"
|
pre="unsafe fn from_jsval(cx: *mut JSContext,\n"
|
||||||
" value: HandleValue, _option: ())"
|
" value: HandleValue,\n"
|
||||||
|
" _option: ())\n"
|
||||||
" -> Result<ConversionResult<%s>, ()> {\n" % self.type,
|
" -> Result<ConversionResult<%s>, ()> {\n" % self.type,
|
||||||
post="\n}")
|
post="\n}")
|
||||||
return CGWrapper(
|
return CGWrapper(
|
||||||
|
|
|
@ -104,15 +104,14 @@ impl<T: Float + FromJSValConvertible<Config=()>> FromJSValConvertible for Finite
|
||||||
impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> {
|
impl <T: Reflectable + IDLInterface> FromJSValConvertible for Root<T> {
|
||||||
type Config = ();
|
type Config = ();
|
||||||
|
|
||||||
unsafe fn from_jsval(cx: *mut JSContext,
|
unsafe fn from_jsval(_cx: *mut JSContext,
|
||||||
value: HandleValue,
|
value: HandleValue,
|
||||||
_config: Self::Config)
|
_config: Self::Config)
|
||||||
-> Result<ConversionResult<Root<T>>, ()> {
|
-> Result<ConversionResult<Root<T>>, ()> {
|
||||||
let result = root_from_handlevalue(value);
|
Ok(match root_from_handlevalue(value) {
|
||||||
if let Err(()) = result {
|
Ok(result) => ConversionResult::Success(result),
|
||||||
throw_type_error(cx, "value is not an object");
|
Err(()) => ConversionResult::Failure("value is not an object".into()),
|
||||||
}
|
})
|
||||||
result.map(ConversionResult::Success)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue