-
Notifications
You must be signed in to change notification settings - Fork 365
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
Support for IDL wstring #2124
Merged
Merged
Support for IDL wstring #2124
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d5f3863
Support for IDL wstring
eboasson 1851ee6
Check correct use of surrogates in wstring
eboasson 0552b3c
Use UTF-16 string length in dds_stream_getsize
eboasson df06f23
Initial wchar support
eboasson fecfdc5
Fix bounded (w)string in-memory sizes in dynsub
eboasson 9d30699
Fix union case used for STRING16 in type builder
eboasson 03a5601
Remove unused "cdr_align" in type builder
eboasson 08be4d1
Add missing "or is_wstring" by introducing "is_xstring" to test for e…
eboasson cd8721f
Note lack of support for wstring/wchar in constant expressions
eboasson bf3341a
Add WCHAR, WSTR, BWSTR to enum dds_stream_opcode doc
eboasson 9fc7506
DDS_OP_PLM has no type code, only an offset
eboasson fc49149
CDR wstring length is in bytes, not code units
eboasson 951587f
Add a few missing wstring/wchar cases in cdrstream
eboasson a900a56
Fix bound in (sequence|array) of bounded strings
eboasson 2fd2600
Fix double-counting sizeof(wchar_t) in array/seq
eboasson a3b1d80
Add FOREACH, FOREACH_PAIR to ddsrt
eboasson 881a86e
Add wstring tests
eboasson e74ed11
Fix MSVC macro expansion
dpotman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
#include <string.h> | ||
#include <stdlib.h> | ||
#include <assert.h> | ||
#include <wchar.h> | ||
|
||
#include "dds/dds.h" | ||
#include "dds/ddsi/ddsi_xt_typeinfo.h" | ||
|
@@ -162,9 +163,9 @@ static bool build_typecache_simple (const uint8_t disc, size_t *align, size_t *s | |
case CASE(INT8, int8_t); | ||
case CASE(UINT8, uint8_t); | ||
case CASE(CHAR8, int8_t); | ||
case CASE(CHAR16, uint16_t); | ||
case CASE(CHAR16, wchar_t); | ||
case CASE(STRING8, unsigned char *); | ||
case CASE(STRING16, uint16_t *); | ||
case CASE(STRING16, wchar_t *); | ||
#undef CASE | ||
} | ||
return false; | ||
|
@@ -204,7 +205,7 @@ static void build_typecache_ti (const DDS_XTypes_TypeIdentifier *typeid, size_t | |
case DDS_XTypes_TI_STRING8_SMALL: | ||
case DDS_XTypes_TI_STRING8_LARGE: { | ||
uint32_t bound; | ||
if (typeid->_d == DDS_XTypes_TI_PLAIN_SEQUENCE_SMALL) { | ||
if (typeid->_d == DDS_XTypes_TI_STRING8_SMALL) { | ||
bound = typeid->_u.string_sdefn.bound; | ||
} else { | ||
bound = typeid->_u.string_ldefn.bound; | ||
|
@@ -218,6 +219,23 @@ static void build_typecache_ti (const DDS_XTypes_TypeIdentifier *typeid, size_t | |
} | ||
break; | ||
} | ||
case DDS_XTypes_TI_STRING16_SMALL: | ||
case DDS_XTypes_TI_STRING16_LARGE: { | ||
uint32_t bound; | ||
if (typeid->_d == DDS_XTypes_TI_STRING16_SMALL) { | ||
bound = typeid->_u.string_sdefn.bound; | ||
} else { | ||
bound = typeid->_u.string_ldefn.bound; | ||
} | ||
if (bound == 0) { | ||
*align = _Alignof (wchar_t *); | ||
*size = sizeof (wchar_t *); | ||
} else { | ||
*align = 1; | ||
*size = bound; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, should also use |
||
} | ||
break; | ||
} | ||
case DDS_XTypes_TI_PLAIN_SEQUENCE_SMALL: | ||
case DDS_XTypes_TI_PLAIN_SEQUENCE_LARGE: { | ||
const DDS_XTypes_TypeIdentifier *et; | ||
|
@@ -466,6 +484,9 @@ static bool load_deps_ti (dds_entity_t participant, const DDS_XTypes_TypeIdentif | |
case DDS_XTypes_TI_STRING8_SMALL: | ||
case DDS_XTypes_TI_STRING8_LARGE: | ||
return true; | ||
case DDS_XTypes_TI_STRING16_SMALL: | ||
case DDS_XTypes_TI_STRING16_LARGE: | ||
return true; | ||
case DDS_XTypes_TI_PLAIN_SEQUENCE_SMALL: | ||
return load_deps_ti (participant, typeid->_u.seq_sdefn.element_identifier); | ||
case DDS_XTypes_TI_PLAIN_SEQUENCE_LARGE: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,9 @@ module M1 { | |
@optional long x; | ||
}; | ||
}; | ||
|
||
struct D { | ||
wstring ws; | ||
wchar wc; | ||
unsigned long count; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the
size
parameter bebound * sizeof (wchar_t) + sizeof (L'\0')
?