Skip to content

Commit

Permalink
meta: no context-less meta_any from meta objects as it ought to be
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Jan 10, 2025
1 parent 0b97fa5 commit 6f5e935
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ TODO:
* sparse_set shrink_to_fit argument for sparse array shrink policy (none, empty, deep, whatever)
* any cdynamic to support const ownership construction
* track meta context on meta elements
* no context-less meta_any{} from meta objects if possible
14 changes: 7 additions & 7 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ struct meta_data {
* @return A wrapper containing the value of the underlying variable.
*/
[[nodiscard]] meta_any get(meta_handle instance) const {
return (node.get != nullptr) ? node.get(*ctx, meta_handle{*ctx, std::move(instance)}) : meta_any{};
return (node.get != nullptr) ? node.get(*ctx, meta_handle{*ctx, std::move(instance)}) : meta_any{meta_ctx_arg, *ctx};
}

/**
Expand Down Expand Up @@ -1004,7 +1004,7 @@ struct meta_func {
* @return A wrapper containing the returned value, if any.
*/
meta_any invoke(meta_handle instance, meta_any *const args, const size_type sz) const {
return ((node.invoke != nullptr) && (sz == arity())) ? node.invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args) : meta_any{};
return ((node.invoke != nullptr) && (sz == arity())) ? node.invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args) : meta_any{meta_ctx_arg, *ctx};
}

/**
Expand Down Expand Up @@ -1378,7 +1378,7 @@ class meta_type {
return node.default_constructor(*ctx);
}

return meta_any{};
return meta_any{meta_ctx_arg, *ctx};
}

/**
Expand All @@ -1399,7 +1399,7 @@ class meta_type {
* @return A wrapper that references the given instance.
*/
[[nodiscard]] meta_any from_void(void *elem, bool transfer_ownership = false) const {
return ((elem != nullptr) && (node.from_void != nullptr)) ? node.from_void(*ctx, elem, transfer_ownership ? elem : nullptr) : meta_any{};
return ((elem != nullptr) && (node.from_void != nullptr)) ? node.from_void(*ctx, elem, transfer_ownership ? elem : nullptr) : meta_any{meta_ctx_arg, *ctx};
}

/**
Expand All @@ -1408,7 +1408,7 @@ class meta_type {
* @return A wrapper that references the given instance.
*/
[[nodiscard]] meta_any from_void(const void *elem) const {
return ((elem != nullptr) && (node.from_void != nullptr)) ? node.from_void(*ctx, nullptr, elem) : meta_any{};
return ((elem != nullptr) && (node.from_void != nullptr)) ? node.from_void(*ctx, nullptr, elem) : meta_any{meta_ctx_arg, *ctx};
}

/**
Expand All @@ -1435,7 +1435,7 @@ class meta_type {
}
}

return meta_any{};
return meta_any{meta_ctx_arg, *ctx};
}

/**
Expand Down Expand Up @@ -1475,7 +1475,7 @@ class meta_type {
*/
[[nodiscard]] meta_any get(const id_type id, meta_handle instance) const {
const auto candidate = data(id);
return candidate ? candidate.get(std::move(instance)) : meta_any{};
return candidate ? candidate.get(std::move(instance)) : meta_any{meta_ctx_arg, *ctx};
}

/*! @copydoc meta_data::traits */
Expand Down

0 comments on commit 6f5e935

Please sign in to comment.