Skip to content

Commit ffd71bc

Browse files
committed
add clear module ABI & API
1 parent ad70ef5 commit ffd71bc

File tree

23 files changed

+313
-128
lines changed

23 files changed

+313
-128
lines changed

crates/bindings-cpp/include/spacetimedb/abi/FFI.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
/**
1010
* @file FFI.h
1111
* @brief SpacetimeDB Foreign Function Interface (FFI) layer for C++ modules
12-
*
12+
*
1313
* This file re-exports the raw ABI functions with additional type aliases
1414
* and convenience functions. Since we now use C# style opaque types that
1515
* are ABI-compatible, no conversion is needed.
16-
*
16+
*
1717
* Organization:
1818
* - Raw C ABI with opaque types is in abi.h
1919
* - This file provides type aliases and convenience functions
20-
*
20+
*
2121
* Key Features:
2222
* - Type-safe opaque types prevent mixing TableId with IndexId etc.
2323
* - Full BSATN integration for all data operations
2424
* - Modern iterator API with proper resource management
2525
* - Comprehensive error handling with Status codes
26-
*
26+
*
2727
* Note: WASI shims for C++ standard library support are provided separately
2828
* in the module library implementation.
2929
*/
@@ -55,6 +55,7 @@ using ::datastore_delete_by_index_scan_range_bsatn;
5555
using ::datastore_delete_by_index_scan_point_bsatn;
5656
using ::datastore_delete_by_btree_scan_bsatn;
5757
using ::datastore_delete_all_by_eq_bsatn;
58+
using ::datastore_clear;
5859
using ::bytes_source_read;
5960
using ::bytes_source_remaining_length;
6061
using ::bytes_sink_write;
@@ -92,11 +93,11 @@ inline int16_t call_reducer(
9293
uint32_t id,
9394
uint64_t sender_0, uint64_t sender_1, uint64_t sender_2, uint64_t sender_3,
9495
uint64_t conn_id_0, uint64_t conn_id_1,
95-
uint64_t timestamp,
96-
BytesSource args,
96+
uint64_t timestamp,
97+
BytesSource args,
9798
BytesSink error) {
9899
return ::__call_reducer__(id, sender_0, sender_1, sender_2, sender_3,
99-
conn_id_0, conn_id_1, timestamp,
100+
conn_id_0, conn_id_1, timestamp,
100101
args, error);
101102
}
102103

@@ -135,4 +136,4 @@ inline void console_log(const uint8_t* message, size_t message_len, LogLevel lev
135136
} // namespace FFI
136137
} // namespace SpacetimeDB
137138

138-
#endif // SPACETIMEDB_FFI_H
139+
#endif // SPACETIMEDB_FFI_H

crates/bindings-cpp/include/spacetimedb/abi/abi.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* @file abi.h
1010
* @brief Raw C ABI interface for SpacetimeDB modules
11-
*
11+
*
1212
* This file contains the raw C-compatible ABI declarations.
1313
* These functions use only C-compatible types and are suitable
1414
* for extern "C" linkage.
@@ -35,6 +35,10 @@
3535
#define STDB_IMPORT_10_4(name) \
3636
__attribute__((import_module("spacetime_10.4"), import_name(#name))) extern
3737

38+
// Clear syscall is in spacetime_10.4
39+
#define STDB_IMPORT_10_5(name) \
40+
__attribute__((import_module("spacetime_10.5"), import_name(#name))) extern
41+
3842
// Import opaque types into global namespace for C compatibility
3943
using SpacetimeDB::Status;
4044
using SpacetimeDB::TableId;
@@ -73,7 +77,7 @@ Status datastore_table_scan_bsatn(TableId table_id, RowIter* out);
7377
STDB_IMPORT(datastore_index_scan_range_bsatn)
7478
Status datastore_index_scan_range_bsatn(
7579
IndexId index_id, const uint8_t* prefix_ptr, size_t prefix_len, ColId prefix_elems,
76-
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
80+
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
7781
RowIter* out);
7882

7983
STDB_IMPORT_10_4(datastore_index_scan_point_bsatn)
@@ -85,7 +89,7 @@ Status datastore_index_scan_point_bsatn(
8589
STDB_IMPORT(datastore_btree_scan_bsatn)
8690
Status datastore_btree_scan_bsatn(
8791
IndexId index_id, const uint8_t* prefix_ptr, size_t prefix_len, ColId prefix_elems,
88-
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
92+
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
8993
RowIter* out);
9094

9195
// ===== Row Iterator Operations =====
@@ -106,7 +110,7 @@ Status datastore_update_bsatn(TableId table_id, IndexId index_id, uint8_t* row_p
106110
STDB_IMPORT(datastore_delete_by_index_scan_range_bsatn)
107111
Status datastore_delete_by_index_scan_range_bsatn(
108112
IndexId index_id, const uint8_t* prefix_ptr, size_t prefix_len, ColId prefix_elems,
109-
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
113+
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
110114
uint32_t* out);
111115

112116
STDB_IMPORT_10_4(datastore_delete_by_index_scan_point_bsatn)
@@ -117,14 +121,17 @@ Status datastore_delete_by_index_scan_point_bsatn(
117121
STDB_IMPORT(datastore_delete_by_btree_scan_bsatn)
118122
Status datastore_delete_by_btree_scan_bsatn(
119123
IndexId index_id, const uint8_t* prefix_ptr, size_t prefix_len, ColId prefix_elems,
120-
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
124+
const uint8_t* rstart_ptr, size_t rstart_len, const uint8_t* rend_ptr, size_t rend_len,
121125
uint32_t* out);
122126

123127
STDB_IMPORT(datastore_delete_all_by_eq_bsatn)
124128
Status datastore_delete_all_by_eq_bsatn(
125129
TableId table_id, const uint8_t* rel_ptr, size_t rel_len,
126130
uint32_t* out);
127131

132+
STDB_IMPORT_10_5(datastore_clear)
133+
Status datastore_clear(TableId table_id, uint64_t* out);
134+
128135
// ===== Bytes Source/Sink Operations =====
129136
STDB_IMPORT(bytes_source_read)
130137
int16_t bytes_source_read(BytesSource source, uint8_t* buffer_ptr, size_t* buffer_len_ptr);
@@ -205,8 +212,8 @@ int16_t __call_reducer__(
205212
uint32_t id,
206213
uint64_t sender_0, uint64_t sender_1, uint64_t sender_2, uint64_t sender_3,
207214
uint64_t conn_id_0, uint64_t conn_id_1,
208-
uint64_t timestamp,
209-
BytesSource args,
215+
uint64_t timestamp,
216+
BytesSource args,
210217
BytesSink error);
211218

212219
// ========================================================================
@@ -223,4 +230,4 @@ int16_t __call_reducer__(
223230

224231
#pragma clang diagnostic pop
225232

226-
#endif // SPACETIMEDB_ABI_H
233+
#endif // SPACETIMEDB_ABI_H

0 commit comments

Comments
 (0)