Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 707d977

Browse files
author
Timothy Harvey
committed
Fixed WebIDL inconsistencies as follows:
aio.md and ble.md: each had their own version of ReadCallback, so they couldn't be compiled together; we changed the types to include the package name to uniquely identify each one buffer.md: Javascript objects have a method called toString, so changed the operation name to to_string; changed "Uint8" to the WebIDL type "octet"; set a default value for the to_string operation and specified it as "optional" to match the corresponding zephry code gpio.md and sensors.md: like aio/ble, these each declared their own version of "ChangeCallback", so we prepended each instance with its package name pme.md: set JSON to all caps, because that's the way that WebIDL defines it
1 parent 8157c05 commit 707d977

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

docs/aio.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ interface AIO {
4545
(unsigned long or string) pin;
4646
};<p>interface AIOPin {
4747
unsigned long read();
48-
void readAsync(ReadCallback callback); // TODO: change to return a promise
49-
void on(string eventType, ReadCallback callback);
48+
void readAsync(aio_ReadCallback callback); // TODO: change to return a promise
49+
void on(string eventType, aio_ReadCallback callback);
5050
void close();
51-
};<p>callback ReadCallback = void (unsigned long value);
51+
};<p>callback aio_ReadCallback = void (unsigned long value);
5252
</pre> </details>
5353

5454
AIO API
@@ -70,10 +70,10 @@ AIOPin API
7070
* Returns: the latest reading from the pin (an unsigned integer). Blocks until it gets the result.
7171

7272
### pin.readAsync(callback)
73-
* 'callback' *ReadCallback* User-provided callback function that takes
73+
* 'callback' *aio_ReadCallback* User-provided callback function that takes
7474
a single unsigned integer and has no return value.
7575

76-
Pass a function for `ReadCallback` that will be called later when the result is
76+
Pass a function for `aio_ReadCallback` that will be called later when the result is
7777
obtained.
7878

7979
*WARNING: Making an async call like this allocates some memory while the call
@@ -89,7 +89,7 @@ returns a promise.*
8989
### pin.on(eventType, callback)
9090
* 'eventType' *string* Type of event; currently, the only supported
9191
type is "change".
92-
* 'callback' *ReadCallback* User-provided callback function that takes
92+
* 'callback' *aio_ReadCallback* User-provided callback function that takes
9393
a single, unsigned integer and has no return value; can be null.
9494

