diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-10-29 16:32:47 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-10-29 16:32:47 +0200 |
commit | 287207841db5df93cf7ff9c71a5f1548deb26b09 (patch) | |
tree | 61d3a8e057ecefb3e19c0c4474542d8dad6bb0e7 | |
parent | 0074deba9a2ff99c877abe1293f72a9ed76f46c1 (diff) |
Remove the NANOPB_INTERNALS functions from public API.
These have been deprecated since nanopb-0.1.6 (some since 0.1.3).
Equivalent functions with better interface are available in the API.
Update issue 91
Status: FixedInGit
-rw-r--r-- | docs/reference.rst | 4 | ||||
-rw-r--r-- | pb_decode.c | 9 | ||||
-rw-r--r-- | pb_decode.h | 19 | ||||
-rw-r--r-- | pb_encode.c | 8 | ||||
-rw-r--r-- | pb_encode.h | 18 | ||||
-rw-r--r-- | tests/SConstruct | 2 | ||||
-rw-r--r-- | tests/decode_unittests/SConscript | 2 | ||||
-rw-r--r-- | tests/decode_unittests/decode_unittests.c | 4 | ||||
-rw-r--r-- | tests/encode_unittests/SConscript | 2 | ||||
-rw-r--r-- | tests/encode_unittests/encode_unittests.c | 4 |
10 files changed, 27 insertions, 45 deletions
diff --git a/docs/reference.rst b/docs/reference.rst index 51556d35..32283734 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -25,7 +25,9 @@ __BIG_ENDIAN__ Set this if your platform stores integers and systems (different layout for ints and floats) are currently not supported. NANOPB_INTERNALS Set this to expose the field encoder functions - that are hidden since nanopb-0.1.3. + that are hidden since nanopb-0.1.3. Starting + with nanopb-0.2.4, this flag does nothing. Use + the newer functions that have better interface. PB_MAX_REQUIRED_FIELDS Maximum number of required fields to check for presence. Default value is 64. Increases stack usage 1 byte per every 8 fields. Compiler diff --git a/pb_decode.c b/pb_decode.c index f012e931..90fa18d2 100644 --- a/pb_decode.c +++ b/pb_decode.c @@ -47,6 +47,15 @@ static bool checkreturn default_extension_decoder(pb_istream_t *stream, pb_exten static bool checkreturn decode_extension(pb_istream_t *stream, uint32_t tag, pb_wire_type_t wire_type, pb_field_iterator_t *iter); static bool checkreturn find_extension_field(pb_field_iterator_t *iter); static void pb_message_set_to_defaults(const pb_field_t fields[], void *dest_struct); +static bool pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest); +static bool checkreturn pb_skip_varint(pb_istream_t *stream); +static bool checkreturn pb_skip_string(pb_istream_t *stream); /* --- Function pointers to field decoders --- * Order in the array must match pb_action_t LTYPE numbering. diff --git a/pb_decode.h b/pb_decode.h index 98a64cc0..f71b5f1b 100644 --- a/pb_decode.h +++ b/pb_decode.h @@ -131,25 +131,6 @@ bool pb_decode_fixed64(pb_istream_t *stream, void *dest); bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream); void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream); - -/******************************* - * Internal / legacy functions * - *******************************/ - -#ifdef NANOPB_INTERNALS -bool pb_dec_varint(pb_istream_t *stream, const pb_field_t *field, void *dest); -bool pb_dec_svarint(pb_istream_t *stream, const pb_field_t *field, void *dest); -bool pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest); -bool pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest); - -bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest); -bool pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest); -bool pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest); - -bool pb_skip_varint(pb_istream_t *stream); -bool pb_skip_string(pb_istream_t *stream); -#endif - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/pb_encode.c b/pb_encode.c index 90236524..ebf20de5 100644 --- a/pb_encode.c +++ b/pb_encode.c @@ -27,7 +27,13 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie static bool checkreturn encode_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); static bool checkreturn default_extension_encoder(pb_ostream_t *stream, const pb_extension_t *extension); static bool checkreturn encode_extension_field(pb_ostream_t *stream, const pb_field_t *field, const void *pData); - +static bool checkreturn pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src); +static bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src); /* --- Function pointers to field encoders --- * Order in the array must match pb_action_t LTYPE numbering. diff --git a/pb_encode.h b/pb_encode.h index 3009820b..900994aa 100644 --- a/pb_encode.h +++ b/pb_encode.h @@ -143,24 +143,6 @@ bool pb_encode_fixed64(pb_ostream_t *stream, const void *value); */ bool pb_encode_submessage(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct); - -/******************************* - * Internal / legacy functions * - *******************************/ - -#ifdef NANOPB_INTERNALS -bool pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src); -bool pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src); -bool pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src); -bool pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src); -bool pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src); -bool pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src); -#endif - -/* This function is not recommended for new programs. Use pb_encode_submessage() - * instead, it has the same functionality with a less confusing interface. */ -bool pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void *src); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/tests/SConstruct b/tests/SConstruct index 3f4d7702..100fb544 100644 --- a/tests/SConstruct +++ b/tests/SConstruct @@ -78,6 +78,8 @@ if 'gcc' in env['CC']: # More strict checks on the nanopb core env.Append(CORECFLAGS = '-Wextra -Wcast-qual -Wlogical-op -Wconversion') + env.Append(CORECFLAGS = ' -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls') + env.Append(CORECFLAGS = ' -Wstack-protector') elif 'clang' in env['CC']: # CLang env.Append(CFLAGS = '-ansi -g -O0 -Wall -Werror') diff --git a/tests/decode_unittests/SConscript b/tests/decode_unittests/SConscript index 5e0f8407..9a639f7b 100644 --- a/tests/decode_unittests/SConscript +++ b/tests/decode_unittests/SConscript @@ -1,4 +1,4 @@ Import('env') -p = env.Program(["decode_unittests.c", "#common/unittestproto.pb.c", "#common/pb_decode.o"]) +p = env.Program(["decode_unittests.c", "#common/unittestproto.pb.c"]) env.RunTest(p) diff --git a/tests/decode_unittests/decode_unittests.c b/tests/decode_unittests/decode_unittests.c index 9c447a57..1be01913 100644 --- a/tests/decode_unittests/decode_unittests.c +++ b/tests/decode_unittests/decode_unittests.c @@ -1,8 +1,8 @@ -#define NANOPB_INTERNALS +/* This includes the whole .c file to get access to static functions. */ +#include "pb_decode.c" #include <stdio.h> #include <string.h> -#include "pb_decode.h" #include "unittests.h" #include "unittestproto.pb.h" diff --git a/tests/encode_unittests/SConscript b/tests/encode_unittests/SConscript index 6a5ffcff..7509ec03 100644 --- a/tests/encode_unittests/SConscript +++ b/tests/encode_unittests/SConscript @@ -1,5 +1,5 @@ # Build and run the stand-alone unit tests for the nanopb encoder part. Import('env') -p = env.Program(["encode_unittests.c", "#common/unittestproto.pb.c", "#common/pb_encode.o"]) +p = env.Program(["encode_unittests.c", "#common/unittestproto.pb.c"]) env.RunTest(p) diff --git a/tests/encode_unittests/encode_unittests.c b/tests/encode_unittests/encode_unittests.c index fd9a730c..edbc10a9 100644 --- a/tests/encode_unittests/encode_unittests.c +++ b/tests/encode_unittests/encode_unittests.c @@ -1,8 +1,8 @@ -#define NANOPB_INTERNALS +/* This includes the whole .c file to get access to static functions. */ +#include "pb_encode.c" #include <stdio.h> #include <string.h> -#include "pb_encode.h" #include "unittests.h" #include "unittestproto.pb.h" |