Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
4d74e349
Commit
4d74e349
authored
May 18, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak slides.
parent
7c66aa5f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
109 deletions
+25
-109
index.md
doc/slides-2017.05.18/index.md
+25
-109
No files found.
doc/slides-2017.05.18/index.md
View file @
4d74e349
...
...
@@ -336,16 +336,16 @@ Header parsing is zero-copy.
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
Old and busted
:
Ugly imperative code
:
{% highlight c++ %}
capnp::MallocMessageBuilder message;
auto root = message.initRoot
<MyStruct>
();
root.set
Int32Field
(123);
root.set
TextField
("foo");
auto inner = root.init
StructField
();
inner.set
BoolField
(true);
root.set
Foo
(123);
root.set
Bar
("foo");
auto inner = root.init
Baz
();
inner.set
Qux
(true);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
...
...
@@ -356,17 +356,17 @@ capnp::writeMessageToFd(fd, message);
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
N
ew hotness
:
N
ice declarative code
:
{% highlight c++ %}
using namespace capnp::init;
capnp::MallocMessageBuilder message;
message.initRoot
<MyStruct>
(
$
int32Field
= 123,
$
textField
= "foo",
$
structField
(
$
boolField
= true
$
foo
= 123,
$
bar
= "foo",
$
baz
(
$
qux
= true
)
);
capnp::writeMessageToFd(fd, message);
...
...
@@ -384,10 +384,10 @@ Even better:
using namespace capnp::init;
capnp::writeMessageToFd
<MyStruct>
(fd,
$
int32Field
= 123,
$
textField
= "foo",
$
structField
(
$
boolField
= true
$
foo
= 123,
$
bar
= "foo",
$
baz
(
$
qux
= true
)
);
{% endhighlight %}
...
...
@@ -404,7 +404,7 @@ struct {
struct Setter {
T value;
template
<typename
U
>
void operator()(U& target) {
target.set
Int32Field
(kj::fwd
<T>
(value));
target.set
Foo
(kj::fwd
<T>
(value));
}
};
...
...
@@ -412,7 +412,7 @@ struct {
Setter
<T>
operator=(T&& value) {
return { kj::fwd
<T>
(value) };
}
} $
int32Field
;
} $
foo
;
{% endhighlight %}
</section>
...
...
@@ -421,16 +421,16 @@ struct {
<section
markdown=
"1"
data-title=
"POCS"
>
Kind of painful
:
Not idiomatic
:
{% highlight c++ %}
capnp::MallocMessageBuilder message;
MyStruct::Builder root = message.initRoot
<MyStruct>
();
root.set
Int32Field
(123);
root.set
TextField
("foo");
InnerStruct::Builder inner = root.init
StructField
();
inner.set
BoolField
(true);
root.set
Foo
(123);
root.set
Bar
("foo");
InnerStruct::Builder inner = root.init
Baz
();
inner.set
Qux
(true);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
...
...
@@ -445,11 +445,11 @@ Plain Old C++ Structs?
{% highlight c++ %}
MyStruct root;
root.
int32Field
= 123;
root.
textField
= "foo";
root.
foo
= 123;
root.
bar
= "foo";
InnerStruct inner;
inner.
boolField
= true;
root.
structField
= kj::mv(inner);
inner.
qux
= true;
root.
baz
= kj::mv(inner);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
...
...
@@ -578,87 +578,3 @@ interface AddressBookService {
Questions?
</section>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment