Update RocksDb header file and automate regeneration of wrapper.

This commit is contained in:
web3-developer 2024-06-21 12:08:16 +08:00
parent f5dcb34ae8
commit 45f7a9266f
No known key found for this signature in database
GPG Key ID: 496A1BB40CE64F40
7 changed files with 3238 additions and 3107 deletions

File diff suppressed because it is too large Load Diff

View File

@ -630,6 +630,9 @@ extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* rocksdb_create_snapshot(
extern ROCKSDB_LIBRARY_API void rocksdb_release_snapshot(
rocksdb_t* db, const rocksdb_snapshot_t* snapshot);
extern ROCKSDB_LIBRARY_API uint64_t
rocksdb_snapshot_get_sequence_number(const rocksdb_snapshot_t* snapshot);
/* Returns NULL if property name is unknown.
Else returns a pointer to a malloc()-ed null-terminated value. */
extern ROCKSDB_LIBRARY_API char* rocksdb_property_value(rocksdb_t* db,
@ -713,8 +716,8 @@ extern ROCKSDB_LIBRARY_API void rocksdb_flush_wal(rocksdb_t* db,
extern ROCKSDB_LIBRARY_API void rocksdb_disable_file_deletions(rocksdb_t* db,
char** errptr);
extern ROCKSDB_LIBRARY_API void rocksdb_enable_file_deletions(
rocksdb_t* db, unsigned char force, char** errptr);
extern ROCKSDB_LIBRARY_API void rocksdb_enable_file_deletions(rocksdb_t* db,
char** errptr);
/* Management operations */
@ -1174,10 +1177,16 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_env(rocksdb_options_t*,
rocksdb_env_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log(rocksdb_options_t*,
rocksdb_logger_t*);
extern ROCKSDB_LIBRARY_API rocksdb_logger_t* rocksdb_options_get_info_log(
rocksdb_options_t* opt);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log_level(
rocksdb_options_t*, int);
extern ROCKSDB_LIBRARY_API int rocksdb_options_get_info_log_level(
rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API rocksdb_logger_t*
rocksdb_logger_create_stderr_logger(int log_level, const char* prefix);
extern ROCKSDB_LIBRARY_API void rocksdb_logger_destroy(
rocksdb_logger_t* logger);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_write_buffer_size(
rocksdb_options_t*, size_t);
extern ROCKSDB_LIBRARY_API size_t
@ -1283,6 +1292,9 @@ rocksdb_options_set_max_bytes_for_level_multiplier_additional(
rocksdb_options_t*, int* level_values, size_t num_levels);
extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_statistics(
rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_ttl(rocksdb_options_t*,
uint64_t);
extern ROCKSDB_LIBRARY_API uint64_t rocksdb_options_get_ttl(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds(
rocksdb_options_t*, uint64_t);
extern ROCKSDB_LIBRARY_API uint64_t
@ -1518,10 +1530,6 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_advise_random_on_open(
rocksdb_options_t*, unsigned char);
extern ROCKSDB_LIBRARY_API unsigned char
rocksdb_options_get_advise_random_on_open(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void
rocksdb_options_set_access_hint_on_compaction_start(rocksdb_options_t*, int);
extern ROCKSDB_LIBRARY_API int
rocksdb_options_get_access_hint_on_compaction_start(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_adaptive_mutex(
rocksdb_options_t*, unsigned char);
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_use_adaptive_mutex(
@ -1703,6 +1711,10 @@ extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t*
rocksdb_ratelimiter_create_auto_tuned(int64_t rate_bytes_per_sec,
int64_t refill_period_us,
int32_t fairness);
extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t*
rocksdb_ratelimiter_create_with_mode(int64_t rate_bytes_per_sec,
int64_t refill_period_us, int32_t fairness,
int mode, bool auto_tuned);
extern ROCKSDB_LIBRARY_API void rocksdb_ratelimiter_destroy(
rocksdb_ratelimiter_t*);
@ -3039,4 +3051,4 @@ rocksdb_wait_for_compact_options_get_timeout(
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif

3142
rocksdb/lib/rocksdb_gen.nim Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Nim-RocksDB
# Copyright 2018-2024 Status Research & Development GmbH
# Copyright 2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Nim-RocksDB
# Copyright 2018-2024 Status Research & Development GmbH
# Copyright 2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Nim-RocksDB
# Copyright 2018-2024 Status Research & Development GmbH
# Copyright 2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)

73
scripts/generate_wrapper.sh Executable file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Nim-RocksDB
# Copyright 2024 Status Research & Development GmbH
# Licensed under either of
#
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
#
# at your option. This file may not be copied, modified, or distributed except according to those terms.
set -e
cd "$(dirname "${BASH_SOURCE[0]}")"/..
VENDOR_HEADER_FILE="vendor/rocksdb/include/rocksdb/c.h"
OUTPUT_HEADER_FILE="rocksdb/lib/rocksdb.h"
C2NIM_GENERATED_WRAPPER="rocksdb/lib/rocksdb_gen.nim"
# copy and rename vendor c.h to rocksdb.h
cp ${VENDOR_HEADER_FILE} ${OUTPUT_HEADER_FILE}
# update rocksdb.h file with c2nim settings required to generate nim wrapper
sed -i ':a;N;$!ba;s/#ifdef _WIN32\
#ifdef ROCKSDB_DLL\
#ifdef ROCKSDB_LIBRARY_EXPORTS\
#define ROCKSDB_LIBRARY_API __declspec(dllexport)\
#else\
#define ROCKSDB_LIBRARY_API __declspec(dllimport)\
#endif\
#else\
#define ROCKSDB_LIBRARY_API\
#endif\
#else\
#define ROCKSDB_LIBRARY_API\
#endif/#ifdef C2NIM\
# def ROCKSDB_LIBRARY_API\
# dynlib librocksdb\
# cdecl\
# if defined(windows)\
# define librocksdb "librocksdb.dll"\
# elif defined(macosx)\
# define librocksdb "librocksdb.dylib"\
# else\
# define librocksdb "librocksdb.so"\
# endif\
# mangle uint32_t uint32\
# mangle uint16_t uint16\
# mangle uint8_t uint8\
# mangle uint64_t uint64\
# mangle int32_t int32\
# mangle int16_t int16\
# mangle int8_t int8\
# mangle int64_t int64\
# mangle cuchar uint8\
#else\
# ifdef _WIN32\
# ifdef ROCKSDB_DLL\
# ifdef ROCKSDB_LIBRARY_EXPORTS\
# define ROCKSDB_LIBRARY_API __declspec(dllexport)\
# else\
# define ROCKSDB_LIBRARY_API __declspec(dllimport)\
# endif\
# else\
# define ROCKSDB_LIBRARY_API\
# endif\
# else\
# define ROCKSDB_LIBRARY_API\
# endif\
#endif/g' ${OUTPUT_HEADER_FILE}
# generate nim wrapper
c2nim ${OUTPUT_HEADER_FILE} --out:"${C2NIM_GENERATED_WRAPPER}"