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
6d6c97a8
Commit
6d6c97a8
authored
Feb 20, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintenance
parent
53e5796f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
118 deletions
+55
-118
cppa/detail/decorated_tuple.hpp
cppa/detail/decorated_tuple.hpp
+15
-34
cppa/detail/object_array.hpp
cppa/detail/object_array.hpp
+3
-5
cppa/detail/tuple_cast_impl.hpp
cppa/detail/tuple_cast_impl.hpp
+1
-12
cppa/match.hpp
cppa/match.hpp
+1
-1
cppa/tuple.hpp
cppa/tuple.hpp
+1
-12
cppa/util/fixed_vector.hpp
cppa/util/fixed_vector.hpp
+7
-2
src/abstract_tuple.cpp
src/abstract_tuple.cpp
+3
-12
src/object_array.cpp
src/object_array.cpp
+0
-35
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+24
-5
No files found.
cppa/detail/decorated_tuple.hpp
View file @
6d6c97a8
...
...
@@ -62,27 +62,21 @@ class decorated_tuple : public abstract_tuple
typedef
cow_ptr
<
abstract_tuple
>
cow_pointer_type
;
static
cow_pointer_type
create
(
cow_pointer_type
d
,
vector_type
const
&
v
)
static
inline
cow_pointer_type
create
(
cow_pointer_type
d
,
vector_type
const
&
v
)
{
return
{(
new
decorated_tuple
(
std
::
move
(
d
)))
->
init
(
v
)};
}
// creates a subtuple form @p d with sizeof...(ElementTypes) elements
static
cow_pointer_type
create
(
cow_pointer_type
d
)
{
return
{(
new
decorated_tuple
(
std
::
move
(
d
)))
->
init
()};
return
{
new
decorated_tuple
(
std
::
move
(
d
),
v
)};
}
// creates a subtuple form @p d with an offset
static
cow_pointer_type
create
(
cow_pointer_type
d
,
size_t
offset
)
static
inline
cow_pointer_type
create
(
cow_pointer_type
d
,
size_t
offset
)
{
return
{
(
new
decorated_tuple
(
std
::
move
(
d
)))
->
init
(
offset
)};
return
{
new
decorated_tuple
(
std
::
move
(
d
),
offset
)};
}
virtual
void
*
mutable_at
(
size_t
pos
)
{
CPPA_REQUIRE
(
pos
<
size
());
CPPA_REQUIRE
(
m_mapping
[
pos
]
<
m_decorated
->
size
());
return
m_decorated
->
mutable_at
(
m_mapping
[
pos
]);
}
...
...
@@ -99,14 +93,12 @@ class decorated_tuple : public abstract_tuple
virtual
void
const
*
at
(
size_t
pos
)
const
{
CPPA_REQUIRE
(
pos
<
size
());
CPPA_REQUIRE
(
m_mapping
[
pos
]
<
m_decorated
->
size
());
return
m_decorated
->
at
(
m_mapping
[
pos
]);
}
virtual
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
{
CPPA_REQUIRE
(
pos
<
size
());
CPPA_REQUIRE
(
m_mapping
[
pos
]
<
m_decorated
->
size
());
return
m_decorated
->
type_at
(
m_mapping
[
pos
]);
}
...
...
@@ -130,38 +122,27 @@ class decorated_tuple : public abstract_tuple
cow_pointer_type
m_decorated
;
vector_type
m_mapping
;
decorated_tuple
(
cow_pointer_type
&&
d
)
:
m_decorated
(
std
::
move
(
d
))
{
}
decorated_tuple
(
decorated_tuple
const
&
)
=
default
;
decorated_tuple
*
init
(
vector_type
const
&
v
)
decorated_tuple
(
cow_pointer_type
d
,
vector_type
const
&
v
)
:
m_decorated
(
std
::
move
(
d
)),
m_mapping
(
v
)
{
CPPA_REQUIRE
(
m_decorated
->
size
()
>=
sizeof
...(
ElementTypes
));
CPPA_REQUIRE
(
v
.
size
()
==
sizeof
...(
ElementTypes
));
CPPA_REQUIRE
(
*
(
std
::
max_element
(
v
.
begin
(),
v
.
end
()))
<
m_decorated
->
size
());
m_mapping
.
resize
(
v
.
size
());
std
::
copy
(
v
.
begin
(),
v
.
end
(),
m_mapping
.
begin
());
return
this
;
}
decorated_tuple
*
init
()
{
CPPA_REQUIRE
(
m_decorated
->
size
()
>=
sizeof
...(
ElementTypes
));
size_t
i
=
0
;
m_mapping
.
resize
(
sizeof
...(
ElementTypes
));
std
::
generate
(
m_mapping
.
begin
(),
m_mapping
.
end
(),
[
&
]()
{
return
i
++
;});
return
this
;
CPPA_REQUIRE
(
*
(
std
::
max_element
(
v
.
begin
(),
v
.
end
()))
<
m_decorated
->
size
());
}
decorated_tuple
*
init
(
size_t
offset
)
decorated_tuple
(
cow_pointer_type
d
,
size_t
offset
)
:
m_decorated
(
std
::
move
(
d
))
{
CPPA_REQUIRE
((
m_decorated
->
size
()
-
offset
)
==
sizeof
...(
ElementTypes
));
CPPA_REQUIRE
((
m_decorated
->
size
()
-
offset
)
>=
sizeof
...(
ElementTypes
));
CPPA_REQUIRE
(
offset
>
0
);
size_t
i
=
offset
;
m_mapping
.
resize
(
sizeof
...(
ElementTypes
));
std
::
generate
(
m_mapping
.
begin
(),
m_mapping
.
end
(),
[
&
]()
{
return
i
++
;});
return
this
;
}
decorated_tuple
(
decorated_tuple
const
&
)
=
default
;
decorated_tuple
&
operator
=
(
decorated_tuple
const
&
)
=
delete
;
};
...
...
cppa/detail/object_array.hpp
View file @
6d6c97a8
...
...
@@ -48,11 +48,9 @@ class object_array : public abstract_tuple
using
abstract_tuple
::
const_iterator
;
object_array
();
object_array
(
object_array
&&
other
);
object_array
(
object_array
const
&
other
);
object_array
()
=
default
;
object_array
(
object_array
&&
)
=
default
;
object_array
(
object_array
const
&
)
=
default
;
void
push_back
(
object
&&
what
);
...
...
cppa/detail/tuple_cast_impl.hpp
View file @
6d6c97a8
...
...
@@ -95,19 +95,8 @@ struct tuple_cast_impl<pattern_characteristic::no_wildcard, Result, T...>
template
<
class
Result
,
typename
...
T
>
struct
tuple_cast_impl
<
pattern_characteristic
::
trailing_wildcard
,
Result
,
T
...
>
:
tuple_cast_impl
<
pattern_characteristic
::
no_wildcard
,
Result
,
T
...
>
{
template
<
class
Tuple
>
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
)
{
if
(
match
<
T
...
>
(
tup
))
return
{
Result
::
subtuple
(
tup
.
vals
())};
return
{};
}
template
<
class
Tuple
>
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
,
pattern
<
T
...
>
const
&
p
)
{
if
(
match
(
tup
,
p
))
return
{
Result
::
subtuple
(
tup
.
vals
())};
return
{};
}
};
template
<
class
Result
,
typename
...
T
>
...
...
cppa/match.hpp
View file @
6d6c97a8
...
...
@@ -390,7 +390,7 @@ struct matcher<pattern_characteristic::wildcard_in_between, T...>
{
// first range
size_t
i
=
0
;
mv
.
resize
(
size
);
mv
.
resize
(
size
-
1
);
auto
begin
=
mv
.
begin
();
std
::
generate
(
begin
,
begin
+
wc_pos
,
[
&
]()
{
return
i
++
;
});
// second range
...
...
cppa/tuple.hpp
View file @
6d6c97a8
...
...
@@ -130,20 +130,9 @@ class tuple
return
{
priv_ctor
(),
decorated_type
::
create
(
std
::
move
(
ptr
),
mv
)};
}
// *this is a [0, N) subtuple
inline
static
tuple
subtuple
(
cow_ptr_type
ptr
)
{
// N == ptr->size() ?
if
(
ptr
->
size
()
==
num_elements
)
return
from
(
std
::
move
(
ptr
));
// no, create subtuple
return
{
priv_ctor
(),
decorated_type
::
create
(
std
::
move
(
ptr
))};
}
inline
static
tuple
offset_subtuple
(
cow_ptr_type
ptr
,
size_t
offset
)
{
// N == ptr->size() ?
if
(
ptr
->
size
()
==
num_elements
)
return
from
(
std
::
move
(
ptr
));
// no, create subtuple
CPPA_REQUIRE
(
offset
>
0
);
return
{
priv_ctor
(),
decorated_type
::
create
(
std
::
move
(
ptr
),
offset
)};
}
...
...
cppa/util/fixed_vector.hpp
View file @
6d6c97a8
...
...
@@ -80,6 +80,13 @@ class fixed_vector
std
::
copy
(
other
.
begin
(),
other
.
end
(),
m_data
);
}
fixed_vector
&
operator
=
(
fixed_vector
const
&
other
)
{
resize
(
other
.
size
());
std
::
copy
(
other
.
begin
(),
other
.
end
(),
begin
());
return
*
this
;
}
void
resize
(
size_type
s
)
{
CPPA_REQUIRE
(
s
<=
MaxSize
);
...
...
@@ -132,13 +139,11 @@ class fixed_vector
inline
reference
operator
[](
size_type
pos
)
{
CPPA_REQUIRE
(
pos
<
m_size
);
return
at
(
pos
);
}
inline
const_reference
operator
[](
size_type
pos
)
const
{
CPPA_REQUIRE
(
pos
<
m_size
);
return
at
(
pos
);
}
...
...
src/abstract_tuple.cpp
View file @
6d6c97a8
...
...
@@ -34,18 +34,9 @@ namespace cppa { namespace detail {
bool
abstract_tuple
::
equals
(
const
abstract_tuple
&
other
)
const
{
if
(
this
==
&
other
)
return
true
;
if
(
size
()
!=
other
.
size
())
return
false
;
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
{
auto
uti
=
type_at
(
i
);
if
(
uti
!=
other
.
type_at
(
i
))
return
false
;
auto
lhs
=
at
(
i
);
auto
rhs
=
other
.
at
(
i
);
// compare addresses first, then values
if
(
lhs
!=
rhs
&&
!
(
uti
->
equals
(
lhs
,
rhs
)))
return
false
;
}
return
true
;
return
this
==
&
other
||
(
size
()
==
other
.
size
()
&&
std
::
equal
(
begin
(),
end
(),
other
.
begin
(),
detail
::
full_eq
));
}
abstract_tuple
::
abstract_tuple
(
abstract_tuple
const
&
)
:
ref_counted
()
{
}
...
...
src/object_array.cpp
View file @
6d6c97a8
...
...
@@ -32,20 +32,6 @@
namespace
cppa
{
namespace
detail
{
object_array
::
object_array
()
{
}
object_array
::
object_array
(
object_array
&&
other
)
:
m_elements
(
std
::
move
(
other
.
m_elements
))
{
}
object_array
::
object_array
(
object_array
const
&
other
)
:
m_elements
(
other
.
m_elements
)
{
}
void
object_array
::
push_back
(
object
const
&
what
)
{
m_elements
.
push_back
(
what
);
...
...
@@ -76,27 +62,6 @@ void const* object_array::at(size_t pos) const
return
m_elements
[
pos
].
value
();
}
bool
object_array
::
equals
(
cppa
::
detail
::
abstract_tuple
const
&
ut
)
const
{
if
(
size
()
==
ut
.
size
())
{
for
(
size_t
i
=
0
;
i
<
size
();
++
i
)
{
auto
utype
=
type_at
(
i
);
if
(
utype
==
ut
.
type_at
(
i
))
{
if
(
!
utype
->
equals
(
at
(
i
),
ut
.
at
(
i
)))
return
false
;
}
else
{
return
false
;
}
}
return
true
;
}
return
false
;
}
uniform_type_info
const
*
object_array
::
type_at
(
size_t
pos
)
const
{
return
m_elements
[
pos
].
type
();
...
...
unit_testing/test__tuple.cpp
View file @
6d6c97a8
...
...
@@ -60,7 +60,7 @@ size_t test__tuple()
cout
<<
" t0: "
<<
t0
.
vals
().
get
()
<<
endl
<<
" v0: "
<<
v0
.
vals
().
get
()
<<
endl
<<
"*v0: "
<<
dynamic_cast
<
detail
::
decorated_tuple
<
std
::
string
>
const
*>
(
v0
.
vals
().
get
())
->
decorated
().
get
()
<<
endl
//
<< "*v0: " << dynamic_cast<detail::decorated_tuple<std::string> const*>(v0.vals().get())->decorated().get() << endl
<<
"at0: "
<<
at0
.
vals
().
get
()
<<
endl
;
...
...
@@ -86,19 +86,38 @@ size_t test__tuple()
// perfect match
auto
opt0
=
tuple_cast
<
std
::
string
,
int
,
float
,
double
>
(
at1
);
CPPA_CHECK
(
opt0
);
if
(
opt0
)
{
CPPA_CHECK_EQUAL
(
*
opt0
,
make_tuple
(
"one"
,
2
,
3.
f
,
4.0
));
}
if
(
opt0
)
{
CPPA_CHECK_EQUAL
(
*
opt0
,
make_tuple
(
"one"
,
2
,
3.
f
,
4.0
));
CPPA_CHECK_EQUAL
(
&
get
<
0
>
(
*
opt0
),
at1
.
at
(
0
));
}
// leading wildcard
auto
opt1
=
tuple_cast
<
anything
,
double
>
(
at1
);
CPPA_CHECK
(
opt1
);
if
(
opt1
)
{
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt1
),
4.0
);
}
if
(
opt1
)
{
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt1
),
4.0
);
CPPA_CHECK_EQUAL
(
&
get
<
0
>
(
*
opt1
),
at1
.
at
(
3
));
}
// trailing wildcard
auto
opt2
=
tuple_cast
<
std
::
string
,
anything
>
(
at1
);
CPPA_CHECK
(
opt2
);
if
(
opt2
)
{
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt2
),
"one"
);
}
if
(
opt2
)
{
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt2
),
"one"
);
CPPA_CHECK_EQUAL
(
&
get
<
0
>
(
*
opt2
),
at1
.
at
(
0
));
}
// wildcard in between
auto
opt3
=
tuple_cast
<
std
::
string
,
anything
,
double
>
(
at1
);
CPPA_CHECK
(
opt3
);
if
(
opt3
)
{
CPPA_CHECK_EQUAL
(
*
opt3
,
make_tuple
(
"one"
,
4.0
));
}
if
(
opt3
)
{
CPPA_CHECK_EQUAL
(
*
opt3
,
make_tuple
(
"one"
,
4.0
));
CPPA_CHECK_EQUAL
(
get
<
0
>
(
*
opt3
),
"one"
);
CPPA_CHECK_EQUAL
(
get
<
1
>
(
*
opt3
),
4.0
);
CPPA_CHECK_EQUAL
(
&
get
<
0
>
(
*
opt3
),
at1
.
at
(
0
));
CPPA_CHECK_EQUAL
(
&
get
<
1
>
(
*
opt3
),
at1
.
at
(
3
));
}
}
return
CPPA_TEST_RESULT
;
}
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