@@ -27,6 +27,7 @@ var isObject = require( '@stdlib/assert/is-object' );
27
27
var hasProp = require ( '@stdlib/assert/has-property' ) ;
28
28
var setReadOnly = require ( '@stdlib/utils/define-nonenumerable-read-only-property' ) ;
29
29
var setReadWriteAccessor = require ( '@stdlib/utils/define-nonenumerable-read-write-accessor' ) ;
30
+ var setReadOnlyAccessor = require ( '@stdlib/utils/define-nonenumerable-read-only-accessor' ) ;
30
31
var propertyDescriptor = require ( '@stdlib/utils/property-descriptor' ) ;
31
32
var contains = require ( '@stdlib/array/base/assert/contains' ) . factory ;
32
33
var join = require ( '@stdlib/array/base/join' ) ;
@@ -149,6 +150,153 @@ function factory( dtype ) {
149
150
*/
150
151
inherit ( Results , Struct ) ;
151
152
153
+ /**
154
+ * Constructor name.
155
+ *
156
+ * @private
157
+ * @name name
158
+ * @memberof Results
159
+ * @readonly
160
+ * @type {string }
161
+ */
162
+ setReadOnly ( Results , 'name' , Struct . name ) ;
163
+
164
+ /**
165
+ * Alignment.
166
+ *
167
+ * @private
168
+ * @name alignment
169
+ * @memberof Results
170
+ * @readonly
171
+ * @type {PositiveInteger }
172
+ */
173
+ setReadOnly ( Results , 'alignment' , Struct . alignment ) ;
174
+
175
+ /**
176
+ * Size (in bytes) of the `struct`.
177
+ *
178
+ * @private
179
+ * @name byteLength
180
+ * @memberof Results
181
+ * @readonly
182
+ * @type {PositiveInteger }
183
+ */
184
+ setReadOnly ( Results , 'byteLength' , Struct . byteLength ) ;
185
+
186
+ /**
187
+ * Returns a list of `struct` fields.
188
+ *
189
+ * @private
190
+ * @name fields
191
+ * @memberof Results
192
+ * @readonly
193
+ * @type {Array<string> }
194
+ */
195
+ setReadOnlyAccessor ( Results , 'fields' , function get ( ) {
196
+ return Struct . fields ;
197
+ } ) ;
198
+
199
+ /**
200
+ * Returns a string corresponding to the `struct` layout.
201
+ *
202
+ * @private
203
+ * @name layout
204
+ * @memberof Results
205
+ * @readonly
206
+ * @type {string }
207
+ */
208
+ setReadOnlyAccessor ( Results , 'layout' , function get ( ) {
209
+ return Struct . layout ;
210
+ } ) ;
211
+
212
+ /**
213
+ * Returns the length, in bytes, of the value specified by the provided field name.
214
+ *
215
+ * @private
216
+ * @name byteLengthOf
217
+ * @memberof Results
218
+ * @readonly
219
+ * @type {Function }
220
+ * @param {string } name - field name
221
+ * @throws {Error } struct must have at least one field
222
+ * @throws {TypeError } must provide a recognized field name
223
+ * @returns {NonNegativeInteger } byte length
224
+ */
225
+ setReadOnly ( Results , 'byteLengthOf' , Struct . byteLengthOf ) ;
226
+
227
+ /**
228
+ * Returns the offset, in bytes, from the beginning of a `struct` to the value specified by the provided field name.
229
+ *
230
+ * @private
231
+ * @name byteOffsetOf
232
+ * @memberof Results
233
+ * @readonly
234
+ * @type {Function }
235
+ * @param {string } name - field name
236
+ * @throws {Error } struct must have at least one field
237
+ * @throws {TypeError } must provide a recognized field name
238
+ * @returns {NonNegativeInteger } byte offset
239
+ */
240
+ setReadOnly ( Results , 'byteOffsetOf' , Struct . byteOffsetOf ) ;
241
+
242
+ /**
243
+ * Returns the description associated with a provided field name.
244
+ *
245
+ * @private
246
+ * @name descriptionOf
247
+ * @memberof Results
248
+ * @readonly
249
+ * @type {Function }
250
+ * @param {string } name - field name
251
+ * @throws {Error } struct must have at least one field
252
+ * @throws {TypeError } must provide a recognized field name
253
+ * @returns {string } description
254
+ */
255
+ setReadOnly ( Results , 'descriptionOf' , Struct . descriptionOf ) ;
256
+
257
+ /**
258
+ * Returns the type associated with a provided field name.
259
+ *
260
+ * @private
261
+ * @name typeOf
262
+ * @memberof Results
263
+ * @readonly
264
+ * @type {Function }
265
+ * @param {string } name - field name
266
+ * @throws {Error } struct must have at least one field
267
+ * @throws {TypeError } must provide a recognized field name
268
+ * @returns {(string|Object) } type
269
+ */
270
+ setReadOnly ( Results , 'typeOf' , Struct . typeOf ) ;
271
+
272
+ /**
273
+ * Returns the underlying byte buffer of a `struct`.
274
+ *
275
+ * @private
276
+ * @name bufferOf
277
+ * @memberof Results
278
+ * @readonly
279
+ * @type {Function }
280
+ * @param {Object } obj - struct instance
281
+ * @throws {TypeError } must provide a `struct` instance
282
+ * @returns {ArrayBuffer } underlying byte buffer
283
+ */
284
+ setReadOnly ( Results , 'bufferOf' , Struct . bufferOf ) ;
285
+
286
+ /**
287
+ * Returns the underlying byte buffer of a `struct` as a `DataView`.
288
+ *
289
+ * @private
290
+ * @name viewOf
291
+ * @memberof Results
292
+ * @readonly
293
+ * @type {Function }
294
+ * @param {Object } obj - struct instance
295
+ * @throws {TypeError } must provide a `struct` instance
296
+ * @returns {DataView } view of underlying byte buffer
297
+ */
298
+ setReadOnly ( Results , 'viewOf' , Struct . viewOf ) ;
299
+
152
300
/**
153
301
* Test name.
154
302
*
0 commit comments