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
Hide 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.
...
@@ -336,16 +336,16 @@ Header parsing is zero-copy.
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
Old and busted
:
Ugly imperative code
:
{% highlight c++ %}
{% highlight c++ %}
capnp::MallocMessageBuilder message;
capnp::MallocMessageBuilder message;
auto root = message.initRoot
<MyStruct>
();
auto root = message.initRoot
<MyStruct>
();
root.set
Int32Field
(123);
root.set
Foo
(123);
root.set
TextField
("foo");
root.set
Bar
("foo");
auto inner = root.init
StructField
();
auto inner = root.init
Baz
();
inner.set
BoolField
(true);
inner.set
Qux
(true);
capnp::writeMessageToFd(fd, message);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
{% endhighlight %}
...
@@ -356,17 +356,17 @@ capnp::writeMessageToFd(fd, message);
...
@@ -356,17 +356,17 @@ capnp::writeMessageToFd(fd, message);
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
<section
markdown=
"1"
data-title=
"Designated Initializers"
>
N
ew hotness
:
N
ice declarative code
:
{% highlight c++ %}
{% highlight c++ %}
using namespace capnp::init;
using namespace capnp::init;
capnp::MallocMessageBuilder message;
capnp::MallocMessageBuilder message;
message.initRoot
<MyStruct>
(
message.initRoot
<MyStruct>
(
$
int32Field
= 123,
$
foo
= 123,
$
textField
= "foo",
$
bar
= "foo",
$
structField
(
$
baz
(
$
boolField
= true
$
qux
= true
)
)
);
);
capnp::writeMessageToFd(fd, message);
capnp::writeMessageToFd(fd, message);
...
@@ -384,10 +384,10 @@ Even better:
...
@@ -384,10 +384,10 @@ Even better:
using namespace capnp::init;
using namespace capnp::init;
capnp::writeMessageToFd
<MyStruct>
(fd,
capnp::writeMessageToFd
<MyStruct>
(fd,
$
int32Field
= 123,
$
foo
= 123,
$
textField
= "foo",
$
bar
= "foo",
$
structField
(
$
baz
(
$
boolField
= true
$
qux
= true
)
)
);
);
{% endhighlight %}
{% endhighlight %}
...
@@ -404,7 +404,7 @@ struct {
...
@@ -404,7 +404,7 @@ struct {
struct Setter {
struct Setter {
T value;
T value;
template
<typename
U
>
void operator()(U& target) {
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 {
...
@@ -412,7 +412,7 @@ struct {
Setter
<T>
operator=(T&& value) {
Setter
<T>
operator=(T&& value) {
return { kj::fwd
<T>
(value) };
return { kj::fwd
<T>
(value) };
}
}
} $
int32Field
;
} $
foo
;
{% endhighlight %}
{% endhighlight %}
</section>
</section>
...
@@ -421,16 +421,16 @@ struct {
...
@@ -421,16 +421,16 @@ struct {
<section
markdown=
"1"
data-title=
"POCS"
>
<section
markdown=
"1"
data-title=
"POCS"
>
Kind of painful
:
Not idiomatic
:
{% highlight c++ %}
{% highlight c++ %}
capnp::MallocMessageBuilder message;
capnp::MallocMessageBuilder message;
MyStruct::Builder root = message.initRoot
<MyStruct>
();
MyStruct::Builder root = message.initRoot
<MyStruct>
();
root.set
Int32Field
(123);
root.set
Foo
(123);
root.set
TextField
("foo");
root.set
Bar
("foo");
InnerStruct::Builder inner = root.init
StructField
();
InnerStruct::Builder inner = root.init
Baz
();
inner.set
BoolField
(true);
inner.set
Qux
(true);
capnp::writeMessageToFd(fd, message);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
{% endhighlight %}
...
@@ -445,11 +445,11 @@ Plain Old C++ Structs?
...
@@ -445,11 +445,11 @@ Plain Old C++ Structs?
{% highlight c++ %}
{% highlight c++ %}
MyStruct root;
MyStruct root;
root.
int32Field
= 123;
root.
foo
= 123;
root.
textField
= "foo";
root.
bar
= "foo";
InnerStruct inner;
InnerStruct inner;
inner.
boolField
= true;
inner.
qux
= true;
root.
structField
= kj::mv(inner);
root.
baz
= kj::mv(inner);
capnp::writeMessageToFd(fd, message);
capnp::writeMessageToFd(fd, message);
{% endhighlight %}
{% endhighlight %}
...
@@ -578,87 +578,3 @@ interface AddressBookService {
...
@@ -578,87 +578,3 @@ interface AddressBookService {
Questions?
Questions?
</section>
</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