Skip to content

Commit

Permalink
Replace the union types with the correct typedefs in the webidl files…
Browse files Browse the repository at this point in the history
… and the API classes.
  • Loading branch information
zakorgy authored and dati91 committed May 3, 2016
1 parent 76d6685 commit 402bc55
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
7 changes: 3 additions & 4 deletions components/script/dom/bluetoothremotegattcharacteristic.rs
Expand Up @@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::
BluetoothRemoteGATTCharacteristicMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::error::Error::{Network, Type};
use dom::bindings::error::{Fallible, ErrorResult};
use dom::bindings::global::GlobalRef;
Expand All @@ -19,7 +18,7 @@ use dom::bindings::str::ByteString;
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
use dom::bluetoothuuid::BluetoothUUID;
use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg};
use util::str::DOMString;
Expand Down Expand Up @@ -94,7 +93,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
}

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
fn GetDescriptor(&self, descriptor: StringOrUnsignedLong) -> Fallible<Root<BluetoothRemoteGATTDescriptor>> {
fn GetDescriptor(&self, descriptor: BluetoothDescriptorUUID) -> Fallible<Root<BluetoothRemoteGATTDescriptor>> {
let uuid: String = match BluetoothUUID::GetDescriptor(self.global().r(), descriptor.clone()) {
Ok(domstring) => domstring.to_string(),
Err(error) => return Err(error),
Expand Down Expand Up @@ -124,7 +123,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptors
fn GetDescriptors(&self,
descriptor: Option<StringOrUnsignedLong>)
descriptor: Option<BluetoothDescriptorUUID>)
-> Fallible<Vec<Root<BluetoothRemoteGATTDescriptor>>> {
let mut uuid: Option<String> = None;
if let Some(d)= descriptor {
Expand Down
7 changes: 3 additions & 4 deletions components/script/dom/bluetoothremotegattserver.rs
Expand Up @@ -5,15 +5,14 @@
use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods;
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::error::Error::Type;
use dom::bindings::error::{Fallible, ErrorResult};
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
use dom::bluetoothuuid::BluetoothUUID;
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg};
use std::cell::Cell;
Expand Down Expand Up @@ -106,7 +105,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {
}

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
fn GetPrimaryService(&self, service: StringOrUnsignedLong) -> Fallible<Root<BluetoothRemoteGATTService>> {
fn GetPrimaryService(&self, service: BluetoothServiceUUID) -> Fallible<Root<BluetoothRemoteGATTService>> {
let uuid: String = match BluetoothUUID::GetService(self.global().r(), service.clone()) {
Ok(domstring) => domstring.to_string(),
Err(error) => return Err(error),
Expand Down Expand Up @@ -138,7 +137,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer {

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservices
fn GetPrimaryServices(&self,
service: Option<StringOrUnsignedLong>)
service: Option<BluetoothServiceUUID>)
-> Fallible<Vec<Root<BluetoothRemoteGATTService>>> {
let mut uuid: Option<String> = None;
if let Some(s)= service {
Expand Down
7 changes: 3 additions & 4 deletions components/script/dom/bluetoothremotegattservice.rs
Expand Up @@ -4,7 +4,6 @@

use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding;
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::error::Error::Type;
use dom::bindings::error::Fallible;
use dom::bindings::global::GlobalRef;
Expand All @@ -13,7 +12,7 @@ use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties;
use dom::bluetoothdevice::BluetoothDevice;
use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
use dom::bluetoothuuid::BluetoothUUID;
use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothUUID};
use ipc_channel::ipc::{self, IpcSender};
use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg};
use util::str::DOMString;
Expand Down Expand Up @@ -86,7 +85,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristic
fn GetCharacteristic(&self,
characteristic: StringOrUnsignedLong)
characteristic: BluetoothCharacteristicUUID)
-> Fallible<Root<BluetoothRemoteGATTCharacteristic>> {
let uuid: String = match BluetoothUUID::GetCharacteristic(self.global().r(), characteristic.clone()) {
Ok(domstring) => domstring.to_string(),
Expand Down Expand Up @@ -137,7 +136,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService {

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristics
fn GetCharacteristics(&self,
characteristic: Option<StringOrUnsignedLong>)
characteristic: Option<BluetoothCharacteristicUUID>)
-> Fallible<Vec<Root<BluetoothRemoteGATTCharacteristic>>> {
let mut uuid: Option<String> = None;
if let Some(c)= characteristic {
Expand Down
9 changes: 6 additions & 3 deletions components/script/dom/bluetoothuuid.rs
Expand Up @@ -11,6 +11,9 @@ use regex::Regex;
use util::str::DOMString;

pub type UUID = DOMString;
pub type BluetoothServiceUUID = StringOrUnsignedLong;
pub type BluetoothCharacteristicUUID = StringOrUnsignedLong;
pub type BluetoothDescriptorUUID = StringOrUnsignedLong;

// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid
#[dom_struct]
Expand Down Expand Up @@ -274,23 +277,23 @@ impl BluetoothUUID {
}

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice
pub fn GetService(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible<UUID> {
pub fn GetService(globalref: GlobalRef, name: BluetoothServiceUUID) -> Fallible<UUID> {
BluetoothUUID::resolve_uuid_name(globalref,
name,
BLUETOOTH_ASSIGNED_SERVICES,
DOMString::from(SERVICE_PREFIX))
}

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic
pub fn GetCharacteristic(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible<UUID> {
pub fn GetCharacteristic(globalref: GlobalRef, name: BluetoothCharacteristicUUID) -> Fallible<UUID> {
BluetoothUUID::resolve_uuid_name(globalref,
name,
BLUETOOTH_ASSIGNED_CHARCTERISTICS,
DOMString::from(CHARACTERISTIC_PREFIX))
}

// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor
pub fn GetDescriptor(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible<UUID> {
pub fn GetDescriptor(globalref: GlobalRef, name: BluetoothDescriptorUUID) -> Fallible<UUID> {
BluetoothUUID::resolve_uuid_name(globalref,
name,
BLUETOOTH_ASSIGNED_DESCRIPTORS,
Expand Down
Expand Up @@ -11,9 +11,9 @@ interface BluetoothRemoteGATTCharacteristic {
readonly attribute BluetoothCharacteristicProperties properties;
readonly attribute ByteString? value;
[Throws]
BluetoothRemoteGATTDescriptor getDescriptor((DOMString or unsigned long) descriptor);
BluetoothRemoteGATTDescriptor getDescriptor(BluetoothDescriptorUUID descriptor);
[Throws]
sequence<BluetoothRemoteGATTDescriptor> getDescriptors(optional (DOMString or unsigned long) descriptor);
sequence<BluetoothRemoteGATTDescriptor> getDescriptors(optional BluetoothDescriptorUUID descriptor);
//Promise<BluetoothRemoteGATTDescriptor> getDescriptor(BluetoothDescriptorUUID descriptor);
//Promise<sequence<BluetoothRemoteGATTDescriptor>>
//getDescriptors(optional BluetoothDescriptorUUID descriptor);
Expand Down
Expand Up @@ -13,9 +13,9 @@ interface BluetoothRemoteGATTServer {
[Throws]
void disconnect();
[Throws]
BluetoothRemoteGATTService getPrimaryService((DOMString or unsigned long) service);
BluetoothRemoteGATTService getPrimaryService(BluetoothServiceUUID service);
[Throws]
sequence<BluetoothRemoteGATTService> getPrimaryServices(optional (DOMString or unsigned long) service);
sequence<BluetoothRemoteGATTService> getPrimaryServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTService> getPrimaryService(BluetoothServiceUUID service);
//Promise<sequence<BluetoothRemoteGATTService>>getPrimaryServices(optional BluetoothServiceUUID service);
//Promise<BluetoothRemoteGATTServer> connect();
Expand Down
Expand Up @@ -10,10 +10,10 @@ interface BluetoothRemoteGATTService {
readonly attribute DOMString uuid;
readonly attribute boolean isPrimary;
[Throws]
BluetoothRemoteGATTCharacteristic getCharacteristic((DOMString or unsigned long) characteristic);
BluetoothRemoteGATTCharacteristic getCharacteristic(BluetoothCharacteristicUUID characteristic);
[Throws]
sequence<BluetoothRemoteGATTCharacteristic> getCharacteristics
(optional (DOMString or unsigned long) characteristic);
(optional BluetoothCharacteristicUUID characteristic);
//Promise<BluetoothRemoteGATTCharacteristic>getCharacteristic(BluetoothCharacteristicUUID characteristic);
//Promise<sequence<BluetoothRemoteGATTCharacteristic>>
//getCharacteristics(optional BluetoothCharacteristicUUID characteristic);
Expand Down

0 comments on commit 402bc55

Please sign in to comment.