Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename rosidl_generator_c namespace to rosidl_runtime_c #150

Merged
merged 1 commit into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/TypeSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#ifndef RMW_CYCLONEDDS_CPP__TYPESUPPORT_HPP_
#define RMW_CYCLONEDDS_CPP__TYPESUPPORT_HPP_

#include <rosidl_generator_c/string.h>
#include <rosidl_generator_c/string_functions.h>
#include <rosidl_generator_c/u16string_functions.h>
#include <rosidl_runtime_c/string.h>
#include <rosidl_runtime_c/string_functions.h>
#include <rosidl_runtime_c/u16string_functions.h>

#include <cassert>
#include <string>
Expand Down Expand Up @@ -53,15 +53,15 @@ struct StringHelper;
template<>
struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
{
using type = rosidl_generator_c__String;
using type = rosidl_runtime_c__String;

static std::string convert_to_std_string(void * data)
{
auto c_string = static_cast<rosidl_generator_c__String *>(data);
auto c_string = static_cast<rosidl_runtime_c__String *>(data);
if (!c_string) {
RCUTILS_LOG_ERROR_NAMED(
"rmw_cyclonedds_cpp",
"Failed to cast data as rosidl_generator_c__String");
"Failed to cast data as rosidl_runtime_c__String");
return "";
}
if (!c_string->data) {
Expand All @@ -73,7 +73,7 @@ struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
return std::string(c_string->data);
}

static std::string convert_to_std_string(rosidl_generator_c__String & data)
static std::string convert_to_std_string(rosidl_runtime_c__String & data)
{
return std::string(data.data);
}
Expand All @@ -82,8 +82,8 @@ struct StringHelper<rosidl_typesupport_introspection_c__MessageMembers>
{
std::string str;
deser >> str;
rosidl_generator_c__String * c_str = static_cast<rosidl_generator_c__String *>(field);
rosidl_generator_c__String__assign(c_str, str.c_str());
rosidl_runtime_c__String * c_str = static_cast<rosidl_runtime_c__String *>(field);
rosidl_runtime_c__String__assign(c_str, str.c_str());
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "rosidl_typesupport_introspection_c/message_introspection.h"
#include "rosidl_typesupport_introspection_c/service_introspection.h"

#include "rosidl_generator_c/primitives_sequence_functions.h"
#include "rosidl_generator_c/u16string_functions.h"
#include "rosidl_runtime_c/primitives_sequence_functions.h"
#include "rosidl_runtime_c/u16string_functions.h"

#include "serdes.hpp"
#include "u16string.hpp"
Expand All @@ -56,19 +56,19 @@ SPECIALIZE_GENERIC_C_SEQUENCE(uint32, uint32_t)
SPECIALIZE_GENERIC_C_SEQUENCE(int64, int64_t)
SPECIALIZE_GENERIC_C_SEQUENCE(uint64, uint64_t)

typedef struct rosidl_generator_c__void__Sequence
typedef struct rosidl_runtime_c__void__Sequence
{
void * data;
/// The number of valid items in data
size_t size;
/// The number of allocated items in data
size_t capacity;
} rosidl_generator_c__void__Sequence;
} rosidl_runtime_c__void__Sequence;

inline
bool
rosidl_generator_c__void__Sequence__init(
rosidl_generator_c__void__Sequence * sequence, size_t size, size_t member_size)
rosidl_runtime_c__void__Sequence__init(
rosidl_runtime_c__void__Sequence * sequence, size_t size, size_t member_size)
{
if (!sequence) {
return false;
Expand All @@ -88,7 +88,7 @@ rosidl_generator_c__void__Sequence__init(

inline
void
rosidl_generator_c__void__Sequence__fini(rosidl_generator_c__void__Sequence * sequence)
rosidl_runtime_c__void__Sequence__fini(rosidl_runtime_c__void__Sequence * sequence)
{
if (!sequence) {
return;
Expand Down Expand Up @@ -182,7 +182,7 @@ static size_t calculateMaxAlign(const MembersType * members)
if (std::is_same<MembersType,
rosidl_typesupport_introspection_c__MessageMembers>::value)
{
alignment = alignof(rosidl_generator_c__String);
alignment = alignof(rosidl_runtime_c__String);
} else {
alignment = alignof(std::string);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ size_t get_array_size_and_assign_field(
void * & subros_message,
size_t, size_t)
{
auto tmpsequence = static_cast<rosidl_generator_c__void__Sequence *>(field);
auto tmpsequence = static_cast<rosidl_runtime_c__void__Sequence *>(field);
if (member->is_upper_bound_ && tmpsequence->size > member->array_size_) {
throw std::runtime_error("vector overcomes the maximum length");
}
Expand Down Expand Up @@ -353,34 +353,34 @@ inline void deserialize_field<std::string>(
CStringHelper::assign(deser, field, call_new);
} else {
if (member->array_size_ && !member->is_upper_bound_) {
auto deser_field = static_cast<rosidl_generator_c__String *>(field);
auto deser_field = static_cast<rosidl_runtime_c__String *>(field);
// tmpstring is defined here and not below to avoid
// memory allocation in every iteration of the for loop
std::string tmpstring;
for (size_t i = 0; i < member->array_size_; ++i) {
deser.deserialize(tmpstring);
if (!rosidl_generator_c__String__assign(&deser_field[i], tmpstring.c_str())) {
throw std::runtime_error("unable to assign rosidl_generator_c__String");
if (!rosidl_runtime_c__String__assign(&deser_field[i], tmpstring.c_str())) {
throw std::runtime_error("unable to assign rosidl_runtime_c__String");
}
}
} else {
std::vector<std::string> cpp_string_vector;
deser >> cpp_string_vector;

auto & string_array_field = *reinterpret_cast<rosidl_generator_c__String__Sequence *>(field);
auto & string_array_field = *reinterpret_cast<rosidl_runtime_c__String__Sequence *>(field);
if (
!rosidl_generator_c__String__Sequence__init(
!rosidl_runtime_c__String__Sequence__init(
&string_array_field, cpp_string_vector.size()))
{
throw std::runtime_error("unable to initialize rosidl_generator_c__String array");
throw std::runtime_error("unable to initialize rosidl_runtime_c__String array");
}

for (size_t i = 0; i < cpp_string_vector.size(); ++i) {
if (
!rosidl_generator_c__String__assign(
!rosidl_runtime_c__String__assign(
&string_array_field.data[i], cpp_string_vector[i].c_str()))
{
throw std::runtime_error("unable to assign rosidl_generator_c__String");
throw std::runtime_error("unable to assign rosidl_runtime_c__String");
}
}
}
Expand All @@ -399,19 +399,19 @@ inline void deserialize_field<std::wstring>(
if (!member->is_array_) {
deser >> wstr;
wstring_to_u16string(
wstr, *static_cast<rosidl_generator_c__U16String *>(field));
wstr, *static_cast<rosidl_runtime_c__U16String *>(field));
} else if (member->array_size_ && !member->is_upper_bound_) {
auto array = static_cast<rosidl_generator_c__U16String *>(field);
auto array = static_cast<rosidl_runtime_c__U16String *>(field);
for (size_t i = 0; i < member->array_size_; ++i) {
deser >> wstr;
wstring_to_u16string(wstr, array[i]);
}
} else {
uint32_t size;
deser >> size;
auto sequence = static_cast<rosidl_generator_c__U16String__Sequence *>(field);
if (!rosidl_generator_c__U16String__Sequence__init(sequence, size)) {
throw std::runtime_error("unable to initialize rosidl_generator_c__U16String sequence");
auto sequence = static_cast<rosidl_runtime_c__U16String__Sequence *>(field);
if (!rosidl_runtime_c__U16String__Sequence__init(sequence, size)) {
throw std::runtime_error("unable to initialize rosidl_runtime_c__U16String sequence");
}
for (size_t i = 0; i < sequence->size; ++i) {
deser >> wstr;
Expand Down Expand Up @@ -452,8 +452,8 @@ inline size_t get_submessage_array_deserialize(
{
(void)member;
uint32_t vsize = deser.deserialize_len(1);
auto tmparray = static_cast<rosidl_generator_c__void__Sequence *>(field);
rosidl_generator_c__void__Sequence__init(tmparray, vsize, sub_members_size);
auto tmparray = static_cast<rosidl_runtime_c__void__Sequence *>(field);
rosidl_runtime_c__void__Sequence__init(tmparray, vsize, sub_members_size);
subros_message = reinterpret_cast<void *>(tmparray->data);
return vsize;
}
Expand Down
6 changes: 3 additions & 3 deletions rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
template<> \
struct GenericCSequence<C_TYPE> \
{ \
using type = rosidl_generator_c__ ## C_NAME ## __Sequence; \
using type = rosidl_runtime_c__ ## C_NAME ## __Sequence; \
\
static void fini(type * array) { \
rosidl_generator_c__ ## C_NAME ## __Sequence__fini(array); \
rosidl_runtime_c__ ## C_NAME ## __Sequence__fini(array); \
} \
\
static bool init(type * array, size_t size) { \
return rosidl_generator_c__ ## C_NAME ## __Sequence__init(array, size); \
return rosidl_runtime_c__ ## C_NAME ## __Sequence__init(array, size); \
} \
};

Expand Down
6 changes: 3 additions & 3 deletions rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/u16string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
#define RMW_CYCLONEDDS_CPP__U16STRING_HPP_

#include <string>
#include "rosidl_generator_c/u16string_functions.h"
#include "rosidl_runtime_c/u16string_functions.h"

namespace rmw_cyclonedds_cpp
{

void u16string_to_wstring(
const rosidl_generator_c__U16String & u16str, std::wstring & wstr);
const rosidl_runtime_c__U16String & u16str, std::wstring & wstr);

bool wstring_to_u16string(
const std::wstring & wstr, rosidl_generator_c__U16String & u16str);
const std::wstring & wstr, rosidl_runtime_c__U16String & u16str);

void u16string_to_wstring(const std::u16string & u16str, std::wstring & wstr);

Expand Down
2 changes: 1 addition & 1 deletion rmw_cyclonedds_cpp/src/Serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <memory>

#include "TypeSupport2.hpp"
#include "rosidl_generator_c/service_type_support_struct.h"
#include "rosidl_runtime_c/service_type_support_struct.h"
#include "serdata.hpp"

namespace rmw_cyclonedds_cpp
Expand Down
8 changes: 4 additions & 4 deletions rmw_cyclonedds_cpp/src/TypeSupport2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include "bytewise.hpp"
#include "rmw_cyclonedds_cpp/exception.hpp"
#include "rosidl_generator_c/string_functions.h"
#include "rosidl_generator_c/u16string_functions.h"
#include "rosidl_runtime_c/string_functions.h"
#include "rosidl_runtime_c/u16string_functions.h"
#include "rosidl_typesupport_introspection_c/identifier.h"
#include "rosidl_typesupport_introspection_c/message_introspection.h"
#include "rosidl_typesupport_introspection_c/service_introspection.h"
Expand Down Expand Up @@ -397,7 +397,7 @@ class U16StringValueType : public AnyValueType
struct ROSIDLC_StringValueType : public U8StringValueType
{
public:
using type = rosidl_generator_c__String;
using type = rosidl_runtime_c__String;

TypedSpan<const char_traits::char_type> data(const void * ptr) const override
{
Expand All @@ -419,7 +419,7 @@ struct ROSIDLC_StringValueType : public U8StringValueType
class ROSIDLC_WStringValueType : public U16StringValueType
{
public:
using type = rosidl_generator_c__U16String;
using type = rosidl_runtime_c__U16String;

TypedSpan<const char_traits::char_type> data(const void * ptr) const override
{
Expand Down
8 changes: 4 additions & 4 deletions rmw_cyclonedds_cpp/src/u16string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

#include <string>
#include "rosidl_generator_c/u16string_functions.h"
#include "rosidl_runtime_c/u16string_functions.h"

namespace rmw_cyclonedds_cpp
{
Expand All @@ -39,17 +39,17 @@ bool wstring_to_u16string(const std::wstring & wstr, std::u16string & u16str)
return true;
}

void u16string_to_wstring(const rosidl_generator_c__U16String & u16str, std::wstring & wstr)
void u16string_to_wstring(const rosidl_runtime_c__U16String & u16str, std::wstring & wstr)
{
wstr.resize(u16str.size);
for (size_t i = 0; i < u16str.size; ++i) {
wstr[i] = static_cast<wchar_t>(u16str.data[i]);
}
}

bool wstring_to_u16string(const std::wstring & wstr, rosidl_generator_c__U16String & u16str)
bool wstring_to_u16string(const std::wstring & wstr, rosidl_runtime_c__U16String & u16str)
{
bool succeeded = rosidl_generator_c__U16String__resize(&u16str, wstr.size());
bool succeeded = rosidl_runtime_c__U16String__resize(&u16str, wstr.size());
if (!succeeded) {
return false;
}
Expand Down