Skip to content

Commit fe37a29

Browse files
committed
Prepare 0.3.0 release
1 parent 8bc12b5 commit fe37a29

File tree

172 files changed

+16073
-10506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+16073
-10506
lines changed

.gitignore

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1919
# IN THE SOFTWARE.
2020

21-
# Mac OS X internals
22-
.DS_Store
23-
2421
# Files generated by autoconf
2522
aclocal.m4
2623
autom4te.cache/
@@ -49,13 +46,18 @@ Makefile.in
4946
# Files generated by dsymutil
5047
*.dSYM
5148

52-
# Files generated by build process
49+
# Files generated by protobluff
50+
*.pb.c
51+
*.pb.h
52+
53+
# Files generated by the build process
5354
*.la
5455
*.lo
5556
*.a
5657
*.o
5758

5859
# Executables
60+
examples/**/example
5961
src/bin/protoc-gen-protobluff
6062
tests/**/test
6163

@@ -65,7 +67,10 @@ tests/**/*.log
6567
tests/*.log
6668

6769
# Files generated by lcov and genhtml
68-
tools/coverage/coverage.info
69-
tools/coverage/**/
70+
tests/coverage.info
71+
tests/coverage/**/
7072
*.gcno
71-
*.gcda
73+
*.gcda
74+
75+
# Mac OS X internals
76+
.DS_Store

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ before_install:
5858
- ./autogen.sh
5959

6060
# Perform build and tests
61-
script: ./configure --enable-coverage && make && make test
61+
script: ./configure --enable-coverage && make && make test coverage
6262

6363
# If successful, create and push coverage report
6464
after_success:
65-
- cd tools/coverage && make
66-
- coveralls-lcov coverage.info
65+
- coveralls-lcov tests/coverage.info

CHANGELOG

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,54 @@
1+
protobluff-0.3.0 (2015-11-30)
2+
3+
Complete overhaul of the internal structure: an encoder and decoder have
4+
been implemented which now form the core of protobluff, together with the
5+
buffer, descriptor and varint-packing logic. protobluff is turning into a
6+
full-featured multi-purpose library: messages can be streamed using the
7+
encoding and/or decoding functions, fields and messages can be read and
8+
written without decoding/encoding the entire message using the message
9+
and cursor functions (as before).
10+
11+
In addition protobluff has been split into a lite and full runtime. The lite
12+
runtime only contains the core functionality and currently weighs 14kb
13+
(stripped) on x86_64, the full runtime weighs 36kb (stripped). Though not
14+
being the highest priority task on the list, compatibility with embedded
15+
environments is planned, as the groundwork has now been done. Furthermore
16+
the project structure has been revamped and is now completely modular, and
17+
some examples on how to use protobluff for encoding/decoding were added.
18+
19+
Regardless of the addition of a whole bunch of new functions, this release is
20+
mostly compatible with prior versions. Nevertheless, the libtool version has
21+
been updated to 2.0.0 to reflect some breaking changes. See the MIGRATION
22+
file for more information on how to migrate from older versions.
23+
24+
Runtime:
25+
26+
* Complete overhaul of runtime
27+
* Fixed improper encoding and decoding of zig-zag encoded varints
28+
* Added functions for type-specific packing and unpacking of varints
29+
* Added function to efficiently grow buffers
30+
* Added decoder and encoder to stream messages
31+
* Added tests for all new structures
32+
* Added validator as a replacement for pb_message_check()
33+
* Added some usage examples for encoding and decoding messages
34+
* Changed directory structure to reflect new modular design
35+
* Changed macros to inline functions for better type checking
36+
* Renamed binary into buffer and fleshed out the implementation
37+
* Renamed binary stream into stream and refactored implementation
38+
* Merged journaling with binary functionality into journal
39+
* Merged descriptors into single translation unit
40+
* Adapted existing code to work with new internal structure
41+
42+
Generator:
43+
44+
* Fixed accessor generation for nested enumerations
45+
* Added compile-time field, message, enum and enum value deprecations
46+
* Added generators for interfacing with the decoder and encoder
47+
* Changed generated code from macros to inline functions
48+
149
protobluff-0.2.2 (2015-09-05)
250

3-
* Fixed circular message type references in code generator
51+
* Fixed circular message type references in generator
452
* Added chunk allocator implementation
553
* Added tests for chunk allocator
654
* Removed implicit default values for non-optional enums
@@ -30,9 +78,9 @@ protobluff-0.2.0 (2015-08-27)
3078
* Removed double underscore prefixes in function names
3179
* Renamed pb_message_validate() into pb_message_check()
3280

33-
Code generator:
81+
Generator:
3482

35-
* Complete overhaul of code generator
83+
* Complete overhaul of generator
3684
* Fixed order of message descriptor fields in generated code
3785
* Added generators for extensions
3886
* Added generators for enums and enum values