9595
The callback function is called any time the analog voltage changes. (At the moment,

docs/ble.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ dictionary PrimaryServiceInit {
6565
string uuid;
6666
sequence < string > properties; // 'read', 'write', 'notify'
6767
sequence < DescriptorInit > descriptors;
68-
ReadCallback onReadRequest; // optional
68+
ble_ReadCallback onReadRequest; // optional
6969
WriteCallback onWriteRequest; // optional
7070
SubscribeCallback onSubscribe; // optional
7171
UnsubscribeCallback onUnsubscribe; // optional
7272
NotifyCallback onNotify; // optional
7373
};<p>interface Characteristic {
74-
attribute ReadCallback onReadRequest;
74+
attribute ble_ReadCallback onReadRequest;
7575
attribute WriteCallback onWriteRequest;
7676
attribute SubscribeCallback onSubscribe;
7777
attribute UnsubscribeCallback onUnsubscribe;
7878
attribute NotifyCallback onNotify;
7979
attribute CharacteristicResult response;
80-
};<p>callback ReadCallback = void (unsigned long offset,
80+
};<p>callback ble_ReadCallback = void (unsigned long offset,
8181
FulfillReadCallback fulfillReadCallback);
8282
[ExternalInterface=(Buffer)]
8383
callback WriteCallback = void (Buffer data, unsigned long offset,
@@ -210,7 +210,7 @@ This object has 3 required fields:
210210
3. `descriptors` *array of [Descriptors](#descriptor)*
211211

212212
It may also contain these optional callback fields:
213-
1. `onReadRequest` *ReadCallback*
213+
1. `onReadRequest` *ble_ReadCallback*
214214
* Called when the client is requesting to read data from the characteristic.
215215
* See below for common argument definitions
216216
2. `onWriteRequest` *WriteCallback*

docs/buffer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ZJS API for Buffer
1010
* [buf.copy(target[, targetStart, [sourceStart[, sourceEnd]]])](#bufcopytarget-targetstart-sourcestart-sourceend)
1111
* [buf.fill(value[, offset[, end[, encoding]]])](#buffillvalue-offset-end-encoding)
1212
* [buf.readUInt*(offset)](#bufreaduint-family)
13-
* [buf.toString([encoding])](#buftostringencoding)
13+
* [buf.to_string([encoding])](#bufto_stringencoding)
1414
* [buf.write(string[, offset[, length[, encoding]]])](#bufwritestring-offset-length-encoding)
1515
* [buf.writeUInt*(value, offset)](#bufwriteuint-family)
1616
* [Sample Apps](#sample-apps)
@@ -29,7 +29,7 @@ specific API functions. We have a short document explaining [ZJS WebIDL convent
2929
<details>
3030
<summary> Click to show/hide WebIDL</summary>
3131
<pre>
32-
[ Constructor(sequence < Uint8 > initialValues),
32+
[ Constructor(sequence < octet > initialValues),
3333
Constructor(unsigned long size),
3434
Constructor(ByteString initialString), ]
3535
interface Buffer {
@@ -46,7 +46,7 @@ interface Buffer {
4646
short readUInt16LE(optional unsigned long offset = 0);
4747
long readUInt32BE(optional unsigned long offset = 0);
4848
long readUInt32LE(optional unsigned long offset = 0);
49-
string toString(string encoding);
49+
string to_string(optional string encoding = "utf8");
5050
long write(string value, optional long offset = 0,
5151
optional long length = 0,
5252
optional string encoding = "utf8");
@@ -121,7 +121,7 @@ little-endian (lowest byte first) integer depending on the function version.
121121
The `offset` should be provided but will be treated as 0 if not given. Returns
122122
an error if the buffer is not big enough.
123123

124-
### buf.toString([encoding])
124+
### buf.to_string([encoding])
125125
* `encoding` *string* Encoding to use.
126126
* Returns: *string*
127127

docs/gpio.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ dictionary GPIOInit {
4444
long read();
4545
void write(long value);
4646
void close();
47-
attribute ChangeCallback onchange;
48-
};<p>callback ChangeCallback = void (GPIOEvent event);<p>dictionary GPIOEvent {
47+
attribute gpio_ChangeCallback onchange;
48+
};<p>callback gpio_ChangeCallback = void (GPIOEvent event);<p>dictionary GPIOEvent {
4949
long value;
5050
};<p>enum GPIOMode { "out", "in" };
5151
enum GPIOEdge { "none", "rising", "falling", "any" };
@@ -112,7 +112,7 @@ writing anymore.
112112

113113
### pin.onchange
114114

115-
* `onchange` *ChangeCallback*
115+
* `onchange` *gpio_ChangeCallback*
116116

117117
Set this attribute to a function that will receive events whenever the pin
118118
changes according to the edge condition specified at pin initialization. The

docs/pme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ interface PME {
7070
void setClassifierMode(unsigned short mode);
7171
unsigned short getDistanceMode();
7272
void setDistanceMode(unsigned short mode);
73-
sequence < Json > saveNeurons();
74-
void restoreNeurons(sequence < Json > objects);
73+
sequence < JSON > saveNeurons();
74+
void restoreNeurons(sequence < JSON > objects);
7575
<p>
7676
attribute unsigned short RBF_MODE; // RBF classification mode
7777
attribute unsigned short KNN_MODE; // KNN classification mode

docs/sensors.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ explaining [ZJS WebIDL conventions](Notes_on_WebIDL.md).
3737
<summary>Click to show WebIDL</summary>
3838
<pre>
3939
interface Sensor {
40-
readonly attribute boolean activated; // whether the sensor is activated or not
41-
readonly attribute boolean hasReading; // whether the sensor has readings available
42-
readonly attribute double timestamp; // timestamp of the latest reading in milliseconds
43-
attribute double frequency; // sampling frequency in hertz
44-
void start(); // starts the sensor
45-
void stop(); // stops the sensor
46-
attribute ChangeCallback onreading; // callback handler for change events
47-
attribute ActivateCallback onactivate; // callback handler for activate events
48-
attribute ErrorCallback onerror; // callback handler for error events
40+
readonly attribute boolean activated; // whether the sensor is activated or not
41+
readonly attribute boolean hasReading; // whether the sensor has readings available
42+
readonly attribute double timestamp; // timestamp of the latest reading in milliseconds
43+
attribute double frequency; // sampling frequency in hertz
44+
void start(); // starts the sensor
45+
void stop(); // stops the sensor
46+
attribute sensor_ChangeCallback onreading; // callback handler for change events
47+
attribute ActivateCallback onactivate; // callback handler for activate events
48+
attribute ErrorCallback onerror; // callback handler for error events
4949
};<p>
5050
dictionary SensorOptions {
5151
double frequency; // desired frequency, default is 20 if unset
5252
};<p>interface SensorErrorEvent {
5353
attribute Error error;
54-
};<p>callback ChangeCallback = void();
54+
};<p>callback sensor_ChangeCallback = void();
5555
callback ActivateCallback = void();
5656
callback ErrorCallback = void(SensorErrorEvent error);<p>[Constructor(optional AccelerometerOptions accelerometerOptions)]
5757
interface Accelerometer : Sensor {

0 commit comments

Comments
 (0)