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
c53ca2f3
Commit
c53ca2f3
authored
Oct 16, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Associate 'Capability' type with null interface schema.
parent
c6712690
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
11 deletions
+33
-11
capability.h
c++/src/capnp/capability.h
+0
-8
common.h
c++/src/capnp/common.h
+14
-0
generated-header-support.h
c++/src/capnp/generated-header-support.h
+7
-2
schema-test.c++
c++/src/capnp/schema-test.c++
+3
-0
schema.c++
c++/src/capnp/schema.c++
+9
-1
No files found.
c++/src/capnp/capability.h
View file @
c53ca2f3
...
...
@@ -55,14 +55,6 @@ public:
RemotePromise
&
operator
=
(
RemotePromise
&&
other
)
=
default
;
};
struct
Capability
{
// A capability without type-safe methods. Typed capability clients wrap `Client` and typed
// capability servers subclass `Server` to dispatch to the regular, typed methods.
class
Client
;
class
Server
;
};
// =======================================================================================
class
RequestHook
;
...
...
c++/src/capnp/common.h
View file @
c53ca2f3
...
...
@@ -107,6 +107,20 @@ namespace _ { // private
template
<
typename
T
,
Kind
k
>
struct
Kind_
<
List
<
T
,
k
>>
{
static
constexpr
Kind
kind
=
Kind
::
LIST
;
};
}
// namespace _ (private)
struct
Capability
{
// A capability without type-safe methods. Typed capability clients wrap `Client` and typed
// capability servers subclass `Server` to dispatch to the regular, typed methods.
//
// Contents defined in capability.h. Declared here just so we can specialize Kind_.
class
Client
;
class
Server
;
};
namespace
_
{
// private
template
<>
struct
Kind_
<
Capability
>
{
static
constexpr
Kind
kind
=
Kind
::
INTERFACE
;
};
}
// namespace _ (private)
template
<
typename
T
,
Kind
k
=
kind
<
T
>
()
>
struct
ReaderFor_
{
typedef
typename
T
::
Reader
Type
;
};
template
<
typename
T
>
struct
ReaderFor_
<
T
,
Kind
::
PRIMITIVE
>
{
typedef
T
Type
;
};
template
<
typename
T
>
struct
ReaderFor_
<
T
,
Kind
::
ENUM
>
{
typedef
T
Type
;
};
...
...
c++/src/capnp/generated-header-support.h
View file @
c53ca2f3
...
...
@@ -108,8 +108,13 @@ inline const RawSchema& rawSchema() {
return
RawSchema_
<
T
>::
get
();
}
template
<
typename
T
>
struct
TypeId_
;
template
<
typename
T
>
struct
TypeId_
;
extern
const
RawSchema
NULL_INTERFACE_SCHEMA
;
// defined in schema.c++
template
<>
struct
TypeId_
<
Capability
>
{
static
constexpr
uint64_t
typeId
=
0x03
;
};
template
<>
struct
RawSchema_
<
Capability
>
{
static
inline
const
RawSchema
&
get
()
{
return
NULL_INTERFACE_SCHEMA
;
}
};
template
<
typename
T
>
struct
UnionMemberIndex_
;
...
...
c++/src/capnp/schema-test.c++
View file @
c53ca2f3
...
...
@@ -262,6 +262,9 @@ TEST(Schema, NullSchemas) {
EXPECT_EQ
(
"(null enum schema)"
,
EnumSchema
().
getProto
().
getDisplayName
());
EXPECT_EQ
(
"(null interface schema)"
,
InterfaceSchema
().
getProto
().
getDisplayName
());
EXPECT_EQ
(
"(null const schema)"
,
ConstSchema
().
getProto
().
getDisplayName
());
EXPECT_TRUE
(
Schema
::
from
<
Capability
>
()
==
InterfaceSchema
());
EXPECT_EQ
(
InterfaceSchema
().
getProto
().
getId
(),
typeId
<
Capability
>
());
}
}
// namespace
...
...
c++/src/capnp/schema.c++
View file @
c53ca2f3
...
...
@@ -31,7 +31,7 @@ namespace _ { // private
// Null schemas generated using the below schema file with:
//
// capnp eval -Isrc null-schemas.capnp
interfac
e --flat |
// capnp eval -Isrc null-schemas.capnp
nod
e --flat |
// hexdump -v -e '8/1 "0x%02x, "' -e '1/8 "\n"'; echo
//
// I totally don't understand hexdump format strings and came up with this command based on trial
...
...
@@ -428,6 +428,10 @@ InterfaceSchema::Method InterfaceSchema::getMethodByName(kj::StringPtr name) con
}
bool
InterfaceSchema
::
extends
(
InterfaceSchema
other
)
const
{
if
(
other
.
raw
==
&
_
::
NULL_INTERFACE_SCHEMA
)
{
// We consider all interfaces to extend the null schema.
return
true
;
}
uint
counter
=
0
;
return
extends
(
other
,
counter
);
}
...
...
@@ -453,6 +457,10 @@ bool InterfaceSchema::extends(InterfaceSchema other, uint& counter) const {
}
kj
::
Maybe
<
InterfaceSchema
>
InterfaceSchema
::
findSuperclass
(
uint64_t
typeId
)
const
{
if
(
typeId
==
_
::
NULL_INTERFACE_SCHEMA
.
id
)
{
// We consider all interfaces to extend the null schema.
return
InterfaceSchema
();
}
uint
counter
=
0
;
return
findSuperclass
(
typeId
,
counter
);
}
...
...
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