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
30c7d54b
Unverified
Commit
30c7d54b
authored
Jun 30, 2018
by
Kenton Varda
Committed by
GitHub
Jun 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #701 from antis81/fix/const-eq-operators
fix const-correctness on AnyPointer equality checks
parents
06a71367
5ace519a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
36 deletions
+36
-36
any.c++
c++/src/capnp/any.c++
+6
-6
any.h
c++/src/capnp/any.h
+24
-24
layout.c++
c++/src/capnp/layout.c++
+1
-1
layout.h
c++/src/capnp/layout.h
+5
-5
No files found.
c++/src/capnp/any.c++
View file @
30c7d54b
...
...
@@ -79,7 +79,7 @@ kj::Own<ClientHook> AnyPointer::Pipeline::asCap() {
#endif // !CAPNP_LITE
Equality
AnyStruct
::
Reader
::
equals
(
AnyStruct
::
Reader
right
)
{
Equality
AnyStruct
::
Reader
::
equals
(
AnyStruct
::
Reader
right
)
const
{
auto
dataL
=
getDataSection
();
size_t
dataSizeL
=
dataL
.
size
();
while
(
dataSizeL
>
0
&&
dataL
[
dataSizeL
-
1
]
==
0
)
{
...
...
@@ -150,7 +150,7 @@ kj::StringPtr KJ_STRINGIFY(Equality res) {
KJ_UNREACHABLE
;
}
Equality
AnyList
::
Reader
::
equals
(
AnyList
::
Reader
right
)
{
Equality
AnyList
::
Reader
::
equals
(
AnyList
::
Reader
right
)
const
{
if
(
size
()
!=
right
.
size
())
{
return
Equality
::
NOT_EQUAL
;
}
...
...
@@ -209,7 +209,7 @@ Equality AnyList::Reader::equals(AnyList::Reader right) {
KJ_UNREACHABLE
;
}
Equality
AnyPointer
::
Reader
::
equals
(
AnyPointer
::
Reader
right
)
{
Equality
AnyPointer
::
Reader
::
equals
(
AnyPointer
::
Reader
right
)
const
{
if
(
getPointerType
()
!=
right
.
getPointerType
())
{
return
Equality
::
NOT_EQUAL
;
}
...
...
@@ -227,7 +227,7 @@ Equality AnyPointer::Reader::equals(AnyPointer::Reader right) {
KJ_UNREACHABLE
;
}
bool
AnyPointer
::
Reader
::
operator
==
(
AnyPointer
::
Reader
right
)
{
bool
AnyPointer
::
Reader
::
operator
==
(
AnyPointer
::
Reader
right
)
const
{
switch
(
equals
(
right
))
{
case
Equality
:
:
EQUAL
:
return
true
;
...
...
@@ -240,7 +240,7 @@ bool AnyPointer::Reader::operator==(AnyPointer::Reader right) {
KJ_UNREACHABLE
;
}
bool
AnyStruct
::
Reader
::
operator
==
(
AnyStruct
::
Reader
right
)
{
bool
AnyStruct
::
Reader
::
operator
==
(
AnyStruct
::
Reader
right
)
const
{
switch
(
equals
(
right
))
{
case
Equality
:
:
EQUAL
:
return
true
;
...
...
@@ -253,7 +253,7 @@ bool AnyStruct::Reader::operator==(AnyStruct::Reader right) {
KJ_UNREACHABLE
;
}
bool
AnyList
::
Reader
::
operator
==
(
AnyList
::
Reader
right
)
{
bool
AnyList
::
Reader
::
operator
==
(
AnyList
::
Reader
right
)
const
{
switch
(
equals
(
right
))
{
case
Equality
:
:
EQUAL
:
return
true
;
...
...
c++/src/capnp/any.h
View file @
30c7d54b
...
...
@@ -104,9 +104,9 @@ struct AnyPointer {
inline
bool
isList
()
const
{
return
getPointerType
()
==
PointerType
::
LIST
;
}
inline
bool
isCapability
()
const
{
return
getPointerType
()
==
PointerType
::
CAPABILITY
;
}
Equality
equals
(
AnyPointer
::
Reader
right
);
bool
operator
==
(
AnyPointer
::
Reader
right
);
inline
bool
operator
!=
(
AnyPointer
::
Reader
right
)
{
Equality
equals
(
AnyPointer
::
Reader
right
)
const
;
bool
operator
==
(
AnyPointer
::
Reader
right
)
const
;
inline
bool
operator
!=
(
AnyPointer
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
@@ -158,13 +158,13 @@ struct AnyPointer {
inline
bool
isList
()
{
return
getPointerType
()
==
PointerType
::
LIST
;
}
inline
bool
isCapability
()
{
return
getPointerType
()
==
PointerType
::
CAPABILITY
;
}
inline
Equality
equals
(
AnyPointer
::
Reader
right
)
{
inline
Equality
equals
(
AnyPointer
::
Reader
right
)
const
{
return
asReader
().
equals
(
right
);
}
inline
bool
operator
==
(
AnyPointer
::
Reader
right
)
{
inline
bool
operator
==
(
AnyPointer
::
Reader
right
)
const
{
return
asReader
()
==
right
;
}
inline
bool
operator
!=
(
AnyPointer
::
Reader
right
)
{
inline
bool
operator
!=
(
AnyPointer
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
@@ -466,10 +466,10 @@ public:
inline
MessageSize
totalSize
()
const
{
return
_reader
.
totalSize
().
asPublic
();
}
kj
::
ArrayPtr
<
const
byte
>
getDataSection
()
{
kj
::
ArrayPtr
<
const
byte
>
getDataSection
()
const
{
return
_reader
.
getDataSectionAsBlob
();
}
List
<
AnyPointer
>::
Reader
getPointerSection
()
{
List
<
AnyPointer
>::
Reader
getPointerSection
()
const
{
return
List
<
AnyPointer
>::
Reader
(
_reader
.
getPointerSectionAsList
());
}
...
...
@@ -477,9 +477,9 @@ public:
return
_reader
.
canonicalize
();
}
Equality
equals
(
AnyStruct
::
Reader
right
);
bool
operator
==
(
AnyStruct
::
Reader
right
);
inline
bool
operator
!=
(
AnyStruct
::
Reader
right
)
{
Equality
equals
(
AnyStruct
::
Reader
right
)
const
;
bool
operator
==
(
AnyStruct
::
Reader
right
)
const
;
inline
bool
operator
!=
(
AnyStruct
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
@@ -521,13 +521,13 @@ public:
return
List
<
AnyPointer
>::
Builder
(
_builder
.
getPointerSectionAsList
());
}
inline
Equality
equals
(
AnyStruct
::
Reader
right
)
{
inline
Equality
equals
(
AnyStruct
::
Reader
right
)
const
{
return
asReader
().
equals
(
right
);
}
inline
bool
operator
==
(
AnyStruct
::
Reader
right
)
{
inline
bool
operator
==
(
AnyStruct
::
Reader
right
)
const
{
return
asReader
()
==
right
;
}
inline
bool
operator
!=
(
AnyStruct
::
Reader
right
)
{
inline
bool
operator
!=
(
AnyStruct
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
@@ -646,14 +646,14 @@ public:
:
_reader
(
_
::
PointerHelpers
<
FromReader
<
T
>>::
getInternalReader
(
kj
::
fwd
<
T
>
(
value
)))
{}
#endif
inline
ElementSize
getElementSize
()
{
return
_reader
.
getElementSize
();
}
inline
uint
size
()
{
return
unbound
(
_reader
.
size
()
/
ELEMENTS
);
}
inline
ElementSize
getElementSize
()
const
{
return
_reader
.
getElementSize
();
}
inline
uint
size
()
const
{
return
unbound
(
_reader
.
size
()
/
ELEMENTS
);
}
inline
kj
::
ArrayPtr
<
const
byte
>
getRawBytes
()
{
return
_reader
.
asRawBytes
();
}
inline
kj
::
ArrayPtr
<
const
byte
>
getRawBytes
()
const
{
return
_reader
.
asRawBytes
();
}
Equality
equals
(
AnyList
::
Reader
right
);
bool
operator
==
(
AnyList
::
Reader
right
);
inline
bool
operator
!=
(
AnyList
::
Reader
right
)
{
Equality
equals
(
AnyList
::
Reader
right
)
const
;
bool
operator
==
(
AnyList
::
Reader
right
)
const
;
inline
bool
operator
!=
(
AnyList
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
@@ -661,7 +661,7 @@ public:
return
_reader
.
totalSize
().
asPublic
();
}
template
<
typename
T
>
ReaderFor
<
T
>
as
()
{
template
<
typename
T
>
ReaderFor
<
T
>
as
()
const
{
// T must be List<U>.
return
ReaderFor
<
T
>
(
_reader
);
}
...
...
@@ -689,11 +689,11 @@ public:
inline
ElementSize
getElementSize
()
{
return
_builder
.
getElementSize
();
}
inline
uint
size
()
{
return
unbound
(
_builder
.
size
()
/
ELEMENTS
);
}
Equality
equals
(
AnyList
::
Reader
right
);
inline
bool
operator
==
(
AnyList
::
Reader
right
)
{
Equality
equals
(
AnyList
::
Reader
right
)
const
;
inline
bool
operator
==
(
AnyList
::
Reader
right
)
const
{
return
asReader
()
==
right
;
}
inline
bool
operator
!=
(
AnyList
::
Reader
right
)
{
inline
bool
operator
!=
(
AnyList
::
Reader
right
)
const
{
return
!
(
*
this
==
right
);
}
...
...
c++/src/capnp/layout.c++
View file @
30c7d54b
...
...
@@ -3079,7 +3079,7 @@ Data::Reader ListReader::asData() {
return
Data
::
Reader
(
reinterpret_cast
<
const
byte
*>
(
ptr
),
unbound
(
elementCount
/
ELEMENTS
));
}
kj
::
ArrayPtr
<
const
byte
>
ListReader
::
asRawBytes
()
{
kj
::
ArrayPtr
<
const
byte
>
ListReader
::
asRawBytes
()
const
{
KJ_REQUIRE
(
structPointerCount
==
ZERO
*
POINTERS
,
"Expected data only, got pointers."
)
{
return
kj
::
ArrayPtr
<
const
byte
>
();
...
...
c++/src/capnp/layout.h
View file @
30c7d54b
...
...
@@ -597,8 +597,8 @@ public:
inline
StructDataBitCount
getDataSectionSize
()
const
{
return
dataSize
;
}
inline
StructPointerCount
getPointerSectionSize
()
const
{
return
pointerCount
;
}
inline
kj
::
ArrayPtr
<
const
byte
>
getDataSectionAsBlob
();
inline
_
::
ListReader
getPointerSectionAsList
();
inline
kj
::
ArrayPtr
<
const
byte
>
getDataSectionAsBlob
()
const
;
inline
_
::
ListReader
getPointerSectionAsList
()
const
;
kj
::
Array
<
word
>
canonicalize
();
...
...
@@ -780,7 +780,7 @@ public:
Data
::
Reader
asData
();
// Reinterpret the list as a blob. Throws an exception if the elements are not byte-sized.
kj
::
ArrayPtr
<
const
byte
>
asRawBytes
();
kj
::
ArrayPtr
<
const
byte
>
asRawBytes
()
const
;
template
<
typename
T
>
KJ_ALWAYS_INLINE
(
T
getDataElement
(
ElementCount
index
)
const
);
...
...
@@ -1080,12 +1080,12 @@ inline PointerBuilder StructBuilder::getPointerField(StructPointerOffset ptrInde
// -------------------------------------------------------------------
inline
kj
::
ArrayPtr
<
const
byte
>
StructReader
::
getDataSectionAsBlob
()
{
inline
kj
::
ArrayPtr
<
const
byte
>
StructReader
::
getDataSectionAsBlob
()
const
{
return
kj
::
ArrayPtr
<
const
byte
>
(
reinterpret_cast
<
const
byte
*>
(
data
),
unbound
(
dataSize
/
BITS_PER_BYTE
/
BYTES
));
}
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
{
inline
_
::
ListReader
StructReader
::
getPointerSectionAsList
()
const
{
return
_
::
ListReader
(
segment
,
capTable
,
pointers
,
pointerCount
*
(
ONE
*
ELEMENTS
/
POINTERS
),
ONE
*
POINTERS
*
BITS_PER_POINTER
/
ELEMENTS
,
ZERO
*
BITS
,
ONE
*
POINTERS
,
ElementSize
::
POINTER
,
nestingLimit
);
...
...
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