Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
b47702ee
Commit
b47702ee
authored
Feb 19, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix minor warnings found via cppcheck
parent
fd9a200d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
60 deletions
+59
-60
libcaf_core/caf/uniform_type_info.hpp
libcaf_core/caf/uniform_type_info.hpp
+3
-7
libcaf_core/src/get_mac_addresses.cpp
libcaf_core/src/get_mac_addresses.cpp
+1
-1
libcaf_core/src/local_actor.cpp
libcaf_core/src/local_actor.cpp
+2
-2
libcaf_core/src/string_serialization.cpp
libcaf_core/src/string_serialization.cpp
+36
-44
libcaf_core/src/try_match.cpp
libcaf_core/src/try_match.cpp
+1
-1
libcaf_io/src/default_multiplexer.cpp
libcaf_io/src/default_multiplexer.cpp
+1
-5
unit_testing/test_serialization.cpp
unit_testing/test_serialization.cpp
+15
-0
No files found.
libcaf_core/caf/uniform_type_info.hpp
View file @
b47702ee
...
@@ -48,11 +48,10 @@ struct uniform_value_t {
...
@@ -48,11 +48,10 @@ struct uniform_value_t {
void
*
val
;
void
*
val
;
virtual
uniform_value
copy
()
=
0
;
virtual
uniform_value
copy
()
=
0
;
virtual
~
uniform_value_t
();
virtual
~
uniform_value_t
();
};
};
template
<
class
T
,
class
...
Ts
>
template
<
class
T
,
class
...
Ts
>
uniform_value
make_uniform_value
(
const
uniform_type_info
*
ti
,
Ts
&&
...
args
)
{
uniform_value
make_uniform_value
(
const
uniform_type_info
*
u
ti
,
Ts
&&
...
args
)
{
struct
container
:
uniform_value_t
{
struct
container
:
uniform_value_t
{
T
value
;
T
value
;
container
(
const
uniform_type_info
*
ptr
,
T
arg
)
:
value
(
std
::
move
(
arg
))
{
container
(
const
uniform_type_info
*
ptr
,
T
arg
)
:
value
(
std
::
move
(
arg
))
{
...
@@ -62,9 +61,8 @@ uniform_value make_uniform_value(const uniform_type_info* ti, Ts&&... args) {
...
@@ -62,9 +61,8 @@ uniform_value make_uniform_value(const uniform_type_info* ti, Ts&&... args) {
uniform_value
copy
()
override
{
uniform_value
copy
()
override
{
return
uniform_value
{
new
container
(
ti
,
value
)};
return
uniform_value
{
new
container
(
ti
,
value
)};
}
}
};
};
return
uniform_value
{
new
container
(
ti
,
T
(
std
::
forward
<
Ts
>
(
args
)...))};
return
uniform_value
{
new
container
(
u
ti
,
T
(
std
::
forward
<
Ts
>
(
args
)...))};
}
}
/**
/**
...
@@ -276,12 +274,10 @@ class uniform_type_info {
...
@@ -276,12 +274,10 @@ class uniform_type_info {
uint16_t
m_type_nr
;
uint16_t
m_type_nr
;
};
};
using
uniform_type_info_ptr
=
std
::
unique_ptr
<
uniform_type_info
>
;
/**
/**
* @relates uniform_type_info
* @relates uniform_type_info
*/
*/
using
uniform_type_info_ptr
=
std
::
unique_ptr
<
uniform_type_info
>
;
/**
/**
* @relates uniform_type_info
* @relates uniform_type_info
...
...
libcaf_core/src/get_mac_addresses.cpp
View file @
b47702ee
...
@@ -180,7 +180,7 @@ constexpr size_t max_iterations = 3;
...
@@ -180,7 +180,7 @@ constexpr size_t max_iterations = 3;
struct
c_free
{
struct
c_free
{
template
<
class
T
>
template
<
class
T
>
void
operator
()(
T
*
ptr
)
{
void
operator
()(
T
*
ptr
)
const
{
free
(
ptr
);
free
(
ptr
);
}
}
};
};
...
...
libcaf_core/src/local_actor.cpp
View file @
b47702ee
...
@@ -204,7 +204,7 @@ message_id local_actor::sync_send_impl(message_priority mp,
...
@@ -204,7 +204,7 @@ message_id local_actor::sync_send_impl(message_priority mp,
return
nri
.
response_id
();
return
nri
.
response_id
();
}
}
//<backward_compatibility version="0.12">
//
<backward_compatibility version="0.12">
message
&
local_actor
::
last_dequeued
()
{
message
&
local_actor
::
last_dequeued
()
{
if
(
!
m_current_element
)
{
if
(
!
m_current_element
)
{
auto
errstr
=
"last_dequeued called after forward_to or not in a callback"
;
auto
errstr
=
"last_dequeued called after forward_to or not in a callback"
;
...
@@ -222,6 +222,6 @@ actor_addr& local_actor::last_sender() {
...
@@ -222,6 +222,6 @@ actor_addr& local_actor::last_sender() {
}
}
return
m_current_element
->
sender
;
return
m_current_element
->
sender
;
}
}
//</backward_compatibility>
//
</backward_compatibility>
}
// namespace caf
}
// namespace caf
libcaf_core/src/string_serialization.cpp
View file @
b47702ee
...
@@ -338,8 +338,9 @@ class string_deserializer : public deserializer, public dummy_backend {
...
@@ -338,8 +338,9 @@ class string_deserializer : public deserializer, public dummy_backend {
// and ':' must be ignored
// and ':' must be ignored
consume
(
':'
);
consume
(
':'
);
}
}
auto
str_end
=
m_str
.
end
();
string
::
iterator
substr_end
;
string
::
iterator
substr_end
;
auto
find_if_
cond
=
[](
char
c
)
->
bool
{
auto
find_if_
pred
=
[](
char
c
)
->
bool
{
switch
(
c
)
{
switch
(
c
)
{
case
')'
:
case
')'
:
case
'}'
:
case
'}'
:
...
@@ -351,70 +352,61 @@ class string_deserializer : public deserializer, public dummy_backend {
...
@@ -351,70 +352,61 @@ class string_deserializer : public deserializer, public dummy_backend {
return
false
;
return
false
;
}
}
};
};
char
needle
=
(
get
<
string
>
(
&
storage
))
?
'"'
:
'\''
;
if
(
get
<
string
>
(
&
storage
)
||
get
<
atom_value
>
(
&
storage
))
{
if
(
get
<
string
>
(
&
storage
)
||
get
<
atom_value
>
(
&
storage
))
{
char
needle
=
(
get
<
string
>
(
&
storage
))
?
'"'
:
'\''
;
if
(
*
m_pos
!=
needle
)
{
if
(
*
m_pos
==
needle
)
{
throw
std
::
runtime_error
(
"expected opening quotation mark"
);
// skip leading "
}
++
m_pos
;
auto
pred
=
[
needle
](
char
prev
,
char
curr
)
{
char
last_char
=
needle
;
return
prev
!=
'\\'
&&
curr
==
needle
;
auto
find_if_str_cond
=
[
&
last_char
,
needle
](
char
c
)
->
bool
{
};
if
(
c
==
needle
&&
last_char
!=
'\\'
)
{
substr_end
=
std
::
adjacent_find
(
m_pos
,
str_end
,
pred
);
return
true
;
if
(
substr_end
!=
str_end
)
{
}
++
m_pos
;
// skip opening quote
last_char
=
c
;
++
substr_end
;
// set iterator to position of closing quote
return
false
;
};
substr_end
=
find_if
(
m_pos
,
m_str
.
end
(),
find_if_str_cond
);
}
else
{
substr_end
=
find_if
(
m_pos
,
m_str
.
end
(),
find_if_cond
);
}
}
}
else
{
}
else
{
substr_end
=
find_if
(
m_pos
,
m_str
.
end
(),
find_if_con
d
);
substr_end
=
find_if
(
m_pos
,
str_end
,
find_if_pre
d
);
}
}
if
(
substr_end
==
m_str
.
end
()
)
{
if
(
substr_end
==
str_end
)
{
throw
std
::
runtime_error
(
"malformed string (unterminated value)"
);
throw
std
::
runtime_error
(
"malformed string (unterminated value)"
);
}
}
string
substr
(
m_pos
,
substr_end
);
string
substr
(
m_pos
,
substr_end
);
m_pos
+=
static_cast
<
difference_type
>
(
substr
.
size
());
m_pos
+=
static_cast
<
difference_type
>
(
substr
.
size
());
if
(
get
<
string
>
(
&
storage
)
||
get
<
atom_value
>
(
&
storage
))
{
if
(
get
<
string
>
(
&
storage
)
||
get
<
atom_value
>
(
&
storage
))
{
char
needle
=
(
get
<
string
>
(
&
storage
))
?
'"'
:
'\''
;
// skip trailing "
// skip trailing "
if
(
*
m_pos
!=
needle
)
{
if
(
m_pos
==
str_end
||
*
m_pos
!=
needle
)
{
string
error_msg
;
string
error_msg
;
error_msg
=
"malformed string, expected '"
;
error_msg
=
"malformed string, expected '"
;
error_msg
+=
needle
;
error_msg
+=
needle
;
error_msg
+=
"' found '"
;
error_msg
+=
"' found '"
;
error_msg
+=
*
m_pos
;
if
(
m_pos
==
str_end
)
{
error_msg
+=
"-end of string-"
;
}
else
{
error_msg
+=
*
m_pos
;
}
error_msg
+=
"'"
;
error_msg
+=
"'"
;
throw
std
::
runtime_error
(
error_msg
);
throw
std
::
runtime_error
(
error_msg
);
}
}
++
m_pos
;
++
m_pos
;
// replace '\"' by '"'
// replace '\"' by '"'
char
last_char
=
' '
;
auto
pred
=
[
needle
](
char
prev
,
char
curr
)
{
auto
cond
=
[
&
last_char
,
needle
](
char
c
)
->
bool
{
return
prev
==
'\\'
&&
curr
==
needle
;
if
(
c
==
needle
&&
last_char
==
'\\'
)
{
return
true
;
}
last_char
=
c
;
return
false
;
};
};
string
tmp
;
string
tmp
;
auto
sbegin
=
substr
.
begin
();
auto
prev
=
substr
.
begin
();
auto
send
=
substr
.
end
();
auto
last
=
substr
.
end
();
for
(
auto
i
=
find_if
(
sbegin
,
send
,
cond
);
i
!=
send
;
do
{
i
=
find_if
(
i
,
send
,
cond
))
{
auto
i
=
std
::
adjacent_find
(
prev
,
last
,
pred
);
--
i
;
tmp
.
append
(
prev
,
i
);
tmp
.
append
(
sbegin
,
i
);
if
(
i
==
last
)
{
tmp
+=
needle
;
prev
=
last
;
i
+=
2
;
}
else
{
sbegin
=
i
;
tmp
+=
needle
;
}
prev
=
i
+
2
;
if
(
sbegin
!=
substr
.
begin
())
{
}
tmp
.
append
(
sbegin
,
send
);
}
while
(
prev
!=
last
);
}
substr
.
swap
(
tmp
);
if
(
!
tmp
.
empty
())
{
substr
=
std
::
move
(
tmp
);
}
}
}
from_string_reader
fsr
(
substr
);
from_string_reader
fsr
(
substr
);
apply_visitor
(
fsr
,
storage
);
apply_visitor
(
fsr
,
storage
);
...
...
libcaf_core/src/try_match.cpp
View file @
b47702ee
...
@@ -69,7 +69,7 @@ class set_commit_rollback {
...
@@ -69,7 +69,7 @@ class set_commit_rollback {
inline
void
inc
()
{
inline
void
inc
()
{
++
m_pos
;
++
m_pos
;
}
}
inline
pointer
current
()
{
inline
pointer
current
()
const
{
return
&
m_data
[
m_pos
];
return
&
m_data
[
m_pos
];
}
}
inline
void
commit
()
{
inline
void
commit
()
{
...
...
libcaf_io/src/default_multiplexer.cpp
View file @
b47702ee
...
@@ -204,12 +204,8 @@ namespace network {
...
@@ -204,12 +204,8 @@ namespace network {
a
.
inaddr
.
sin_family
=
AF_INET
;
a
.
inaddr
.
sin_family
=
AF_INET
;
a
.
inaddr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
a
.
inaddr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
a
.
inaddr
.
sin_port
=
0
;
a
.
inaddr
.
sin_port
=
0
;
bool
success
=
false
;
// makes sure all sockets are closed in case of an error
// makes sure all sockets are closed in case of an error
auto
guard
=
detail
::
make_scope_guard
([
&
]
{
auto
guard
=
detail
::
make_scope_guard
([
&
]
{
if
(
success
)
{
return
;
// everyhting's fine
}
auto
e
=
WSAGetLastError
();
auto
e
=
WSAGetLastError
();
closesocket
(
listener
);
closesocket
(
listener
);
closesocket
(
socks
[
0
]);
closesocket
(
socks
[
0
]);
...
@@ -242,7 +238,7 @@ namespace network {
...
@@ -242,7 +238,7 @@ namespace network {
auto
write_fd
=
ccall
(
cc_valid_socket
,
"accept() failed"
,
auto
write_fd
=
ccall
(
cc_valid_socket
,
"accept() failed"
,
accept
,
listener
,
NULL
,
NULL
);
accept
,
listener
,
NULL
,
NULL
);
closesocket
(
listener
);
closesocket
(
listener
);
success
=
true
;
guard
.
disable
()
;
return
{
read_fd
,
write_fd
};
return
{
read_fd
,
write_fd
};
}
}
...
...
unit_testing/test_serialization.cpp
View file @
b47702ee
...
@@ -118,6 +118,19 @@ enum class test_enum {
...
@@ -118,6 +118,19 @@ enum class test_enum {
}
// namespace <anonymous>
}
// namespace <anonymous>
void
test_string_serialization
()
{
auto
input
=
make_message
(
"hello
\"
actor world
\"
!"
,
atom
(
"foo"
));
auto
s
=
to_string
(
input
);
CAF_CHECK_EQUAL
(
s
,
R"#(@<>+@str+@atom ( "hello \"actor world\"!", 'foo' ))#"
);
auto
m
=
from_string
<
message
>
(
s
);
if
(
!
m
)
{
CAF_PRINTERR
(
"from_string failed"
);
return
;
}
CAF_CHECK
(
*
m
==
input
);
CAF_CHECK_EQUAL
(
to_string
(
*
m
),
to_string
(
input
));
}
int
main
()
{
int
main
()
{
CAF_TEST
(
test_serialization
);
CAF_TEST
(
test_serialization
);
...
@@ -144,6 +157,8 @@ int main() {
...
@@ -144,6 +157,8 @@ int main() {
CAF_CHECK_EQUAL
(
to_string
(
nid
),
to_string
(
*
nid2
));
CAF_CHECK_EQUAL
(
to_string
(
nid
),
to_string
(
*
nid2
));
}
}
test_string_serialization
();
/*
/*
auto oarr = new detail::object_array;
auto oarr = new detail::object_array;
oarr->push_back(object::from(static_cast<uint32_t>(42)));
oarr->push_back(object::from(static_cast<uint32_t>(42)));
...
...
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