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
0b56818f
Commit
0b56818f
authored
Feb 27, 2023
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate review feedback
parent
cd076a93
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
38 deletions
+33
-38
libcaf_core/caf/detail/meta_object.hpp
libcaf_core/caf/detail/meta_object.hpp
+1
-1
libcaf_core/src/async/batch.cpp
libcaf_core/src/async/batch.cpp
+3
-3
libcaf_core/src/config_value.cpp
libcaf_core/src/config_value.cpp
+7
-7
libcaf_core/src/detail/meta_object.cpp
libcaf_core/src/detail/meta_object.cpp
+2
-3
libcaf_core/src/error.cpp
libcaf_core/src/error.cpp
+5
-7
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+4
-4
libcaf_core/src/message_builder.cpp
libcaf_core/src/message_builder.cpp
+5
-5
libcaf_core/src/type_id.cpp
libcaf_core/src/type_id.cpp
+2
-2
libcaf_core/src/type_id_list.cpp
libcaf_core/src/type_id_list.cpp
+4
-6
No files found.
libcaf_core/caf/detail/meta_object.hpp
View file @
0b56818f
...
...
@@ -66,7 +66,7 @@ CAF_CORE_EXPORT span<const meta_object> global_meta_objects();
/// Returns the global meta object for given type ID. Aborts the program if no
/// meta object exists for `id`.
CAF_CORE_EXPORT
const
meta_object
*
global_meta_object
(
type_id_t
id
);
CAF_CORE_EXPORT
const
meta_object
&
global_meta_object
(
type_id_t
id
);
/// Returns the global meta object for given type ID or `nullptr` if no meta
/// object exists for `id`.
...
...
libcaf_core/src/async/batch.cpp
View file @
0b56818f
...
...
@@ -35,17 +35,17 @@ bool batch::data::save(Inspector& sink) const {
sink
.
emplace_error
(
sec
::
unsafe_type
);
return
false
;
}
auto
meta
=
detail
::
global_meta_object
(
item_type_
);
auto
&
meta
=
detail
::
global_meta_object
(
item_type_
);
auto
ptr
=
storage_
;
if
(
!
sink
.
begin_sequence
(
size_
))
return
false
;
auto
len
=
size_
;
do
{
if
constexpr
(
std
::
is_same_v
<
Inspector
,
binary_serializer
>
)
{
if
(
!
meta
->
save_binary
(
sink
,
ptr
))
if
(
!
meta
.
save_binary
(
sink
,
ptr
))
return
false
;
}
else
{
if
(
!
meta
->
save
(
sink
,
ptr
))
if
(
!
meta
.
save
(
sink
,
ptr
))
return
false
;
}
ptr
+=
item_size_
;
...
...
libcaf_core/src/config_value.cpp
View file @
0b56818f
...
...
@@ -195,11 +195,11 @@ error_code<sec> config_value::default_construct(type_id_t id) {
return
sec
::
none
;
default:
if
(
auto
meta
=
detail
::
global_meta_object_or_null
(
id
))
{
using
detail
::
make_scope_guard
;
auto
ptr
=
malloc
(
meta
->
padded_size
);
auto
free_guard
=
detail
::
make_scope_guard
([
ptr
]
{
free
(
ptr
);
});
auto
free_guard
=
make_scope_guard
([
ptr
]
{
free
(
ptr
);
});
meta
->
default_construct
(
ptr
);
auto
destroy_guard
=
detail
::
make_scope_guard
([
=
]
{
meta
->
destroy
(
ptr
);
});
auto
destroy_guard
=
make_scope_guard
([
=
]
{
meta
->
destroy
(
ptr
);
});
config_value_writer
writer
{
this
};
if
(
meta
->
save
(
writer
,
ptr
))
{
return
sec
::
none
;
...
...
@@ -519,12 +519,12 @@ config_value::parse_msg_impl(std::string_view str,
return
false
;
auto
pos
=
ptr
->
storage
();
for
(
auto
type
:
ls
)
{
auto
meta
=
detail
::
global_meta_object
(
type
);
meta
->
default_construct
(
pos
);
auto
&
meta
=
detail
::
global_meta_object
(
type
);
meta
.
default_construct
(
pos
);
ptr
->
inc_constructed_elements
();
if
(
!
meta
->
load
(
reader
,
pos
))
if
(
!
meta
.
load
(
reader
,
pos
))
return
false
;
pos
+=
meta
->
padded_size
;
pos
+=
meta
.
padded_size
;
}
result
.
reset
(
ptr
.
release
(),
false
);
return
reader
.
end_sequence
();
...
...
libcaf_core/src/detail/meta_object.cpp
View file @
0b56818f
...
...
@@ -51,11 +51,11 @@ span<const meta_object> global_meta_objects() {
return
{
meta_objects
,
meta_objects_size
};
}
const
meta_object
*
global_meta_object
(
type_id_t
id
)
{
const
meta_object
&
global_meta_object
(
type_id_t
id
)
{
if
(
id
<
meta_objects_size
)
{
auto
&
meta
=
meta_objects
[
id
];
if
(
!
meta
.
type_name
.
empty
())
return
&
meta
;
return
meta
;
}
CAF_CRITICAL_FMT
(
"found no meta object for type ID %d!
\n
"
...
...
@@ -66,7 +66,6 @@ const meta_object* global_meta_object(type_id_t id) {
" - <module>::init_global_meta_objects() for all loaded modules
\n
"
" - caf::init_global_meta_objects<T>() for all custom ID blocks"
,
static_cast
<
int
>
(
id
));
return
nullptr
;
}
const
meta_object
*
global_meta_object_or_null
(
type_id_t
id
)
{
...
...
libcaf_core/src/error.cpp
View file @
0b56818f
...
...
@@ -64,21 +64,19 @@ int error::compare(uint8_t code, type_id_t category) const noexcept {
// -- inspection support -----------------------------------------------------
std
::
string
to_string
(
const
error
&
x
)
{
using
const_void_ptr
=
const
void
*
;
using
const_meta_ptr
=
const
detail
::
meta_object
*
;
if
(
!
x
)
return
"none"
;
std
::
string
result
;
auto
append
=
[
&
result
](
const
_void_ptr
ptr
,
const
_meta_ptr
meta
)
->
const_void_ptr
{
meta
->
stringify
(
result
,
ptr
);
return
static_cast
<
const
std
::
byte
*>
(
ptr
)
+
meta
->
padded_size
;
auto
append
=
[
&
result
](
const
void
*
ptr
,
const
detail
::
meta_object
&
meta
)
->
const
void
*
{
meta
.
stringify
(
result
,
ptr
);
return
static_cast
<
const
std
::
byte
*>
(
ptr
)
+
meta
.
padded_size
;
};
auto
code
=
x
.
code
();
append
(
&
code
,
detail
::
global_meta_object
(
x
.
category
()));
if
(
auto
&
ctx
=
x
.
context
())
{
result
+=
'('
;
auto
ptr
=
static_cast
<
const
_void_ptr
>
(
ctx
.
cdata
().
storage
());
auto
ptr
=
static_cast
<
const
void
*
>
(
ctx
.
cdata
().
storage
());
auto
types
=
ctx
.
types
();
ptr
=
append
(
ptr
,
detail
::
global_meta_object
(
types
[
0
]));
for
(
size_t
index
=
1
;
index
<
types
.
size
();
++
index
)
{
...
...
libcaf_core/src/message.cpp
View file @
0b56818f
...
...
@@ -71,8 +71,8 @@ bool load_data(Deserializer& source, message::data_ptr& data) {
CAF_ASSERT
(
ids
.
size
()
==
msg_size
);
size_t
data_size
=
0
;
for
(
auto
id
:
ids
)
{
if
(
auto
meta
_obj
=
detail
::
global_meta_object_or_null
(
id
))
data_size
+=
meta
_obj
->
padded_size
;
if
(
auto
meta
=
detail
::
global_meta_object_or_null
(
id
))
data_size
+=
meta
->
padded_size
;
else
STOP
(
sec
::
unknown_type
);
}
...
...
@@ -289,12 +289,12 @@ std::string to_string(const message& msg) {
auto
types
=
msg
.
types
();
if
(
!
types
.
empty
())
{
auto
ptr
=
msg
.
cdata
().
storage
();
auto
meta
=
detail
::
global_meta_object
(
types
[
0
]);
auto
*
meta
=
&
detail
::
global_meta_object
(
types
[
0
]);
meta
->
stringify
(
result
,
ptr
);
ptr
+=
meta
->
padded_size
;
for
(
size_t
index
=
1
;
index
<
types
.
size
();
++
index
)
{
result
+=
", "
;
meta
=
detail
::
global_meta_object
(
types
[
index
]);
meta
=
&
detail
::
global_meta_object
(
types
[
index
]);
meta
->
stringify
(
result
,
ptr
);
ptr
+=
meta
->
padded_size
;
}
...
...
libcaf_core/src/message_builder.cpp
View file @
0b56818f
...
...
@@ -52,9 +52,9 @@ public:
}
std
::
byte
*
copy_init
(
std
::
byte
*
storage
)
const
override
{
auto
*
meta
=
global_meta_object
(
src_
.
type_at
(
index_
));
meta
->
copy_construct
(
storage
,
src_
.
data
().
at
(
index_
));
return
storage
+
meta
->
padded_size
;
auto
&
meta
=
global_meta_object
(
src_
.
type_at
(
index_
));
meta
.
copy_construct
(
storage
,
src_
.
data
().
at
(
index_
));
return
storage
+
meta
.
padded_size
;
}
std
::
byte
*
move_init
(
std
::
byte
*
storage
)
override
{
...
...
@@ -75,8 +75,8 @@ message_builder& message_builder::append_from(const caf::message& msg,
auto
end
=
std
::
min
(
msg
.
size
(),
first
+
n
);
for
(
size_t
index
=
first
;
index
<
end
;
++
index
)
{
auto
tid
=
msg
.
type_at
(
index
);
auto
*
meta
=
detail
::
global_meta_object
(
tid
);
storage_size_
+=
meta
->
padded_size
;
auto
&
meta
=
detail
::
global_meta_object
(
tid
);
storage_size_
+=
meta
.
padded_size
;
types_
.
push_back
(
tid
);
elements_
.
emplace_back
(
std
::
make_unique
<
message_builder_element_adapter
>
(
msg
,
index
));
...
...
libcaf_core/src/type_id.cpp
View file @
0b56818f
...
...
@@ -9,8 +9,8 @@
namespace
caf
{
std
::
string_view
query_type_name
(
type_id_t
type
)
{
if
(
auto
ptr
=
detail
::
global_meta_object_or_null
(
type
))
return
ptr
->
type_name
;
if
(
auto
meta
=
detail
::
global_meta_object_or_null
(
type
))
return
meta
->
type_name
;
return
{};
}
...
...
libcaf_core/src/type_id_list.cpp
View file @
0b56818f
...
...
@@ -12,10 +12,8 @@ namespace caf {
size_t
type_id_list
::
data_size
()
const
noexcept
{
auto
result
=
size_t
{
0
};
for
(
auto
type
:
*
this
)
{
auto
meta
=
detail
::
global_meta_object
(
type
);
result
+=
meta
->
padded_size
;
}
for
(
auto
type
:
*
this
)
result
+=
detail
::
global_meta_object
(
type
).
padded_size
;
return
result
;
}
...
...
@@ -25,12 +23,12 @@ std::string to_string(type_id_list xs) {
std
::
string
result
;
result
+=
'['
;
{
auto
tn
=
detail
::
global_meta_object
(
xs
[
0
])
->
type_name
;
auto
tn
=
detail
::
global_meta_object
(
xs
[
0
])
.
type_name
;
result
.
insert
(
result
.
end
(),
tn
.
begin
(),
tn
.
end
());
}
for
(
size_t
index
=
1
;
index
<
xs
.
size
();
++
index
)
{
result
+=
", "
;
auto
tn
=
detail
::
global_meta_object
(
xs
[
index
])
->
type_name
;
auto
tn
=
detail
::
global_meta_object
(
xs
[
index
])
.
type_name
;
result
.
insert
(
result
.
end
(),
tn
.
begin
(),
tn
.
end
());
}
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