Skip to content

Commit

Permalink
Convert C API interface functions to CAPI_INTERFACE (#4460)
Browse files Browse the repository at this point in the history
Convert C API interface functions to use `CAPI_INTERFACE`. This
completes the work in #4430.

There are a very small number of functions not converted. One is not in
the C API (i.e. it doesn't have `extern "C"` linkage), but is used by
the C++ API, and on top of that it's for a deprecated operation. The
others are small, informational functions that do return values directly
and do not use `capi_return_t`.

---
TYPE: NO_HISTORY
DESC: Convert C API interface functions to CAPI_INTERFACE
  • Loading branch information
eric-hughes-tiledb authored Oct 31, 2023
1 parent b8ec44f commit aede0f1
Show file tree
Hide file tree
Showing 25 changed files with 1,340 additions and 905 deletions.
87 changes: 52 additions & 35 deletions tiledb/api/c_api/attribute/attribute_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,150 +205,167 @@ capi_return_t tiledb_attribute_get_enumeration_name(

using tiledb::api::api_entry_context;

int32_t tiledb_attribute_alloc(
CAPI_INTERFACE(
attribute_alloc,
tiledb_ctx_t* ctx,
const char* name,
tiledb_datatype_t type,
tiledb_attribute_handle_t** attr) noexcept {
tiledb_attribute_handle_t** attr) {
return api_entry_context<tiledb::api::tiledb_attribute_alloc>(
ctx, name, type, attr);
}

void tiledb_attribute_free(tiledb_attribute_handle_t** attr) noexcept {
CAPI_INTERFACE_VOID(attribute_free, tiledb_attribute_handle_t** attr) {
return tiledb::api::api_entry_void<tiledb::api::tiledb_attribute_free>(attr);
}

int32_t tiledb_attribute_set_nullable(
CAPI_INTERFACE(
attribute_set_nullable,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint8_t nullable) noexcept {
uint8_t nullable) {
return api_entry_context<tiledb::api::tiledb_attribute_set_nullable>(
ctx, attr, nullable);
}

int32_t tiledb_attribute_set_filter_list(
CAPI_INTERFACE(
attribute_set_filter_list,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
tiledb_filter_list_t* filter_list) noexcept {
tiledb_filter_list_t* filter_list) {
return api_entry_context<tiledb::api::tiledb_attribute_set_filter_list>(
ctx, attr, filter_list);
}

int32_t tiledb_attribute_set_cell_val_num(
CAPI_INTERFACE(
attribute_set_cell_val_num,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint32_t cell_val_num) noexcept {
uint32_t cell_val_num) {
return api_entry_context<tiledb::api::tiledb_attribute_set_cell_val_num>(
ctx, attr, cell_val_num);
}

int32_t tiledb_attribute_get_name(
CAPI_INTERFACE(
attribute_get_name,
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
const char** name) noexcept {
const char** name) {
return api_entry_context<tiledb::api::tiledb_attribute_get_name>(
ctx, attr, name);
}

int32_t tiledb_attribute_get_type(
CAPI_INTERFACE(
attribute_get_type,
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
tiledb_datatype_t* type) noexcept {
tiledb_datatype_t* type) {
return api_entry_context<tiledb::api::tiledb_attribute_get_type>(
ctx, attr, type);
}

int32_t tiledb_attribute_get_nullable(
CAPI_INTERFACE(
attribute_get_nullable,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
uint8_t* nullable) noexcept {
uint8_t* nullable) {
return api_entry_context<tiledb::api::tiledb_attribute_get_nullable>(
ctx, attr, nullable);
}

int32_t tiledb_attribute_get_filter_list(
CAPI_INTERFACE(
attribute_get_filter_list,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
tiledb_filter_list_t** filter_list) noexcept {
tiledb_filter_list_t** filter_list) {
return api_entry_context<tiledb::api::tiledb_attribute_get_filter_list>(
ctx, attr, filter_list);
}

int32_t tiledb_attribute_get_cell_val_num(
CAPI_INTERFACE(
attribute_get_cell_val_num,
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
uint32_t* cell_val_num) noexcept {
uint32_t* cell_val_num) {
return api_entry_context<tiledb::api::tiledb_attribute_get_cell_val_num>(
ctx, attr, cell_val_num);
}

int32_t tiledb_attribute_get_cell_size(
CAPI_INTERFACE(
attribute_get_cell_size,
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
uint64_t* cell_size) noexcept {
uint64_t* cell_size) {
return api_entry_context<tiledb::api::tiledb_attribute_get_cell_size>(
ctx, attr, cell_size);
}

int32_t tiledb_attribute_dump(
CAPI_INTERFACE(
attribute_dump,
tiledb_ctx_t* ctx,
const tiledb_attribute_handle_t* attr,
FILE* out) noexcept {
FILE* out) {
return api_entry_context<tiledb::api::tiledb_attribute_dump>(ctx, attr, out);
}

int32_t tiledb_attribute_set_fill_value(
CAPI_INTERFACE(
attribute_set_fill_value,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
const void* value,
uint64_t size) noexcept {
uint64_t size) {
return api_entry_context<tiledb::api::tiledb_attribute_set_fill_value>(
ctx, attr, value, size);
}

int32_t tiledb_attribute_get_fill_value(
CAPI_INTERFACE(
attribute_get_fill_value,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
const void** value,
uint64_t* size) noexcept {
uint64_t* size) {
return api_entry_context<tiledb::api::tiledb_attribute_get_fill_value>(
ctx, attr, value, size);
}

int32_t tiledb_attribute_set_fill_value_nullable(
CAPI_INTERFACE(
attribute_set_fill_value_nullable,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
const void* value,
uint64_t size,
uint8_t valid) noexcept {
uint8_t valid) {
return api_entry_context<
tiledb::api::tiledb_attribute_set_fill_value_nullable>(
ctx, attr, value, size, valid);
}

int32_t tiledb_attribute_get_fill_value_nullable(
CAPI_INTERFACE(
attribute_get_fill_value_nullable,
tiledb_ctx_t* ctx,
tiledb_attribute_handle_t* attr,
const void** value,
uint64_t* size,
uint8_t* valid) noexcept {
uint8_t* valid) {
return api_entry_context<
tiledb::api::tiledb_attribute_get_fill_value_nullable>(
ctx, attr, value, size, valid);
}

capi_return_t tiledb_attribute_set_enumeration_name(
CAPI_INTERFACE(
attribute_set_enumeration_name,
tiledb_ctx_t* ctx,
tiledb_attribute_t* attr,
const char* enumeration_name) noexcept {
const char* enumeration_name) {
return api_entry_context<tiledb::api::tiledb_attribute_set_enumeration_name>(
ctx, attr, enumeration_name);
}

capi_return_t tiledb_attribute_get_enumeration_name(
CAPI_INTERFACE(
attribute_get_enumeration_name,
tiledb_ctx_t* ctx,
tiledb_attribute_t* attr,
tiledb_string_t** name) noexcept {
tiledb_string_t** name) {
return api_entry_context<tiledb::api::tiledb_attribute_get_enumeration_name>(
ctx, attr, name);
}
25 changes: 14 additions & 11 deletions tiledb/api/c_api/buffer/buffer_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,45 +98,48 @@ capi_return_t tiledb_buffer_set_data(
using tiledb::api::api_entry_context;
using tiledb::api::api_entry_void;

capi_return_t tiledb_buffer_alloc(
tiledb_ctx_t* ctx, tiledb_buffer_t** buffer) noexcept {
CAPI_INTERFACE(buffer_alloc, tiledb_ctx_t* ctx, tiledb_buffer_t** buffer) {
return api_entry_context<tiledb::api::tiledb_buffer_alloc>(ctx, buffer);
}

void tiledb_buffer_free(tiledb_buffer_t** buffer) noexcept {
CAPI_INTERFACE_VOID(buffer_free, tiledb_buffer_t** buffer) {
return api_entry_void<tiledb::api::tiledb_buffer_free>(buffer);
}

capi_return_t tiledb_buffer_set_type(
CAPI_INTERFACE(
buffer_set_type,
tiledb_ctx_t* ctx,
tiledb_buffer_t* buffer,
tiledb_datatype_t datatype) noexcept {
tiledb_datatype_t datatype) {
return api_entry_context<tiledb::api::tiledb_buffer_set_type>(
ctx, buffer, datatype);
}

capi_return_t tiledb_buffer_get_type(
CAPI_INTERFACE(
buffer_get_type,
tiledb_ctx_t* ctx,
const tiledb_buffer_t* buffer,
tiledb_datatype_t* datatype) noexcept {
tiledb_datatype_t* datatype) {
return api_entry_context<tiledb::api::tiledb_buffer_get_type>(
ctx, buffer, datatype);
}

capi_return_t tiledb_buffer_get_data(
CAPI_INTERFACE(
buffer_get_data,
tiledb_ctx_t* ctx,
const tiledb_buffer_t* buffer,
void** data,
uint64_t* size) noexcept {
uint64_t* size) {
return api_entry_context<tiledb::api::tiledb_buffer_get_data>(
ctx, buffer, data, size);
}

capi_return_t tiledb_buffer_set_data(
CAPI_INTERFACE(
buffer_set_data,
tiledb_ctx_t* ctx,
tiledb_buffer_t* buffer,
void* data,
uint64_t size) noexcept {
uint64_t size) {
return api_entry_context<tiledb::api::tiledb_buffer_set_data>(
ctx, buffer, data, size);
}
26 changes: 15 additions & 11 deletions tiledb/api/c_api/buffer_list/buffer_list_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,45 +121,49 @@ capi_return_t tiledb_buffer_list_flatten(
using tiledb::api::api_entry_context;
using tiledb::api::api_entry_void;

capi_return_t tiledb_buffer_list_alloc(
tiledb_ctx_t* ctx, tiledb_buffer_list_t** buffer_list) noexcept {
CAPI_INTERFACE(
buffer_list_alloc, tiledb_ctx_t* ctx, tiledb_buffer_list_t** buffer_list) {
return api_entry_context<tiledb::api::tiledb_buffer_list_alloc>(
ctx, buffer_list);
}

void tiledb_buffer_list_free(tiledb_buffer_list_t** buffer_list) noexcept {
CAPI_INTERFACE_VOID(buffer_list_free, tiledb_buffer_list_t** buffer_list) {
return api_entry_void<tiledb::api::tiledb_buffer_list_free>(buffer_list);
}

capi_return_t tiledb_buffer_list_get_num_buffers(
CAPI_INTERFACE(
buffer_list_get_num_buffers,
tiledb_ctx_t* ctx,
const tiledb_buffer_list_t* buffer_list,
uint64_t* num_buffers) noexcept {
uint64_t* num_buffers) {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_num_buffers>(
ctx, buffer_list, num_buffers);
}

capi_return_t tiledb_buffer_list_get_buffer(
CAPI_INTERFACE(
buffer_list_get_buffer,
tiledb_ctx_t* ctx,
const tiledb_buffer_list_t* buffer_list,
uint64_t buffer_idx,
tiledb_buffer_t** buffer) noexcept {
tiledb_buffer_t** buffer) {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_buffer>(
ctx, buffer_list, buffer_idx, buffer);
}

capi_return_t tiledb_buffer_list_get_total_size(
CAPI_INTERFACE(
buffer_list_get_total_size,
tiledb_ctx_t* ctx,
const tiledb_buffer_list_t* buffer_list,
uint64_t* total_size) noexcept {
uint64_t* total_size) {
return api_entry_context<tiledb::api::tiledb_buffer_list_get_total_size>(
ctx, buffer_list, total_size);
}

capi_return_t tiledb_buffer_list_flatten(
CAPI_INTERFACE(
buffer_list_flatten,
tiledb_ctx_t* ctx,
tiledb_buffer_list_t* buffer_list,
tiledb_buffer_t** buffer) noexcept {
tiledb_buffer_t** buffer) {
return api_entry_context<tiledb::api::tiledb_buffer_list_flatten>(
ctx, buffer_list, buffer);
}
8 changes: 4 additions & 4 deletions tiledb/api/c_api/data_order/data_order_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ capi_return_t tiledb_data_order_from_str(

using tiledb::api::api_entry_plain;

capi_return_t tiledb_data_order_to_str(
tiledb_data_order_t data_order, const char** str) noexcept {
CAPI_INTERFACE(
data_order_to_str, tiledb_data_order_t data_order, const char** str) {
return api_entry_plain<tiledb::api::tiledb_data_order_to_str>(
data_order, str);
}

capi_return_t tiledb_data_order_from_str(
const char* str, tiledb_data_order_t* data_order) noexcept {
CAPI_INTERFACE(
data_order_from_str, const char* str, tiledb_data_order_t* data_order) {
return api_entry_plain<tiledb::api::tiledb_data_order_from_str>(
str, data_order);
}
7 changes: 3 additions & 4 deletions tiledb/api/c_api/datatype/datatype_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ uint64_t tiledb_datatype_size(tiledb_datatype_t type) {

using tiledb::api::api_entry_plain;

capi_return_t tiledb_datatype_to_str(
tiledb_datatype_t datatype, const char** str) noexcept {
CAPI_INTERFACE(datatype_to_str, tiledb_datatype_t datatype, const char** str) {
return api_entry_plain<tiledb::api::tiledb_datatype_to_str>(datatype, str);
}

capi_return_t tiledb_datatype_from_str(
const char* str, tiledb_datatype_t* datatype) noexcept {
CAPI_INTERFACE(
datatype_from_str, const char* str, tiledb_datatype_t* datatype) {
return api_entry_plain<tiledb::api::tiledb_datatype_from_str>(str, datatype);
}

Expand Down
Loading

0 comments on commit aede0f1

Please sign in to comment.