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
84235207
Commit
84235207
authored
Aug 23, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle TODO(soon)s.
parent
a499aceb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
86 deletions
+1
-86
layout.h
c++/src/capnp/layout.h
+1
-1
message.h
c++/src/capnp/message.h
+0
-6
common-test.c++
c++/src/kj/parse/common-test.c++
+0
-39
common.h
c++/src/kj/parse/common.h
+0
-40
No files found.
c++/src/capnp/layout.h
View file @
84235207
...
...
@@ -937,7 +937,7 @@ template <typename T>
inline
T
ListBuilder
::
getDataElement
(
ElementCount
index
)
{
return
reinterpret_cast
<
WireValue
<
T
>*>
(
ptr
+
index
*
step
/
BITS_PER_BYTE
)
->
get
();
// TODO(
soon
): Benchmark this alternate implementation, which I suspect may make better use of
// TODO(
perf
): Benchmark this alternate implementation, which I suspect may make better use of
// the x86 SIB byte. Also use it for all the other getData/setData implementations below, and
// the various non-inline methods that look up pointers.
// Also if using this, consider changing ptr back to void* instead of byte*.
...
...
c++/src/capnp/message.h
View file @
84235207
...
...
@@ -393,12 +393,6 @@ void copyToUnchecked(Reader&& reader, kj::ArrayPtr<word> uncheckedBuffer) {
builder
.
requireFilled
();
}
template
<
typename
Type
>
static
typename
Type
::
Reader
defaultValue
()
{
// TODO(soon): Correctly handle lists. Maybe primitives too?
return
typename
Type
::
Reader
(
_
::
StructReader
());
}
}
// namespace capnp
#endif // CAPNP_MESSAGE_H_
c++/src/kj/parse/common-test.c++
View file @
84235207
...
...
@@ -486,45 +486,6 @@ TEST(CommonParsers, References) {
}
}
TEST
(
CommonParsers
,
AcceptIfParser
)
{
auto
parser
=
acceptIf
(
oneOf
(
transform
(
exactly
(
'a'
),
[]()
->
uint
{
return
123
;
}),
transform
(
exactly
(
'b'
),
[]()
->
uint
{
return
456
;
}),
transform
(
exactly
(
'c'
),
[]()
->
uint
{
return
789
;
})),
[](
uint
i
)
{
return
i
>
200
;});
{
StringPtr
text
=
"a"
;
Input
input
(
text
.
begin
(),
text
.
end
());
Maybe
<
uint
>
result
=
parser
(
input
);
EXPECT_TRUE
(
result
==
nullptr
);
}
{
StringPtr
text
=
"b"
;
Input
input
(
text
.
begin
(),
text
.
end
());
Maybe
<
uint
>
result
=
parser
(
input
);
KJ_IF_MAYBE
(
value
,
result
)
{
EXPECT_EQ
(
456u
,
*
value
);
}
else
{
ADD_FAILURE
()
<<
"Expected parse result, got null."
;
}
EXPECT_TRUE
(
input
.
atEnd
());
}
{
StringPtr
text
=
"c"
;
Input
input
(
text
.
begin
(),
text
.
end
());
Maybe
<
uint
>
result
=
parser
(
input
);
KJ_IF_MAYBE
(
value
,
result
)
{
EXPECT_EQ
(
789u
,
*
value
);
}
else
{
ADD_FAILURE
()
<<
"Expected parse result, got null."
;
}
EXPECT_TRUE
(
input
.
atEnd
());
}
}
TEST
(
CommonParsers
,
NotLookingAt
)
{
auto
parser
=
notLookingAt
(
exactly
(
'a'
));
...
...
c++/src/kj/parse/common.h
View file @
84235207
...
...
@@ -722,46 +722,6 @@ constexpr TransformWithLocation_<SubParser, TransformFunc> transformWithLocation
kj
::
fwd
<
SubParser
>
(
subParser
),
kj
::
fwd
<
TransformFunc
>
(
functor
));
}
// -------------------------------------------------------------------
// acceptIf()
// Output = Same as SubParser
template
<
typename
SubParser
,
typename
Condition
>
class
AcceptIf_
{
public
:
explicit
constexpr
AcceptIf_
(
SubParser
&&
subParser
,
Condition
&&
condition
)
:
subParser
(
kj
::
fwd
<
SubParser
>
(
subParser
)),
condition
(
kj
::
fwd
<
Condition
>
(
condition
))
{}
template
<
typename
Input
>
Maybe
<
OutputType
<
SubParser
,
Input
>>
operator
()(
Input
&
input
)
const
{
KJ_IF_MAYBE
(
subResult
,
subParser
(
input
))
{
if
(
condition
(
*
subResult
))
{
return
kj
::
mv
(
*
subResult
);
}
else
{
return
nullptr
;
}
}
else
{
return
nullptr
;
}
}
private
:
SubParser
subParser
;
Condition
condition
;
};
template
<
typename
SubParser
,
typename
Condition
>
constexpr
AcceptIf_
<
SubParser
,
Condition
>
acceptIf
(
SubParser
&&
subParser
,
Condition
&&
condition
)
{
// Constructs a parser which executes some other parser and then invokes the functor
// `condition` on the result to check if it is valid. Typically, `condition` is a lambda
// returning true or false. Like with `transform()`, `condition` is invoked using `kj::apply`
// to unpack tuples.
//
// TODO(soon): Remove in favor of transformOrReject()?
return
AcceptIf_
<
SubParser
,
Condition
>
(
kj
::
fwd
<
SubParser
>
(
subParser
),
kj
::
fwd
<
Condition
>
(
condition
));
}
// -------------------------------------------------------------------
// notLookingAt()
// Fails if the given parser succeeds at the current location.
...
...
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