Skip to content

Commit 578606d

Browse files
committed
docs: add note
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fd7bc75 commit 578606d

File tree

1 file changed

+3
-1
lines changed
  • lib/node_modules/@stdlib/dstructs/struct

1 file changed

+3
-1
lines changed

lib/node_modules/@stdlib/dstructs/struct/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,16 @@ TODO: document constructor API
102102

103103
- The struct schema supports default values. In C, uninitialized members are zero-filled.
104104
- The struct schema supports "casting modes", which govern member assignment operations and support placing (or relaxing) strict requirements on what types of values may be assigned to struct members. In C, members have no such limitations, with the C compiler performing implicit casting (e.g., a signed integer will be implicitly cast to an unsigned integer when a member has an unsigned integer data type).
105-
- Only fixed-width types are supported (e.g., `int8`, `float64`, etc). In C, members can have types which may vary across platforms (e.g., `int`).
105+
- Only fixed-width types are supported (e.g., `int8`, `float64`, etc). In C, members can have types which may vary across platforms (e.g., `int`, `enum`, `long double`, etc).
106106
- Member types must be serializable to an ArrayBuffer (e.g., no functions, general objects, etc). In C, members have no such limitations (e.g., a member can be a function pointer).
107107
- Union types must all have the same byte length. In C, members of union types can have different byte lengths.
108108
- struct instances can have "hidden" (i.e., non-enumerable) fields. In C, all members are part of a `struct`'s public API.
109109
- struct instances can have read-only fields. In C, one can use a `const` qualifier to prevent assignment after initialization; however, one can circumvent this restriction using pointer tricks.
110110
- Member types can have an associated description, which is useful when wanting to inspect struct instances in interactive contexts, such as REPLs.
111111
- struct instances support string and JSON serialization.
112112

113+
- A primary use case for emulating C `struct` behavior is to facilitate interoperation between JavaScript and C. For example, by creating a JavaScript struct instance which has the same alignment and layout as a C `struct`, one can pass a pointer to a struct instance's underlying byte buffer from JavaScript to C and then simply perform a cast to interpret as an equivalent C `struct`. This enables zero-copy interchange when, e.g., calling into Node.js native native add-ons and can greatly reduce overhead when working with heterogeneous composite data types.
114+
113115
</section>
114116

115117
<!-- /.notes -->

0 commit comments

Comments
 (0)