Skip to content

Commit 493c910

Browse files
committed
add codegen support for stl-fs-path
This adds codegen support for `stl-fs-path`, representing `std::filesystem::path`
1 parent 36117ef commit 493c910

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

SYNTAX.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,15 @@ Primitive fields can be classified as following:
239239

240240
These tags correspond to ``char[bytes]``, ``char*``, and ``std::string``.
241241

242-
4) File Stream::
242+
5) Path::
243+
244+
<stl-fs-path name='id'.../>
245+
246+
This tag corresponds to ``std::filesystem::path`` and is used to
247+
abstractly represent a path to a filesystem object in an
248+
architecture-independent manner.
249+
250+
6) File Stream::
243251

244252
<stl-fstream name='id'/>
245253

StructFields.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ my %custom_primitive_handlers = (
115115
'stl-mutex' => sub { header_ref("mutex"); return "std::mutex"; },
116116
'stl-condition-variable' => sub { header_ref("condition_variable"); return "std::condition_variable"; },
117117
'stl-future' => sub { header_ref("future"); return "std::future<void>"; },
118+
'stl-fs-path' => sub { header_ref("filesystem"); return "std::filesystem::path"; },
118119
);
119120

120121
my %custom_primitive_inits = (
@@ -125,6 +126,13 @@ my %custom_primitive_inits = (
125126
add_simple_init "\"$cur_init_value\"";
126127
}
127128
},
129+
'stl-fs-path' => sub {
130+
if (defined $cur_init_value) {
131+
$cur_init_value =~ s/\\/\\\\/g;
132+
$cur_init_value =~ s/\"/\\\"/g;
133+
add_simple_init "\"$cur_init_value\"";
134+
}
135+
},
128136
);
129137

130138
my %custom_container_handlers = (

data-definition.xsd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
<xs:element name="stl-weak-ptr" type="StlWeakPtrField" />
233233
<xs:element name="stl-function" type="StlFunctionField" />
234234
<xs:element name="stl-variant" type="StlVariantField" />
235+
<xs:element name="stl-fs-path" type="StlPathField" />
235236
<xs:element name="df-linked-list" type="DfLinkedListField" />
236237
<xs:element name="df-array" type="DfArrayField" />
237238
<xs:element name="df-flagarray" type="DfFlagArrayField" />
@@ -379,6 +380,12 @@
379380
</xs:extension>
380381
</xs:complexContent>
381382
</xs:complexType>
383+
<xs:complexType name="StlPathField">
384+
<xs:complexContent>
385+
<xs:extension base="SimpleFieldType">
386+
</xs:extension>
387+
</xs:complexContent>
388+
</xs:complexType>
382389
<xs:complexType name="StlVectorField">
383390
<xs:complexContent>
384391
<xs:extension base="ContainerFieldType">

lower-1.xslt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ Error: field <xsl:value-of select='$enum-key'/> corresponds to an enum value of
218218
<prim-type ld:meta='primitive' ld:subtype='stl-mutex'/>
219219
<prim-type ld:meta='primitive' ld:subtype='stl-condition-variable'/>
220220
<prim-type ld:meta='primitive' ld:subtype='stl-future'/>
221+
<prim-type ld:meta='primitive' ld:subtype='stl-fs-path'/>
221222
</ld:primitive-types>
222223

223-
<xsl:template match='int8_t|uint8_t|int16_t|uint16_t|int32_t|uint32_t|int64_t|uint64_t|size_t|ssize_t|long|ulong|bool|flag-bit|s-float|d-float|padding|static-string|ptr-string|stl-string|stl-fstream|stl-mutex|stl-condition-variable|stl-future'>
224+
<xsl:template match='int8_t|uint8_t|int16_t|uint16_t|int32_t|uint32_t|int64_t|uint64_t|size_t|ssize_t|long|ulong|bool|flag-bit|s-float|d-float|padding|static-string|ptr-string|stl-string|stl-fstream|stl-mutex|stl-condition-variable|stl-future|stl-fs-path'>
224225
<xsl:param name='level' select='-1'/>
225226
<ld:field>
226227
<xsl:apply-templates select='@*'/>

0 commit comments

Comments
 (0)