MIGRATION

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
0.2.x => 0.3.0
2+
3+
Binaries
4+
5+
The "binary" which holds the underlying serialized data in wire format was
6+
renamed to be a "buffer". Additionally, the journaling functionality is now
7+
part of a "journal" which itself contains a buffer that is tracked. The
8+
former is necessary for encoding and decoding messages, the later for
9+
performing random access on encoded messages.
10+
11+
< 0.3.0:
12+
13+
pb_binary_t binary = pb_binary_create(...);
14+
pb_binary_destroy(&binary);
15+
16+
= 0.3.0:
17+
18+
pb_buffer_t buffer = pb_buffer_create(...);
19+
pb_buffer_destroy(&buffer);
20+
21+
pb_journal_t journal = pb_journal_create(...);
22+
pb_journal_destroy(&journal);
23+
24+
Validation
25+
26+
Message validation was refactored into a separate "validator" structure,
27+
so that validation can directly take place on a binary. This step was
28+
necessary to make validation available to the lite runtime.
29+
30+
< 0.3.0:
31+
32+
pb_message_t message = pb_message_create(...);
33+
pb_message_check(&message);
34+
35+
= 0.3.0:
36+
37+
pb_validator_t validator = pb_validator_create(...);
38+
pb_validator_check(&validator, &buffer);
39+
40+
0.1.x => 0.2.0
41+
42+
Validation
43+
44+
The function for message validation was renamed into pb_message_check() in
45+
order to remove any ambiguities with pb_message_valid() which checks if the
46+
message is still valid in terms of alignment.
47+
48+
< 0.2.0
49+
50+
pb_message_t message = pb_message_create(...);
51+
pb_message_validate(&message);
52+
53+
= 0.2.0
54+
55+
pb_message_t message = pb_message_create(...);
56+
pb_message_check(&message);

Makefile.am

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ SUBDIRS = include src tests
3131
# Create pkg-config recipe
3232
pkgconfigdir = @libdir@/pkgconfig
3333
pkgconfig_DATA = \
34-
src/lib/libprotobluff.pc
34+
src/protobluff.pc \
35+
src/protobluff-lite.pc
3536

3637
# -----------------------------------------------------------------------------
3738
# Custom build rules
@@ -71,6 +72,19 @@ purge: clean
7172
rm -f stamp-h1
7273
rm -f test-driver
7374

75+
# -----------------------------------------------------------------------------
76+
# Coverage report
77+
# -----------------------------------------------------------------------------
78+
79+
if HAVE_COVERAGE
80+
81+
# Generate and display code coverage report
82+
coverage:
83+
@LCOV@ -q -c --no-external -d @top_builddir@/src -o tests/coverage.info
84+
@GENHTML@ tests/coverage.info -o tests/coverage -c tests/coverage.css
85+
86+
endif # HAVE_COVERAGE
87+
7488
# -----------------------------------------------------------------------------
7589
# Leak check
7690
# -----------------------------------------------------------------------------
@@ -79,9 +93,10 @@ if HAVE_VALGRIND
7993

8094
# Perform leak check using unit tests
8195
memcheck: check
82-
@for t in `find tests -maxdepth 2 -executable -type f`; do \
96+
@for t in `find tests -maxdepth 3 -perm +111 -type f`; do \
8397
@LIBTOOL@ --mode=execute @VALGRIND@ --dsymutil=yes --tool=memcheck \
84-
--track-origins=yes --leak-check=full --show-reachable=yes $$t; \
98+
--track-origins=yes --leak-check=full --show-reachable=yes \
99+
--suppressions=valgrind.supp $$t; \
85100
done
86101

87102
endif # HAVE_VALGRIND

