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
f651e5cf
Commit
f651e5cf
authored
Aug 23, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverse order of KJ_MAP to be consistent with e.g. KJ_IF_MAYBE.
parent
e65d5d0f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
16 deletions
+16
-16
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+0
-0
capnpc-capnp.c++
c++/src/capnp/compiler/capnpc-capnp.c++
+9
-9
compiler.c++
c++/src/capnp/compiler/compiler.c++
+1
-1
node-translator.c++
c++/src/capnp/compiler/node-translator.c++
+1
-1
stringify.c++
c++/src/capnp/stringify.c++
+1
-1
array-test.c++
c++/src/kj/array-test.c++
+1
-1
array.h
c++/src/kj/array.h
+3
-3
No files found.
c++/src/capnp/compiler/capnpc-c++.c++
View file @
f651e5cf
This diff is collapsed.
Click to expand it.
c++/src/capnp/compiler/capnpc-capnp.c++
View file @
f651e5cf
...
...
@@ -296,7 +296,7 @@ private:
}
kj
::
StringTree
genAnnotations
(
List
<
schema
::
Annotation
>::
Reader
list
,
Schema
scope
)
{
return
kj
::
strTree
(
KJ_MAP
(
list
,
ann
)
{
return
genAnnotation
(
ann
,
scope
);
});
return
kj
::
strTree
(
KJ_MAP
(
ann
,
list
)
{
return
genAnnotation
(
ann
,
scope
);
});
}
kj
::
StringTree
genAnnotations
(
Schema
schema
)
{
auto
proto
=
schema
.
getProto
();
...
...
@@ -326,7 +326,7 @@ private:
template
<
typename
MemberList
>
kj
::
Array
<
decltype
(
kj
::
instance
<
MemberList
>
()[
0
])
>
sortByCodeOrder
(
MemberList
&&
list
)
{
auto
sorted
=
KJ_MAP
(
list
,
item
)
{
return
item
;
};
auto
sorted
=
KJ_MAP
(
item
,
list
)
{
return
item
;
};
std
::
sort
(
sorted
.
begin
(),
sorted
.
end
(),
OrderByCodeOrder
());
return
kj
::
mv
(
sorted
);
}
...
...
@@ -338,7 +338,7 @@ private:
// subsequent fields.
bool
seenUnion
=
false
;
return
KJ_MAP
(
sortByCodeOrder
(
schema
.
getFields
()),
field
)
{
return
KJ_MAP
(
field
,
sortByCodeOrder
(
schema
.
getFields
())
)
{
if
(
field
.
getProto
().
hasDiscriminantValue
())
{
if
(
seenUnion
)
{
return
kj
::
strTree
();
...
...
@@ -350,7 +350,7 @@ private:
auto
unionFields
=
sortByCodeOrder
(
schema
.
getUnionFields
());
return
kj
::
strTree
(
indent
,
"union { # tag bits ["
,
offset
*
16
,
", "
,
offset
*
16
+
16
,
")
\n
"
,
KJ_MAP
(
u
nionFields
,
uField
)
{
KJ_MAP
(
u
Field
,
unionFields
)
{
return
genStructField
(
uField
.
getProto
(),
schema
,
indent
.
next
());
},
indent
,
"}
\n
"
);
...
...
@@ -424,7 +424,7 @@ private:
case
schema
:
:
Node
::
ENUM
:
{
return
kj
::
strTree
(
indent
,
"enum "
,
name
,
" @0x"
,
kj
::
hex
(
proto
.
getId
()),
genAnnotations
(
schema
),
" {
\n
"
,
KJ_MAP
(
sortByCodeOrder
(
schema
.
asEnum
().
getEnumerants
()),
enumerant
)
{
KJ_MAP
(
enumerant
,
sortByCodeOrder
(
schema
.
asEnum
().
getEnumerants
())
)
{
return
kj
::
strTree
(
indent
.
next
(),
enumerant
.
getProto
().
getName
(),
" @"
,
enumerant
.
getIndex
(),
genAnnotations
(
enumerant
.
getProto
().
getAnnotations
(),
schema
),
...
...
@@ -437,12 +437,12 @@ private:
return
kj
::
strTree
(
indent
,
"interface "
,
name
,
" @0x"
,
kj
::
hex
(
proto
.
getId
()),
genAnnotations
(
schema
),
" {
\n
"
,
KJ_MAP
(
sortByCodeOrder
(
schema
.
asInterface
().
getMethods
()),
method
)
{
KJ_MAP
(
method
,
sortByCodeOrder
(
schema
.
asInterface
().
getMethods
())
)
{
int
i
=
0
;
auto
methodProto
=
method
.
getProto
();
return
kj
::
strTree
(
indent
.
next
(),
methodProto
.
getName
(),
" @"
,
method
.
getIndex
(),
"("
,
KJ_MAP
(
methodProto
.
getParams
(),
param
)
{
KJ_MAP
(
param
,
methodProto
.
getParams
()
)
{
bool
hasDefault
=
i
>=
methodProto
.
getRequiredParamCount
()
||
!
isEmptyValue
(
param
.
getDefaultValue
());
return
kj
::
strTree
(
...
...
@@ -504,7 +504,7 @@ private:
kj
::
StringTree
genNestedDecls
(
Schema
schema
,
Indent
indent
)
{
uint64_t
id
=
schema
.
getProto
().
getId
();
return
kj
::
strTree
(
KJ_MAP
(
schema
.
getProto
().
getNestedNodes
(),
nested
)
{
return
kj
::
strTree
(
KJ_MAP
(
nested
,
schema
.
getProto
().
getNestedNodes
()
)
{
return
genDecl
(
schemaLoader
.
get
(
nested
.
getId
()),
nested
.
getName
(),
id
,
indent
);
});
}
...
...
@@ -516,7 +516,7 @@ private:
return
kj
::
strTree
(
"# "
,
proto
.
getDisplayName
(),
"
\n
"
,
"@0x"
,
kj
::
hex
(
proto
.
getId
()),
";
\n
"
,
KJ_MAP
(
proto
.
getAnnotations
(),
ann
)
{
return
genAnnotation
(
ann
,
file
,
""
,
";
\n
"
);
},
KJ_MAP
(
ann
,
proto
.
getAnnotations
()
)
{
return
genAnnotation
(
ann
,
file
,
""
,
";
\n
"
);
},
genNestedDecls
(
file
,
Indent
(
0
)));
}
...
...
c++/src/capnp/compiler/compiler.c++
View file @
f651e5cf
...
...
@@ -523,7 +523,7 @@ const Compiler::Node::Content& Compiler::Node::getContent(Content::State minimum
// Create the final schema.
KJ_IF_MAYBE
(
exception
,
kj
::
runCatchingExceptions
([
&
](){
auto
nodeSet
=
locked
->
translator
->
finish
();
locked
->
auxSchemas
=
KJ_MAP
(
nodeSet
.
auxNodes
,
auxNode
)
{
locked
->
auxSchemas
=
KJ_MAP
(
auxNode
,
nodeSet
.
auxNodes
)
{
return
module
->
getCompiler
().
getFinalLoader
().
loadOnce
(
auxNode
);
};
locked
->
finalSchema
=
module
->
getCompiler
().
getFinalLoader
().
loadOnce
(
nodeSet
.
node
);
...
...
c++/src/capnp/compiler/node-translator.c++
View file @
f651e5cf
...
...
@@ -536,7 +536,7 @@ NodeTranslator::NodeTranslator(
NodeTranslator
::
NodeSet
NodeTranslator
::
getBootstrapNode
()
{
return
NodeSet
{
wipNode
.
getReader
(),
KJ_MAP
(
g
roups
,
g
)
{
return
g
.
getReader
();
}
KJ_MAP
(
g
,
groups
)
{
return
g
.
getReader
();
}
};
}
...
...
c++/src/capnp/stringify.c++
View file @
f651e5cf
...
...
@@ -173,7 +173,7 @@ static kj::StringTree print(const DynamicValue::Reader& value,
case
DynamicValue
:
:
LIST
:
{
auto
listValue
=
value
.
as
<
DynamicList
>
();
auto
which
=
listValue
.
getSchema
().
whichElementType
();
kj
::
Array
<
kj
::
StringTree
>
elements
=
KJ_MAP
(
listValue
,
element
)
{
kj
::
Array
<
kj
::
StringTree
>
elements
=
KJ_MAP
(
element
,
listValue
)
{
return
print
(
element
,
which
,
indent
.
next
(),
BARE
);
};
return
kj
::
strTree
(
'['
,
indent
.
delimit
(
kj
::
mv
(
elements
),
mode
),
']'
);
...
...
c++/src/kj/array-test.c++
View file @
f651e5cf
...
...
@@ -331,7 +331,7 @@ TEST(Array, OwnConst) {
TEST
(
Array
,
Map
)
{
StringPtr
foo
=
"abcd"
;
Array
<
char
>
bar
=
KJ_MAP
(
foo
,
c
)
->
char
{
return
c
+
1
;
};
Array
<
char
>
bar
=
KJ_MAP
(
c
,
foo
)
->
char
{
return
c
+
1
;
};
EXPECT_STREQ
(
"bcde"
,
str
(
bar
).
cStr
());
}
...
...
c++/src/kj/array.h
View file @
f651e5cf
...
...
@@ -466,15 +466,15 @@ private:
};
// =======================================================================================
// KJ_MAP
_ARRAY
// KJ_MAP
#define KJ_MAP(
array, elementName
) \
#define KJ_MAP(
elementName, array
) \
::kj::_::Mapper<KJ_DECLTYPE_REF(array)>(array) * [&](decltype(*(array).begin()) elementName)
// Applies some function to every element of an array, returning an Array of the results, with
// nice syntax. Example:
//
// StringPtr foo = "abcd";
// Array<char> bar = KJ_MAP(
foo, c
) -> char { return c + 1; };
// Array<char> bar = KJ_MAP(
c, foo
) -> char { return c + 1; };
// KJ_ASSERT(str(bar) == "bcde");
namespace
_
{
// private
...
...
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