@onda-lang/processor-abi 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +1 -1
- package/src/index.d.ts +13 -4
- package/src/index.js +39 -4
package/README.md
CHANGED
|
@@ -25,6 +25,12 @@ validate artifacts without installing the compiler or duplicating the ABI schema
|
|
|
25
25
|
The detailed TypeScript records mirror `onda_processor_abi::ProcessorDescriptor`; both packages
|
|
26
26
|
validate the same checked-in conformance fixture.
|
|
27
27
|
|
|
28
|
+
The current descriptor represents every bindable buffer-array slot as a physical
|
|
29
|
+
`metadata.buffers` entry and records logical contiguous groups in `metadata.buffer_arrays`. At
|
|
30
|
+
runtime all four descriptor tables are present when any buffer exists, but an individual sample
|
|
31
|
+
pointer may be null. Null entries select the processor's neutral one-frame zero/discard storage;
|
|
32
|
+
they are valid bindings, not an incomplete artifact.
|
|
33
|
+
|
|
28
34
|
`createParamControl()` validates and decodes one parameter descriptor into a reusable control with
|
|
29
35
|
`constrainPlain()`, `normalizedToPlain()`, and `plainToNormalized()` methods. It preserves exact
|
|
30
36
|
endpoints, clamps out-of-range values, applies linear, logarithmic, or SuperCollider-style curved
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const PROCESSOR_ARTIFACT_FORMAT: "onda-processor";
|
|
2
2
|
// Synchronized from format-versions.json; do not edit these copies directly.
|
|
3
|
-
export const PROCESSOR_ARTIFACT_FORMAT_VERSION:
|
|
4
|
-
export const PROCESSOR_ABI_VERSION:
|
|
3
|
+
export const PROCESSOR_ARTIFACT_FORMAT_VERSION: 3;
|
|
4
|
+
export const PROCESSOR_ABI_VERSION: 3;
|
|
5
5
|
export const PROCESSOR_EXECUTION_OK: 0;
|
|
6
6
|
export const PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE: 1;
|
|
7
7
|
export const PROCESSOR_SNAPSHOT_FORMAT_VERSION: 1;
|
|
@@ -122,10 +122,18 @@ export interface OndaBufferMetadata {
|
|
|
122
122
|
element_size_bytes: number;
|
|
123
123
|
channels: "mono" | "static" | "dynamic";
|
|
124
124
|
static_channels: number | null;
|
|
125
|
+
/** Declared buffer access capability. */
|
|
125
126
|
access: "read_only" | "read_write";
|
|
127
|
+
/** Whether reachable code may write this physical slot; unresolved selectors are conservative. */
|
|
126
128
|
may_write: boolean;
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
export interface OndaBufferArrayMetadata {
|
|
132
|
+
name: string;
|
|
133
|
+
first_buffer: number;
|
|
134
|
+
len: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
129
137
|
export interface OndaEventParamMetadata {
|
|
130
138
|
name: string;
|
|
131
139
|
type_repr: string;
|
|
@@ -161,9 +169,9 @@ export interface OndaStateMetadata {
|
|
|
161
169
|
|
|
162
170
|
export interface OndaProcessorMetadata {
|
|
163
171
|
format: "onda-processor";
|
|
164
|
-
format_version:
|
|
172
|
+
format_version: 3;
|
|
165
173
|
artifact_kind: OndaArtifactKind;
|
|
166
|
-
abi_version:
|
|
174
|
+
abi_version: 3;
|
|
167
175
|
backend: string;
|
|
168
176
|
mir_schema_version: number;
|
|
169
177
|
target: OndaTargetInfo;
|
|
@@ -198,6 +206,7 @@ export interface OndaProcessorMetadata {
|
|
|
198
206
|
control_outputs: OndaIoMetadata[];
|
|
199
207
|
params: OndaIoMetadata[];
|
|
200
208
|
buffers: OndaBufferMetadata[];
|
|
209
|
+
buffer_arrays: OndaBufferArrayMetadata[];
|
|
201
210
|
events: OndaEventMetadata[];
|
|
202
211
|
states: OndaStateMetadata[];
|
|
203
212
|
};
|
package/src/index.js
CHANGED
|
@@ -4,8 +4,8 @@ const PARAM_CONTROL = globalThis.__ONDA_PARAM_CONTROL_V2__;
|
|
|
4
4
|
|
|
5
5
|
export const PROCESSOR_ARTIFACT_FORMAT = "onda-processor";
|
|
6
6
|
// Synchronized from format-versions.json; do not edit these copies directly.
|
|
7
|
-
export const PROCESSOR_ARTIFACT_FORMAT_VERSION =
|
|
8
|
-
export const PROCESSOR_ABI_VERSION =
|
|
7
|
+
export const PROCESSOR_ARTIFACT_FORMAT_VERSION = 3;
|
|
8
|
+
export const PROCESSOR_ABI_VERSION = 3;
|
|
9
9
|
export const PROCESSOR_EXECUTION_OK = 0;
|
|
10
10
|
export const PROCESSOR_EXECUTION_RUNTIME_SAFETY_FAILURE = 1;
|
|
11
11
|
export const PROCESSOR_SNAPSHOT_FORMAT_VERSION = 1;
|
|
@@ -223,6 +223,41 @@ export function validateProcessorMetadata(metadata, expectedKind = null) {
|
|
|
223
223
|
metadata.metadata.buffers.forEach((entry, index) =>
|
|
224
224
|
validateBufferMetadata(entry, `metadata.buffers[${index}]`)
|
|
225
225
|
);
|
|
226
|
+
const bufferArrays = metadata.metadata.buffer_arrays ?? [];
|
|
227
|
+
if (!Array.isArray(bufferArrays)) {
|
|
228
|
+
throw new OndaArtifactError("metadata.buffer_arrays must be an array");
|
|
229
|
+
}
|
|
230
|
+
const bufferArrayNames = new Set();
|
|
231
|
+
const groupedBuffers = new Set();
|
|
232
|
+
bufferArrays.forEach((entry, index) => {
|
|
233
|
+
const path = `metadata.buffer_arrays[${index}]`;
|
|
234
|
+
requireString(entry?.name, `${path}.name`);
|
|
235
|
+
requireInteger(entry?.first_buffer, `${path}.first_buffer`, 0);
|
|
236
|
+
requireInteger(entry?.len, `${path}.len`, 1);
|
|
237
|
+
if (bufferArrayNames.has(entry.name)) {
|
|
238
|
+
throw new OndaArtifactError(`${path}.name duplicates buffer array '${entry.name}'`);
|
|
239
|
+
}
|
|
240
|
+
bufferArrayNames.add(entry.name);
|
|
241
|
+
if (entry.first_buffer + entry.len > metadata.metadata.buffers.length) {
|
|
242
|
+
throw new OndaArtifactError(`${path} exceeds metadata.buffers`);
|
|
243
|
+
}
|
|
244
|
+
const first = metadata.metadata.buffers[entry.first_buffer];
|
|
245
|
+
for (let slot = entry.first_buffer; slot < entry.first_buffer + entry.len; slot += 1) {
|
|
246
|
+
if (groupedBuffers.has(slot)) {
|
|
247
|
+
throw new OndaArtifactError(`${path} overlaps another buffer array at slot ${slot}`);
|
|
248
|
+
}
|
|
249
|
+
groupedBuffers.add(slot);
|
|
250
|
+
const buffer = metadata.metadata.buffers[slot];
|
|
251
|
+
if (
|
|
252
|
+
buffer.scalar !== first.scalar ||
|
|
253
|
+
buffer.channels !== first.channels ||
|
|
254
|
+
buffer.static_channels !== first.static_channels ||
|
|
255
|
+
buffer.access !== first.access
|
|
256
|
+
) {
|
|
257
|
+
throw new OndaArtifactError(`${path} contains incompatible buffer descriptors`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
226
261
|
metadata.metadata.events.forEach((entry, index) =>
|
|
227
262
|
validateEventMetadata(entry, `metadata.events[${index}]`)
|
|
228
263
|
);
|
|
@@ -363,8 +398,8 @@ function validateBufferMetadata(value, path) {
|
|
|
363
398
|
throw new OndaArtifactError(`${path}.access has an unsupported value`);
|
|
364
399
|
}
|
|
365
400
|
requireBoolean(value?.may_write, `${path}.may_write`);
|
|
366
|
-
if (value.may_write
|
|
367
|
-
throw new OndaArtifactError(`${path}.may_write
|
|
401
|
+
if (value.may_write && value.access !== "read_write") {
|
|
402
|
+
throw new OndaArtifactError(`${path}.may_write requires read_write access`);
|
|
368
403
|
}
|
|
369
404
|
}
|
|
370
405
|
|