зеркало из https://github.com/mozilla/gecko-dev.git
Bug 888595 - Convert BluetoothDevice to WebIDL. r=bz, r=echou
We keep the old XPIDL files in place to stay compatible with existing code. They can probably be removed when all bindings have been converted to WebIDL.
This commit is contained in:
Родитель
e66199f950
Коммит
37771b0aa4
|
@ -155,6 +155,11 @@ DOMInterfaces = {
|
|||
'headerFile': 'BluetoothAdapter.h'
|
||||
},
|
||||
|
||||
'BluetoothDevice': {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothDevice',
|
||||
'headerFile': 'BluetoothDevice.h'
|
||||
},
|
||||
|
||||
'BluetoothManager': {
|
||||
'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
|
||||
'headerFile': 'BluetoothManager.h'
|
||||
|
@ -1737,8 +1742,6 @@ def addExternalIface(iface, nativeType=None, headerFile=None,
|
|||
|
||||
addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
|
||||
headerFile='nsIDOMActivityOptions.h')
|
||||
addExternalIface('BluetoothDevice', nativeType='nsIDOMBluetoothDevice',
|
||||
headerFile='nsIDOMBluetoothDevice.h')
|
||||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
|
||||
|
|
|
@ -205,7 +205,7 @@ ParserResults.pkl: $(globalgen_dependencies)
|
|||
--cachedir=$(CACHE_DIR) \
|
||||
$(all_webidl_files)
|
||||
|
||||
# Make sure .deps actually exists, since we'll try to write to it from
|
||||
# Make sure .deps actually exists, since we'll try to write to it from
|
||||
# BindingGen.py but we're typically running in the export phase, which is
|
||||
# before anyone has bothered creating .deps.
|
||||
# Then, pass our long lists through files to try to avoid blowing out the
|
||||
|
|
|
@ -519,7 +519,7 @@ BluetoothAdapter::GetPairedDevices(ErrorResult& aRv)
|
|||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
BluetoothAdapter::PairUnpair(bool aPair, nsIDOMBluetoothDevice* aDevice,
|
||||
BluetoothAdapter::PairUnpair(bool aPair, BluetoothDevice& aDevice,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
|
||||
|
@ -533,7 +533,7 @@ BluetoothAdapter::PairUnpair(bool aPair, nsIDOMBluetoothDevice* aDevice,
|
|||
new BluetoothVoidReplyRunnable(request);
|
||||
|
||||
nsAutoString addr;
|
||||
aDevice->GetAddress(addr);
|
||||
aDevice.GetAddress(addr);
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
if (!bs) {
|
||||
|
@ -558,13 +558,13 @@ BluetoothAdapter::PairUnpair(bool aPair, nsIDOMBluetoothDevice* aDevice,
|
|||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
BluetoothAdapter::Pair(nsIDOMBluetoothDevice* aDevice, ErrorResult& aRv)
|
||||
BluetoothAdapter::Pair(BluetoothDevice& aDevice, ErrorResult& aRv)
|
||||
{
|
||||
return PairUnpair(true, aDevice, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
BluetoothAdapter::Unpair(nsIDOMBluetoothDevice* aDevice, ErrorResult& aRv)
|
||||
BluetoothAdapter::Unpair(BluetoothDevice& aDevice, ErrorResult& aRv)
|
||||
{
|
||||
return PairUnpair(false, aDevice, aRv);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ struct MediaPlayStatus;
|
|||
|
||||
BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
class BluetoothDevice;
|
||||
class BluetoothSignal;
|
||||
class BluetoothNamedValue;
|
||||
class BluetoothValue;
|
||||
|
@ -95,9 +96,9 @@ public:
|
|||
already_AddRefed<DOMRequest> StopDiscovery(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
Pair(nsIDOMBluetoothDevice* aDevice, ErrorResult& aRv);
|
||||
Pair(BluetoothDevice& aDevice, ErrorResult& aRv);
|
||||
already_AddRefed<DOMRequest>
|
||||
Unpair(nsIDOMBluetoothDevice* aDevice, ErrorResult& aRv);
|
||||
Unpair(BluetoothDevice& aDevice, ErrorResult& aRv);
|
||||
already_AddRefed<DOMRequest>
|
||||
GetPairedDevices(ErrorResult& aRv);
|
||||
already_AddRefed<DOMRequest>
|
||||
|
@ -162,7 +163,7 @@ private:
|
|||
already_AddRefed<mozilla::dom::DOMRequest>
|
||||
StartStopDiscovery(bool aStart, ErrorResult& aRv);
|
||||
already_AddRefed<mozilla::dom::DOMRequest>
|
||||
PairUnpair(bool aPair, nsIDOMBluetoothDevice* aDevice, ErrorResult& aRv);
|
||||
PairUnpair(bool aPair, BluetoothDevice& aDevice, ErrorResult& aRv);
|
||||
|
||||
JS::Heap<JSObject*> mJsUuids;
|
||||
JS::Heap<JSObject*> mJsDeviceAddresses;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "nsTArrayHelpers.h"
|
||||
|
||||
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
|
||||
#include "mozilla/dom/BluetoothDeviceBinding.h"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
|
||||
|
@ -48,14 +49,16 @@ NS_IMPL_RELEASE_INHERITED(BluetoothDevice, nsDOMEventTargetHelper)
|
|||
|
||||
BluetoothDevice::BluetoothDevice(nsPIDOMWindow* aWindow,
|
||||
const nsAString& aAdapterPath,
|
||||
const BluetoothValue& aValue) :
|
||||
BluetoothPropertyContainer(BluetoothObjectType::TYPE_DEVICE),
|
||||
mJsUuids(nullptr),
|
||||
mJsServices(nullptr),
|
||||
mAdapterPath(aAdapterPath),
|
||||
mIsRooted(false)
|
||||
const BluetoothValue& aValue)
|
||||
: nsDOMEventTargetHelper(aWindow)
|
||||
, BluetoothPropertyContainer(BluetoothObjectType::TYPE_DEVICE)
|
||||
, mJsUuids(nullptr)
|
||||
, mJsServices(nullptr)
|
||||
, mAdapterPath(aAdapterPath)
|
||||
, mIsRooted(false)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
BindToOwner(aWindow);
|
||||
const InfallibleTArray<BluetoothNamedValue>& values =
|
||||
|
@ -195,68 +198,32 @@ BluetoothDevice::Notify(const BluetoothSignal& aData)
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetAddress(nsAString& aAddress)
|
||||
JS::Value
|
||||
BluetoothDevice::GetUuids(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
aAddress = mAddress;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetName(nsAString& aName)
|
||||
{
|
||||
aName = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetIcon(nsAString& aIcon)
|
||||
{
|
||||
aIcon = mIcon;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetDeviceClass(uint32_t* aClass)
|
||||
{
|
||||
*aClass = mClass;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetPaired(bool* aPaired)
|
||||
{
|
||||
*aPaired = mPaired;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetConnected(bool* aConnected)
|
||||
{
|
||||
*aConnected = mConnected;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetUuids(JSContext* aCx, JS::Value* aUuids)
|
||||
{
|
||||
if (mJsUuids) {
|
||||
aUuids->setObject(*mJsUuids);
|
||||
} else {
|
||||
if (!mJsUuids) {
|
||||
NS_WARNING("UUIDs not yet set!\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return JS::NullValue();
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
return JS::ObjectValue(*xpc_UnmarkGrayObject(mJsUuids));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BluetoothDevice::GetServices(JSContext* aCx, JS::Value* aServices)
|
||||
JS::Value
|
||||
BluetoothDevice::GetServices(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
if (mJsServices) {
|
||||
aServices->setObject(*mJsServices);
|
||||
} else {
|
||||
if (!mJsServices) {
|
||||
NS_WARNING("Services not yet set!\n");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return JS::Value(JSVAL_NULL);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
return JS::ObjectValue(*xpc_UnmarkGrayObject(mJsServices));
|
||||
}
|
||||
|
||||
JSObject*
|
||||
BluetoothDevice::WrapObject(JSContext* aContext, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return BluetoothDeviceBinding::Wrap(aContext, aScope, this);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,39 @@ public:
|
|||
|
||||
void Notify(const BluetoothSignal& aParam);
|
||||
|
||||
void GetAddress(nsString& aAddress) const
|
||||
{
|
||||
aAddress = mAddress;
|
||||
}
|
||||
|
||||
void GetName(nsString& aName) const
|
||||
{
|
||||
aName = mName;
|
||||
}
|
||||
|
||||
void GetIcon(nsString& aIcon) const
|
||||
{
|
||||
aIcon = mIcon;
|
||||
}
|
||||
|
||||
uint32_t Class() const
|
||||
{
|
||||
return mClass;
|
||||
}
|
||||
|
||||
bool Paired() const
|
||||
{
|
||||
return mPaired;
|
||||
}
|
||||
|
||||
bool Connected() const
|
||||
{
|
||||
return mConnected;
|
||||
}
|
||||
|
||||
JS::Value GetUuids(JSContext* aContext, ErrorResult& aRv);
|
||||
JS::Value GetServices(JSContext* aContext, ErrorResult& aRv);
|
||||
|
||||
nsISupports*
|
||||
ToISupports()
|
||||
{
|
||||
|
@ -52,6 +85,15 @@ public:
|
|||
void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
|
||||
|
||||
void Unroot();
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
|
||||
const BluetoothValue& aValue);
|
||||
|
|
|
@ -6,15 +6,9 @@
|
|||
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(7297ef65-db38-45f1-a5dc-b7347aaa223d)]
|
||||
// XPIDL interfaces might need this definition; so we keep it in place
|
||||
// until we completely switched to WebIDL. See bug 900904.
|
||||
[scriptable, builtinclass, uuid(291fdda9-4f96-4f2f-857f-900f89fb0412)]
|
||||
interface nsIDOMBluetoothDevice : nsIDOMEventTarget
|
||||
{
|
||||
readonly attribute DOMString address;
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute DOMString icon;
|
||||
[binaryname(DeviceClass)] readonly attribute unsigned long class;
|
||||
[implicit_jscontext] readonly attribute jsval uuids;
|
||||
[implicit_jscontext] readonly attribute jsval services;
|
||||
readonly attribute bool connected;
|
||||
readonly attribute bool paired;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
interface BluetoothDevice : EventTarget {
|
||||
readonly attribute DOMString address;
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute DOMString icon;
|
||||
readonly attribute boolean connected;
|
||||
readonly attribute boolean paired;
|
||||
readonly attribute unsigned long class;
|
||||
|
||||
// array of type DOMString[]
|
||||
[Throws]
|
||||
readonly attribute any uuids;
|
||||
|
||||
// array of type DOMString[]
|
||||
[Throws]
|
||||
readonly attribute any services;
|
||||
};
|
|
@ -3,7 +3,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
interface BluetoothDevice;
|
||||
|
||||
[Constructor(DOMString type, optional BluetoothDeviceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
|
||||
interface BluetoothDeviceEvent : Event
|
||||
|
|
|
@ -477,6 +477,7 @@ webidl_files += \
|
|||
ifdef MOZ_B2G_BT
|
||||
webidl_files += \
|
||||
BluetoothAdapter.webidl \
|
||||
BluetoothDevice.webidl \
|
||||
BluetoothDeviceEvent.webidl \
|
||||
BluetoothManager.webidl \
|
||||
BluetoothStatusChangedEvent.webidl \
|
||||
|
|
|
@ -34,6 +34,12 @@ LOCAL_INCLUDES = \
|
|||
-I$(topsrcdir)/js/ipc \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_BT
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/dom/bluetooth \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
../loader/$(LIB_PREFIX)jsloader_s.$(LIB_SUFFIX) \
|
||||
../wrappers/$(LIB_PREFIX)xpcwrappers_s.$(LIB_SUFFIX) \
|
||||
|
|
|
@ -78,6 +78,7 @@ exclude_automatic_type_include = [
|
|||
|
||||
""" Map xpidl interface names to implementation classes. The third column is the canonical interface. """
|
||||
xpidl_to_native = [
|
||||
['nsIDOMBluetoothDevice', 'bluetooth::BluetoothDevice', 'nsIDOMBluetoothDevice'],
|
||||
['nsIDOMDocument', 'nsIDocument', 'nsIDocument'],
|
||||
['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'],
|
||||
['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'],
|
||||
|
|
Загрузка…
Ссылка в новой задаче