mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make Promise::resolve_native actually sound
We shouldn't have to pass a raw JSContext pointer, and to enter the promise's context's compartment by hand.
This commit is contained in:
parent
658dc8a501
commit
5addc2dfa3
17 changed files with 42 additions and 53 deletions
|
@ -135,8 +135,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTService {
|
|||
// Step 7.
|
||||
BluetoothResponse::GetCharacteristics(characteristics_vec, single) => {
|
||||
if single {
|
||||
promise.resolve_native(promise_cx,
|
||||
&device.get_or_create_characteristic(&characteristics_vec[0], &self));
|
||||
promise.resolve_native(&device.get_or_create_characteristic(&characteristics_vec[0], &self));
|
||||
return;
|
||||
}
|
||||
let mut characteristics = vec!();
|
||||
|
@ -144,21 +143,20 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTService {
|
|||
let bt_characteristic = device.get_or_create_characteristic(&characteristic, &self);
|
||||
characteristics.push(bt_characteristic);
|
||||
}
|
||||
promise.resolve_native(promise_cx, &characteristics);
|
||||
promise.resolve_native(&characteristics);
|
||||
},
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren
|
||||
// Step 7.
|
||||
BluetoothResponse::GetIncludedServices(services_vec, single) => {
|
||||
if single {
|
||||
return promise.resolve_native(promise_cx,
|
||||
&device.get_or_create_service(&services_vec[0], &device.get_gatt()));
|
||||
return promise.resolve_native(&device.get_or_create_service(&services_vec[0], &device.get_gatt()));
|
||||
}
|
||||
let mut services = vec!();
|
||||
for service in services_vec {
|
||||
let bt_service = device.get_or_create_service(&service, &device.get_gatt());
|
||||
services.push(bt_service);
|
||||
}
|
||||
promise.resolve_native(promise_cx, &services);
|
||||
promise.resolve_native(&services);
|
||||
},
|
||||
_ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue