Skip to content

Commit 228ee8d

Browse files
authored
Merge pull request #877 from ab9rf/static-wstring
add codegen support for `static-wstring`
2 parents 3b5b853 + 94dc5f2 commit 228ee8d

6 files changed

Lines changed: 25 additions & 1 deletion

File tree

Common.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,14 @@ my @primitive_type_list =
177177
size_t ssize_t
178178
s-float d-float
179179
bool flag-bit
180-
padding static-string);
180+
padding static-string static-wstring);
181181

182182
my %primitive_aliases = (
183183
'ulong' => 'unsigned long',
184184
's-float' => 'float',
185185
'd-float' => 'double',
186186
'static-string' => 'char',
187+
'static-wstring' => 'wchar_t',
187188
'flag-bit' => 'void',
188189
'padding' => 'void',
189190
);

SYNTAX.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ Primitive fields can be classified as following:
234234
4) String::
235235

236236
<static-string name='id' size='bytes'.../>
237+
<static-wstring name='id' size='words'.../>
237238
<ptr-string name='id'.../>
238239
<stl-string name='id'.../>
239240

StructFields.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ sub get_struct_field_type($;%) {
294294
my $count = $tag->getAttribute('size') || 0;
295295
$prefix = "char";
296296
$suffix = "[$count]";
297+
} elsif ($subtype eq 'static-wstring') {
298+
my $count = $tag->getAttribute('size') || 0;
299+
$prefix = "wchar_t";
300+
$suffix = "[$count]";
297301
} elsif ($subtype eq 'padding') {
298302
my $count = $tag->getAttribute('size') || 0;
299303
my $alignment = $tag->getAttribute('alignment') || 1;
@@ -572,6 +576,9 @@ sub render_field_metadata_rec($$) {
572576
if ($subtype eq 'static-string') {
573577
my $count = $field->getAttribute('size') || 0;
574578
push @field_defs, [ "${FLD}(STATIC_STRING, $name)", 'NULL', $count, $extra ];
579+
} elsif ($subtype eq 'static-wstring') {
580+
my $count = $field->getAttribute('size') || 0;
581+
push @field_defs, [ "${FLD}(PRIMITIVE, $name)", 'NULL', $count, $extra ];
575582
}
576583
} elsif ($meta eq 'global' || $meta eq 'compound') {
577584
if (is_attr_true($field, 'ld:enum-size-forced')) {

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Template for new versions:
1919
# Future
2020

2121
## Structures
22+
- added codegen support for ``static-wstring`` (``wchar_t *``), required to support DF 53.11
2223

2324
# 53.10-r2
2425

data-definition.xsd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
<xs:element name="pointer" type="PointerField" />
240240
<xs:element name="ptr-string" type="PtrStringField" />
241241
<xs:element name="static-string" type="StaticStringField" />
242+
<xs:element name="static-wstring" type="StaticWStringField" />
242243
<xs:element name="padding" type="PaddingField" />
243244
</xs:choice>
244245
</xs:group>
@@ -555,6 +556,14 @@
555556
</xs:extension>
556557
</xs:complexContent>
557558
</xs:complexType>
559+
<xs:complexType name="StaticWStringField">
560+
<xs:complexContent>
561+
<xs:extension base="SimpleFieldType">
562+
<xs:attribute name="size" type="xs:positiveInteger" use="required">
563+
</xs:attribute>
564+
</xs:extension>
565+
</xs:complexContent>
566+
</xs:complexType>
558567
<xs:complexType name="PaddingField">
559568
<xs:complexContent>
560569
<xs:extension base="SimpleFieldType">

lower-1.xslt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,17 @@ Error: field <xsl:value-of select='$enum-key'/> corresponds to an enum value of
207207

208208
<prim-type ld:meta='bytes' ld:subtype='padding'/>
209209
<prim-type ld:meta='bytes' ld:subtype='static-string'/>
210+
<prim-type ld:meta='bytes' ld:subtype='static-wstring'/>
210211

211212
<prim-type ld:meta='pointer' ld:subtype='pointer'/>
212213
<prim-type ld:meta='pointer' ld:subtype='ptr-string' ld:is-container='true'>
213214
<static-string/>
214215
</prim-type>
215216

217+
<prim-type ld:meta='pointer' ld:subtype='ptr-wstring' ld:is-container='true'>
218+
<static-wstring/>
219+
</prim-type>
220+
216221
<prim-type ld:meta='primitive' ld:subtype='stl-string'/>
217222
<prim-type ld:meta='primitive' ld:subtype='stl-fstream'/>
218223
<prim-type ld:meta='primitive' ld:subtype='stl-mutex'/>

0 commit comments

Comments
 (0)