Repository navigation
feat(bindings/ocaml): generate Capability from core - #9128
chitralverma wants to merge 1 commit into
Conversation
Xuanwo
left a comment
There was a problem hiding this comment.
AI-generated review of 0e4aab0f3f.
Please expose Capability structurally in bindings/ocaml/lib/operator.mli. The public module alias requires downstream wrappers to preserve module identity. For example, this wrapper compiles against the base and fails with a signature mismatch on this head.
module Wrapped : module type of Opendal.Operator = struct
include Opendal.Operator
module Capability = struct
include Opendal.Operator.Capability
end
endChanging the interface declaration fixes the wrapper. The implementation alias in operator.ml can stay as it is.
-module Capability = Capability
+module Capability : module type of CapabilityWith this change, all 96 accessor declarations are preserved. The wrapper, native and bytecode consumers, and the 23 binding tests pass.
|
Thanks, adopted in 46fa975. I added your wrapper as a compile-time check in Verified locally: |
Same as Capability in apache#9128: a module alias in the interface forces downstream wrappers to keep module identity. Add a compile-time regression test for such a wrapper. Signed-off-by: Chitral Verma <chitralverma@gmail.com>
aedc77c to
13c6d96
Compare
|
(AI-generated reply) The branch is rebased onto |
Generate the OCaml Capability FFI accessors and public module from core/core/src/types/capability.rs, and check for drift in CI. Part of apache#9122. Signed-off-by: Chitral Verma <chitralverma@gmail.com>
13c6d96 to
4b6051a
Compare
Which issue does this PR close?
Part of #9122.
Rationale for this change
The OCaml
Capabilitymodule was hand-copied from core across the Rust FFI accessors (src/operator/capability.rs) and the publicCapabilitymodule inlib/operator.ml{,i}. It exposed only 16 of the 98 core fields. This PR generates it fromcore/core/src/types/capability.rs, as Java (#8644) and .NET (#8146) already do.What changes are included in this PR?
dev/src/generate/ocaml.rs+dev/src/generate/ocaml/*.j2: newgenerate -l ocamltarget that renders:bindings/ocaml/src/operator/capability.rs: one#[ocaml::func]accessor per core field.bindings/ocaml/lib/capability.ml{,i}: the publicCapabilitymodule, with odoc taken from core. The module doc notes that the flags describe the core operator, so a flag can be true even when the binding has no matching function (for examplerestore).src/operator.ml{,i}: theexternaldeclarations, regenerated from the Rust accessors byocaml-buildduring the build.lib/operator.ml{,i}:operator.mlaliases the generated module (module Capability = Capability), andoperator.mliexposes it structurally (module Capability : module type of Capability).Operator.Capability.*keeps working, and downstream wrappers that re-includeCapabilitystill matchmodule type of Opendal.Operator.test/test.mladds a compile-time check for such a wrapper..ocamlformat-ignore: ignores the generatedlib/capability.ml{,i}, like the existingsrc/**entry.ci_odev.yml(check_generated): runsgenerate -l ocamlandcargo fmtfor OCaml.ci_bindings_ocaml.yml: afterdune runtest, which also rebuildssrc/operator.ml{,i}, regenerates and runsgit diff --exit-code. The workflow also triggers ondev/src/generate/**and corecapability.rs.Are there any user-facing changes?
Yes, additions only.
Operator.Capabilitynow exposes every core capability. Size limits (for examplewrite_multi_max_size) areint64 option, asMetadataalready does forlast_modified. Existing accessors keep their names and types.Breaking changes
AI Usage Statement
mainand regenerated the files for the new core fields (read_with_checksum,write_with_checksum), followed up on review, ran the OCaml checks after the rebase, and updated this description.