Skip to content

Commit

Permalink
refactor(bindings/C): Alter naming convention for consistency (#3282)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyjixyjixyji authored Oct 21, 2023
1 parent e48968b commit c7bfe23
Show file tree
Hide file tree
Showing 21 changed files with 1,408 additions and 1,230 deletions.
1 change: 1 addition & 0 deletions bindings/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ all: build test examples

.PHONY: format
format:
cargo fmt
find . -name '*.cpp' -exec clang-format -i --style=WebKit --verbose {} \;
find . -name '*.c' -exec clang-format -i --style=WebKit --verbose {} \;

Expand Down
9 changes: 5 additions & 4 deletions bindings/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ A simple read and write example
int main()
{
/* Initialize a operator for "memory" backend, with no options */
opendal_operator_ptr op = opendal_operator_new("memory", 0);
assert(op.ptr != NULL);
opendal_result_operator_new result = opendal_operator_new("memory", 0);
assert(result.operator_ptr != NULL);
assert(result.error == NULL);

/* Prepare some data to be written */
opendal_bytes data = {
Expand All @@ -26,11 +27,11 @@ int main()
};

/* Write this into path "/testpath" */
opendal_error *error = opendal_operator_blocking_write(op, "/testpath", data);
opendal_error *error = opendal_operator_write(op, "/testpath", data);
assert(error == NULL);

/* We can read it out, make sure the data is the same */
opendal_result_read r = opendal_operator_blocking_read(op, "/testpath");
opendal_result_read r = opendal_operator_read(op, "/testpath");
opendal_bytes* read_bytes = r.data;
assert(r.error == NULL);
assert(read_bytes->len == 24);
Expand Down
8 changes: 4 additions & 4 deletions bindings/c/examples/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ int main()
{
/* Initialize a operator for "memory" backend, with no options */
opendal_result_operator_new result = opendal_operator_new("memory", 0);
assert(result.operator_ptr != NULL);
assert(result.op != NULL);
assert(result.error == NULL);

opendal_operator_ptr* op = result.operator_ptr;
opendal_operator* op = result.op;

/* Prepare some data to be written */
opendal_bytes data = {
Expand All @@ -37,11 +37,11 @@ int main()
};

/* Write this into path "/testpath" */
opendal_error* error = opendal_operator_blocking_write(op, "/testpath", data);
opendal_error* error = opendal_operator_write(op, "/testpath", data);
assert(error == NULL);

/* We can read it out, make sure the data is the same */
opendal_result_read r = opendal_operator_blocking_read(op, "/testpath");
opendal_result_read r = opendal_operator_read(op, "/testpath");
opendal_bytes* read_bytes = r.data;
assert(r.error == NULL);
assert(read_bytes->len == 24);
Expand Down
6 changes: 3 additions & 3 deletions bindings/c/examples/error_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ int main()
{
/* Initialize a operator for "memory" backend, with no options */
opendal_result_operator_new result = opendal_operator_new("memory", 0);
assert(result.operator_ptr != NULL);
assert(result.op != NULL);
assert(result.error == NULL);

opendal_operator_ptr* op = result.operator_ptr;
opendal_operator* op = result.op;

/* The read is supposed to fail */
opendal_result_read r = opendal_operator_blocking_read(op, "/testpath");
opendal_result_read r = opendal_operator_read(op, "/testpath");
assert(r.error != NULL);
assert(r.error->code == OPENDAL_NOT_FOUND);

Expand Down
Loading

0 comments on commit c7bfe23

Please sign in to comment.