-
Notifications
You must be signed in to change notification settings - Fork 18
/
MIGRATION
105 lines (67 loc) · 2.96 KB
/
MIGRATION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
0.5.0 => 1.0.0
Messages
Raw pointer access has been removed, because unaligned access of floats
and doubles may cause undefined behavior on some architectures. Now, the
values should be loaded and stored with the get and put accessors.
This makes it necessary to regenerate the bindings and change all accessors
that write values through raw pointers.
< 1.0.0:
float *value = person_raw_weight(&person);
= 1.0.0:
float value;
person_get_weight(&person, &value);
person_put_weight(&person, &value);
0.4.0 => 0.5.0
The bindings have to be regenerated.
0.3.x => 0.4.0
Encoder
In order to handle packed fields, the encoder does now take a fourth
argument, namely the amount of values to be encoded. This is a prerequisite
for the support of packed fields. Now, multiple values can be encoded all
at once, regardless of whether a field is packed or not. This also applies
for messages, which have already been implemented as nested encoders.
This makes it necessary to regenerate the bindings and change all accessors
that write values to repeated fields.
< 0.4.0:
pb_encoder_t person = person_encoder_create(...);
person_encode_phone(&person, &phonenumbers[0]);
person_encode_phone(&person, &phonenumbers[1]);
= 0.4.0:
pb_encoder_t person = person_encoder_create(...);
person_encode_phone(&person, &phonenumbers, 2);
0.2.x => 0.3.0
Binaries
The "binary" which holds the underlying serialized data in wire format was
renamed to be a "buffer". Additionally, the journaling functionality is now
part of a "journal" which itself contains a buffer that is tracked. The
former is necessary for encoding and decoding messages, the later for
performing random access on encoded messages.
< 0.3.0:
pb_binary_t binary = pb_binary_create(...);
pb_binary_destroy(&binary);
= 0.3.0:
pb_buffer_t buffer = pb_buffer_create(...);
pb_buffer_destroy(&buffer);
pb_journal_t journal = pb_journal_create(...);
pb_journal_destroy(&journal);
Validation
Message validation was refactored into a separate "validator" structure,
so that validation can directly take place on a buffer. This step was
necessary to make validation available to the lite runtime.
< 0.3.0:
pb_message_t message = pb_message_create(...);
pb_message_check(&message);
= 0.3.0:
pb_validator_t validator = pb_validator_create(...);
pb_validator_check(&validator, &buffer);
0.1.x => 0.2.0
Validation
The function for message validation was renamed into pb_message_check() in
order to remove any ambiguities with pb_message_valid() which checks if the
message is still valid in terms of alignment.
< 0.2.0
pb_message_t message = pb_message_create(...);
pb_message_validate(&message);
= 0.2.0
pb_message_t message = pb_message_create(...);
pb_message_check(&message);