chitralverma opened a new pull request, #9331:
URL: https://github.com/apache/opendal/pull/9331

   # Which issue does this PR close?
   
   Part of #9324 (tracker #9320).
   
   # Rationale for this change
   
   Following the suggestion on #9320 to start small, this PR generates a single 
C++ options struct, `ListOptions`, from `core/core/src/types/options.rs` with 
the shared `core_options` parser, as the Node.js `ListOptions` pilot (#9322) 
does. It exposes no new option. The other C++ options structs stay 
hand-written, and this PR stays a draft until the Node.js pilot settles the 
pattern.
   
   # What changes are included in this PR?
   
   - `dev/src/generate/cpp.rs`: an `OPTIONS` table lists the five `ListOptions` 
members with their core kinds, in their released order. It renders all four 
layers:
     - the public struct in the new generated `include/options.hpp`, which 
`data_structure.hpp` includes as it includes the generated `capability.hpp` and 
`metadata.hpp`;
     - the cxx bridge struct in the generated `src/options.rs`, in 
`opendal::ffi::options` with its own value structs, as `src/metadata.rs` does;
     - `utils::ToFfiOptions(const ListOptions &)` in the generated 
`src/utils/options_converter.{hpp,cpp}`;
     - `From<FfiListOptions> for opendal::options::ListOptions` in 
`src/options.rs`.
   
     Generation fails when a listed member is missing from core, is listed 
twice, or changes kind in core. A core field that the table does not list 
(today only `glob`) keeps its core default, and the generated conversion names 
it under `// Not exposed in C++ yet:`.
   - `src/lib.rs`, `src/operator.cpp`, `build.rs`, and `CMakeLists.txt` drop 
the hand-written `ListOptions` mirror and conversions and build the new bridge.
   - `ci_bindings_cpp.yml` also runs on changes to 
`core/core/src/types/options.rs`, which the generator now reads.
   - Tests:
     - `dev`: the `ListOptions` text copied from `main`'s `data_structure.hpp` 
must appear verbatim in the generated header. Separate tests cover the rejected 
tables, and check that a new core field leaves the members unchanged and is 
reported as unexposed.
     - `tests/options_test.cpp`: a positional initializer in `main`'s member 
order reaches the bridge; structured bindings bind each member in order; an 
explicit `limit = 0` stays set; a default-initialized `const ListOptions` 
reaches the bridge with every value absent. That declaration compiles only 
while each `bool` keeps its default member initializer.
     - `src/options_test.rs`: every bridge field reaches core, an explicit zero 
limit becomes `Some(0)`, and absent values stay `None`.
   
     Scratch mutations confirmed that each test can fail. Swapping two table 
rows fails the dev header test and the structured-binding test. Dropping a row 
fails the dev test and breaks compilation of both binding tests. Removing the 
`{false}` initializers fails the dev test and breaks compilation of the `const` 
default test (GCC and Clang). Sending `limit` as absent fails two C++ tests. 
Dropping `start_after` in the Rust conversion fails the Rust test and the 
existing `OpenDALOptionsTest.ListOptions*` tests. Adding a field to core 
`ListOptions` changes only that "not exposed" list, and changing the kind of 
core `limit` stops generation.
   
   # Are there any user-facing changes?
   
   None. `ListOptions` moves from `data_structure.hpp` to `options.hpp`, which 
`data_structure.hpp` includes, so code that includes either header sees the 
same declaration. The struct text is byte-identical to `main`'s, and 
`data_structure.hpp` otherwise differs from `main` only by the added `#include 
"options.hpp"`.
   
   A probe compiled against `main`'s and this PR's headers printed identical 
`sizeof`, `alignof`, member offsets, member types, and default values for all 
eight options structs. Positional initialization, structured bindings, and 
C++20 designated initialization also behaved the same. This held on Linux 
x86-64 with GCC 13.3 and clang 18.1.3, in C++17 and C++20. `ListOptions` stays 
64 bytes with 8-byte alignment.
   
   # Breaking changes
   
   None
   
   # AI Usage Statement
   
   - Harness: Claude Code via T3 Code. Model: Claude Opus 5.5 
(`claude-opus-5-5`). Effort: xhigh. Role: implemented the generator, templates, 
wiring, and tests; ran the mutation, layout, and Linux container checks; 
drafted this description. The author reviews every change and claim.
   - Decisions for review: the generated header is named `options.hpp` so that 
later steps can move more options structs into it. The options bridge declares 
its own `OptionalString` and `OptionalUsize` in `opendal::ffi::options`, as the 
Metadata bridge does, while the hand-written structs keep the `opendal::ffi` 
copies. The generated header copies no core rustdoc, because `main`'s 
`ListOptions` has none.
   


-- 
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]

Reply via email to