Skip to content

Commit

Permalink
Merge pull request #827 from ab9rf/stl-path
Browse files Browse the repository at this point in the history
add codegen support for `stl-fs-path`
  • Loading branch information
myk002 authored Feb 27, 2025
2 parents 26ba382 + 493c910 commit 997f392
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
10 changes: 9 additions & 1 deletion SYNTAX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ Primitive fields can be classified as following:

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

4) File Stream::
5) Path::

<stl-fs-path name='id'.../>

This tag corresponds to ``std::filesystem::path`` and is used to
abstractly represent a path to a filesystem object in an
architecture-independent manner.

6) File Stream::

<stl-fstream name='id'/>

Expand Down
8 changes: 8 additions & 0 deletions StructFields.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ my %custom_primitive_handlers = (
'stl-mutex' => sub { header_ref("mutex"); return "std::mutex"; },
'stl-condition-variable' => sub { header_ref("condition_variable"); return "std::condition_variable"; },
'stl-future' => sub { header_ref("future"); return "std::future<void>"; },
'stl-fs-path' => sub { header_ref("filesystem"); return "std::filesystem::path"; },
);

my %custom_primitive_inits = (
Expand All @@ -125,6 +126,13 @@ my %custom_primitive_inits = (
add_simple_init "\"$cur_init_value\"";
}
},
'stl-fs-path' => sub {
if (defined $cur_init_value) {
$cur_init_value =~ s/\\/\\\\/g;
$cur_init_value =~ s/\"/\\\"/g;
add_simple_init "\"$cur_init_value\"";
}
},
);

my %custom_container_handlers = (
Expand Down
7 changes: 7 additions & 0 deletions data-definition.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
<xs:element name="stl-weak-ptr" type="StlWeakPtrField" />
<xs:element name="stl-function" type="StlFunctionField" />
<xs:element name="stl-variant" type="StlVariantField" />
<xs:element name="stl-fs-path" type="StlPathField" />
<xs:element name="df-linked-list" type="DfLinkedListField" />
<xs:element name="df-array" type="DfArrayField" />
<xs:element name="df-flagarray" type="DfFlagArrayField" />
Expand Down Expand Up @@ -379,6 +380,12 @@
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="StlPathField">
<xs:complexContent>
<xs:extension base="SimpleFieldType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="StlVectorField">
<xs:complexContent>
<xs:extension base="ContainerFieldType">
Expand Down
3 changes: 2 additions & 1 deletion lower-1.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,10 @@ Error: field <xsl:value-of select='$enum-key'/> corresponds to an enum value of
<prim-type ld:meta='primitive' ld:subtype='stl-mutex'/>
<prim-type ld:meta='primitive' ld:subtype='stl-condition-variable'/>
<prim-type ld:meta='primitive' ld:subtype='stl-future'/>
<prim-type ld:meta='primitive' ld:subtype='stl-fs-path'/>
</ld:primitive-types>

<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'>
<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'>
<xsl:param name='level' select='-1'/>
<ld:field>
<xsl:apply-templates select='@*'/>
Expand Down

0 comments on commit 997f392

Please sign in to comment.