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
7ee5a950
Commit
7ee5a950
authored
Apr 09, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pattern matching
parent
30bdfb6a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
51 deletions
+25
-51
Makefile.am
Makefile.am
+0
-1
cppa.files
cppa.files
+0
-1
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+25
-49
No files found.
Makefile.am
View file @
7ee5a950
...
@@ -176,7 +176,6 @@ nobase_library_include_HEADERS = \
...
@@ -176,7 +176,6 @@ nobase_library_include_HEADERS = \
cppa/tuple_cast.hpp
\
cppa/tuple_cast.hpp
\
cppa/type_value_pair.hpp
\
cppa/type_value_pair.hpp
\
cppa/uniform_type_info.hpp
\
cppa/uniform_type_info.hpp
\
cppa/util/a_matches_b.hpp
\
cppa/util/abstract_uniform_type_info.hpp
\
cppa/util/abstract_uniform_type_info.hpp
\
cppa/util/apply_tuple.hpp
\
cppa/util/apply_tuple.hpp
\
cppa/util/arg_match_t.hpp
\
cppa/util/arg_match_t.hpp
\
...
...
cppa.files
View file @
7ee5a950
...
@@ -258,4 +258,3 @@ cppa/detail/matches.hpp
...
@@ -258,4 +258,3 @@ cppa/detail/matches.hpp
unit_testing/test__match.cpp
unit_testing/test__match.cpp
cppa/guard_expr.hpp
cppa/guard_expr.hpp
src/pattern.cpp
src/pattern.cpp
cppa/util/a_matches_b.hpp
unit_testing/test__tuple.cpp
View file @
7ee5a950
...
@@ -317,8 +317,7 @@ class apply_policy<util::type_list<>, Args>
...
@@ -317,8 +317,7 @@ class apply_policy<util::type_list<>, Args>
};
};
template
<
class
InvokePolicy
>
struct
invoke_helper
struct
invoke_helper_
{
{
template
<
class
Leaf
>
template
<
class
Leaf
>
bool
operator
()(
Leaf
const
&
leaf
,
bool
operator
()(
Leaf
const
&
leaf
,
...
@@ -327,24 +326,17 @@ struct invoke_helper_
...
@@ -327,24 +326,17 @@ struct invoke_helper_
void
const
*
v2
,
void
const
*
v2
,
detail
::
abstract_tuple
const
&
v3
)
const
detail
::
abstract_tuple
const
&
v3
)
const
{
{
return
InvokePolicy
::
invoke
(
leaf
,
v0
,
v1
,
v2
,
v3
);
typedef
typename
Leaf
::
args_list
alist
;
typedef
invoke_policy
<
get_wildcard_position
<
alist
>
(),
alist
>
impl
;
return
impl
::
invoke
(
leaf
,
v0
,
v1
,
v2
,
v3
);
}
}
template
<
class
Leaf
,
typename
...
Args
>
template
<
class
Leaf
,
typename
...
Args
>
bool
operator
()(
Leaf
const
&
leaf
,
Args
const
&
...
args
)
const
bool
operator
()(
Leaf
const
&
leaf
,
{
return
InvokePolicy
::
invoke_args
(
leaf
,
args
...);
}
};
struct
invoke_helper
{
template
<
class
ArgTypes
,
class
...
Leaves
,
typename
...
Args
>
bool
operator
()(
detail
::
tdata
<
ArgTypes
,
Leaves
...
>
const
&
list
,
Args
const
&
...
args
)
const
Args
const
&
...
args
)
const
{
{
typedef
invoke_policy
<
get_wildcard_position
<
ArgTypes
>
(),
ArgTypes
>
ipolicy
;
typedef
typename
Leaf
::
args_list
alist
;
invoke_helper_
<
ipolicy
>
fun
;
typedef
invoke_policy
<
get_wildcard_position
<
alist
>
(),
alist
>
impl
;
return
util
::
static_foreach
<
1
,
sizeof
...(
Leaves
)
+
1
>::
eval_or
(
list
,
fun
,
args
...);
return
impl
::
invoke_args
(
leaf
,
args
...);
}
}
};
};
...
@@ -428,7 +420,7 @@ struct tdata_concatenate<tdata<Lhs...>, tdata<Rhs...> >
...
@@ -428,7 +420,7 @@ struct tdata_concatenate<tdata<Lhs...>, tdata<Rhs...> >
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
template
<
class
Leaves
>
template
<
class
...
Leaves
>
class
conditional_fun
class
conditional_fun
{
{
...
@@ -456,7 +448,7 @@ class conditional_fun
...
@@ -456,7 +448,7 @@ class conditional_fun
detail
::
abstract_tuple
const
&
tup
)
const
detail
::
abstract_tuple
const
&
tup
)
const
{
{
invoke_helper
fun
;
invoke_helper
fun
;
return
util
::
static_foreach
<
0
,
Leaves
::
tdata_size
>::
eval_or
(
m_leaves
,
fun
,
arg_types
,
timpl
,
native_arg
,
tup
);
return
util
::
static_foreach
<
0
,
sizeof
...(
Leaves
)
>::
eval_or
(
m_leaves
,
fun
,
arg_types
,
timpl
,
native_arg
,
tup
);
}
}
bool
invoke
(
any_tuple
const
&
tup
)
const
bool
invoke
(
any_tuple
const
&
tup
)
const
...
@@ -472,26 +464,26 @@ class conditional_fun
...
@@ -472,26 +464,26 @@ class conditional_fun
bool
operator
()(
Args
const
&
...
args
)
bool
operator
()(
Args
const
&
...
args
)
{
{
invoke_helper
fun
;
invoke_helper
fun
;
return
util
::
static_foreach
<
0
,
Leaves
::
tdata_size
>::
eval_or
(
m_leaves
,
fun
,
args
...);
return
util
::
static_foreach
<
0
,
sizeof
...(
Leaves
)
>::
eval_or
(
m_leaves
,
fun
,
args
...);
}
}
typedef
typename
Leaves
::
back_type
back_leaf
;
/*
typedef
typename
back_leaf
::
head_type
back_arg_types
;
template<typename OtherLeaves>
template<typename OtherLeaves>
conditional_fun<typename detail::tdata_concatenate<Leaves, OtherLeaves>::type>
conditional_fun<typename detail::tdata_concatenate<Leaves, OtherLeaves>::type>
or_else(conditional_fun<OtherLeaves> const& other) const
or_else(conditional_fun<OtherLeaves> const& other) const
{
{
return {m_leaves, other.m_leaves};
return {m_leaves, other.m_leaves};
}
}
*/
template
<
class
...
LeafImpl
>
template
<
class
...
Rhs
>
conditional_fun
<
typename
cfh_
<
back_arg_types
,
Leaves
,
LeafImpl
...
>::
type
>
conditional_fun
<
Leaves
...,
Rhs
...
>
or_else
(
conditional_fun
<
detail
::
tdata
<
detail
::
tdata
<
back_arg_types
,
LeafImpl
...
>>
>
const
&
other
)
const
or_else
(
conditional_fun
<
Rhs
...
>
const
&
other
)
const
{
{
return
{
m_leaves
,
other
.
m_leaves
.
back
().
tail
()
};
return
{
m_leaves
,
other
.
m_leaves
};
}
}
/*
template<class... LeafImpl, class Others0, class... Others>
template<class... LeafImpl, class Others0, class... Others>
conditional_fun<
conditional_fun<
typename detail::tdata_concatenate<
typename detail::tdata_concatenate<
...
@@ -506,36 +498,26 @@ class conditional_fun
...
@@ -506,36 +498,26 @@ class conditional_fun
return or_else(head_fun{other.m_leaves.head})
return or_else(head_fun{other.m_leaves.head})
.or_else(tail_fun{other.m_leaves.tail()});
.or_else(tail_fun{other.m_leaves.tail()});
}
}
*/
//private:
//private:
// structure: tdata< tdata<type_list<...>, ...>,
// structure: tdata< tdata<type_list<...>, ...>,
// tdata<type_list<...>, ...>,
// tdata<type_list<...>, ...>,
// ...>
// ...>
Leaves
m_leaves
;
detail
::
tdata
<
Leaves
...
>
m_leaves
;
};
};
template
<
class
ArgTypes
,
class
Expr
,
class
Guard
,
typename
...
TFuns
>
template
<
class
ArgTypes
,
class
Expr
,
class
Guard
,
typename
...
TFuns
>
conditional_fun
<
conditional_fun
<
typename
cfl_
<
ArgTypes
,
Expr
,
Guard
,
TFuns
...
>::
type
>
detail
::
tdata
<
detail
::
tdata
<
ArgTypes
,
typename
cfl_
<
ArgTypes
,
Expr
,
Guard
,
TFuns
...
>::
type
>>>
cfun
(
Expr
e
,
Guard
g
,
TFuns
...
tfs
)
cfun
(
Expr
e
,
Guard
g
,
TFuns
...
tfs
)
{
{
typedef
detail
::
tdata
<
typedef
typename
cfl_
<
ArgTypes
,
Expr
,
Guard
,
TFuns
...
>::
type
leaf_type
;
ArgTypes
,
typename
cfl_
<
ArgTypes
,
Expr
,
Guard
,
TFuns
...
>::
type
>
result
;
typedef
typename
result
::
tail_type
ttype
;
typedef
typename
ttype
::
head_type
leaf_type
;
typedef
typename
util
::
get_callable_trait
<
Expr
>::
arg_types
expr_args
;
typedef
typename
util
::
get_callable_trait
<
Expr
>::
arg_types
expr_args
;
static_assert
(
ArgTypes
::
size
>=
expr_args
::
size
,
static_assert
(
ArgTypes
::
size
>=
expr_args
::
size
,
"Functor has too many arguments"
);
"Functor has too many arguments"
);
return
result
{
return
leaf_type
{
std
::
move
(
g
),
std
::
move
(
e
),
std
::
move
(
tfs
)...};
ArgTypes
{},
leaf_type
{
std
::
move
(
g
),
std
::
move
(
e
),
std
::
move
(
tfs
)...}
};
}
}
#define VERBOSE(LineOfCode) cout << #LineOfCode << " = " << (LineOfCode) << endl
#define VERBOSE(LineOfCode) cout << #LineOfCode << " = " << (LineOfCode) << endl
...
@@ -590,15 +572,11 @@ struct cf_builder
...
@@ -590,15 +572,11 @@ struct cf_builder
}
}
template
<
typename
Expr
>
template
<
typename
Expr
>
conditional_fun
<
conditional_fun
<
conditional_fun_leaf
<
Expr
,
Guard
,
Transformers
,
Pattern
>
>
detail
::
tdata
<
detail
::
tdata
<
Pattern
,
conditional_fun_leaf
<
Expr
,
Guard
,
Transformers
,
Pattern
>>>>
operator
>>
(
Expr
expr
)
const
operator
>>
(
Expr
expr
)
const
{
{
typedef
conditional_fun_leaf
<
Expr
,
Guard
,
Transformers
,
Pattern
>
tfun
;
typedef
conditional_fun_leaf
<
Expr
,
Guard
,
Transformers
,
Pattern
>
tfun
;
typedef
detail
::
tdata
<
Pattern
,
tfun
>
result
;
return
tfun
{
m_guard
,
std
::
move
(
expr
),
m_funs
};
return
result
{
Pattern
{},
tfun
{
m_guard
,
std
::
move
(
expr
),
m_funs
}};
}
}
};
};
...
@@ -779,8 +757,6 @@ size_t test__tuple()
...
@@ -779,8 +757,6 @@ size_t test__tuple()
cout
<<
detail
::
demangle
(
typeid
(
zz3
).
name
())
<<
endl
;
cout
<<
detail
::
demangle
(
typeid
(
zz3
).
name
())
<<
endl
;
exit
(
0
);
typedef
util
::
type_list
<
int
,
int
>
token1
;
typedef
util
::
type_list
<
int
,
int
>
token1
;
typedef
util
::
type_list
<
float
>
token2
;
typedef
util
::
type_list
<
float
>
token2
;
...
...
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