mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1027552 - Align values in BluetoothAttributeEvent.attrs with webidl, r=btian
This commit is contained in:
parent
92ea56e2a5
commit
b9397c68ff
@ -699,7 +699,10 @@ BluetoothAdapter::EnableDisable(bool aEnable)
|
||||
}
|
||||
|
||||
nsTArray<nsString> types;
|
||||
types.AppendElement(NS_LITERAL_STRING("State"));
|
||||
BT_APPEND_ENUM_STRING(types,
|
||||
BluetoothAdapterAttribute,
|
||||
BluetoothAdapterAttribute::State);
|
||||
|
||||
DispatchAttributeEvent(types);
|
||||
|
||||
nsRefPtr<BluetoothReplyRunnable> result =
|
||||
@ -792,7 +795,7 @@ BluetoothAdapter::HandlePropertyChanged(const BluetoothValue& aValue)
|
||||
// BluetoothAdapterAttribute properties
|
||||
if (IsAdapterAttributeChanged(type, arr[i].value())) {
|
||||
SetPropertyByValue(arr[i]);
|
||||
types.AppendElement(arr[i].name());
|
||||
BT_APPEND_ENUM_STRING(types, BluetoothAdapterAttribute, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,18 @@ extern bool gBluetoothDebugFlag;
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Convert an enum value to string then append it to an array.
|
||||
*/
|
||||
#define BT_APPEND_ENUM_STRING(array, enumType, enumValue) \
|
||||
do { \
|
||||
uint32_t index = uint32_t(enumValue); \
|
||||
nsAutoString name; \
|
||||
name.AssignASCII(enumType##Values::strings[index].value, \
|
||||
enumType##Values::strings[index].length); \
|
||||
array.AppendElement(name); \
|
||||
} while(0) \
|
||||
|
||||
#define BEGIN_BLUETOOTH_NAMESPACE \
|
||||
namespace mozilla { namespace dom { namespace bluetooth {
|
||||
#define END_BLUETOOTH_NAMESPACE \
|
||||
|
@ -260,7 +260,9 @@ BluetoothManager::DispatchAttributeEvent()
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
|
||||
nsTArray<nsString> types;
|
||||
types.AppendElement(NS_LITERAL_STRING("DefaultAdapter"));
|
||||
BT_APPEND_ENUM_STRING(types,
|
||||
BluetoothManagerAttribute,
|
||||
BluetoothManagerAttribute::DefaultAdapter);
|
||||
|
||||
if (!ToJSValue(cx, types, &value)) {
|
||||
JS_ClearPendingException(cx);
|
||||
|
Loading…
Reference in New Issue
Block a user