Skip to content

Commit

Permalink
Merge pull request #4630 from jrw972/wchar-conversion
Browse files Browse the repository at this point in the history
MetaStruct conversion of wchar is compiler dependent
  • Loading branch information
iguessthislldo committed May 8, 2024
2 parents d5aeb63 + 26d2d2e commit 6a506e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dds/DCPS/FilterEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ Value::Value(const std::string& s, bool conversion_preferred)
{}

#ifdef DDS_HAS_WCHAR
Value::Value(ACE_OutputCDR::from_wchar wc, bool conversion_preferred)
: type_(VAL_INT), i_(wc.val_), conversion_preferred_(conversion_preferred)
{}

Value::Value(const std::wstring& s, bool conversion_preferred)
: type_(VAL_STRING), s_(ACE_OS::strdup(ACE_Wide_To_Ascii(s.c_str()).char_rep()))
, conversion_preferred_(conversion_preferred)
Expand Down
1 change: 1 addition & 0 deletions dds/DCPS/FilterEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct OpenDDS_Dcps_Export Value {
Value(const char* s, bool conversion_preferred = false);
Value(const std::string& s, bool conversion_preferred = false);
#ifdef DDS_HAS_WCHAR
Value(ACE_OutputCDR::from_wchar wc, bool conversion_preferred = false);
Value(const std::wstring& s, bool conversion_preferred = false);
#endif
Value(const TAO::String_Manager& s, bool conversion_preferred = false);
Expand Down
11 changes: 11 additions & 0 deletions dds/idl/metaclass_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ namespace {
prefix += "static_cast<int>(";
}
suffix = use_cxx11 ? "()))" : ")";
} else if (cls & CL_PRIMITIVE) {
AST_Type* const actual = resolveActualType(field->field_type());
const AST_PredefinedType::PredefinedType pt =
dynamic_cast<AST_PredefinedType*>(actual)->pt();
if (use_cxx11) {
suffix += "()";
}
if (pt == AST_PredefinedType::PT_wchar) {
prefix = "ACE_OutputCDR::from_wchar(" + prefix;
suffix += ")";
}
} else if (use_cxx11) {
suffix += "()";
}
Expand Down

0 comments on commit 6a506e1

Please sign in to comment.