Hello,

I wanted to test the performance of serializing a single scaler type of 
message. For example:
@0xf123cfa3565bb5a6;

struct TestBool {
 value @0 :Bool;
}
struct TestInt8 {
 value @0 :Int8;
}

When I was testing scaler types of Int8 and UInt8, by calling  
auto r2 = message.getRoot<TestInt8>();
cout << r2.getValue() << "\nsize: " << size << endl;

returned nothing for the value:

size: 16


However, when I set the field to Int16, the correct value is returned.

127

size: 16

The complete code is pasted below:
    capnp::MallocMessageBuilder message;
    TestInt8::Builder r1 = message.getRoot<TestInt8>();
    r1.setValue(127);
    auto serialized = message.getSegmentsForOutput();
    // auto serialized = capnp::messageToFlatArray(message);

    //capnp::SegmentArrayMessageReader reader(serialized);
    size_t size = 0;
    for (auto segment : serialized) {
      size += segment.asBytes().size();
    }
    auto r2 = message.getRoot<TestInt8>();
    cout << r2.getValue() << "\nsize: " << size << endl;

Is there anything wrong? It only happened for Int8 and UInt8 cases.
Also, is the size I am getting the correct serialized size?

Best,
Shuo

-- 
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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to