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
db48145f
Commit
db48145f
authored
Jun 28, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintenance
parent
6cbdec38
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
103 additions
and
140 deletions
+103
-140
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+25
-28
cppa/detail/abstract_tuple.hpp
cppa/detail/abstract_tuple.hpp
+2
-2
cppa/detail/to_uniform_name.hpp
cppa/detail/to_uniform_name.hpp
+3
-0
cppa/detail/uniform_type_info_map.hpp
cppa/detail/uniform_type_info_map.hpp
+0
-2
src/any_tuple.cpp
src/any_tuple.cpp
+7
-12
src/self.cpp
src/self.cpp
+3
-3
src/shared_spinlock.cpp
src/shared_spinlock.cpp
+0
-13
src/string_serialization.cpp
src/string_serialization.cpp
+14
-10
src/uniform_type_info.cpp
src/uniform_type_info.cpp
+49
-70
No files found.
cppa/any_tuple.hpp
View file @
db48145f
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include "cppa/cow_tuple.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/comparable.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/detail/tuple_view.hpp"
#include "cppa/detail/tuple_view.hpp"
...
@@ -55,6 +56,7 @@ class any_tuple {
...
@@ -55,6 +56,7 @@ class any_tuple {
public:
public:
typedef
cow_ptr
<
detail
::
abstract_tuple
>
value_ptr
;
typedef
detail
::
abstract_tuple
::
const_iterator
const_iterator
;
typedef
detail
::
abstract_tuple
::
const_iterator
const_iterator
;
/**
/**
...
@@ -74,8 +76,6 @@ class any_tuple {
...
@@ -74,8 +76,6 @@ class any_tuple {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
any_tuple
(
cow_tuple
<
Args
...
>&&
t
)
:
m_vals
(
std
::
move
(
t
.
m_vals
))
{
}
any_tuple
(
cow_tuple
<
Args
...
>&&
t
)
:
m_vals
(
std
::
move
(
t
.
m_vals
))
{
}
explicit
any_tuple
(
detail
::
abstract_tuple
*
);
/**
/**
* @brief Move constructor.
* @brief Move constructor.
*/
*/
...
@@ -143,9 +143,9 @@ class any_tuple {
...
@@ -143,9 +143,9 @@ class any_tuple {
inline
const_iterator
end
()
const
{
return
m_vals
->
end
();
}
inline
const_iterator
end
()
const
{
return
m_vals
->
end
();
}
inline
cow_ptr
<
detail
::
abstract_tuple
>&
vals
()
{
return
m_vals
;
}
inline
value_ptr
&
vals
()
{
return
m_vals
;
}
inline
const
cow_ptr
<
detail
::
abstract_tuple
>&
vals
()
const
{
return
m_vals
;
}
inline
const
value_ptr
&
vals
()
const
{
return
m_vals
;
}
inline
const
cow_ptr
<
detail
::
abstract_tuple
>
&
cvals
()
const
{
return
m_vals
;
}
inline
const
value_ptr
&
cvals
()
const
{
return
m_vals
;
}
inline
const
std
::
type_info
*
type_token
()
const
{
inline
const
std
::
type_info
*
type_token
()
const
{
return
m_vals
->
type_token
();
return
m_vals
->
type_token
();
...
@@ -162,7 +162,7 @@ class any_tuple {
...
@@ -162,7 +162,7 @@ class any_tuple {
typename
util
::
rm_ref
<
T
>::
type
typename
util
::
rm_ref
<
T
>::
type
>::
value
>::
value
>::
type
*
=
0
)
{
>::
type
*
=
0
)
{
static
constexpr
bool
can_optimize
=
std
::
is_reference
<
T
>::
value
static
constexpr
bool
can_optimize
=
std
::
is_reference
<
T
>::
value
&&
!
std
::
is_const
<
T
>::
value
;
&&
!
std
::
is_const
<
T
>::
value
;
std
::
integral_constant
<
bool
,
can_optimize
>
token
;
std
::
integral_constant
<
bool
,
can_optimize
>
token
;
return
any_tuple
{
container_view
(
std
::
forward
<
T
>
(
value
),
token
)};
return
any_tuple
{
container_view
(
std
::
forward
<
T
>
(
value
),
token
)};
...
@@ -179,66 +179,63 @@ class any_tuple {
...
@@ -179,66 +179,63 @@ class any_tuple {
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
static_assert
(
util
::
is_legal_tuple_type
<
converted
>::
value
,
static_assert
(
util
::
is_legal_tuple_type
<
converted
>::
value
,
"T is not a valid tuple type"
);
"T is not a valid tuple type"
);
typedef
typename
std
::
remove_reference
<
T
>::
type
plain_type
;
static
constexpr
bool
can_optimize
=
static
constexpr
bool
can_optimize
=
std
::
is_same
<
converted
,
vtype
>::
value
std
::
is_same
<
converted
,
vtype
>::
value
&&
std
::
is_reference
<
T
>::
value
&&
std
::
is_reference
<
T
>::
value
&&
!
std
::
is_const
<
typename
std
::
remove_reference
<
T
>::
type
>::
value
;
&&
!
std
::
is_const
<
plain_
type
>::
value
;
std
::
integral_constant
<
bool
,
can_optimize
>
token
;
std
::
integral_constant
<
bool
,
can_optimize
>
token
;
return
any_tuple
{
simple_view
(
std
::
forward
<
T
>
(
value
),
token
)};
return
any_tuple
{
simple_view
(
std
::
forward
<
T
>
(
value
),
token
)};
}
}
void
force_detach
()
{
inline
void
force_detach
()
{
m_vals
.
detach
();
}
m_vals
.
detach
();
}
void
reset
();
void
reset
();
explicit
any_tuple
(
detail
::
abstract_tuple
*
);
private:
private:
cow_ptr
<
detail
::
abstract_tuple
>
m_vals
;
value_ptr
m_vals
;
explicit
any_tuple
(
const
cow_ptr
<
detail
::
abstract_tuple
>
&
vals
);
explicit
any_tuple
(
const
value_ptr
&
vals
);
typedef
detail
::
abstract_tuple
*
tup
_ptr
;
typedef
detail
::
abstract_tuple
*
abstract
_ptr
;
template
<
typename
T
>
template
<
typename
T
>
static
inline
tup_ptr
simple_view
(
T
&
value
,
static
inline
abstract_ptr
simple_view
(
T
&
value
,
std
::
true_type
)
{
std
::
integral_constant
<
bool
,
true
>
)
{
return
new
detail
::
tuple_view
<
T
>
(
&
value
);
return
new
detail
::
tuple_view
<
T
>
(
&
value
);
}
}
template
<
typename
First
,
typename
Second
>
template
<
typename
First
,
typename
Second
>
static
inline
tup
_ptr
simple_view
(
std
::
pair
<
First
,
Second
>&
p
,
static
inline
abstract
_ptr
simple_view
(
std
::
pair
<
First
,
Second
>&
p
,
std
::
integral_constant
<
bool
,
true
>
)
{
std
::
true_type
)
{
return
new
detail
::
tuple_view
<
First
,
Second
>
(
&
p
.
first
,
&
p
.
second
);
return
new
detail
::
tuple_view
<
First
,
Second
>
(
&
p
.
first
,
&
p
.
second
);
}
}
template
<
typename
T
>
template
<
typename
T
>
static
inline
tup_ptr
simple_view
(
T
&&
value
,
static
inline
abstract_ptr
simple_view
(
T
&&
value
,
std
::
false_type
)
{
std
::
integral_constant
<
bool
,
false
>
)
{
typedef
typename
util
::
rm_ref
<
T
>::
type
vtype
;
typedef
typename
util
::
rm_ref
<
T
>::
type
vtype
;
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
return
new
detail
::
tuple_vals
<
converted
>
(
std
::
forward
<
T
>
(
value
));
return
new
detail
::
tuple_vals
<
converted
>
(
std
::
forward
<
T
>
(
value
));
}
}
template
<
typename
First
,
typename
Second
>
template
<
typename
First
,
typename
Second
>
static
inline
any_tuple
view
(
std
::
pair
<
First
,
Second
>
p
,
static
inline
any_tuple
view
(
std
::
pair
<
First
,
Second
>
p
,
std
::
false_type
)
{
std
::
integral_constant
<
bool
,
false
>
)
{
return
new
detail
::
tuple_vals
<
First
,
Second
>
(
std
::
move
(
p
.
first
),
return
new
detail
::
tuple_vals
<
First
,
Second
>
(
std
::
move
(
p
.
first
),
std
::
move
(
p
.
second
));
std
::
move
(
p
.
second
));
}
}
template
<
typename
T
>
template
<
typename
T
>
static
inline
detail
::
abstract_tuple
*
container_view
(
T
&
value
,
static
inline
abstract_ptr
container_view
(
T
&
value
,
std
::
true_type
)
{
std
::
integral_constant
<
bool
,
true
>
)
{
return
new
detail
::
container_tuple_view
<
T
>
(
&
value
);
return
new
detail
::
container_tuple_view
<
T
>
(
&
value
);
}
}
template
<
typename
T
>
template
<
typename
T
>
static
inline
detail
::
abstract_tuple
*
container_view
(
T
&&
value
,
static
inline
abstract_ptr
container_view
(
T
&&
value
,
std
::
false_type
)
{
std
::
integral_constant
<
bool
,
false
>
)
{
typedef
typename
util
::
rm_ref
<
T
>::
type
ctype
;
typedef
typename
util
::
rm_ref
<
T
>::
type
ctype
;
return
new
detail
::
container_tuple_view
<
T
>
(
new
ctype
(
std
::
forward
<
T
>
(
value
)),
true
);
auto
cptr
=
new
ctype
(
std
::
forward
<
T
>
(
value
));
return
new
detail
::
container_tuple_view
<
T
>
(
cptr
,
true
);
}
}
};
};
...
...
cppa/detail/abstract_tuple.hpp
View file @
db48145f
...
@@ -87,10 +87,10 @@ class abstract_tuple : public ref_counted {
...
@@ -87,10 +87,10 @@ class abstract_tuple : public ref_counted {
typedef
tuple_iterator
<
abstract_tuple
>
const_iterator
;
typedef
tuple_iterator
<
abstract_tuple
>
const_iterator
;
inline
const_iterator
begin
()
const
{
return
{
this
};
}
inline
const_iterator
begin
()
const
{
return
{
this
};
}
inline
const_iterator
cbegin
()
const
{
return
{
this
};
}
inline
const_iterator
cbegin
()
const
{
return
{
this
};
}
inline
const_iterator
end
()
const
{
return
{
this
,
size
()};
}
inline
const_iterator
end
()
const
{
return
{
this
,
size
()};
}
inline
const_iterator
cend
()
const
{
return
{
this
,
size
()};
}
inline
const_iterator
cend
()
const
{
return
{
this
,
size
()};
}
};
};
...
...
cppa/detail/to_uniform_name.hpp
View file @
db48145f
...
@@ -39,6 +39,9 @@ namespace cppa { namespace detail {
...
@@ -39,6 +39,9 @@ namespace cppa { namespace detail {
std
::
string
to_uniform_name
(
const
std
::
string
&
demangled_name
);
std
::
string
to_uniform_name
(
const
std
::
string
&
demangled_name
);
std
::
string
to_uniform_name
(
const
std
::
type_info
&
tinfo
);
std
::
string
to_uniform_name
(
const
std
::
type_info
&
tinfo
);
template
<
class
T
>
inline
std
::
string
to_uniform_name
()
{
return
to_uniform_name
(
typeid
(
T
));
}
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
#endif // CPPA_TO_UNIFORM_NAME_HPP
#endif // CPPA_TO_UNIFORM_NAME_HPP
cppa/detail/uniform_type_info_map.hpp
View file @
db48145f
...
@@ -84,8 +84,6 @@ class uniform_type_info_map {
...
@@ -84,8 +84,6 @@ class uniform_type_info_map {
// maps sizeof(-integer_type-) to { signed-names-set, unsigned-names-set }
// maps sizeof(-integer_type-) to { signed-names-set, unsigned-names-set }
int_map
m_ints
;
int_map
m_ints
;
};
};
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
...
...
src/any_tuple.cpp
View file @
db48145f
...
@@ -32,28 +32,23 @@
...
@@ -32,28 +32,23 @@
#include "cppa/detail/empty_tuple.hpp"
#include "cppa/detail/empty_tuple.hpp"
#include "cppa/detail/singleton_manager.hpp"
#include "cppa/detail/singleton_manager.hpp"
namespace
{
namespace
cppa
{
inline
cppa
::
detail
::
empty_tuple
*
s_empty_tuple
()
{
namespace
{
return
cppa
::
detail
::
singleton_manager
::
get_empty_tuple
();
inline
detail
::
empty_tuple
*
s_empty_tuple
()
{
return
detail
::
singleton_manager
::
get_empty_tuple
();
}
}
}
// namespace <anonymous>
}
// namespace <anonymous>
namespace
cppa
{
any_tuple
::
any_tuple
()
:
m_vals
(
s_empty_tuple
())
{
}
any_tuple
::
any_tuple
()
:
m_vals
(
s_empty_tuple
())
{
any_tuple
::
any_tuple
(
detail
::
abstract_tuple
*
ptr
)
:
m_vals
(
ptr
)
{
}
}
any_tuple
::
any_tuple
(
detail
::
abstract_tuple
*
ptr
)
:
m_vals
(
ptr
)
{
}
any_tuple
::
any_tuple
(
any_tuple
&&
other
)
:
m_vals
(
s_empty_tuple
())
{
any_tuple
::
any_tuple
(
any_tuple
&&
other
)
:
m_vals
(
s_empty_tuple
())
{
m_vals
.
swap
(
other
.
m_vals
);
m_vals
.
swap
(
other
.
m_vals
);
}
}
any_tuple
::
any_tuple
(
const
cow_ptr
<
detail
::
abstract_tuple
>&
vals
)
:
m_vals
(
vals
)
{
any_tuple
::
any_tuple
(
const
value_ptr
&
vals
)
:
m_vals
(
vals
)
{
}
}
any_tuple
&
any_tuple
::
operator
=
(
any_tuple
&&
other
)
{
any_tuple
&
any_tuple
::
operator
=
(
any_tuple
&&
other
)
{
m_vals
.
swap
(
other
.
m_vals
);
m_vals
.
swap
(
other
.
m_vals
);
...
...
src/self.cpp
View file @
db48145f
...
@@ -38,14 +38,14 @@
...
@@ -38,14 +38,14 @@
#include "cppa/local_actor.hpp"
#include "cppa/local_actor.hpp"
#include "cppa/thread_mapped_actor.hpp"
#include "cppa/thread_mapped_actor.hpp"
namespace
cppa
{
namespace
{
namespace
{
boost
::
thread_specific_ptr
<
cppa
::
local_actor
>
t_this_actor
(
&
cppa
::
self_type
::
cleanup_fun
);
boost
::
thread_specific_ptr
<
local_actor
>
t_this_actor
(
&
self_type
::
cleanup_fun
);
}
// namespace <anonymous>
}
// namespace <anonymous>
namespace
cppa
{
void
self_type
::
cleanup_fun
(
cppa
::
local_actor
*
what
)
{
void
self_type
::
cleanup_fun
(
cppa
::
local_actor
*
what
)
{
if
(
what
)
{
if
(
what
)
{
auto
ptr
=
dynamic_cast
<
thread_mapped_actor
*>
(
what
);
auto
ptr
=
dynamic_cast
<
thread_mapped_actor
*>
(
what
);
...
...
src/shared_spinlock.cpp
View file @
db48145f
...
@@ -63,19 +63,6 @@ void shared_spinlock::lock() {
...
@@ -63,19 +63,6 @@ void shared_spinlock::lock() {
void
shared_spinlock
::
lock_upgrade
()
{
void
shared_spinlock
::
lock_upgrade
()
{
unlock_shared
();
unlock_shared
();
lock
();
lock
();
/*
long v = m_flag.load();
for (;;) {
if (v != 1) {
//std::this_thread::yield();
v = m_flag.load();
}
else if (m_flag.compare_exchange_weak(v, min_long)) {
return;
}
// else: next iteration
}
*/
}
}
void
shared_spinlock
::
unlock
()
{
void
shared_spinlock
::
unlock
()
{
...
...
src/string_serialization.cpp
View file @
db48145f
...
@@ -136,7 +136,8 @@ class string_serializer : public serializer {
...
@@ -136,7 +136,8 @@ class string_serializer : public serializer {
throw
std
::
runtime_error
(
"expected uint64 value after @atom"
);
throw
std
::
runtime_error
(
"expected uint64 value after @atom"
);
}
}
// write atoms as strings instead of integer values
// write atoms as strings instead of integer values
auto
av
=
static_cast
<
atom_value
>
(
get
<
std
::
uint64_t
>
(
value
));
(
pt_writer
(
out
))(
to_string
(
av
));
auto
av
=
static_cast
<
atom_value
>
(
get
<
std
::
uint64_t
>
(
value
));
(
pt_writer
(
out
))(
to_string
(
av
));
}
}
else
{
else
{
value
.
apply
(
pt_writer
(
out
));
value
.
apply
(
pt_writer
(
out
));
...
@@ -202,13 +203,17 @@ class string_deserializer : public deserializer {
...
@@ -202,13 +203,17 @@ class string_deserializer : public deserializer {
inline
std
::
string
::
iterator
next_delimiter
()
{
inline
std
::
string
::
iterator
next_delimiter
()
{
return
std
::
find_if
(
m_pos
,
m_str
.
end
(),
[]
(
char
c
)
->
bool
{
return
std
::
find_if
(
m_pos
,
m_str
.
end
(),
[]
(
char
c
)
->
bool
{
switch
(
c
)
{
switch
(
c
)
{
case
'('
:
case
'('
:
case
')'
:
case
')'
:
case
'{'
:
case
'{'
:
case
'}'
:
case
'}'
:
case
' '
:
case
' '
:
case
','
:
return
true
;
case
','
:
{
default
:
return
false
;
return
true
;
}
default:
{
return
false
;
}
}
}
});
});
}
}
...
@@ -284,8 +289,7 @@ class string_deserializer : public deserializer {
...
@@ -284,8 +289,7 @@ class string_deserializer : public deserializer {
size_t
begin_sequence
()
{
size_t
begin_sequence
()
{
integrity_check
();
integrity_check
();
consume
(
'{'
);
consume
(
'{'
);
auto
list_end
=
std
::
find
(
m_pos
,
m_str
.
end
(),
'}'
);
return
std
::
count
(
m_pos
,
std
::
find
(
m_pos
,
m_str
.
end
(),
'}'
),
','
)
+
1
;
return
std
::
count
(
m_pos
,
list_end
,
','
)
+
1
;
}
}
void
end_sequence
()
{
void
end_sequence
()
{
...
...
src/uniform_type_info.cpp
View file @
db48145f
...
@@ -38,8 +38,6 @@
...
@@ -38,8 +38,6 @@
#include <limits>
#include <limits>
#include <cstring>
#include <cstring>
#include <cstdint>
#include <cstdint>
#include <sstream>
#include <iostream>
#include <type_traits>
#include <type_traits>
#include "cppa/atom.hpp"
#include "cppa/atom.hpp"
...
@@ -64,24 +62,12 @@
...
@@ -64,24 +62,12 @@
#include "cppa/detail/uniform_type_info_map.hpp"
#include "cppa/detail/uniform_type_info_map.hpp"
#include "cppa/detail/default_uniform_type_info_impl.hpp"
#include "cppa/detail/default_uniform_type_info_impl.hpp"
using
std
::
cout
;
namespace
cppa
{
namespace
detail
{
using
std
::
endl
;
using
cppa
::
util
::
void_type
;
namespace
std
{
ostream
&
operator
<<
(
ostream
&
o
,
const
cppa
::
actor_ptr
&
)
{
return
o
;
}
istream
&
operator
>>
(
istream
&
i
,
cppa
::
actor_ptr
&
)
{
return
i
;
}
ostream
&
operator
<<
(
ostream
&
o
,
const
cppa
::
util
::
void_type
&
)
{
return
o
;
}
istream
&
operator
>>
(
istream
&
i
,
cppa
::
util
::
void_type
&
)
{
return
i
;
}
}
// namespace std
namespace
{
namespace
{
inline
cppa
::
detail
::
uniform_type_info_map
&
uti_map
()
{
inline
uniform_type_info_map
&
uti_map
()
{
return
*
cppa
::
detail
::
singleton_manager
::
get_uniform_type_info_map
();
return
*
singleton_manager
::
get_uniform_type_info_map
();
}
}
inline
const
char
*
raw_name
(
const
std
::
type_info
&
tinfo
)
{
inline
const
char
*
raw_name
(
const
std
::
type_info
&
tinfo
)
{
...
@@ -93,9 +79,8 @@ inline const char* raw_name(const std::type_info& tinfo) {
...
@@ -93,9 +79,8 @@ inline const char* raw_name(const std::type_info& tinfo) {
}
}
template
<
typename
T
>
template
<
typename
T
>
struct
is_signed
struct
is_signed
:
:
std
::
integral_constant
<
bool
,
std
::
numeric_limits
<
T
>::
is_signed
>
{
std
::
integral_constant
<
bool
,
std
::
numeric_limits
<
T
>::
is_signed
>
{
};
};
template
<
typename
T
>
template
<
typename
T
>
inline
const
char
*
raw_name
()
{
inline
const
char
*
raw_name
()
{
...
@@ -103,54 +88,51 @@ inline const char* raw_name() {
...
@@ -103,54 +88,51 @@ inline const char* raw_name() {
}
}
typedef
std
::
set
<
std
::
string
>
string_set
;
typedef
std
::
set
<
std
::
string
>
string_set
;
typedef
std
::
map
<
int
,
std
::
pair
<
string_set
,
string_set
>
>
int_name_mapping
;
template
<
typename
Int
>
template
<
typename
Int
>
void
push
(
std
::
map
<
int
,
std
::
pair
<
string_set
,
string_set
>>&
ints
,
inline
void
push_impl
(
int_name_mapping
&
ints
,
std
::
true_type
)
{
std
::
integral_constant
<
bool
,
true
>
)
{
// signed version
ints
[
sizeof
(
Int
)].
first
.
insert
(
raw_name
<
Int
>
());
// signed version
ints
[
sizeof
(
Int
)].
first
.
insert
(
raw_name
<
Int
>
());
}
}
template
<
typename
Int
>
template
<
typename
Int
>
void
push
(
std
::
map
<
int
,
std
::
pair
<
string_set
,
string_set
>>&
ints
,
inline
void
push_impl
(
int_name_mapping
&
ints
,
std
::
false_type
)
{
std
::
integral_constant
<
bool
,
false
>
)
{
// unsigned version
ints
[
sizeof
(
Int
)].
second
.
insert
(
raw_name
<
Int
>
());
// unsigned version
ints
[
sizeof
(
Int
)].
second
.
insert
(
raw_name
<
Int
>
());
}
}
template
<
typename
Int
>
template
<
typename
Int
>
void
push
(
std
::
map
<
int
,
std
::
pair
<
string_set
,
string_set
>>
&
ints
)
{
inline
void
push
(
int_name_mapping
&
ints
)
{
push
<
Int
>
(
ints
,
is_signed
<
Int
>
()
);
push
_impl
<
Int
>
(
ints
,
is_signed
<
Int
>
{}
);
}
}
template
<
typename
Int0
,
typename
Int1
,
typename
...
Ints
>
template
<
typename
Int0
,
typename
Int1
,
typename
...
Ints
>
void
push
(
std
::
map
<
int
,
std
::
pair
<
string_set
,
string_set
>>
&
ints
)
{
inline
void
push
(
int_name_mapping
&
ints
)
{
push
<
Int0
>
(
ints
,
is_signed
<
Int0
>
()
);
push
_impl
<
Int0
>
(
ints
,
is_signed
<
Int0
>
{}
);
push
<
Int1
,
Ints
...
>
(
ints
);
push
<
Int1
,
Ints
...
>
(
ints
);
}
}
}
// namespace <anonymous>
const
std
::
string
s_nullptr_type_name
{
"@0"
};
namespace
cppa
{
namespace
detail
{
const
std
::
string
nullptr_type_name
=
"@0"
;
void
serialize_nullptr
(
serializer
*
sink
)
{
void
serialize_nullptr
(
serializer
*
sink
)
{
sink
->
begin_object
(
nullptr_type_name
);
sink
->
begin_object
(
s_
nullptr_type_name
);
sink
->
end_object
();
sink
->
end_object
();
}
}
void
deserialize_nullptr
(
deserializer
*
source
)
{
void
deserialize_nullptr
(
deserializer
*
source
)
{
source
->
begin_object
(
nullptr_type_name
);
source
->
begin_object
(
s_
nullptr_type_name
);
source
->
end_object
();
source
->
end_object
();
}
}
}
// namespace <anonymous>
class
void_type_tinfo
:
public
uniform_type_info
{
class
void_type_tinfo
:
public
uniform_type_info
{
public:
public:
void_type_tinfo
()
:
uniform_type_info
(
to_uniform_name
(
typeid
(
void_type
)
))
{}
void_type_tinfo
()
:
uniform_type_info
(
to_uniform_name
<
util
::
void_type
>
(
))
{}
bool
equals
(
const
std
::
type_info
&
tinfo
)
const
{
bool
equals
(
const
std
::
type_info
&
tinfo
)
const
{
return
typeid
(
void_type
)
==
tinfo
;
return
typeid
(
util
::
void_type
)
==
tinfo
;
}
}
protected:
protected:
...
@@ -184,7 +166,7 @@ class void_type_tinfo : public uniform_type_info {
...
@@ -184,7 +166,7 @@ class void_type_tinfo : public uniform_type_info {
private:
private:
void_type
m_value
;
util
::
void_type
m_value
;
};
};
...
@@ -194,7 +176,7 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
...
@@ -194,7 +176,7 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
static
void
s_serialize
(
const
actor_ptr
&
ptr
,
static
void
s_serialize
(
const
actor_ptr
&
ptr
,
serializer
*
sink
,
serializer
*
sink
,
const
std
::
string
name
)
{
const
std
::
string
&
name
)
{
if
(
ptr
==
nullptr
)
{
if
(
ptr
==
nullptr
)
{
serialize_nullptr
(
sink
);
serialize_nullptr
(
sink
);
}
}
...
@@ -214,10 +196,10 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
...
@@ -214,10 +196,10 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
static
void
s_deserialize
(
actor_ptr
&
ptrref
,
static
void
s_deserialize
(
actor_ptr
&
ptrref
,
deserializer
*
source
,
deserializer
*
source
,
const
std
::
string
name
)
{
const
std
::
string
&
name
)
{
std
::
string
cname
=
source
->
seek_object
();
std
::
string
cname
=
source
->
seek_object
();
if
(
cname
!=
name
)
{
if
(
cname
!=
name
)
{
if
(
cname
==
nullptr_type_name
)
{
if
(
cname
==
s_
nullptr_type_name
)
{
deserialize_nullptr
(
source
);
deserialize_nullptr
(
source
);
ptrref
.
reset
();
ptrref
.
reset
();
}
}
...
@@ -260,9 +242,7 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
...
@@ -260,9 +242,7 @@ class actor_ptr_tinfo : public util::abstract_uniform_type_info<actor_ptr> {
protected:
protected:
void
serialize
(
const
void
*
ptr
,
serializer
*
sink
)
const
{
void
serialize
(
const
void
*
ptr
,
serializer
*
sink
)
const
{
s_serialize
(
*
reinterpret_cast
<
const
actor_ptr
*>
(
ptr
),
s_serialize
(
*
reinterpret_cast
<
const
actor_ptr
*>
(
ptr
),
sink
,
name
());
sink
,
name
());
}
}
void
deserialize
(
void
*
ptr
,
deserializer
*
source
)
const
{
void
deserialize
(
void
*
ptr
,
deserializer
*
source
)
const
{
...
@@ -294,7 +274,7 @@ class group_ptr_tinfo : public util::abstract_uniform_type_info<group_ptr> {
...
@@ -294,7 +274,7 @@ class group_ptr_tinfo : public util::abstract_uniform_type_info<group_ptr> {
const
std
::
string
&
name
)
{
const
std
::
string
&
name
)
{
std
::
string
cname
=
source
->
seek_object
();
std
::
string
cname
=
source
->
seek_object
();
if
(
cname
!=
name
)
{
if
(
cname
!=
name
)
{
if
(
cname
==
nullptr_type_name
)
{
if
(
cname
==
s_
nullptr_type_name
)
{
deserialize_nullptr
(
source
);
deserialize_nullptr
(
source
);
ptrref
.
reset
();
ptrref
.
reset
();
}
}
...
@@ -380,7 +360,7 @@ class channel_ptr_tinfo : public util::abstract_uniform_type_info<channel_ptr> {
...
@@ -380,7 +360,7 @@ class channel_ptr_tinfo : public util::abstract_uniform_type_info<channel_ptr> {
group_ptr_tinfo
::
s_deserialize
(
tmp
,
source
,
group_ptr_type_name
);
group_ptr_tinfo
::
s_deserialize
(
tmp
,
source
,
group_ptr_type_name
);
ptrref
=
tmp
;
ptrref
=
tmp
;
}
}
else
if
(
subobj
==
nullptr_type_name
)
{
(
void
)
source
->
seek_object
();
else
if
(
subobj
==
s_
nullptr_type_name
)
{
(
void
)
source
->
seek_object
();
deserialize_nullptr
(
source
);
deserialize_nullptr
(
source
);
ptrref
.
reset
();
ptrref
.
reset
();
}
}
...
@@ -411,8 +391,7 @@ class channel_ptr_tinfo : public util::abstract_uniform_type_info<channel_ptr> {
...
@@ -411,8 +391,7 @@ class channel_ptr_tinfo : public util::abstract_uniform_type_info<channel_ptr> {
public:
public:
channel_ptr_tinfo
()
:
group_ptr_name
(
to_uniform_name
(
typeid
(
group_ptr
)))
channel_ptr_tinfo
()
:
group_ptr_name
(
to_uniform_name
(
typeid
(
group_ptr
)))
,
actor_ptr_name
(
to_uniform_name
(
typeid
(
actor_ptr
)))
{
,
actor_ptr_name
(
to_uniform_name
(
typeid
(
actor_ptr
)))
{
}
}
};
};
...
@@ -447,7 +426,7 @@ class any_tuple_tinfo : public util::abstract_uniform_type_info<any_tuple> {
...
@@ -447,7 +426,7 @@ class any_tuple_tinfo : public util::abstract_uniform_type_info<any_tuple> {
}
}
source
->
end_sequence
();
source
->
end_sequence
();
source
->
end_object
();
source
->
end_object
();
atref
=
any_tuple
(
result
)
;
atref
=
any_tuple
{
result
}
;
}
}
protected:
protected:
...
@@ -472,8 +451,8 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
...
@@ -472,8 +451,8 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
public:
public:
virtual
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
{
virtual
void
serialize
(
const
void
*
instance
,
serializer
*
sink
)
const
{
const
addressed_message
&
msg
=
*
reinterpret_cast
<
const
addressed_message
*>
(
instance
);
auto
&
msg
=
*
reinterpret_cast
<
const
addressed_message
*>
(
instance
);
const
any_tuple
&
data
=
msg
.
content
();
auto
&
data
=
msg
.
content
();
sink
->
begin_object
(
name
());
sink
->
begin_object
(
name
());
actor_ptr_tinfo
::
s_serialize
(
msg
.
sender
(),
sink
,
actor_ptr_name
);
actor_ptr_tinfo
::
s_serialize
(
msg
.
sender
(),
sink
,
actor_ptr_name
);
channel_ptr_tinfo
::
s_serialize
(
msg
.
receiver
(),
channel_ptr_tinfo
::
s_serialize
(
msg
.
receiver
(),
...
@@ -489,7 +468,7 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
...
@@ -489,7 +468,7 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
auto
tname
=
source
->
seek_object
();
auto
tname
=
source
->
seek_object
();
if
(
tname
!=
name
())
throw
42
;
if
(
tname
!=
name
())
throw
42
;
source
->
begin_object
(
tname
);
source
->
begin_object
(
tname
);
a
ddressed_message
&
msg
=
*
reinterpret_cast
<
addressed_message
*>
(
instance
);
a
uto
&
msg
=
*
reinterpret_cast
<
addressed_message
*>
(
instance
);
//actor_ptr sender;
//actor_ptr sender;
//channel_ptr receiver;
//channel_ptr receiver;
//any_tuple content;
//any_tuple content;
...
@@ -506,11 +485,10 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
...
@@ -506,11 +485,10 @@ class addr_msg_tinfo : public util::abstract_uniform_type_info<addressed_message
// content);
// content);
}
}
addr_msg_tinfo
()
:
any_tuple_name
(
to_uniform_name
(
typeid
(
any_tuple
)))
addr_msg_tinfo
()
:
any_tuple_name
(
to_uniform_name
<
any_tuple
>
())
,
actor_ptr_name
(
to_uniform_name
(
typeid
(
actor_ptr
)))
,
actor_ptr_name
(
to_uniform_name
<
actor_ptr
>
())
,
group_ptr_name
(
to_uniform_name
(
typeid
(
group_ptr
)))
,
group_ptr_name
(
to_uniform_name
<
group_ptr
>
())
,
channel_ptr_name
(
to_uniform_name
(
typeid
(
channel_ptr
)))
{
,
channel_ptr_name
(
to_uniform_name
<
channel_ptr
>
())
{
}
}
};
};
...
@@ -539,7 +517,7 @@ class process_info_ptr_tinfo : public util::abstract_uniform_type_info<process_i
...
@@ -539,7 +517,7 @@ class process_info_ptr_tinfo : public util::abstract_uniform_type_info<process_i
auto
&
ptrref
=
*
reinterpret_cast
<
ptr_type
*>
(
instance
);
auto
&
ptrref
=
*
reinterpret_cast
<
ptr_type
*>
(
instance
);
std
::
string
cname
=
source
->
seek_object
();
std
::
string
cname
=
source
->
seek_object
();
if
(
cname
!=
name
())
{
if
(
cname
!=
name
())
{
if
(
cname
==
nullptr_type_name
)
{
if
(
cname
==
s_
nullptr_type_name
)
{
deserialize_nullptr
(
source
);
deserialize_nullptr
(
source
);
ptrref
.
reset
();
ptrref
.
reset
();
}
}
...
@@ -636,7 +614,7 @@ class int_tinfo : public detail::default_uniform_type_info_impl<T> {
...
@@ -636,7 +614,7 @@ class int_tinfo : public detail::default_uniform_type_info_impl<T> {
:
map_iter
->
second
.
second
;
:
map_iter
->
second
.
second
;
auto
x
=
raw_name
(
tinfo
);
auto
x
=
raw_name
(
tinfo
);
return
std
::
any_of
(
st
.
begin
(),
st
.
end
(),
return
std
::
any_of
(
st
.
begin
(),
st
.
end
(),
[
&
](
const
std
::
string
&
y
)
{
return
x
==
y
;
});
[
&
x
](
const
std
::
string
&
y
)
{
return
x
==
y
;
});
}
}
};
};
...
@@ -669,6 +647,7 @@ class uniform_type_info_map_helper {
...
@@ -669,6 +647,7 @@ class uniform_type_info_map_helper {
};
};
uniform_type_info_map
::
uniform_type_info_map
()
{
uniform_type_info_map
::
uniform_type_info_map
()
{
// inserts all compiler generated raw-names to m_ings
push
<
char
,
signed
char
,
push
<
char
,
signed
char
,
unsigned
char
,
short
,
unsigned
char
,
short
,
signed
short
,
unsigned
short
,
signed
short
,
unsigned
short
,
...
@@ -687,8 +666,8 @@ uniform_type_info_map::uniform_type_info_map() {
...
@@ -687,8 +666,8 @@ uniform_type_info_map::uniform_type_info_map() {
char16_t
,
char32_t
,
char16_t
,
char32_t
,
size_t
,
ptrdiff_t
,
size_t
,
ptrdiff_t
,
intptr_t
>
(
m_ints
);
intptr_t
>
(
m_ints
);
// insert integers
uniform_type_info_map_helper
helper
{
this
};
uniform_type_info_map_helper
helper
{
this
};
// inserts integer type infos
helper
.
insert_int
<
std
::
int8_t
>
();
helper
.
insert_int
<
std
::
int8_t
>
();
helper
.
insert_int
<
std
::
int16_t
>
();
helper
.
insert_int
<
std
::
int16_t
>
();
helper
.
insert_int
<
std
::
int32_t
>
();
helper
.
insert_int
<
std
::
int32_t
>
();
...
@@ -697,7 +676,7 @@ uniform_type_info_map::uniform_type_info_map() {
...
@@ -697,7 +676,7 @@ uniform_type_info_map::uniform_type_info_map() {
helper
.
insert_uint
<
std
::
uint16_t
>
();
helper
.
insert_uint
<
std
::
uint16_t
>
();
helper
.
insert_uint
<
std
::
uint32_t
>
();
helper
.
insert_uint
<
std
::
uint32_t
>
();
helper
.
insert_uint
<
std
::
uint64_t
>
();
helper
.
insert_uint
<
std
::
uint64_t
>
();
// insert
built-in
types
// insert
type infos for "built-in"
types
helper
.
insert_builtin
<
float
>
();
helper
.
insert_builtin
<
float
>
();
helper
.
insert_builtin
<
double
>
();
helper
.
insert_builtin
<
double
>
();
helper
.
insert_builtin
<
std
::
string
>
();
helper
.
insert_builtin
<
std
::
string
>
();
...
@@ -711,7 +690,7 @@ uniform_type_info_map::uniform_type_info_map() {
...
@@ -711,7 +690,7 @@ uniform_type_info_map::uniform_type_info_map() {
insert
({
raw_name
<
channel_ptr
>
()},
new
channel_ptr_tinfo
);
insert
({
raw_name
<
channel_ptr
>
()},
new
channel_ptr_tinfo
);
insert
({
raw_name
<
atom_value
>
()},
new
atom_value_tinfo
);
insert
({
raw_name
<
atom_value
>
()},
new
atom_value_tinfo
);
insert
({
raw_name
<
detail
::
addressed_message
>
()},
new
addr_msg_tinfo
);
insert
({
raw_name
<
detail
::
addressed_message
>
()},
new
addr_msg_tinfo
);
insert
({
raw_name
<
void_type
>
()},
new
void_type_tinfo
);
insert
({
raw_name
<
util
::
void_type
>
()},
new
void_type_tinfo
);
insert
({
raw_name
<
process_information_ptr
>
()},
new
process_info_ptr_tinfo
);
insert
({
raw_name
<
process_information_ptr
>
()},
new
process_info_ptr_tinfo
);
}
}
...
@@ -771,7 +750,7 @@ std::vector<const uniform_type_info*> uniform_type_info_map::get_all() const {
...
@@ -771,7 +750,7 @@ std::vector<const uniform_type_info*> uniform_type_info_map::get_all() const {
namespace
cppa
{
namespace
cppa
{
bool
announce
(
const
std
::
type_info
&
tinfo
,
uniform_type_info
*
utype
)
{
bool
announce
(
const
std
::
type_info
&
tinfo
,
uniform_type_info
*
utype
)
{
return
uti_map
().
insert
({
raw_name
(
tinfo
)
},
utype
);
return
detail
::
uti_map
().
insert
({
detail
::
raw_name
(
tinfo
)
},
utype
);
}
}
uniform_type_info
::
uniform_type_info
(
const
std
::
string
&
str
)
:
m_name
(
str
)
{
}
uniform_type_info
::
uniform_type_info
(
const
std
::
string
&
str
)
:
m_name
(
str
)
{
}
...
@@ -780,11 +759,11 @@ uniform_type_info::~uniform_type_info() {
...
@@ -780,11 +759,11 @@ uniform_type_info::~uniform_type_info() {
}
}
object
uniform_type_info
::
create
()
const
{
object
uniform_type_info
::
create
()
const
{
return
{
new_instance
(),
this
};
return
{
new_instance
(),
this
};
}
}
const
uniform_type_info
*
uniform_type_info
::
from
(
const
std
::
type_info
&
tinf
)
{
const
uniform_type_info
*
uniform_type_info
::
from
(
const
std
::
type_info
&
tinf
)
{
auto
result
=
uti_map
().
by_raw_name
(
raw_name
(
tinf
));
auto
result
=
detail
::
uti_map
().
by_raw_name
(
detail
::
raw_name
(
tinf
));
if
(
result
==
nullptr
)
{
if
(
result
==
nullptr
)
{
std
::
string
error
=
"uniform_type_info::by_type_info(): "
;
std
::
string
error
=
"uniform_type_info::by_type_info(): "
;
error
+=
detail
::
to_uniform_name
(
tinf
);
error
+=
detail
::
to_uniform_name
(
tinf
);
...
@@ -795,7 +774,7 @@ const uniform_type_info* uniform_type_info::from(const std::type_info& tinf) {
...
@@ -795,7 +774,7 @@ const uniform_type_info* uniform_type_info::from(const std::type_info& tinf) {
}
}
const
uniform_type_info
*
uniform_type_info
::
from
(
const
std
::
string
&
name
)
{
const
uniform_type_info
*
uniform_type_info
::
from
(
const
std
::
string
&
name
)
{
auto
result
=
uti_map
().
by_uniform_name
(
name
);
auto
result
=
detail
::
uti_map
().
by_uniform_name
(
name
);
if
(
result
==
nullptr
)
{
if
(
result
==
nullptr
)
{
throw
std
::
runtime_error
(
name
+
" is an unknown typeid name"
);
throw
std
::
runtime_error
(
name
+
" is an unknown typeid name"
);
}
}
...
@@ -805,11 +784,11 @@ const uniform_type_info* uniform_type_info::from(const std::string& name) {
...
@@ -805,11 +784,11 @@ const uniform_type_info* uniform_type_info::from(const std::string& name) {
object
uniform_type_info
::
deserialize
(
deserializer
*
from
)
const
{
object
uniform_type_info
::
deserialize
(
deserializer
*
from
)
const
{
auto
ptr
=
new_instance
();
auto
ptr
=
new_instance
();
deserialize
(
ptr
,
from
);
deserialize
(
ptr
,
from
);
return
{
ptr
,
this
};
return
{
ptr
,
this
};
}
}
std
::
vector
<
const
uniform_type_info
*>
uniform_type_info
::
instances
()
{
std
::
vector
<
const
uniform_type_info
*>
uniform_type_info
::
instances
()
{
return
uti_map
().
get_all
();
return
detail
::
uti_map
().
get_all
();
}
}
const
uniform_type_info
*
uniform_typeid
(
const
std
::
type_info
&
tinfo
)
{
const
uniform_type_info
*
uniform_typeid
(
const
std
::
type_info
&
tinfo
)
{
...
...
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