mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 23:37:33 +09:00
WebUSB pt.3
This commit is contained in:
parent
c68c8eb0b7
commit
83e4aee77c
7 changed files with 54 additions and 17 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#define mozilla_dom_USBAlternateInterface_h
|
||||
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/DOMString.h"
|
||||
#include "mozilla/dom/USBEndpoint.h"
|
||||
#include "mozilla/dom/USBBinding.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
@ -24,7 +25,11 @@ public:
|
|||
uint8_t InterfaceClass() const { return mClass; }
|
||||
uint8_t InterfaceSubclass() const { return mSubclass; }
|
||||
uint8_t InterfaceProtocol() const { return mProtocol; }
|
||||
void GetInterfaceName(Nullable<nsString>& aValue) const { aValue = mName; }
|
||||
void GetInterfaceName(DOMString& aValue) const
|
||||
{
|
||||
if (mName.IsNull()) aValue.SetNull();
|
||||
else aValue.SetOwnedString(mName.Value());
|
||||
}
|
||||
void GetEndpoints(nsTArray<RefPtr<USBEndpoint>>& aValue) const { aValue = mEndpoints; }
|
||||
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#define mozilla_dom_USBConfiguration_h
|
||||
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/DOMString.h"
|
||||
#include "mozilla/dom/USBInterface.h"
|
||||
#include "mozilla/dom/USBBinding.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
@ -21,7 +22,11 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(USBConfiguration)
|
||||
nsISupports* GetParentObject() const { return mOwner; }
|
||||
uint8_t ConfigurationValue() const { return mValue; }
|
||||
void GetConfigurationName(Nullable<nsString>& aValue) const { aValue = mName; }
|
||||
void GetConfigurationName(DOMString& aValue) const
|
||||
{
|
||||
if (mName.IsNull()) aValue.SetNull();
|
||||
else aValue.SetOwnedString(mName.Value());
|
||||
}
|
||||
void GetInterfaces(nsTArray<RefPtr<USBInterface>>& aValue) const { aValue = mInterfaces; }
|
||||
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -159,14 +159,13 @@ USBInTransferResult::~USBInTransferResult()
|
|||
|
||||
void
|
||||
USBInTransferResult::GetData(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aData,
|
||||
ErrorResult& aRv)
|
||||
JS::MutableHandle<JSObject*> aData)
|
||||
{
|
||||
if (!mData) {
|
||||
mData = ArrayBuffer::Create(aCx, this, mRawData.Length(),
|
||||
mRawData.Elements());
|
||||
if (!mData) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
aData.set(nullptr);
|
||||
return;
|
||||
}
|
||||
mRawData.Clear();
|
||||
|
|
|
|||
|
|
@ -141,6 +141,36 @@ USBDevice::SetDeviceInfo(const USBDeviceInfo& aInfo)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
USBDevice::GetManufacturerName(DOMString& aValue) const
|
||||
{
|
||||
if (mManufacturerName.IsNull()) {
|
||||
aValue.SetNull();
|
||||
} else {
|
||||
aValue.SetOwnedString(mManufacturerName.Value());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
USBDevice::GetProductName(DOMString& aValue) const
|
||||
{
|
||||
if (mProductName.IsNull()) {
|
||||
aValue.SetNull();
|
||||
} else {
|
||||
aValue.SetOwnedString(mProductName.Value());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
USBDevice::GetSerialNumber(DOMString& aValue) const
|
||||
{
|
||||
if (mSerialNumber.IsNull()) {
|
||||
aValue.SetNull();
|
||||
} else {
|
||||
aValue.SetOwnedString(mSerialNumber.Value());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
USBDevice::SetConfigurations(
|
||||
const nsTArray<USBConfigurationInfo>& aConfigurations)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/dom/USBBackend.h"
|
||||
#include "mozilla/dom/USBDescriptors.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "mozilla/dom/DOMString.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "nsString.h"
|
||||
#include <stdint.h>
|
||||
|
|
@ -53,23 +54,20 @@ public:
|
|||
|
||||
uint16_t VendorId() const { return mVendorId; }
|
||||
uint16_t ProductId() const { return mProductId; }
|
||||
uint8_t USBVersionMajor() const { return mUSBVersionMajor; }
|
||||
uint8_t USBVersionMinor() const { return mUSBVersionMinor; }
|
||||
uint8_t USBVersionSubminor() const { return mUSBVersionSubminor; }
|
||||
uint8_t UsbVersionMajor() const { return mUSBVersionMajor; }
|
||||
uint8_t UsbVersionMinor() const { return mUSBVersionMinor; }
|
||||
uint8_t UsbVersionSubminor() const { return mUSBVersionSubminor; }
|
||||
uint8_t DeviceClass() const { return mDeviceClass; }
|
||||
uint8_t DeviceSubclass() const { return mDeviceSubclass; }
|
||||
uint8_t DeviceProtocol() const { return mDeviceProtocol; }
|
||||
uint8_t DeviceVersionMajor() const { return mDeviceVersionMajor; }
|
||||
uint8_t DeviceVersionMinor() const { return mDeviceVersionMinor; }
|
||||
uint8_t DeviceVersionSubminor() const { return mDeviceVersionSubminor; }
|
||||
void GetManufacturerName(Nullable<nsString>& aValue) const
|
||||
{ aValue = mManufacturerName; }
|
||||
void GetProductName(Nullable<nsString>& aValue) const
|
||||
{ aValue = mProductName; }
|
||||
void GetSerialNumber(Nullable<nsString>& aValue) const
|
||||
{ aValue = mSerialNumber; }
|
||||
void GetManufacturerName(DOMString& aValue) const;
|
||||
void GetProductName(DOMString& aValue) const;
|
||||
void GetSerialNumber(DOMString& aValue) const;
|
||||
bool Opened() const { return mOpened; }
|
||||
USBConfiguration* GetConfiguration() const { return mConfiguration; }
|
||||
USBConfiguration* Configuration() const { return mConfiguration; }
|
||||
void GetConfigurations(nsTArray<RefPtr<USBConfiguration>>& aValue) const
|
||||
{ aValue = mConfigurations; }
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(USBInTransferResult)
|
||||
nsISupports* GetParentObject() const { return mOwner; }
|
||||
USBTransferStatus Status() const { return mStatus; }
|
||||
void GetData(JSContext*, JS::MutableHandle<JSObject*>, ErrorResult&);
|
||||
void GetData(JSContext*, JS::MutableHandle<JSObject*>);
|
||||
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
|
||||
private:
|
||||
~USBInTransferResult();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(USBInterface)
|
||||
nsISupports* GetParentObject() const { return mOwner; }
|
||||
uint8_t InterfaceNumber() const { return mNumber; }
|
||||
USBAlternateInterface* GetAlternate() const { return mAlternate; }
|
||||
USBAlternateInterface* Alternate() const { return mAlternate; }
|
||||
void SetAlternate(uint8_t);
|
||||
void GetAlternates(nsTArray<RefPtr<USBAlternateInterface>>& aValue) const { aValue = mAlternates; }
|
||||
bool Claimed() const { return mClaimed; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue