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
d305b645
Commit
d305b645
authored
Jan 17, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintenance
parent
ada8fbb3
Changes
31
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
436 additions
and
197 deletions
+436
-197
Makefile.am
Makefile.am
+0
-3
cppa.files
cppa.files
+2
-3
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+22
-21
cppa/detail/abstract_scheduled_actor.hpp
cppa/detail/abstract_scheduled_actor.hpp
+0
-1
cppa/detail/abstract_tuple.hpp
cppa/detail/abstract_tuple.hpp
+1
-1
cppa/detail/decorated_tuple.hpp
cppa/detail/decorated_tuple.hpp
+2
-2
cppa/detail/empty_tuple.hpp
cppa/detail/empty_tuple.hpp
+1
-1
cppa/detail/invokable.hpp
cppa/detail/invokable.hpp
+11
-4
cppa/detail/matches.hpp
cppa/detail/matches.hpp
+261
-0
cppa/detail/object_array.hpp
cppa/detail/object_array.hpp
+1
-1
cppa/detail/tuple_vals.hpp
cppa/detail/tuple_vals.hpp
+2
-2
cppa/from_string.hpp
cppa/from_string.hpp
+2
-2
cppa/get_view.hpp
cppa/get_view.hpp
+3
-1
cppa/object.hpp
cppa/object.hpp
+3
-3
cppa/pattern.hpp
cppa/pattern.hpp
+48
-12
cppa/tuple.hpp
cppa/tuple.hpp
+1
-1
cppa/tuple_cast.hpp
cppa/tuple_cast.hpp
+31
-5
cppa/util/any_tuple_iterator.hpp
cppa/util/any_tuple_iterator.hpp
+0
-97
src/abstract_scheduled_actor.cpp
src/abstract_scheduled_actor.cpp
+9
-3
src/abstract_tuple.cpp
src/abstract_tuple.cpp
+3
-3
src/actor_proxy.cpp
src/actor_proxy.cpp
+2
-2
src/any_tuple.cpp
src/any_tuple.cpp
+4
-4
src/converted_thread_context.cpp
src/converted_thread_context.cpp
+4
-3
src/empty_tuple.cpp
src/empty_tuple.cpp
+1
-1
src/object.cpp
src/object.cpp
+3
-3
src/object_array.cpp
src/object_array.cpp
+8
-8
src/post_office.cpp
src/post_office.cpp
+1
-1
src/uniform_type_info.cpp
src/uniform_type_info.cpp
+1
-1
unit_testing/main.cpp
unit_testing/main.cpp
+0
-3
unit_testing/test__pattern.cpp
unit_testing/test__pattern.cpp
+5
-1
unit_testing/test__serialization.cpp
unit_testing/test__serialization.cpp
+4
-4
No files found.
Makefile.am
View file @
d305b645
...
@@ -13,7 +13,6 @@ libcppa_la_SOURCES = \
...
@@ -13,7 +13,6 @@ libcppa_la_SOURCES = \
src/actor_registry.cpp
\
src/actor_registry.cpp
\
src/addressed_message.cpp
\
src/addressed_message.cpp
\
src/any_tuple.cpp
\
src/any_tuple.cpp
\
src/any_tuple_iterator.cpp
\
src/atom.cpp
\
src/atom.cpp
\
src/attachable.cpp
\
src/attachable.cpp
\
src/binary_deserializer.cpp
\
src/binary_deserializer.cpp
\
...
@@ -120,7 +119,6 @@ nobase_library_include_HEADERS = \
...
@@ -120,7 +119,6 @@ nobase_library_include_HEADERS = \
cppa/detail/object_array.hpp
\
cppa/detail/object_array.hpp
\
cppa/detail/object_impl.hpp
\
cppa/detail/object_impl.hpp
\
cppa/detail/pair_member.hpp
\
cppa/detail/pair_member.hpp
\
cppa/detail/pattern_details.hpp
\
cppa/detail/post_office.hpp
\
cppa/detail/post_office.hpp
\
cppa/detail/post_office_msg.hpp
\
cppa/detail/post_office_msg.hpp
\
cppa/detail/primitive_member.hpp
\
cppa/detail/primitive_member.hpp
\
...
@@ -170,7 +168,6 @@ nobase_library_include_HEADERS = \
...
@@ -170,7 +168,6 @@ nobase_library_include_HEADERS = \
cppa/tuple_view.hpp
\
cppa/tuple_view.hpp
\
cppa/uniform_type_info.hpp
\
cppa/uniform_type_info.hpp
\
cppa/util/abstract_uniform_type_info.hpp
\
cppa/util/abstract_uniform_type_info.hpp
\
cppa/util/any_tuple_iterator.hpp
\
cppa/util/arg_match_t.hpp
\
cppa/util/arg_match_t.hpp
\
cppa/util/at.hpp
\
cppa/util/at.hpp
\
cppa/util/callable_trait.hpp
\
cppa/util/callable_trait.hpp
\
...
...
cppa.files
View file @
d305b645
...
@@ -179,8 +179,6 @@ cppa/detail/delegate.hpp
...
@@ -179,8 +179,6 @@ cppa/detail/delegate.hpp
src/delegate.cpp
src/delegate.cpp
cppa/detail/receive_loop_helper.hpp
cppa/detail/receive_loop_helper.hpp
cppa/util/wrapped.hpp
cppa/util/wrapped.hpp
cppa/util/any_tuple_iterator.hpp
src/any_tuple_iterator.cpp
cppa/detail/boxed.hpp
cppa/detail/boxed.hpp
cppa/detail/unboxed.hpp
cppa/detail/unboxed.hpp
src/invoke_rules.cpp
src/invoke_rules.cpp
...
@@ -207,7 +205,6 @@ src/addressed_message.cpp
...
@@ -207,7 +205,6 @@ src/addressed_message.cpp
unit_testing/test__yield_interface.cpp
unit_testing/test__yield_interface.cpp
cppa/anything.hpp
cppa/anything.hpp
cppa/pattern.hpp
cppa/pattern.hpp
cppa/detail/pattern_details.hpp
unit_testing/test__pattern.cpp
unit_testing/test__pattern.cpp
cppa/util/fixed_vector.hpp
cppa/util/fixed_vector.hpp
cppa/detail/implicit_conversions.hpp
cppa/detail/implicit_conversions.hpp
...
@@ -251,3 +248,5 @@ cppa/util/is_builtin.hpp
...
@@ -251,3 +248,5 @@ cppa/util/is_builtin.hpp
cppa/util/type_pair.hpp
cppa/util/type_pair.hpp
cppa/util/tbind.hpp
cppa/util/tbind.hpp
cppa/util/option.hpp
cppa/util/option.hpp
cppa/tuple_cast.hpp
cppa/detail/matches.hpp
cppa/any_tuple.hpp
View file @
d305b645
...
@@ -39,18 +39,12 @@
...
@@ -39,18 +39,12 @@
namespace
cppa
{
namespace
cppa
{
//template<typename... Types>
//tuple_view<Types...> tuple_cast(any_tuple&& tup);
/**
/**
* @brief Describes a fixed-length tuple with elements of any type.
* @brief Describes a fixed-length tuple with elements of any type.
*/
*/
class
any_tuple
class
any_tuple
{
{
//template<typename... Types>
//friend tuple_view<Types...> tuple_cast(any_tuple&& tup);
cow_ptr
<
detail
::
abstract_tuple
>
m_vals
;
cow_ptr
<
detail
::
abstract_tuple
>
m_vals
;
explicit
any_tuple
(
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
);
explicit
any_tuple
(
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
);
...
@@ -81,7 +75,7 @@ class any_tuple
...
@@ -81,7 +75,7 @@ class any_tuple
void
const
*
at
(
size_t
p
)
const
;
void
const
*
at
(
size_t
p
)
const
;
uniform_type_info
const
&
utype_info
_at
(
size_t
p
)
const
;
uniform_type_info
const
*
type
_at
(
size_t
p
)
const
;
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
()
const
;
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
()
const
;
...
@@ -100,7 +94,28 @@ class any_tuple
...
@@ -100,7 +94,28 @@ class any_tuple
template
<
typename
T
>
template
<
typename
T
>
inline
T
&
get_mutable_as
(
size_t
p
);
inline
T
&
get_mutable_as
(
size_t
p
);
class
const_iterator
{
any_tuple
const
&
ref
;
size_t
p
;
public:
inline
const_iterator
(
any_tuple
const
&
data
,
size_t
pos
=
0
)
:
ref
(
data
),
p
(
pos
)
{
}
inline
void
next
()
{
++
p
;
}
inline
bool
at_end
()
const
{
return
p
>=
ref
.
size
();
}
inline
size_t
position
()
const
{
return
p
;
}
inline
void
const
*
value
()
const
{
return
ref
.
at
(
p
);
}
inline
uniform_type_info
const
*
type
()
const
{
return
ref
.
type_at
(
p
);
}
};
inline
const_iterator
begin
()
const
{
return
{
*
this
};
}
};
};
...
@@ -126,20 +141,6 @@ inline T& any_tuple::get_mutable_as(size_t p)
...
@@ -126,20 +141,6 @@ inline T& any_tuple::get_mutable_as(size_t p)
return
*
reinterpret_cast
<
T
*>
(
mutable_at
(
p
));
return
*
reinterpret_cast
<
T
*>
(
mutable_at
(
p
));
}
}
/*
template<typename... Types>
tuple_view<Types...> tuple_cast(any_tuple const& tup)
{
return tuple_view<Types...>::from(tup.vals());
}
template<typename... Types>
tuple_view<Types...> tuple_cast(any_tuple&& tup)
{
return tuple_view<Types...>::from(std::move(tup.m_vals));
}
*/
}
// namespace cppa
}
// namespace cppa
#endif // ANY_TUPLE_HPP
#endif // ANY_TUPLE_HPP
cppa/detail/abstract_scheduled_actor.hpp
View file @
d305b645
...
@@ -109,7 +109,6 @@ class abstract_scheduled_actor : public abstract_actor<local_actor>
...
@@ -109,7 +109,6 @@ class abstract_scheduled_actor : public abstract_actor<local_actor>
bool
m_has_pending_timeout_request
;
bool
m_has_pending_timeout_request
;
std
::
uint32_t
m_active_timeout_id
;
std
::
uint32_t
m_active_timeout_id
;
pattern
<
atom_value
,
std
::
uint32_t
>
m_pattern
;
public:
public:
...
...
cppa/detail/abstract_tuple.hpp
View file @
d305b645
...
@@ -48,7 +48,7 @@ struct abstract_tuple : ref_counted
...
@@ -48,7 +48,7 @@ struct abstract_tuple : ref_counted
virtual
size_t
size
()
const
=
0
;
virtual
size_t
size
()
const
=
0
;
virtual
abstract_tuple
*
copy
()
const
=
0
;
virtual
abstract_tuple
*
copy
()
const
=
0
;
virtual
void
const
*
at
(
size_t
pos
)
const
=
0
;
virtual
void
const
*
at
(
size_t
pos
)
const
=
0
;
virtual
uniform_type_info
const
&
utype_info
_at
(
size_t
pos
)
const
=
0
;
virtual
uniform_type_info
const
*
type
_at
(
size_t
pos
)
const
=
0
;
virtual
bool
equals
(
abstract_tuple
const
&
other
)
const
;
virtual
bool
equals
(
abstract_tuple
const
&
other
)
const
;
...
...
cppa/detail/decorated_tuple.hpp
View file @
d305b645
...
@@ -85,9 +85,9 @@ class decorated_tuple : public abstract_tuple
...
@@ -85,9 +85,9 @@ class decorated_tuple : public abstract_tuple
return
m_decorated
->
at
(
m_mappings
[
pos
]);
return
m_decorated
->
at
(
m_mappings
[
pos
]);
}
}
virtual
uniform_type_info
const
&
utype_info
_at
(
size_t
pos
)
const
virtual
uniform_type_info
const
*
type
_at
(
size_t
pos
)
const
{
{
return
m_decorated
->
utype_info
_at
(
m_mappings
[
pos
]);
return
m_decorated
->
type
_at
(
m_mappings
[
pos
]);
}
}
virtual
bool
equals
(
abstract_tuple
const
&
)
const
virtual
bool
equals
(
abstract_tuple
const
&
)
const
...
...
cppa/detail/empty_tuple.hpp
View file @
d305b645
...
@@ -43,7 +43,7 @@ struct empty_tuple : cppa::detail::abstract_tuple
...
@@ -43,7 +43,7 @@ struct empty_tuple : cppa::detail::abstract_tuple
abstract_tuple
*
copy
()
const
;
abstract_tuple
*
copy
()
const
;
void
const
*
at
(
size_t
)
const
;
void
const
*
at
(
size_t
)
const
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
uniform_type_info
const
&
utype_info
_at
(
size_t
)
const
;
uniform_type_info
const
*
type
_at
(
size_t
)
const
;
};
};
...
...
cppa/detail/invokable.hpp
View file @
d305b645
...
@@ -39,6 +39,8 @@
...
@@ -39,6 +39,8 @@
#include "cppa/any_tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/intermediate.hpp"
#include "cppa/detail/intermediate.hpp"
// forward declaration
// forward declaration
...
@@ -147,7 +149,8 @@ class invokable_impl : public invokable
...
@@ -147,7 +149,8 @@ class invokable_impl : public invokable
bool
invoke
(
any_tuple
const
&
data
)
const
bool
invoke
(
any_tuple
const
&
data
)
const
{
{
vector_type
mv
;
vector_type
mv
;
if
((
*
m_pattern
)(
data
,
&
mv
))
if
(
detail
::
matches
(
pm_decorated
(
data
.
begin
(),
&
mv
),
m_pattern
->
begin
()))
//if ((*m_pattern)(data, &mv))
{
{
if
(
mv
.
size
()
==
data
.
size
())
if
(
mv
.
size
()
==
data
.
size
())
{
{
...
@@ -169,7 +172,8 @@ class invokable_impl : public invokable
...
@@ -169,7 +172,8 @@ class invokable_impl : public invokable
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
{
{
vector_type
mv
;
vector_type
mv
;
if
((
*
m_pattern
)(
data
,
&
mv
))
//if ((*m_pattern)(data, &mv))
if
(
detail
::
matches
(
pm_decorated
(
data
.
begin
(),
&
mv
),
m_pattern
->
begin
()))
{
{
if
(
mv
.
size
()
==
data
.
size
())
if
(
mv
.
size
()
==
data
.
size
())
{
{
...
@@ -219,7 +223,8 @@ class invokable_impl<TupleClass<>, Pattern, TargetFun> : public invokable
...
@@ -219,7 +223,8 @@ class invokable_impl<TupleClass<>, Pattern, TargetFun> : public invokable
bool
invoke
(
any_tuple
const
&
data
)
const
bool
invoke
(
any_tuple
const
&
data
)
const
{
{
if
((
*
m_pattern
)(
data
,
nullptr
))
if
(
detail
::
matches
(
data
.
begin
(),
m_pattern
->
begin
()))
//if ((*m_pattern)(data, nullptr))
{
{
m_iimpl
.
m_target
();
m_iimpl
.
m_target
();
return
true
;
return
true
;
...
@@ -229,7 +234,9 @@ class invokable_impl<TupleClass<>, Pattern, TargetFun> : public invokable
...
@@ -229,7 +234,9 @@ class invokable_impl<TupleClass<>, Pattern, TargetFun> : public invokable
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
{
{
return
((
*
m_pattern
)(
data
,
nullptr
))
?
&
m_iimpl
:
nullptr
;
return
detail
::
matches
(
data
.
begin
(),
m_pattern
->
begin
())
?
&
m_iimpl
:
nullptr
;
//return ((*m_pattern)(data, nullptr)) ? &m_iimpl : nullptr;
}
}
};
};
...
...
cppa/detail/
pattern_detail
s.hpp
→
cppa/detail/
matche
s.hpp
View file @
d305b645
This diff is collapsed.
Click to expand it.
cppa/detail/object_array.hpp
View file @
d305b645
...
@@ -68,7 +68,7 @@ class object_array : public detail::abstract_tuple
...
@@ -68,7 +68,7 @@ class object_array : public detail::abstract_tuple
bool
equals
(
cppa
::
detail
::
abstract_tuple
const
&
)
const
;
bool
equals
(
cppa
::
detail
::
abstract_tuple
const
&
)
const
;
uniform_type_info
const
&
utype_info
_at
(
size_t
pos
)
const
;
uniform_type_info
const
*
type
_at
(
size_t
pos
)
const
;
};
};
...
...
cppa/detail/tuple_vals.hpp
View file @
d305b645
...
@@ -100,9 +100,9 @@ class tuple_vals : public abstract_tuple
...
@@ -100,9 +100,9 @@ class tuple_vals : public abstract_tuple
return
tdata_at
(
m_data
,
pos
);
return
tdata_at
(
m_data
,
pos
);
}
}
uniform_type_info
const
&
utype_info
_at
(
size_t
pos
)
const
uniform_type_info
const
*
type
_at
(
size_t
pos
)
const
{
{
return
*
(
m_types
[
pos
])
;
return
m_types
[
pos
]
;
}
}
bool
equals
(
abstract_tuple
const
&
other
)
const
bool
equals
(
abstract_tuple
const
&
other
)
const
...
...
cppa/from_string.hpp
View file @
d305b645
...
@@ -47,7 +47,7 @@ T from_string(const std::string &what)
...
@@ -47,7 +47,7 @@ T from_string(const std::string &what)
{
{
object
o
=
from_string
(
what
);
object
o
=
from_string
(
what
);
std
::
type_info
const
&
tinfo
=
typeid
(
T
);
std
::
type_info
const
&
tinfo
=
typeid
(
T
);
if
(
o
.
type
()
==
tinfo
)
if
(
tinfo
==
*
(
o
.
type
())
)
{
{
return
std
::
move
(
get
<
T
>
(
o
));
return
std
::
move
(
get
<
T
>
(
o
));
}
}
...
@@ -56,7 +56,7 @@ T from_string(const std::string &what)
...
@@ -56,7 +56,7 @@ T from_string(const std::string &what)
std
::
string
error_msg
=
"expected type name "
;
std
::
string
error_msg
=
"expected type name "
;
error_msg
+=
uniform_typeid
(
tinfo
)
->
name
();
error_msg
+=
uniform_typeid
(
tinfo
)
->
name
();
error_msg
+=
" found "
;
error_msg
+=
" found "
;
error_msg
+=
o
.
type
()
.
name
();
error_msg
+=
o
.
type
()
->
name
();
throw
std
::
logic_error
(
error_msg
);
throw
std
::
logic_error
(
error_msg
);
}
}
}
}
...
...
cppa/get_view.hpp
View file @
d305b645
...
@@ -43,6 +43,8 @@
...
@@ -43,6 +43,8 @@
#include "cppa/util/tbind.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/detail/matches.hpp"
namespace
cppa
{
namespace
cppa
{
template
<
typename
...
MatchRules
>
template
<
typename
...
MatchRules
>
...
@@ -51,7 +53,7 @@ get_view(any_tuple const& ut)
...
@@ -51,7 +53,7 @@ get_view(any_tuple const& ut)
{
{
pattern
<
MatchRules
...
>
p
;
pattern
<
MatchRules
...
>
p
;
typename
pattern
<
MatchRules
...
>::
mapping_vector
mapping
;
typename
pattern
<
MatchRules
...
>::
mapping_vector
mapping
;
if
(
p
(
ut
,
&
mapping
))
if
(
detail
::
matches
(
detail
::
pm_decorated
(
ut
.
begin
(),
&
mapping
),
p
.
begin
()
))
{
{
return
{
ut
.
vals
(),
mapping
};
return
{
ut
.
vals
(),
mapping
};
}
}
...
...
cppa/object.hpp
View file @
d305b645
...
@@ -126,7 +126,7 @@ class object
...
@@ -126,7 +126,7 @@ class object
* @returns A {@link uniform_type_info} describing the current
* @returns A {@link uniform_type_info} describing the current
* type of @p this.
* type of @p this.
*/
*/
uniform_type_info
const
&
type
()
const
;
uniform_type_info
const
*
type
()
const
;
/**
/**
* @brief Gets the stored value.
* @brief Gets the stored value.
...
@@ -180,7 +180,7 @@ T& get_ref(object& obj)
...
@@ -180,7 +180,7 @@ T& get_ref(object& obj)
{
{
static_assert
(
!
std
::
is_pointer
<
T
>::
value
&&
!
std
::
is_reference
<
T
>::
value
,
static_assert
(
!
std
::
is_pointer
<
T
>::
value
&&
!
std
::
is_reference
<
T
>::
value
,
"T is a reference or a pointer type."
);
"T is a reference or a pointer type."
);
if
(
!
(
obj
.
type
(
)
==
typeid
(
T
)))
if
(
!
(
*
(
obj
.
type
()
)
==
typeid
(
T
)))
{
{
throw
std
::
invalid_argument
(
"obj.type() != typeid(T)"
);
throw
std
::
invalid_argument
(
"obj.type() != typeid(T)"
);
}
}
...
@@ -192,7 +192,7 @@ T const& get(object const& obj)
...
@@ -192,7 +192,7 @@ T const& get(object const& obj)
{
{
static_assert
(
!
std
::
is_pointer
<
T
>::
value
&&
!
std
::
is_reference
<
T
>::
value
,
static_assert
(
!
std
::
is_pointer
<
T
>::
value
&&
!
std
::
is_reference
<
T
>::
value
,
"T is a reference or a pointer type."
);
"T is a reference or a pointer type."
);
if
(
!
(
obj
.
type
(
)
==
typeid
(
T
)))
if
(
!
(
*
(
obj
.
type
()
)
==
typeid
(
T
)))
{
{
throw
std
::
invalid_argument
(
"obj.type() != typeid(T)"
);
throw
std
::
invalid_argument
(
"obj.type() != typeid(T)"
);
}
}
...
...
cppa/pattern.hpp
View file @
d305b645
...
@@ -42,9 +42,9 @@
...
@@ -42,9 +42,9 @@
#include "cppa/util/tbind.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/detail/boxed.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/types_array.hpp"
#include "cppa/detail/types_array.hpp"
#include "cppa/detail/pattern_details.hpp"
namespace
cppa
{
namespace
cppa
{
...
@@ -75,6 +75,53 @@ class pattern
...
@@ -75,6 +75,53 @@ class pattern
typedef
typename
tuple_view_type
::
mapping_vector
mapping_vector
;
typedef
typename
tuple_view_type
::
mapping_vector
mapping_vector
;
class
const_iterator
{
pattern
const
*
m_ptr
;
size_t
m_pos
;
public:
const_iterator
(
pattern
const
*
ptr
)
:
m_ptr
(
ptr
),
m_pos
(
0
)
{
}
const_iterator
(
const_iterator
const
&
)
=
default
;
const_iterator
&
operator
=
(
const_iterator
const
&
)
=
default
;
const_iterator
&
next
()
{
++
m_pos
;
return
*
this
;
}
inline
bool
at_end
()
{
return
m_pos
==
sizeof
...(
Types
);
}
inline
uniform_type_info
const
*
type
()
const
{
return
m_ptr
->
m_utis
[
m_pos
];
}
inline
bool
has_value
()
const
{
return
m_ptr
->
m_data_ptr
[
m_pos
]
!=
nullptr
;
}
inline
void
const
*
value
()
const
{
return
m_ptr
->
m_data_ptr
[
m_pos
];
}
};
const_iterator
begin
()
const
{
return
{
this
};
}
pattern
()
pattern
()
{
{
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
...
@@ -98,18 +145,7 @@ class pattern
...
@@ -98,18 +145,7 @@ class pattern
}
}
}
}
bool
operator
()(
cppa
::
any_tuple
const
&
msg
,
mapping_vector
*
mapping
=
nullptr
)
const
{
detail
::
pattern_iterator
<
decltype
(
m_utis
)
>
arg0
(
size
,
m_data_ptr
,
m_utis
);
detail
::
tuple_iterator_arg
<
any_tuple
,
mapping_vector
>
arg1
(
msg
,
mapping
);
return
detail
::
do_match
(
arg0
,
arg1
);
}
// private:
detail
::
tdata
<
Types
...
>
m_data
;
detail
::
tdata
<
Types
...
>
m_data
;
//cppa::uniform_type_info const* m_utis[size];
static
detail
::
types_array
<
Types
...
>
m_utis
;
static
detail
::
types_array
<
Types
...
>
m_utis
;
void
const
*
m_data_ptr
[
size
];
void
const
*
m_data_ptr
[
size
];
...
...
cppa/tuple.hpp
View file @
d305b645
...
@@ -152,7 +152,7 @@ class tuple
...
@@ -152,7 +152,7 @@ class tuple
*/
*/
inline
uniform_type_info
const
*
utype_at
(
size_t
p
)
const
inline
uniform_type_info
const
*
utype_at
(
size_t
p
)
const
{
{
return
m_vals
->
utype_info
_at
(
p
);
return
m_vals
->
type
_at
(
p
);
}
}
# ifdef CPPA_DOCUMENTATION
# ifdef CPPA_DOCUMENTATION
...
...
src/any_tuple_iterator.c
pp
→
cppa/tuple_cast.h
pp
View file @
d305b645
...
@@ -28,13 +28,39 @@
...
@@ -28,13 +28,39 @@
\******************************************************************************/
\******************************************************************************/
#include "cppa/util/any_tuple_iterator.hpp"
#ifndef TUPLE_CAST_HPP
#define TUPLE_CAST_HPP
namespace
cppa
{
namespace
util
{
#include "cppa/pattern.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/util/option.hpp"
#include "cppa/detail/matches.hpp"
any_tuple_iterator
::
any_tuple_iterator
(
const
any_tuple
&
data
,
size_t
pos
)
namespace
cppa
{
:
m_data
(
data
),
m_pos
(
pos
)
template
<
typename
...
P
>
auto
tuple_cast
(
any_tuple
const
&
tup
,
pattern
<
P
...
>
const
&
p
)
->
util
::
option
<
typename
tuple_from_type_list
<
typename
pattern
<
P
...
>::
filtered_types
>::
type
>
{
{
typedef
typename
pattern
<
P
...
>::
mapping_vector
mapping_vector
;
typedef
typename
pattern
<
P
...
>::
filtered_types
filtered_types
;
typedef
typename
tuple_from_type_list
<
filtered_types
>::
type
tuple_type
;
util
::
option
<
tuple_type
>
result
;
mapping_vector
mv
;
if
(
detail
::
matches
(
detail
::
pm_decorated
(
tup
.
begin
(),
&
mv
),
p
.
begin
()))
{
if
(
mv
.
size
()
==
tup
.
size
())
// perfect match
{
result
=
tuple_type
::
from
(
tup
.
vals
());
}
else
{
result
=
tuple_type
::
from
(
new
detail
::
decorated_tuple
<
filtered_types
::
size
>
(
tup
.
vals
(),
mv
));
}
}
return
std
::
move
(
result
);
}
}
}
}
}
// namespace cppa::util
#endif // TUPLE_CAST_HPP
cppa/util/any_tuple_iterator.hpp
deleted
100644 → 0
View file @
ada8fbb3
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef ANY_TUPLE_ITERATOR_HPP
#define ANY_TUPLE_ITERATOR_HPP
#include "cppa/any_tuple.hpp"
namespace
cppa
{
namespace
util
{
class
any_tuple_iterator
{
any_tuple
const
&
m_data
;
size_t
m_pos
;
public:
any_tuple_iterator
(
any_tuple
const
&
data
,
size_t
pos
=
0
);
inline
bool
at_end
()
const
;
template
<
typename
T
>
inline
T
const
&
value
()
const
;
inline
void
const
*
value_ptr
()
const
;
inline
cppa
::
uniform_type_info
const
&
type
()
const
;
inline
size_t
position
()
const
;
inline
void
next
();
};
inline
bool
any_tuple_iterator
::
at_end
()
const
{
return
m_pos
>=
m_data
.
size
();
}
template
<
typename
T
>
inline
T
const
&
any_tuple_iterator
::
value
()
const
{
return
*
reinterpret_cast
<
T
const
*>
(
m_data
.
at
(
m_pos
));
}
inline
uniform_type_info
const
&
any_tuple_iterator
::
type
()
const
{
return
m_data
.
utype_info_at
(
m_pos
);
}
inline
void
const
*
any_tuple_iterator
::
value_ptr
()
const
{
return
m_data
.
at
(
m_pos
);
}
inline
size_t
any_tuple_iterator
::
position
()
const
{
return
m_pos
;
}
inline
void
any_tuple_iterator
::
next
()
{
++
m_pos
;
}
}
}
// namespace cppa::util
#endif // ANY_TUPLE_ITERATOR_HPP
src/abstract_scheduled_actor.cpp
View file @
d305b645
...
@@ -30,13 +30,17 @@
...
@@ -30,13 +30,17 @@
#include "cppa/cppa.hpp"
#include "cppa/cppa.hpp"
#include "cppa/exception.hpp"
#include "cppa/exception.hpp"
#include "cppa/detail/types_array.hpp"
#include "cppa/detail/task_scheduler.hpp"
#include "cppa/detail/task_scheduler.hpp"
#include "cppa/detail/abstract_scheduled_actor.hpp"
#include "cppa/detail/yield_interface.hpp"
#include "cppa/detail/yield_interface.hpp"
#include "cppa/detail/abstract_scheduled_actor.hpp"
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
namespace
{
void
dummy_enqueue
(
void
*
,
abstract_scheduled_actor
*
)
{
}
}
namespace
{
void
dummy_enqueue
(
void
*
,
abstract_scheduled_actor
*
)
{
}
types_array
<
atom_value
,
std
::
uint32_t
>
t_atom_ui32_types
;
}
abstract_scheduled_actor
::
abstract_scheduled_actor
(
int
state
)
abstract_scheduled_actor
::
abstract_scheduled_actor
(
int
state
)
:
next
(
nullptr
)
:
next
(
nullptr
)
...
@@ -124,7 +128,9 @@ void abstract_scheduled_actor::request_timeout(util::duration const& d)
...
@@ -124,7 +128,9 @@ void abstract_scheduled_actor::request_timeout(util::duration const& d)
auto
abstract_scheduled_actor
::
filter_msg
(
const
any_tuple
&
msg
)
->
filter_result
auto
abstract_scheduled_actor
::
filter_msg
(
const
any_tuple
&
msg
)
->
filter_result
{
{
if
(
m_pattern
(
msg
))
if
(
msg
.
size
()
==
2
&&
msg
.
type_at
(
0
)
==
t_atom_ui32_types
[
0
]
&&
msg
.
type_at
(
1
)
==
t_atom_ui32_types
[
1
])
{
{
auto
v0
=
*
reinterpret_cast
<
const
atom_value
*>
(
msg
.
at
(
0
));
auto
v0
=
*
reinterpret_cast
<
const
atom_value
*>
(
msg
.
at
(
0
));
auto
v1
=
*
reinterpret_cast
<
const
std
::
uint32_t
*>
(
msg
.
at
(
1
));
auto
v1
=
*
reinterpret_cast
<
const
std
::
uint32_t
*>
(
msg
.
at
(
1
));
...
...
src/abstract_tuple.cpp
View file @
d305b645
...
@@ -38,12 +38,12 @@ bool abstract_tuple::equals(const abstract_tuple &other) const
...
@@ -38,12 +38,12 @@ bool abstract_tuple::equals(const abstract_tuple &other) const
if
(
size
()
!=
other
.
size
())
return
false
;
if
(
size
()
!=
other
.
size
())
return
false
;
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
{
{
const
cppa
::
uniform_type_info
&
uti
=
utype_info
_at
(
i
);
auto
uti
=
type
_at
(
i
);
if
(
uti
!=
other
.
utype_info
_at
(
i
))
return
false
;
if
(
uti
!=
other
.
type
_at
(
i
))
return
false
;
auto
lhs
=
at
(
i
);
auto
lhs
=
at
(
i
);
auto
rhs
=
other
.
at
(
i
);
auto
rhs
=
other
.
at
(
i
);
// compare first addresses, then values
// compare first addresses, then values
if
(
lhs
!=
rhs
&&
!
(
uti
.
equals
(
lhs
,
rhs
)))
return
false
;
if
(
lhs
!=
rhs
&&
!
(
uti
->
equals
(
lhs
,
rhs
)))
return
false
;
}
}
return
true
;
return
true
;
}
}
...
...
src/actor_proxy.cpp
View file @
d305b645
...
@@ -104,9 +104,9 @@ void actor_proxy::enqueue(actor* sender, const any_tuple& msg)
...
@@ -104,9 +104,9 @@ void actor_proxy::enqueue(actor* sender, const any_tuple& msg)
}
}
*/
*/
if
(
msg
.
size
()
==
2
if
(
msg
.
size
()
==
2
&&
msg
.
utype_info_at
(
0
)
==
typeid
(
atom_value
)
&&
*
(
msg
.
type_at
(
0
)
)
==
typeid
(
atom_value
)
&&
msg
.
get_as
<
atom_value
>
(
0
)
==
atom
(
":KillProxy"
)
&&
msg
.
get_as
<
atom_value
>
(
0
)
==
atom
(
":KillProxy"
)
&&
msg
.
utype_info_at
(
1
)
==
typeid
(
std
::
uint32_t
))
&&
*
(
msg
.
type_at
(
1
)
)
==
typeid
(
std
::
uint32_t
))
{
{
cleanup
(
msg
.
get_as
<
std
::
uint32_t
>
(
1
));
cleanup
(
msg
.
get_as
<
std
::
uint32_t
>
(
1
));
return
;
return
;
...
...
src/any_tuple.cpp
View file @
d305b645
...
@@ -65,9 +65,9 @@ struct offset_decorator : cppa::detail::abstract_tuple
...
@@ -65,9 +65,9 @@ struct offset_decorator : cppa::detail::abstract_tuple
return
m_decorated
->
at
(
pos
+
m_offset
);
return
m_decorated
->
at
(
pos
+
m_offset
);
}
}
const
cppa
::
uniform_type_info
&
utype_info
_at
(
size_t
pos
)
const
const
cppa
::
uniform_type_info
*
type
_at
(
size_t
pos
)
const
{
{
return
m_decorated
->
utype_info
_at
(
pos
+
m_offset
);
return
m_decorated
->
type
_at
(
pos
+
m_offset
);
}
}
private:
private:
...
@@ -131,9 +131,9 @@ const void* any_tuple::at(size_t p) const
...
@@ -131,9 +131,9 @@ const void* any_tuple::at(size_t p) const
return
m_vals
->
at
(
p
);
return
m_vals
->
at
(
p
);
}
}
const
uniform_type_info
&
any_tuple
::
utype_info
_at
(
size_t
p
)
const
const
uniform_type_info
*
any_tuple
::
type
_at
(
size_t
p
)
const
{
{
return
m_vals
->
utype_info
_at
(
p
);
return
m_vals
->
type
_at
(
p
);
}
}
const
cow_ptr
<
detail
::
abstract_tuple
>&
any_tuple
::
vals
()
const
const
cow_ptr
<
detail
::
abstract_tuple
>&
any_tuple
::
vals
()
const
...
...
src/converted_thread_context.cpp
View file @
d305b645
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "cppa/self.hpp"
#include "cppa/self.hpp"
#include "cppa/exception.hpp"
#include "cppa/exception.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/invokable.hpp"
#include "cppa/detail/invokable.hpp"
#include "cppa/detail/intermediate.hpp"
#include "cppa/detail/intermediate.hpp"
#include "cppa/detail/converted_thread_context.hpp"
#include "cppa/detail/converted_thread_context.hpp"
...
@@ -62,13 +63,11 @@ void converted_thread_context::cleanup(std::uint32_t reason)
...
@@ -62,13 +63,11 @@ void converted_thread_context::cleanup(std::uint32_t reason)
void
converted_thread_context
::
enqueue
(
actor
*
sender
,
any_tuple
&&
msg
)
void
converted_thread_context
::
enqueue
(
actor
*
sender
,
any_tuple
&&
msg
)
{
{
m_mailbox
.
push_back
(
fetch_node
(
sender
,
std
::
move
(
msg
)));
m_mailbox
.
push_back
(
fetch_node
(
sender
,
std
::
move
(
msg
)));
//m_mailbox.push_back(new queue_node(sender, std::move(msg)));
}
}
void
converted_thread_context
::
enqueue
(
actor
*
sender
,
const
any_tuple
&
msg
)
void
converted_thread_context
::
enqueue
(
actor
*
sender
,
const
any_tuple
&
msg
)
{
{
m_mailbox
.
push_back
(
fetch_node
(
sender
,
msg
));
m_mailbox
.
push_back
(
fetch_node
(
sender
,
msg
));
//m_mailbox.push_back(new queue_node(sender, msg));
}
}
void
converted_thread_context
::
dequeue
(
invoke_rules
&
rules
)
/*override*/
void
converted_thread_context
::
dequeue
(
invoke_rules
&
rules
)
/*override*/
...
@@ -105,7 +104,9 @@ void converted_thread_context::dequeue(timed_invoke_rules& rules) /*override*/
...
@@ -105,7 +104,9 @@ void converted_thread_context::dequeue(timed_invoke_rules& rules) /*override*/
converted_thread_context
::
throw_on_exit_result
converted_thread_context
::
throw_on_exit_result
converted_thread_context
::
throw_on_exit
(
const
any_tuple
&
msg
)
converted_thread_context
::
throw_on_exit
(
const
any_tuple
&
msg
)
{
{
if
(
m_exit_msg_pattern
(
msg
))
pattern
<
atom_value
,
actor_ptr
,
std
::
uint32_t
>::
mapping_vector
*
ptr
=
nullptr
;
auto
j
=
m_exit_msg_pattern
.
begin
();
if
(
detail
::
matches
(
pm_decorated
(
msg
.
begin
(),
ptr
),
j
))
{
{
auto
reason
=
*
reinterpret_cast
<
const
std
::
uint32_t
*>
(
msg
.
at
(
2
));
auto
reason
=
*
reinterpret_cast
<
const
std
::
uint32_t
*>
(
msg
.
at
(
2
));
if
(
reason
!=
exit_reason
::
normal
)
if
(
reason
!=
exit_reason
::
normal
)
...
...
src/empty_tuple.cpp
View file @
d305b645
...
@@ -53,7 +53,7 @@ const void* empty_tuple::at(size_t) const
...
@@ -53,7 +53,7 @@ const void* empty_tuple::at(size_t) const
throw
std
::
range_error
(
"empty_tuple::at()"
);
throw
std
::
range_error
(
"empty_tuple::at()"
);
}
}
const
uniform_type_info
&
empty_tuple
::
utype_info
_at
(
size_t
)
const
const
uniform_type_info
*
empty_tuple
::
type
_at
(
size_t
)
const
{
{
throw
std
::
range_error
(
"empty_tuple::type_at()"
);
throw
std
::
range_error
(
"empty_tuple::type_at()"
);
}
}
...
...
src/object.cpp
View file @
d305b645
...
@@ -103,14 +103,14 @@ bool operator==(const object& lhs, const object& rhs)
...
@@ -103,14 +103,14 @@ bool operator==(const object& lhs, const object& rhs)
{
{
// values might both point to s_void if lhs and rhs are "empty"
// values might both point to s_void if lhs and rhs are "empty"
return
lhs
.
value
()
==
rhs
.
value
()
return
lhs
.
value
()
==
rhs
.
value
()
||
lhs
.
type
()
.
equals
(
lhs
.
value
(),
rhs
.
value
());
||
lhs
.
type
()
->
equals
(
lhs
.
value
(),
rhs
.
value
());
}
}
return
false
;
return
false
;
}
}
const
uniform_type_info
&
object
::
type
()
const
uniform_type_info
const
*
object
::
type
()
const
{
{
return
*
m_type
;
return
m_type
;
}
}
const
void
*
object
::
value
()
const
const
void
*
object
::
value
()
const
...
...
src/object_array.cpp
View file @
d305b645
...
@@ -41,12 +41,12 @@ object_array::object_array(object_array&& other)
...
@@ -41,12 +41,12 @@ object_array::object_array(object_array&& other)
{
{
}
}
object_array
::
object_array
(
const
object_array
&
other
)
object_array
::
object_array
(
object_array
const
&
other
)
:
m_elements
(
other
.
m_elements
)
:
m_elements
(
other
.
m_elements
)
{
{
}
}
void
object_array
::
push_back
(
const
objec
t
&
what
)
void
object_array
::
push_back
(
object
cons
t
&
what
)
{
{
m_elements
.
push_back
(
what
);
m_elements
.
push_back
(
what
);
}
}
...
@@ -71,21 +71,21 @@ abstract_tuple* object_array::copy() const
...
@@ -71,21 +71,21 @@ abstract_tuple* object_array::copy() const
return
new
object_array
(
*
this
);
return
new
object_array
(
*
this
);
}
}
const
void
*
object_array
::
at
(
size_t
pos
)
const
void
const
*
object_array
::
at
(
size_t
pos
)
const
{
{
return
m_elements
[
pos
].
value
();
return
m_elements
[
pos
].
value
();
}
}
bool
object_array
::
equals
(
c
onst
cppa
::
detail
::
abstract_tuple
&
ut
)
const
bool
object_array
::
equals
(
c
ppa
::
detail
::
abstract_tuple
const
&
ut
)
const
{
{
if
(
size
()
==
ut
.
size
())
if
(
size
()
==
ut
.
size
())
{
{
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
{
{
const
uniform_type_info
&
utype
=
utype_info
_at
(
i
);
auto
utype
=
type
_at
(
i
);
if
(
utype
==
ut
.
utype_info
_at
(
i
))
if
(
utype
==
ut
.
type
_at
(
i
))
{
{
if
(
!
utype
.
equals
(
at
(
i
),
ut
.
at
(
i
)))
return
false
;
if
(
!
utype
->
equals
(
at
(
i
),
ut
.
at
(
i
)))
return
false
;
}
}
else
else
{
{
...
@@ -97,7 +97,7 @@ bool object_array::equals(const cppa::detail::abstract_tuple& ut) const
...
@@ -97,7 +97,7 @@ bool object_array::equals(const cppa::detail::abstract_tuple& ut) const
return
false
;
return
false
;
}
}
const
uniform_type_info
&
object_array
::
utype_info
_at
(
size_t
pos
)
const
uniform_type_info
const
*
object_array
::
type
_at
(
size_t
pos
)
const
{
{
return
m_elements
[
pos
].
type
();
return
m_elements
[
pos
].
type
();
}
}
...
...
src/post_office.cpp
View file @
d305b645
...
@@ -323,7 +323,7 @@ class po_peer
...
@@ -323,7 +323,7 @@ class po_peer
auto
&
content
=
msg
.
content
();
auto
&
content
=
msg
.
content
();
DEBUG
(
"<-- "
<<
to_string
(
content
));
DEBUG
(
"<-- "
<<
to_string
(
content
));
if
(
content
.
size
()
==
1
if
(
content
.
size
()
==
1
&&
content
.
utype_info_at
(
0
)
==
typeid
(
atom_value
)
&&
*
(
content
.
type_at
(
0
)
)
==
typeid
(
atom_value
)
&&
content
.
get_as
<
atom_value
>
(
0
)
==
atom
(
":Monitor"
))
&&
content
.
get_as
<
atom_value
>
(
0
)
==
atom
(
":Monitor"
))
{
{
auto
receiver
=
msg
.
receiver
().
downcast
<
actor
>
();
auto
receiver
=
msg
.
receiver
().
downcast
<
actor
>
();
...
...
src/uniform_type_info.cpp
View file @
d305b645
...
@@ -453,7 +453,7 @@ class any_tuple_tinfo : public util::abstract_uniform_type_info<any_tuple>
...
@@ -453,7 +453,7 @@ class any_tuple_tinfo : public util::abstract_uniform_type_info<any_tuple>
sink
->
begin_sequence
(
atup
.
size
());
sink
->
begin_sequence
(
atup
.
size
());
for
(
size_t
i
=
0
;
i
<
atup
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
atup
.
size
();
++
i
)
{
{
atup
.
utype_info_at
(
i
).
serialize
(
atup
.
at
(
i
),
sink
);
atup
.
type_at
(
i
)
->
serialize
(
atup
.
at
(
i
),
sink
);
}
}
sink
->
end_sequence
();
sink
->
end_sequence
();
sink
->
end_object
();
sink
->
end_object
();
...
...
unit_testing/main.cpp
View file @
d305b645
...
@@ -25,9 +25,6 @@
...
@@ -25,9 +25,6 @@
#include "cppa/detail/task_scheduler.hpp"
#include "cppa/detail/task_scheduler.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
// header for experimental stuff
#include "cppa/util/any_tuple_iterator.hpp"
#define CPPA_TEST_CATCH_BLOCK() \
#define CPPA_TEST_CATCH_BLOCK() \
catch (std::exception& e) \
catch (std::exception& e) \
{ \
{ \
...
...
unit_testing/test__pattern.cpp
View file @
d305b645
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "cppa/tuple.hpp"
#include "cppa/tuple.hpp"
#include "cppa/pattern.hpp"
#include "cppa/pattern.hpp"
#include "cppa/announce.hpp"
#include "cppa/announce.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/util/option.hpp"
#include "cppa/util/option.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/enable_if.hpp"
...
@@ -36,6 +37,7 @@ typedef std::pair<int,int> foobar;
...
@@ -36,6 +37,7 @@ typedef std::pair<int,int> foobar;
static
detail
::
types_array
<
int
,
anything
,
float
>
arr1
;
static
detail
::
types_array
<
int
,
anything
,
float
>
arr1
;
static
detail
::
types_array
<
int
,
anything
,
foobar
>
arr2
;
static
detail
::
types_array
<
int
,
anything
,
foobar
>
arr2
;
/*
template<typename... P>
template<typename... P>
auto tuple_cast(any_tuple const& tup, pattern<P...> const& p) -> util::option<typename tuple_from_type_list<typename pattern<P...>::filtered_types>::type>
auto tuple_cast(any_tuple const& tup, pattern<P...> const& p) -> util::option<typename tuple_from_type_list<typename pattern<P...>::filtered_types>::type>
{
{
...
@@ -55,7 +57,7 @@ auto tuple_cast(any_tuple const& tup, pattern<P...> const& p) -> util::option<ty
...
@@ -55,7 +57,7 @@ auto tuple_cast(any_tuple const& tup, pattern<P...> const& p) -> util::option<ty
}
}
}
}
return std::move(result);
return std::move(result);
}
}
*/
struct
match_helper
struct
match_helper
{
{
...
@@ -112,6 +114,7 @@ size_t test__pattern()
...
@@ -112,6 +114,7 @@ size_t test__pattern()
pattern
<
atom_value
,
anything
,
std
::
string
>
p8
;
pattern
<
atom_value
,
anything
,
std
::
string
>
p8
;
// each one should accept x ...
// each one should accept x ...
auto
x
=
make_tuple
(
atom
(
"FooBar"
),
42
,
"hello world"
);
auto
x
=
make_tuple
(
atom
(
"FooBar"
),
42
,
"hello world"
);
/*
CPPA_CHECK(p0(x));
CPPA_CHECK(p0(x));
CPPA_CHECK(p1(x));
CPPA_CHECK(p1(x));
CPPA_CHECK(p2(x));
CPPA_CHECK(p2(x));
...
@@ -203,5 +206,6 @@ size_t test__pattern()
...
@@ -203,5 +206,6 @@ size_t test__pattern()
CPPA_CHECK(lambda_invoked[5]);
CPPA_CHECK(lambda_invoked[5]);
reset_invoke_states();
reset_invoke_states();
*/
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
}
}
unit_testing/test__serialization.cpp
View file @
d305b645
...
@@ -180,7 +180,7 @@ size_t test__serialization()
...
@@ -180,7 +180,7 @@ size_t test__serialization()
bd
>>
obj1
;
bd
>>
obj1
;
object
obj2
=
from_string
(
to_string
(
msg1
));
object
obj2
=
from_string
(
to_string
(
msg1
));
CPPA_CHECK_EQUAL
(
obj1
,
obj2
);
CPPA_CHECK_EQUAL
(
obj1
,
obj2
);
if
(
obj1
.
type
()
==
typeid
(
any_tuple
)
&&
obj2
.
type
()
==
obj1
.
type
())
if
(
typeid
(
any_tuple
)
==
*
(
obj1
.
type
()
)
&&
obj2
.
type
()
==
obj1
.
type
())
{
{
auto
&
content1
=
get
<
any_tuple
>
(
obj1
);
auto
&
content1
=
get
<
any_tuple
>
(
obj1
);
auto
&
content2
=
get
<
any_tuple
>
(
obj2
);
auto
&
content2
=
get
<
any_tuple
>
(
obj2
);
...
@@ -241,7 +241,7 @@ size_t test__serialization()
...
@@ -241,7 +241,7 @@ size_t test__serialization()
binary_deserializer
bd
(
bs
.
data
(),
bs
.
size
());
binary_deserializer
bd
(
bs
.
data
(),
bs
.
size
());
object
res
;
object
res
;
bd
>>
res
;
bd
>>
res
;
CPPA_CHECK_EQUAL
(
res
.
type
()
.
name
(),
"struct_b"
);
CPPA_CHECK_EQUAL
(
res
.
type
()
->
name
(),
"struct_b"
);
b2
=
get
<
struct_b
>
(
res
);
b2
=
get
<
struct_b
>
(
res
);
}
}
// verify result of serialization / deserialization
// verify result of serialization / deserialization
...
@@ -250,7 +250,7 @@ size_t test__serialization()
...
@@ -250,7 +250,7 @@ size_t test__serialization()
// deserialize b3 from string
// deserialize b3 from string
{
{
object
res
=
from_string
(
b1str
);
object
res
=
from_string
(
b1str
);
CPPA_CHECK_EQUAL
(
res
.
type
()
.
name
(),
"struct_b"
);
CPPA_CHECK_EQUAL
(
res
.
type
()
->
name
(),
"struct_b"
);
b3
=
get
<
struct_b
>
(
res
);
b3
=
get
<
struct_b
>
(
res
);
}
}
CPPA_CHECK_EQUAL
(
b1
,
b3
);
CPPA_CHECK_EQUAL
(
b1
,
b3
);
...
@@ -270,7 +270,7 @@ size_t test__serialization()
...
@@ -270,7 +270,7 @@ size_t test__serialization()
binary_deserializer
bd
(
bs
.
data
(),
bs
.
size
());
binary_deserializer
bd
(
bs
.
data
(),
bs
.
size
());
object
res
;
object
res
;
bd
>>
res
;
bd
>>
res
;
CPPA_CHECK_EQUAL
(
res
.
type
()
.
name
(),
"struct_c"
);
CPPA_CHECK_EQUAL
(
res
.
type
()
->
name
(),
"struct_c"
);
c2
=
get
<
struct_c
>
(
res
);
c2
=
get
<
struct_c
>
(
res
);
}
}
// verify result of serialization / deserialization
// verify result of serialization / deserialization
...
...
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