README.md

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Release Status](https://img.shields.io/github/release/squidfunk/protobluff.svg)](https://github.com/squidfunk/protobluff/releases/latest)
66
[![License](https://img.shields.io/github/license/squidfunk/protobluff.svg)](https://github.com/squidfunk/protobluff/blob/master/LICENSE)
77

8-
protobluff is an extremely lightweight Protocol Buffers implementation for C.
8+
protobluff is a modular Protocol Buffers implementation for C.
99

1010
## Theory of Operation
1111

@@ -19,14 +19,14 @@ number of scattered allocations which in turn is not very cache-friendly.
1919

2020
protobluff follows a different approach. It entirely skips the necessary
2121
decoding and encoding steps when reading or writing values from messages,
22-
as it directly operates on the encoded binary. New values can be incrementally
22+
as it directly operates on the encoded data. New values can be incrementally
2323
read or written, memory management is centralized and handled by the underlying
24-
binary. If no alterations that change the size of the underlying binary are
25-
expected, the binary can be used in *zero-copy mode*, omitting all dynamic
24+
journal. If no alterations that change the size of the underlying journal are
25+
expected, the journal can be used in *zero-copy mode*, omitting all dynamic
2626
allocations.
2727

2828
Updates on fixed-sized wire types on little-endian machines can be carried out
29-
in-place using raw-pointers to the underlying binary. These include the native
29+
in-place using raw-pointers to the underlying data. These include the native
3030
Protocol Buffers types `fixed(32|64)`, `sfixed(32|64)`, `float` and `double`
3131
(see the [Protocol Buffers Encoding Guide][] for more information). Strings may
3232
also be accessed through raw-pointers, however writing a string of different
@@ -100,53 +100,65 @@ Here's a usage example taken from the original description of the Google
100100
Protocol Buffers library and adapted to protobluff:
101101

102102
``` c
103-
/* Create an empty binary to assemble a new person message */
104-
pb_binary_t binary = pb_binary_create_empty();
103+
/* Create an empty journal to assemble a new person message */
104+
pb_journal_t journal = pb_journal_create_empty();
105105

106106
/* Create a person message */
107-
pb_message_t person = person_create(&binary);
107+
pb_message_t person = person_create(&journal);
108108

109109
/* Define the values we want to set */
110-
pb_string_t name = pb_string_init("John Doe"),
111-
email = pb_string_init("[email protected]"),
112-
home = pb_string_init("+1-541-754-3010"),
113-
mobile = pb_string_init("+1-541-293-8228");
110+
pb_string_t name = pb_string_init_from_chars("John Doe"),
111+
email = pb_string_init_from_chars("[email protected]"),
112+
home = pb_string_init_from_chars("+1-541-754-3010"),
113+
mobile = pb_string_init_from_chars("+1-541-293-8228");
114114
int32_t id = 1234;
115115

116116
/* Set values on person message and check return codes */
117117
pb_error_t error = PB_ERROR_NONE;
118118
do {
119119
if ((error = person_put_name(&person, &name)) ||
120-
(error = person_put_email(&person, &email)) ||
121-
(error = person_put_id(&person, &id)))
120+
(error = person_put_id(&person, &id)) ||
121+
(error = person_put_email(&person, &email)))
122122
break;
123123

124124
/* Set home number */
125125
pb_message_t phone1 = person_create_phone(&person);
126-
if ((error = person_phonenumber_put_type_home(&phone1)) ||
127-
(error = person_phonenumber_put_number(&phone1, &home)))
128-
break;
129-
130-
/* Set mobile number */
131-
pb_message_t phone2 = person_create_phone(&person);
132-
if ((error = person_phonenumber_put_type_mobile(&phone2)) ||
133-
(error = person_phonenumber_put_number(&phone2, &mobile)))
134-
break;
135-
136-
/* All values were set successfully, the binary is ready to be persisted,
137-
sent or whatever - no marshalling necessary. The raw message data and size
138-
can be directly obtained through the binary */
139-
const uint8_t *data = pb_binary_data(&binary);
140-
const size_t size = pb_binary_size(&binary);
126+
if (!(error = person_phonenumber_put_number(&phone1, &home)) &&
127+
!(error = person_phonenumber_put_type_home(&phone1))) {
128+
129+
/* Set mobile number */
130+
pb_message_t phone2 = person_create_phone(&person);
131+
if (!(error = person_phonenumber_put_number(&phone2, &mobile)) &&
132+
!(error = person_phonenumber_put_type_mobile(&phone2))) {
133+
134+
/* Dump the journal */
135+
pb_journal_dump(&journal);
136+
137+
/* The encoded message can be accessed as follows */
138+
// const uint8_t *data = pb_journal_data(&journal);
139+
// const size_t size = pb_journal_size(&journal);
140+
}
141+
person_phonenumber_destroy(&phone2);
142+
}
143+
person_phonenumber_destroy(&phone1);
141144
} while (0);
142145

146+
/* Print error, if any */
147+
if (error)
148+
fprintf(stderr, "ERROR: %s\n", pb_error_string(error));
149+
143150
/* Cleanup and invalidate */
144151
person_destroy(&person);
145152

146-
/* Free all allocated memory */
147-
pb_binary_destroy(&binary);
153+
/* Free all allocated memory and return */
154+
pb_journal_destroy(&journal);
155+
return error
156+
? EXIT_FAILURE
157+
: EXIT_SUCCESS;
148158
```
149159
160+
See the examples directory for more information.
161+
150162
## Linking
151163
152164
### Manually
@@ -157,8 +169,8 @@ library. Therefore, the following compiler and linker flags must be obtained
157169
and added to your build toolchain:
158170
159171
``` sh
160-
pkg-config --cflags libprotobluff # Add output to compiler flags
161-
pkg-config --libs libprotobluff # Add output to linker flags
172+
pkg-config --cflags protobluff # Add output to compiler flags
173+
pkg-config --libs protobluff # Add output to linker flags
162174
```
163175

164176
### Autotools
@@ -169,7 +181,7 @@ the compiler flags into the variable `protobluff_CFLAGS` and the linker flags
169181
into the variable `protobluff_LDFLAGS`:
170182

171183
``` makefile
172-
PKG_CHECK_MODULES([protobluff], [libprotobluff])
184+
PKG_CHECK_MODULES([protobluff], [protobluff])
173185
```
174186

175187
## Features
@@ -198,9 +210,8 @@ PKG_CHECK_MODULES([protobluff], [libprotobluff])
198210
### Roadmap
199211

200212
1. Oneofs
201-
2. Streaming API
202-
3. Packed fields
203-
4. Services
213+
2. Packed fields
214+
3. Services
204215

205216
## License
206217

0 commit comments

Comments
 (0)