Discussion:
[capnproto] Changing struct name with id changes generated c++
n***@8thwall.com
2018-02-21 18:39:06 UTC
Permalink
Per capnp "evolving your schema" we tried changing the name of a struct but
keeping its id the same e.g. changing this:

struct MyMessageList {
mList @0: List(MyMessage);
}

struct MyMessage {
field0 @0: Int32;
}

to this:

struct MyMessageList {
mList @0: List(DeprectedMyMessage);
}

struct DeprectedMyMessage @0xd4201303ceef0b19 {
field0 @0: Int32;
}


We found that the generated header files were the same (modulo the name
change), but that the data section in the c++ files had changed values,
which was worrisome. For example:

static const ::capnp::_::AlignedData<58> b_b23f9d28332a82cf = {
| static const ::capnp::_::AlignedData<59>
b_b23f9d28332a82cf = {
static const ::capnp::_::AlignedData<58> b_b23f9d28332a82cf = {
| static const ::capnp::_::AlignedData<59>
b_b23f9d28332a82cf = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
{ 0, 0, 0, 0, 5, 0, 6, 0,
207, 130, 42, 51, 40, 157, 63, 178,
207, 130, 42, 51, 40, 157, 63, 178,
50, 0, 0, 0, 2, 0, 0, 0,
| 60, 0, 0, 0, 2, 0, 0, 0,
171, 205, 79, 88, 213, 104, 54, 210,
171, 205, 79, 88, 213, 104, 54, 210,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
21, 0, 0, 0, 50, 2, 0, 0,
| 21, 0, 0, 0, 130, 2, 0, 0,
53, 0, 0, 0, 7, 0, 0, 0,
| 57, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
49, 0, 0, 0, 175, 0, 0, 0,
| 53, 0, 0, 0, 175, 0, 0, 0,

Is it expected that the data section would change in this way? Does it
affect the serialization / deserialization in a safe or unsafe way? What is
the data section encoding anyway?
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Ian Denhardt
2018-02-21 20:19:00 UTC
Permalink
Post by n***@8thwall.com
Per capnp "evolving your schema" we tried changing the name of a struct
struct MyMessageList {
}
struct MyMessage {
}
struct MyMessageList {
}
}
We found that the generated header files were the same (modulo the name
change), but that the data section in the c++ files had changed values,
...
IIRC, the generated code embeds the (serialized) schema, which can
be used for things like encoding to JSON, or the reflection API. The
change you've made shouldn't affect the (binary) wire format at all.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
n***@8thwall.com
2018-02-21 22:01:41 UTC
Permalink
Great, thanks!
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Kenton Varda
2018-02-22 04:44:34 UTC
Permalink
Ian is correct: These numbers are a Cap'n Proto encoding of your schema
file, which includes names, so they will always change when you modify the
file. But, that doesn't mean there's any incompatibility.

-Kenton
Post by n***@8thwall.com
Per capnp "evolving your schema" we tried changing the name of a struct
struct MyMessageList {
}
struct MyMessage {
}
struct MyMessageList {
}
}
We found that the generated header files were the same (modulo the name
change), but that the data section in the c++ files had changed values,
static const ::capnp::_::AlignedData<58> b_b23f9d28332a82cf = {
| static const ::capnp::_::AlignedData<59>
b_b23f9d28332a82cf = {
static const ::capnp::_::AlignedData<58> b_b23f9d28332a82cf = {
| static const ::capnp::_::AlignedData<59>
b_b23f9d28332a82cf = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
{ 0, 0, 0, 0, 5, 0, 6, 0,
207, 130, 42, 51, 40, 157, 63, 178,
207, 130, 42, 51, 40, 157, 63, 178,
50, 0, 0, 0, 2, 0, 0, 0,
| 60, 0, 0, 0, 2, 0, 0, 0,
171, 205, 79, 88, 213, 104, 54, 210,
171, 205, 79, 88, 213, 104, 54, 210,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
21, 0, 0, 0, 50, 2, 0, 0,
| 21, 0, 0, 0, 130, 2, 0, 0,
53, 0, 0, 0, 7, 0, 0, 0,
| 57, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
49, 0, 0, 0, 175, 0, 0, 0,
| 53, 0, 0, 0, 175, 0, 0, 0,
Is it expected that the data section would change in this way? Does it
affect the serialization / deserialization in a safe or unsafe way? What is
the data section encoding anyway?
--
You received this message because you are subscribed to the Google Groups
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/capnproto.
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
Loading...