cyclors 0.4.0

Low-level API for the native CycloneDDS bindings (libddsc-sys).
Documentation
// Copyright(c) 2021 to 2022 ZettaScale Technology and others
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
// v. 1.0 which is available at
// http://www.eclipse.org/org/documents/edl-v10.php.
//
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

#if defined(__IDLC__)

@bit_bound(10)
enum e { E1, E2, E3 };

@nested @final
union u switch (short) {
case 1:
   e u1;
default:
   long ud;
};

@topic @final
struct test_struct_keys {
  u f1;
  @key char f2;
  u f3;
  @key char f4[2];
};

#else

#include "dds/dds.h"
#include "test_struct_keys.h"
#include "common.h"

const dds_topic_descriptor_t *desc = &test_struct_keys_desc;

void init_sample (void *s)
{
  test_struct_keys *s1 = (test_struct_keys *) s;
  s1->f1._d = 1;
  s1->f1._u.u1 = E2;
  s1->f2 = 'a';
  s1->f3._d = 1;
  s1->f3._u.u1 = E3;
  s1->f4[0] = 'b';
  s1->f4[1] = 'c';
}

int cmp_sample (const void *sa, const void *sb)
{
  test_struct_keys *a = (test_struct_keys *) sa;
  test_struct_keys *b = (test_struct_keys *) sb;
  CMP(a, b, f1._d, 1);
  CMP(a, b, f1._u.u1, E2);
  CMP(a, b, f2, 'a');
  CMP(a, b, f3._d, 1);
  CMP(a, b, f3._u.u1, E3);
  CMP(a, b, f4[0], 'b');
  CMP(a, b, f4[1], 'c');
  return 0;
}

int cmp_key (const void *sa, const void *sb)
{
  test_struct_keys *a = (test_struct_keys *) sa;
  test_struct_keys *b = (test_struct_keys *) sb;
  CMP(a, b, f2, 'a');
  CMP(a, b, f4[0], 'b');
  CMP(a, b, f4[1], 'c');
  return 0;
}

#endif