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
1b468272
Commit
1b468272
authored
Jun 05, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc tweaks.
parent
c247947b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
9 deletions
+36
-9
common.h
c++/src/kj/common.h
+13
-1
exception.c++
c++/src/kj/exception.c++
+4
-3
string.h
c++/src/kj/string.h
+19
-5
No files found.
c++/src/kj/common.h
View file @
1b468272
...
...
@@ -525,7 +525,10 @@ public:
inline
constexpr
ArrayPtr
(
T
*
ptr
,
size_t
size
)
:
ptr
(
ptr
),
size_
(
size
)
{}
inline
constexpr
ArrayPtr
(
T
*
begin
,
T
*
end
)
:
ptr
(
begin
),
size_
(
end
-
begin
)
{}
inline
operator
ArrayPtr
<
const
T
>
()
{
inline
operator
ArrayPtr
<
const
T
>
()
const
{
return
ArrayPtr
<
const
T
>
(
ptr
,
size_
);
}
inline
ArrayPtr
<
const
T
>
asConst
()
const
{
return
ArrayPtr
<
const
T
>
(
ptr
,
size_
);
}
...
...
@@ -548,6 +551,15 @@ public:
inline
bool
operator
==
(
decltype
(
nullptr
))
{
return
size_
==
0
;
}
inline
bool
operator
!=
(
decltype
(
nullptr
))
{
return
size_
!=
0
;
}
inline
bool
operator
==
(
const
ArrayPtr
&
other
)
const
{
if
(
size_
!=
other
.
size_
)
return
false
;
for
(
size_t
i
=
0
;
i
<
size_
;
i
++
)
{
if
(
ptr
[
i
]
!=
other
[
i
])
return
false
;
}
return
true
;
}
inline
bool
operator
!=
(
const
ArrayPtr
&
other
)
const
{
return
!
(
*
this
==
other
);
}
private
:
T
*
ptr
;
size_t
size_
;
...
...
c++/src/kj/exception.c++
View file @
1b468272
...
...
@@ -49,7 +49,7 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
}
exe
[
n
]
=
'\0'
;
String
lines
[
6
];
String
lines
[
8
];
FILE
*
p
=
popen
(
str
(
"addr2line -e "
,
exe
,
' '
,
strArray
(
trace
,
" "
)).
cStr
(),
"r"
);
if
(
p
==
nullptr
)
{
...
...
@@ -61,14 +61,15 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
while
(
i
<
KJ_ARRAY_SIZE
(
lines
)
&&
fgets
(
line
,
sizeof
(
line
),
p
)
!=
nullptr
)
{
// Don't include exception-handling infrastructure in stack trace.
if
(
i
==
0
&&
(
strstr
(
line
,
"kj/exception."
)
!=
nullptr
||
(
strstr
(
line
,
"kj/common.c++"
)
!=
nullptr
||
strstr
(
line
,
"kj/exception."
)
!=
nullptr
||
strstr
(
line
,
"kj/debug."
)
!=
nullptr
))
{
continue
;
}
size_t
len
=
strlen
(
line
);
if
(
len
>
0
&&
line
[
len
-
1
]
==
'\n'
)
line
[
len
-
1
]
=
'\0'
;
lines
[
i
++
]
=
str
(
"
\n
"
,
line
);
lines
[
i
++
]
=
str
(
"
\n
"
,
line
,
": called here"
);
}
// Skip remaining input.
...
...
c++/src/kj/string.h
View file @
1b468272
...
...
@@ -45,6 +45,9 @@ public:
inline
StringPtr
()
:
content
(
""
,
1
)
{}
inline
StringPtr
(
decltype
(
nullptr
))
:
content
(
""
,
1
)
{}
inline
StringPtr
(
const
char
*
value
)
:
content
(
value
,
strlen
(
value
)
+
1
)
{}
inline
StringPtr
(
const
char
*
value
,
size_t
size
)
:
content
(
value
,
size
+
1
)
{
KJ_IREQUIRE
(
value
[
size
]
==
'\0'
,
"StringPtr must be NUL-terminated."
);
}
inline
StringPtr
(
const
String
&
value
);
inline
operator
ArrayPtr
<
const
char
>
()
const
;
...
...
@@ -65,8 +68,12 @@ public:
inline
bool
operator
==
(
decltype
(
nullptr
))
const
{
return
content
.
size
()
<=
1
;
}
inline
bool
operator
!=
(
decltype
(
nullptr
))
const
{
return
content
.
size
()
>
1
;
}
inline
bool
operator
==
(
StringPtr
other
)
const
;
inline
bool
operator
!=
(
StringPtr
other
)
const
{
return
!
(
*
this
==
other
);
}
inline
bool
operator
==
(
const
StringPtr
&
other
)
const
;
inline
bool
operator
!=
(
const
StringPtr
&
other
)
const
{
return
!
(
*
this
==
other
);
}
inline
bool
operator
<
(
const
StringPtr
&
other
)
const
;
inline
bool
operator
>
(
const
StringPtr
&
other
)
const
{
return
other
<
*
this
;
}
inline
bool
operator
<=
(
const
StringPtr
&
other
)
const
{
return
!
(
other
<
*
this
);
}
inline
bool
operator
>=
(
const
StringPtr
&
other
)
const
{
return
!
(
*
this
<
other
);
}
inline
StringPtr
slice
(
size_t
start
)
const
;
inline
ArrayPtr
<
const
char
>
slice
(
size_t
start
,
size_t
end
)
const
;
...
...
@@ -121,8 +128,8 @@ public:
inline
bool
operator
==
(
decltype
(
nullptr
))
const
{
return
content
.
size
()
<=
1
;
}
inline
bool
operator
!=
(
decltype
(
nullptr
))
const
{
return
content
.
size
()
>
1
;
}
inline
bool
operator
==
(
StringPtr
other
)
const
{
return
StringPtr
(
*
this
)
==
other
;
}
inline
bool
operator
!=
(
StringPtr
other
)
const
{
return
!
(
*
this
==
other
);
}
inline
bool
operator
==
(
const
StringPtr
&
other
)
const
{
return
StringPtr
(
*
this
)
==
other
;
}
inline
bool
operator
!=
(
const
StringPtr
&
other
)
const
{
return
!
(
*
this
==
other
);
}
private
:
Array
<
char
>
content
;
...
...
@@ -326,11 +333,18 @@ inline ArrayPtr<const char> StringPtr::asArray() const {
return
content
.
slice
(
0
,
content
.
size
()
-
1
);
}
inline
bool
StringPtr
::
operator
==
(
StringPtr
other
)
const
{
inline
bool
StringPtr
::
operator
==
(
const
StringPtr
&
other
)
const
{
return
content
.
size
()
==
other
.
content
.
size
()
&&
memcmp
(
content
.
begin
(),
other
.
content
.
begin
(),
content
.
size
()
-
1
)
==
0
;
}
inline
bool
StringPtr
::
operator
<
(
const
StringPtr
&
other
)
const
{
bool
shorter
=
content
.
size
()
<
other
.
content
.
size
();
int
cmp
=
memcmp
(
content
.
begin
(),
other
.
content
.
begin
(),
shorter
?
content
.
size
()
:
other
.
content
.
size
());
return
cmp
<
0
||
(
cmp
==
0
&&
shorter
);
}
inline
StringPtr
StringPtr
::
slice
(
size_t
start
)
const
{
return
StringPtr
(
content
.
slice
(
start
,
content
.
size
()));
}
...
...
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