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
e71deb9c
Commit
e71deb9c
authored
Nov 12, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up stuff from the Solaris patch that was merged earlier.
parent
a22cb202
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
30 deletions
+32
-30
configure.ac
c++/configure.ac
+1
-0
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+2
-9
array.h
c++/src/kj/array.h
+1
-1
exception.c++
c++/src/kj/exception.c++
+3
-3
string-test.c++
c++/src/kj/string-test.c++
+2
-0
string.c++
c++/src/kj/string.c++
+7
-4
string.h
c++/src/kj/string.h
+16
-13
No files found.
c++/configure.ac
View file @
e71deb9c
...
@@ -48,6 +48,7 @@ AS_IF([test "$external_capnp" != "no"], [
...
@@ -48,6 +48,7 @@ AS_IF([test "$external_capnp" != "no"], [
])
])
AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"])
AM_CONDITIONAL([USE_EXTERNAL_CAPNP], [test "$external_capnp" != "no"])
# Only used in a test. Cleanup?
AC_SEARCH_LIBS(sched_yield, rt)
AC_SEARCH_LIBS(sched_yield, rt)
LIBS="$PTHREAD_LIBS $LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
...
...
c++/src/capnp/compiler/capnpc-c++.c++
View file @
e71deb9c
...
@@ -245,7 +245,7 @@ private:
...
@@ -245,7 +245,7 @@ private:
switch
(
value
.
which
())
{
switch
(
value
.
which
())
{
case
schema
:
:
Value
::
VOID
:
return
kj
::
strTree
(
" ::capnp::VOID"
);
case
schema
:
:
Value
::
VOID
:
return
kj
::
strTree
(
" ::capnp::VOID"
);
case
schema
:
:
Value
::
BOOL
:
return
kj
::
strTree
(
value
.
getBool
()
?
"true"
:
"false"
);
case
schema
:
:
Value
::
BOOL
:
return
kj
::
strTree
(
value
.
getBool
()
?
"true"
:
"false"
);
case
schema
:
:
Value
::
INT8
:
return
kj
::
strTree
(
int
(
value
.
getInt8
()
));
case
schema
:
:
Value
::
INT8
:
return
kj
::
strTree
(
value
.
getInt8
(
));
case
schema
:
:
Value
::
INT16
:
return
kj
::
strTree
(
value
.
getInt16
());
case
schema
:
:
Value
::
INT16
:
return
kj
::
strTree
(
value
.
getInt16
());
case
schema
:
:
Value
::
INT32
:
return
kj
::
strTree
(
value
.
getInt32
());
case
schema
:
:
Value
::
INT32
:
return
kj
::
strTree
(
value
.
getInt32
());
case
schema
:
:
Value
::
INT64
:
return
kj
::
strTree
(
value
.
getInt64
(),
"ll"
);
case
schema
:
:
Value
::
INT64
:
return
kj
::
strTree
(
value
.
getInt64
(),
"ll"
);
...
@@ -667,13 +667,6 @@ private:
...
@@ -667,13 +667,6 @@ private:
setterDefault
=
" = ::capnp::VOID"
;
setterDefault
=
" = ::capnp::VOID"
;
break
;
break
;
case
schema
:
:
Type
::
INT8
:
kind
=
FieldKind
::
PRIMITIVE
;
if
(
defaultBody
.
getInt8
()
!=
0
)
{
defaultMask
=
kj
::
str
(
int
(
defaultBody
.
getInt8
()),
""
);
}
break
;
#define HANDLE_PRIMITIVE(discrim, typeName, defaultName, suffix) \
#define HANDLE_PRIMITIVE(discrim, typeName, defaultName, suffix) \
case schema::Type::discrim: \
case schema::Type::discrim: \
kind = FieldKind::PRIMITIVE; \
kind = FieldKind::PRIMITIVE; \
...
@@ -683,7 +676,7 @@ private:
...
@@ -683,7 +676,7 @@ private:
break;
break;
HANDLE_PRIMITIVE
(
BOOL
,
bool
,
Bool
,
);
HANDLE_PRIMITIVE
(
BOOL
,
bool
,
Bool
,
);
//
HANDLE_PRIMITIVE(INT8 , ::int8_t , Int8 , );
HANDLE_PRIMITIVE
(
INT8
,
::
int8_t
,
Int8
,
);
HANDLE_PRIMITIVE
(
INT16
,
::
int16_t
,
Int16
,
);
HANDLE_PRIMITIVE
(
INT16
,
::
int16_t
,
Int16
,
);
HANDLE_PRIMITIVE
(
INT32
,
::
int32_t
,
Int32
,
);
HANDLE_PRIMITIVE
(
INT32
,
::
int32_t
,
Int32
,
);
HANDLE_PRIMITIVE
(
INT64
,
::
int64_t
,
Int64
,
ll
);
HANDLE_PRIMITIVE
(
INT64
,
::
int64_t
,
Int64
,
ll
);
...
...
c++/src/kj/array.h
View file @
e71deb9c
...
@@ -447,7 +447,7 @@ public:
...
@@ -447,7 +447,7 @@ public:
inline
explicit
constexpr
CappedArray
(
size_t
s
)
:
currentSize
(
s
)
{}
inline
explicit
constexpr
CappedArray
(
size_t
s
)
:
currentSize
(
s
)
{}
inline
size_t
size
()
const
{
return
currentSize
;
}
inline
size_t
size
()
const
{
return
currentSize
;
}
inline
void
setSize
(
size_t
s
)
{
currentSize
=
s
;
}
inline
void
setSize
(
size_t
s
)
{
KJ_IREQUIRE
(
s
<=
fixedSize
);
currentSize
=
s
;
}
inline
T
*
begin
()
{
return
content
;
}
inline
T
*
begin
()
{
return
content
;
}
inline
T
*
end
()
{
return
content
+
currentSize
;
}
inline
T
*
end
()
{
return
content
+
currentSize
;
}
inline
const
T
*
begin
()
const
{
return
content
;
}
inline
const
T
*
begin
()
const
{
return
content
;
}
...
...
c++/src/kj/exception.c++
View file @
e71deb9c
...
@@ -28,12 +28,12 @@
...
@@ -28,12 +28,12 @@
#include <stdlib.h>
#include <stdlib.h>
#include <exception>
#include <exception>
#if
!defined(__CYGWIN__) && !defined(__sun)
#if
__linux__ || __APPLE__
#define KJ_HAS_BACKTRACE 1
#define KJ_HAS_BACKTRACE 1
#include <execinfo.h>
#include <execinfo.h>
#endif
#endif
#if
defined(__linux__)
&& defined(KJ_DEBUG)
#if
__linux__
&& defined(KJ_DEBUG)
#include <stdio.h>
#include <stdio.h>
#include <pthread.h>
#include <pthread.h>
#endif
#endif
...
@@ -43,7 +43,7 @@ namespace kj {
...
@@ -43,7 +43,7 @@ namespace kj {
namespace
{
namespace
{
String
getStackSymbols
(
ArrayPtr
<
void
*
const
>
trace
)
{
String
getStackSymbols
(
ArrayPtr
<
void
*
const
>
trace
)
{
#if
defined(__linux__)
&& defined(KJ_DEBUG)
#if
__linux__
&& defined(KJ_DEBUG)
// We want to generate a human-readable stack trace.
// We want to generate a human-readable stack trace.
// TODO(someday): It would be really great if we could avoid farming out to addr2line and do
// TODO(someday): It would be really great if we could avoid farming out to addr2line and do
...
...
c++/src/kj/string-test.c++
View file @
e71deb9c
...
@@ -34,6 +34,8 @@ TEST(String, Str) {
...
@@ -34,6 +34,8 @@ TEST(String, Str) {
EXPECT_EQ
(
"1 2 3 4"
,
str
(
1
,
" "
,
2u
,
" "
,
3l
,
" "
,
4ll
));
EXPECT_EQ
(
"1 2 3 4"
,
str
(
1
,
" "
,
2u
,
" "
,
3l
,
" "
,
4ll
));
EXPECT_EQ
(
"1.5 foo 1e15 bar -3"
,
str
(
1.5
f
,
" foo "
,
1e15
,
" bar "
,
-
3
));
EXPECT_EQ
(
"1.5 foo 1e15 bar -3"
,
str
(
1.5
f
,
" foo "
,
1e15
,
" bar "
,
-
3
));
EXPECT_EQ
(
"foo"
,
str
(
'f'
,
'o'
,
'o'
));
EXPECT_EQ
(
"foo"
,
str
(
'f'
,
'o'
,
'o'
));
EXPECT_EQ
(
"123 234 -123 e7"
,
str
((
int8_t
)
123
,
" "
,
(
uint8_t
)
234
,
" "
,
(
int8_t
)
-
123
,
" "
,
hex
((
uint8_t
)
0xe7
)));
}
}
TEST
(
String
,
StartsEndsWith
)
{
TEST
(
String
,
StartsEndsWith
)
{
...
...
c++/src/kj/string.c++
View file @
e71deb9c
...
@@ -44,12 +44,13 @@ String heapString(const char* value, size_t size) {
...
@@ -44,12 +44,13 @@ String heapString(const char* value, size_t size) {
}
}
#define HEXIFY_INT(type, format) \
#define HEXIFY_INT(type, format) \
CappedArray<char, sizeof(type) *
4
> hex(type i) { \
CappedArray<char, sizeof(type) *
2 + 1
> hex(type i) { \
CappedArray<char, sizeof(type) *
4
> result; \
CappedArray<char, sizeof(type) *
2 + 1
> result; \
result.setSize(sprintf(result.begin(), format, i)); \
result.setSize(sprintf(result.begin(), format, i)); \
return result; \
return result; \
}
}
HEXIFY_INT
(
unsigned
char
,
"%x"
);
HEXIFY_INT
(
unsigned
short
,
"%x"
);
HEXIFY_INT
(
unsigned
short
,
"%x"
);
HEXIFY_INT
(
unsigned
int
,
"%x"
);
HEXIFY_INT
(
unsigned
int
,
"%x"
);
HEXIFY_INT
(
unsigned
long
,
"%lx"
);
HEXIFY_INT
(
unsigned
long
,
"%lx"
);
...
@@ -64,12 +65,14 @@ StringPtr Stringifier::operator*(bool b) const {
...
@@ -64,12 +65,14 @@ StringPtr Stringifier::operator*(bool b) const {
}
}
#define STRINGIFY_INT(type, format) \
#define STRINGIFY_INT(type, format) \
CappedArray<char, sizeof(type) *
4
> Stringifier::operator*(type i) const { \
CappedArray<char, sizeof(type) *
3 + 2
> Stringifier::operator*(type i) const { \
CappedArray<char, sizeof(type) *
4
> result; \
CappedArray<char, sizeof(type) *
3 + 2
> result; \
result.setSize(sprintf(result.begin(), format, i)); \
result.setSize(sprintf(result.begin(), format, i)); \
return result; \
return result; \
}
}
STRINGIFY_INT
(
signed
char
,
"%d"
);
STRINGIFY_INT
(
unsigned
char
,
"%u"
);
STRINGIFY_INT
(
short
,
"%d"
);
STRINGIFY_INT
(
short
,
"%d"
);
STRINGIFY_INT
(
unsigned
short
,
"%u"
);
STRINGIFY_INT
(
unsigned
short
,
"%u"
);
STRINGIFY_INT
(
int
,
"%d"
);
STRINGIFY_INT
(
int
,
"%d"
);
...
...
c++/src/kj/string.h
View file @
e71deb9c
...
@@ -270,17 +270,19 @@ struct Stringifier {
...
@@ -270,17 +270,19 @@ struct Stringifier {
StringPtr
operator
*
(
bool
b
)
const
;
StringPtr
operator
*
(
bool
b
)
const
;
CappedArray
<
char
,
sizeof
(
short
)
*
4
>
operator
*
(
short
i
)
const
;
CappedArray
<
char
,
5
>
operator
*
(
signed
char
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
4
>
operator
*
(
unsigned
short
i
)
const
;
CappedArray
<
char
,
5
>
operator
*
(
unsigned
char
i
)
const
;
CappedArray
<
char
,
sizeof
(
int
)
*
4
>
operator
*
(
int
i
)
const
;
CappedArray
<
char
,
sizeof
(
short
)
*
3
+
2
>
operator
*
(
short
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
4
>
operator
*
(
unsigned
int
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
3
+
2
>
operator
*
(
unsigned
short
i
)
const
;
CappedArray
<
char
,
sizeof
(
long
)
*
4
>
operator
*
(
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
int
)
*
3
+
2
>
operator
*
(
int
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
long
)
*
4
>
operator
*
(
unsigned
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
3
+
2
>
operator
*
(
unsigned
int
i
)
const
;
CappedArray
<
char
,
sizeof
(
long
long
)
*
4
>
operator
*
(
long
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
long
)
*
3
+
2
>
operator
*
(
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
long
long
)
*
4
>
operator
*
(
unsigned
long
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
long
)
*
3
+
2
>
operator
*
(
unsigned
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
long
long
)
*
3
+
2
>
operator
*
(
long
long
i
)
const
;
CappedArray
<
char
,
sizeof
(
unsigned
long
long
)
*
3
+
2
>
operator
*
(
unsigned
long
long
i
)
const
;
CappedArray
<
char
,
24
>
operator
*
(
float
f
)
const
;
CappedArray
<
char
,
24
>
operator
*
(
float
f
)
const
;
CappedArray
<
char
,
32
>
operator
*
(
double
f
)
const
;
CappedArray
<
char
,
32
>
operator
*
(
double
f
)
const
;
CappedArray
<
char
,
sizeof
(
const
void
*
)
*
4
>
operator
*
(
const
void
*
s
)
const
;
CappedArray
<
char
,
sizeof
(
const
void
*
)
*
3
+
2
>
operator
*
(
const
void
*
s
)
const
;
template
<
typename
T
>
template
<
typename
T
>
String
operator
*
(
ArrayPtr
<
T
>
arr
)
const
;
String
operator
*
(
ArrayPtr
<
T
>
arr
)
const
;
...
@@ -304,10 +306,11 @@ auto toCharSequence(T&& value) -> decltype(_::STR * kj::fwd<T>(value)) {
...
@@ -304,10 +306,11 @@ auto toCharSequence(T&& value) -> decltype(_::STR * kj::fwd<T>(value)) {
return
_
::
STR
*
kj
::
fwd
<
T
>
(
value
);
return
_
::
STR
*
kj
::
fwd
<
T
>
(
value
);
}
}
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
4
>
hex
(
unsigned
short
i
);
CappedArray
<
char
,
sizeof
(
unsigned
char
)
*
2
+
1
>
hex
(
unsigned
char
i
);
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
4
>
hex
(
unsigned
int
i
);
CappedArray
<
char
,
sizeof
(
unsigned
short
)
*
2
+
1
>
hex
(
unsigned
short
i
);
CappedArray
<
char
,
sizeof
(
unsigned
long
)
*
4
>
hex
(
unsigned
long
i
);
CappedArray
<
char
,
sizeof
(
unsigned
int
)
*
2
+
1
>
hex
(
unsigned
int
i
);
CappedArray
<
char
,
sizeof
(
unsigned
long
long
)
*
4
>
hex
(
unsigned
long
long
i
);
CappedArray
<
char
,
sizeof
(
unsigned
long
)
*
2
+
1
>
hex
(
unsigned
long
i
);
CappedArray
<
char
,
sizeof
(
unsigned
long
long
)
*
2
+
1
>
hex
(
unsigned
long
long
i
);
template
<
typename
...
Params
>
template
<
typename
...
Params
>
String
str
(
Params
&&
...
params
)
{
String
str
(
Params
&&
...
params
)
{
...
...
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