chitralverma opened a new pull request, #9335:
URL: https://github.com/apache/opendal/pull/9335
# Which issue does this PR close?
Part of #9323 (tracker #9320).
# Rationale for this change
#9320 starts small: the Node.js `ListOptions` (#9333) is the pilot, and the
other bindings follow one options struct at a time as drafts until it lands.
This draft generates the C and Go `ListOptions` from
`core/core/src/types/options.rs` with the shared `core_options.rs` parser.
`generate -l c` renders C and Go together, so one PR covers both. It exposes no
new option, and the other C and Go option structs stay hand-written.
# What changes are included in this PR?
- `dev/src/generate/c/options.rs` and
`dev/src/generate/c/{options_rs,options_go}.j2`: `generate -l c` (alias `-l
go`) also renders `bindings/c/src/options.rs` and `bindings/go/options.go`. A
table records the released C member order and how each member encodes its core
field. Generation fails when a released field leaves core or changes its kind.
Core fields not in the table keep their core default in the conversion; today
that is only `glob`.
- Docs come from core: each member, setter, and Go option carries the core
field's full doc comment, and the struct and `WithListFn` carry the core
struct's. As in the Node.js pilot, rustdoc links become plain code spans
(``[`crate::layers::SimulateLayer`]`` becomes `` `crate::layers::SimulateLayer`
``), and identifiers keep their core spelling. The generator adds what core
cannot state: `0` and NULL mean unset, the setter copies `start_after`, and the
`_new`/`_free`/`@param`/`@see` text.
- C: the generated file holds `opendal_list_options`, `_new`, the five
`_set_*` functions, `_free`, and `From<&opendal_list_options> for ListOptions`,
which replaces the inline conversion in `opendal_operator_list_with_cancel`.
`limit` of 0 still means unset, and `_set_start_after` still copies the string
that `_free` releases.
- Go: `WithListFn`, the five `ListWith*` options, `listOptions`, and the
list FFI declarations move from `lister.go` to the generated file.
`Operator.List` calls the generated `parseListOptions` and
`newOpendalListOptions`, which make the same C calls in the same order.
- `bindings/c/src/buffer.rs`: `opendal_string_free` and `opendal_bytes` move
unchanged from `types.rs`. cbindgen writes functions in module order, and the
generated list functions sit between these and the option structs that stay in
`types.rs`.
- Tests pin the API, not doc text:
- `bindings/c/tests/list.cpp`: `static_assert`s pin the member types, the
64-bit `sizeof` and offsets, and the seven prototypes, copied from `opendal.h`
on `main`.
- `bindings/go/options_test.go`: compile-time assignments pin `WithListFn`
and the five `ListWith*` signatures from `main`.
- `bindings/c/src/types.rs`: `test_list_options_into_core` checks the
defaults, an explicit `limit` of 0, and every setter through the conversion.
- `dev`: the rendered C member docs and Go option docs carry the core
docs, rustdoc links become code spans, the conversion defaults exactly `glob`,
and a removed or retyped released field fails generation.
Each new test fails under a mutation, and only that test fails: swapping
`versions` and `deleted` in the table (`tests/list.cpp` offsets), making the
`start_after` setter take `char *` (`tests/list.cpp` prototype), making
`ListWithLimit` take `uint64` while the package still builds
(`options_test.go`), converting `limit` 0 to `Some(0)`
(`test_list_options_into_core`), skipping the kind check, rendering C member or
Go option docs without core text, and keeping rustdoc link targets (`dev`).
Adding a fake `Option<String>` field to core `ListOptions` only adds
`fake_option: None` to the conversion; `opendal.h` and `go doc -all` stay
unchanged, and the `dev` test reports `["fake_option", "glob"]`.
# Are there any user-facing changes?
Doc comments only. No API, ABI, or behavior change.
- C and Zig: `bindings/c/include/opendal.h` differs from `main` only in the
doc comments of `opendal_list_options`, its five members, and its five setters
(57 lines added, 19 removed). Every changed line is a comment, the header is
identical to `main` once comments are removed, and `make doc` reports the same
10 Doxygen warnings as on `main`. A probe prints the same `sizeof`, alignment,
and member offsets for all nine option structs in the header on `main` and on
this branch, on macOS arm64 and Linux arm64 and x86-64.
- A C program compiled with `-Werror` against `main`'s header prints the
same output with `main`'s library and this branch's library on macOS arm64 and
Linux arm64 and x86-64. It calls every setter (including self and substring
aliases of `start_after`), initializes the struct positionally and with
designators, and lists a memory operator with each option, including the
`Unsupported` error for `versions` and `deleted`.
- Go: `go doc -short` is identical to `main`, and `go doc -all` differs only
in the doc text of `WithListFn` and the five `ListWith*` options. `main`'s Go
package passes its 76 tests against this branch's library, and this branch's Go
package passes the same 76 tests against `main`'s library. The existing test
files are unchanged.
# Breaking changes
None.
# AI Usage Statement
- **Harness:** Claude Code via T3 Code | **Model:** Claude Opus 5.5 |
**Effort:** xhigh | **Role:** Implemented the generator, templates, and tests;
ran the surface diffs, compatibility probes, mutation checks, and the C, Go,
Zig, and `odev` CI steps on macOS arm64 and in Linux arm64 and x86-64
containers. Did not run the Go behavior tests, which need an
`opendal-go-services` checkout. Drafted this description. The human author
reviews the change and is responsible for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]