Skip to content

Commit

Permalink
Merge branch 'pr/1596'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Nov 17, 2023
2 parents 8cb591d + a58d538 commit 817c2ed
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.10.0-dev.8 | 2023-11-17 14:04:16 +0100

* doc: Fix typo and outdated info for host applications (Anthony VEREZ)

* Add placeholder section for 1.10 to NEWS. (Benjamin Bannier, Corelight)

1.9.0 | 2023-10-24 16:28:18 +0200

* Release 1.9.0.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.0
1.10.0-dev.8
18 changes: 9 additions & 9 deletions doc/examples/my-http-excerpt.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[...]

namespace __hlt::MyHTTP {
struct RequestLine : hilti::rt::trait::isStruct, hilti::rt::Controllable<RequestLine> {
std::optional<hilti::rt::Bytes> method{};
std::optional<hilti::rt::Bytes> uri{};
std::optional<hilti::rt::ValueReference<Version>> version{};
struct RequestLine : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<RequestLine> {
std::optional<::hilti::rt::Bytes> method{};
std::optional<::hilti::rt::Bytes> uri{};
std::optional<::hilti::rt::ValueReference<Version>> version{};
[...]
};

struct Version : hilti::rt::trait::isStruct, hilti::rt::Controllable<Version> {
std::optional<hilti::rt::Bytes> number{};
struct Version : ::hilti::rt::trait::isStruct, ::hilti::rt::Controllable<Version> {
std::optional<::hilti::rt::Bytes> number{};
[...]
};

[...]
}

namespace hlt::MyHTTP::RequestLine {
extern auto parse1(hilti::rt::ValueReference<hilti::rt::Stream>& data, const std::optional<hilti::rt::stream::View>& cur) -> hilti::rt::Resumable;
extern auto parse2(hilti::rt::ValueReference<__hlt::MyHTTP::RequestLine>& unit, hilti::rt::ValueReference<hilti::rt::Stream>& data, const std::optional<hilti::rt::stream::View>& cur) -> hilti::rt::Resumable;
extern auto parse3(spicy::rt::ParsedUnit& gunit, hilti::rt::ValueReference<hilti::rt::Stream>& data, const std::optional<hilti::rt::stream::View>& cur) -> hilti::rt::Resumable;
extern auto parse1(::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable;
extern auto parse2(::hilti::rt::ValueReference<__hlt::MyHTTP::RequestLine>& unit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable;
extern auto parse3(::hilti::rt::ValueReference<::spicy::rt::ParsedUnit>& gunit, ::hilti::rt::ValueReference<::hilti::rt::Stream>& data, const std::optional<::hilti::rt::stream::View>& cur, const std::optional<::spicy::rt::UnitContext>& context) -> ::hilti::rt::Resumable;
}

[...]
22 changes: 12 additions & 10 deletions doc/host-applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ invocation of ``spicyc`` and can remove e.g., unused code. Since we generate
output files with multiple invocations, optimizations could lead to incomplete
code.

We also need ``spicyc`` to get generate some additional additional
We also need ``spicyc`` to generate some additional
"linker" code implementing internal plumbing necessary for
cross-module functionality. That's what ``-l`` (aka
``--output-linker``) does::
Expand Down Expand Up @@ -94,10 +94,11 @@ signatures:
``parse1``
The simplest form of parsing function receives a stream of input
data, along with an optional view into the stream to limit the
region to parse if desired. ``parse``` will internally instantiate
an instance of the unit's ``struct``, and then feed the unit's
parser with the data stream. However, it won't provide access to
what's being parsed as it doesn't pass back the ``struct``.
region to parse if desired and an optional context.
``parse1`` will internally instantiate an instance of the unit's
``struct``, and then feed the unit's parser with the data stream.
However, it won't provide access to what's being parsed as it
doesn't pass back the ``struct``.

``parse2``
The second form takes a pre-instantiated instance of the unit's
Expand Down Expand Up @@ -147,7 +148,7 @@ If we want that, we can use ``parse2()`` instead and provide it with a

::

# clang++ -o my-http my-http-host.cc my-http-host.cc $(spicy-config --cxxflags --ldflags)
# clang++ -o my-http my-http-host.cc my-http.cc my-http-linker.cc $(spicy-config --cxxflags --ldflags)
# ./my-http $'GET index.html HTTP/1.0\n'
GET, /index.html, 1.0
method : GET
Expand Down Expand Up @@ -239,7 +240,7 @@ prints out our one available parser:

.. literalinclude:: examples/my-http-host-driver.cc
:caption: my-http-host.cc
:lines: 9-12,31-42,57-64
:lines: 9-12,31-44,59-64
:language: c++

::
Expand Down Expand Up @@ -276,7 +277,7 @@ generically over HILTI types like this unit:
:lines: 15-30
:language: c++

Adding ``print(unit->value()`` after the call to ``processInput()``
Adding ``print(unit->value())`` after the call to ``processInput()``
then gives us this output:

::
Expand Down Expand Up @@ -307,8 +308,9 @@ taking the file to load from the command line:
::

# $(spicy-config --cxx) -o my-driver my-driver.cc $(spicy-config --cxxflags --ldflags --dynamic-loading)
# spicyc -j my-http.spicy >my-http.hlto
# ./my-driver my-http.hlto "$(cat data)"
# spicyc -j -o my-http.hlto my-http.spicy
# echo "GET /index.html HTTP/1.0\n\n<dummy>" > data
# ./my-driver my-http.hlto MyHTTP::RequestLine "$(cat data)"
Available parsers:

MyHTTP::RequestLine
Expand Down
2 changes: 1 addition & 1 deletion tests/spicy/doc/my-http-host-driver-hlto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char** argv) {
auto unit = driver.processInput(**parser, data);
assert(unit);

// Print out conntent of parsed unit.
// Print out content of parsed unit.
print(unit->value());

// Wrap up runtime libraries.
Expand Down
2 changes: 1 addition & 1 deletion tests/spicy/doc/my-http-host-driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char** argv) {
auto unit = driver.processInput(**parser, data);
assert(unit);

// Print out conntent of parsed unit.
// Print out content of parsed unit.
print(unit->value());

// Wrap up runtime libraries.
Expand Down

0 comments on commit 817c2ed

Please sign in to comment.