From 68d809c71488e059e777809d3b12e821c796b769 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sun, 13 Oct 2024 17:36:32 +0200 Subject: [PATCH] prefix enum names for better C consumption --- crates/servicepoint_binding_c/cbindgen.toml | 3 +++ .../examples/lang_c/include/servicepoint.h | 10 +++++----- .../servicepoint_binding_c/examples/lang_c/src/main.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/servicepoint_binding_c/cbindgen.toml b/crates/servicepoint_binding_c/cbindgen.toml index 1114264..cbf9e14 100644 --- a/crates/servicepoint_binding_c/cbindgen.toml +++ b/crates/servicepoint_binding_c/cbindgen.toml @@ -31,3 +31,6 @@ all_features = true [export] include = [] exclude = [] + +[enum] +rename_variants = "QualifiedScreamingSnakeCase" diff --git a/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h b/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h index f431793..453c6b1 100644 --- a/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h +++ b/crates/servicepoint_binding_c/examples/lang_c/include/servicepoint.h @@ -49,23 +49,23 @@ enum SPCompressionCode /** * no compression */ - Uncompressed = 0, + SP_COMPRESSION_CODE_UNCOMPRESSED = 0, /** * compress using flate2 with zlib header */ - Zlib = 26490, + SP_COMPRESSION_CODE_ZLIB = 26490, /** * compress using bzip2 */ - Bzip2 = 25210, + SP_COMPRESSION_CODE_BZIP2 = 25210, /** * compress using lzma */ - Lzma = 27770, + SP_COMPRESSION_CODE_LZMA = 27770, /** * compress using Zstandard */ - Zstd = 31347, + SP_COMPRESSION_CODE_ZSTD = 31347, }; #ifndef __cplusplus typedef uint16_t SPCompressionCode; diff --git a/crates/servicepoint_binding_c/examples/lang_c/src/main.c b/crates/servicepoint_binding_c/examples/lang_c/src/main.c index 5054286..6c23ab0 100644 --- a/crates/servicepoint_binding_c/examples/lang_c/src/main.c +++ b/crates/servicepoint_binding_c/examples/lang_c/src/main.c @@ -9,7 +9,7 @@ int main(void) { SPPixelGrid *pixels = sp_pixel_grid_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT); sp_pixel_grid_fill(pixels, true); - SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed); + SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, SP_COMPRESSION_CODE_UNCOMPRESSED); while (sp_connection_send_command(connection, sp_command_clone(command))); sp_command_free(command);