From 69b7061ec16faf5cae9579a5589c051c1d1020f3 Mon Sep 17 00:00:00 2001 From: Chris Campbell Date: Wed, 29 May 2024 22:36:54 -0700 Subject: [PATCH] fix: expose VarSpec in the public API --- .../runtime/docs/functions/createLookupDef.md | 2 +- packages/runtime/docs/interfaces/JsModel.md | 34 +++++++++++++++++++ packages/runtime/docs/interfaces/LookupDef.md | 2 +- packages/runtime/docs/interfaces/VarSpec.md | 22 ++++++++++++ packages/runtime/src/_shared/var-indices.ts | 8 ++--- packages/runtime/src/js-model/js-model.ts | 2 -- 6 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 packages/runtime/docs/interfaces/VarSpec.md diff --git a/packages/runtime/docs/functions/createLookupDef.md b/packages/runtime/docs/functions/createLookupDef.md index e3ae0ea6..c87358bf 100644 --- a/packages/runtime/docs/functions/createLookupDef.md +++ b/packages/runtime/docs/functions/createLookupDef.md @@ -10,7 +10,7 @@ Create a `LookupDef` instance from the given array of `Point` objects. | Name | Type | Description | | :------ | :------ | :------ | -| `varSpec` | `VarSpec` | The spec for the lookup or data variable to be modified. | +| `varSpec` | [`VarSpec`](../interfaces/VarSpec.md) | The spec for the lookup or data variable to be modified. | | `points` | [`Point`](../interfaces/Point.md)[] | The lookup data as an array of `Point` objects. | #### Returns diff --git a/packages/runtime/docs/interfaces/JsModel.md b/packages/runtime/docs/interfaces/JsModel.md index 6a72b1e4..cd160119 100644 --- a/packages/runtime/docs/interfaces/JsModel.md +++ b/packages/runtime/docs/interfaces/JsModel.md @@ -108,6 +108,23 @@ ___ ___ +### setLookup + +**setLookup**(`varSpec`, `points`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `varSpec` | [`VarSpec`](VarSpec.md) | +| `points` | `Float64Array` | + +#### Returns + +`void` + +___ + ### storeOutputs **storeOutputs**(`storeValue`): `void` @@ -124,6 +141,23 @@ ___ ___ +### storeOutput + +**storeOutput**(`varSpec`, `storeValue`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `varSpec` | [`VarSpec`](VarSpec.md) | +| `storeValue` | (`value`: `number`) => `void` | + +#### Returns + +`void` + +___ + ### initConstants **initConstants**(): `void` diff --git a/packages/runtime/docs/interfaces/LookupDef.md b/packages/runtime/docs/interfaces/LookupDef.md index 745e00c6..f05ae059 100644 --- a/packages/runtime/docs/interfaces/LookupDef.md +++ b/packages/runtime/docs/interfaces/LookupDef.md @@ -8,7 +8,7 @@ Specifies the data that will be used to set or override a lookup definition. ### varSpec - **varSpec**: `VarSpec` + **varSpec**: [`VarSpec`](VarSpec.md) The spec for the lookup or data variable to be modified. diff --git a/packages/runtime/docs/interfaces/VarSpec.md b/packages/runtime/docs/interfaces/VarSpec.md new file mode 100644 index 00000000..bc0b406e --- /dev/null +++ b/packages/runtime/docs/interfaces/VarSpec.md @@ -0,0 +1,22 @@ +[@sdeverywhere/runtime](../index.md) / VarSpec + +# Interface: VarSpec + +The variable index metadata that is used to identify a specific instance of a +variable in a generated model. + +## Properties + +### varIndex + + **varIndex**: `number` + +The variable index as used in the generated C/JS code. + +___ + +### subscriptIndices + + `Optional` **subscriptIndices**: `number`[] + +The subscript index values as used in the generated C/JS code. diff --git a/packages/runtime/src/_shared/var-indices.ts b/packages/runtime/src/_shared/var-indices.ts index 2a83b90a..a8227d0d 100644 --- a/packages/runtime/src/_shared/var-indices.ts +++ b/packages/runtime/src/_shared/var-indices.ts @@ -12,13 +12,13 @@ export const indicesPerVariable = 4 /** - * The variable index values for use with the optional input/output indices buffer. - * @hidden This is not yet part of the public API; it is exposed here for use in testing tools. + * The variable index metadata that is used to identify a specific instance of a + * variable in a generated model. */ export interface VarSpec { - /** The variable index as used in the generated C code. */ + /** The variable index as used in the generated C/JS code. */ varIndex: number - /** The subscript index values as used in the generated C code. */ + /** The subscript index values as used in the generated C/JS code. */ subscriptIndices?: number[] } diff --git a/packages/runtime/src/js-model/js-model.ts b/packages/runtime/src/js-model/js-model.ts index fee7ef2d..8f57b7ef 100644 --- a/packages/runtime/src/js-model/js-model.ts +++ b/packages/runtime/src/js-model/js-model.ts @@ -38,11 +38,9 @@ export interface JsModel { setTime(time: number): void setInputs(inputValue: (index: number) => number): void - /** @hidden */ setLookup(varSpec: VarSpec, points: Float64Array): void storeOutputs(storeValue: (value: number) => void): void - /** @hidden */ storeOutput(varSpec: VarSpec, storeValue: (value: number) => void): void initConstants(): void