Git Product home page Git Product logo

Comments (3)

sumanth-nirmal avatar sumanth-nirmal commented on June 11, 2024

@reicheratwork I think I found the issue, it is not about the sequences, but how the check here

if ((idl_mask(type_spec) & IDL_BOOL) == IDL_BOOL &&
is done to verify if the type is bool

Because of this check, uint64 and int64 are also treated as bools, the generated code for the int64, uint64 looks like below

module msg
{
struct log {
sequence<boolean> bool_values_;
sequence<long long> int64_values_;
squence<unsigned long long> uint64_values_;
};
};
...
template<typename T>
void write(T& streamer, const ::msg::log& instance)
{
  {
  uint32_t se_1 = uint32_t(instance.bool_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  {
    const bool b = instance.bool_values_()[i_1];
    write(streamer, b);
  }
  } //i_1
  }
  {
  uint32_t se_1 = uint32_t(instance.int64_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  {
    const bool b = instance.int64_values_()[i_1];
    write(streamer, b);
  }
  } //i_1
  }
  {
  uint32_t se_1 = uint32_t(instance.uint64_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  {
    const bool b = instance.uint64_values_()[i_1];
    write(streamer, b);
  }
  } //i_1
  }
  (void)streamer;
  (void)instance;
}
...

This is incorrect and the correct write() should be as below

template<typename T>
void write(T& streamer, const ::msg::log& instance)
{
  {
  uint32_t se_1 = uint32_t(instance.bool_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  {
    const bool b = instance.bool_values_()[i_1];
    write(streamer, b);
  }
  } //i_1
  }
  {
  uint32_t se_1 = uint32_t(instance.int64_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  write(streamer, instance.int64_values_()[i_1]);
  } //i_1
  }
  {
  uint32_t se_1 = uint32_t(instance.uint64_values_().size());
  write(streamer, se_1);
  for (uint32_t i_1 = 0; i_1 < se_1; i_1++) {
  write(streamer, instance.uint64_values_()[i_1]);
  } //i_1
  }
  (void)streamer;
  (void)instance;
}

This messes up the serialization/de-serialization when int64/uint64 are involved in te IDL types, we should probably fix the check to something like below

-  if ((idl_mask(type_spec) & IDL_BOOL) == IDL_BOOL &&
+  if ((idl_mask(type_spec)) == IDL_BOOL &&

Does it make sense?

from cyclonedds-cxx.

k0ekk0ek avatar k0ekk0ek commented on June 11, 2024

That'll work just fine, but it's better to use idl_type(type_spec). That'll return a valid enum value or IDL_NULL. It was specifically crafted for this type of check.

from cyclonedds-cxx.

sumanth-nirmal avatar sumanth-nirmal commented on June 11, 2024

@k0ekk0ek Thanks, I fixed it according to your suggestion here #124

from cyclonedds-cxx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.