summaryrefslogtreecommitdiff
path: root/src/core/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/model')
-rw-r--r--src/core/model/ResolutionCallbacks.cpp5
-rw-r--r--src/core/model/ResolutionCallbacks.hpp19
-rw-r--r--src/core/model/Typesystem.cpp25
3 files changed, 20 insertions, 29 deletions
diff --git a/src/core/model/ResolutionCallbacks.cpp b/src/core/model/ResolutionCallbacks.cpp
index 8c920f1..88f0aa8 100644
--- a/src/core/model/ResolutionCallbacks.cpp
+++ b/src/core/model/ResolutionCallbacks.cpp
@@ -19,5 +19,8 @@
#include "ResolutionCallbacks.hpp"
namespace ousia {
- // Do nothing here, just make sure the header compiles
+Rooted<Node> NullResolveCallback(const Rtti *, const std::vector<std::string> &)
+{
+ return nullptr;
+}
}
diff --git a/src/core/model/ResolutionCallbacks.hpp b/src/core/model/ResolutionCallbacks.hpp
index 2d9465d..2ac78a6 100644
--- a/src/core/model/ResolutionCallbacks.hpp
+++ b/src/core/model/ResolutionCallbacks.hpp
@@ -57,20 +57,19 @@ using ResolutionResultCallback = std::function<
/**
* The ResolveCallback can be used to trigger the resolution of a certain node.
*
- * @param async if true, the resolution may be deferred. In this case the
- * resultCallback may be called at any later point in the program.
* @param type is the type of node that should be resolved.
* @param path is the path for which a node should be resolved.
- * @param resultCallback is the callback function to which the result of
- * the resolution process is passed. This function is called once the
- * resolution was successful.
- * @return true if the resolution was immediately successful. This does not
- * mean, that the resolved object does not exist, as it may be resolved
- * later.
+ * @return a the resolved node or nullptr if the resolution was not successful.
*/
using ResolveCallback = std::function<
- bool(bool async, const Rtti *type, const std::vector<std::string> &path,
- ResolutionResultCallback resultCallback)>;
+ Rooted<Node>(const Rtti *type, const std::vector<std::string> &path)>;
+
+/**
+ * Empty implementation of the ResolveCallback, always returns nullptr.
+ */
+Rooted<Node> NullResolveCallback(const Rtti *,
+ const std::vector<std::string> &);
+
}
#endif /* _OUSIA_RESOLUTION_CALLBACKS_HPP_ */
diff --git a/src/core/model/Typesystem.cpp b/src/core/model/Typesystem.cpp
index 48e8d90..86ee811 100644
--- a/src/core/model/Typesystem.cpp
+++ b/src/core/model/Typesystem.cpp
@@ -25,15 +25,6 @@
namespace ousia {
-/* Static helper functions */
-
-static bool NullResolveCallback(bool, const Rtti *,
- const std::vector<std::string> &,
- ResolutionResultCallback)
-{
- return false;
-}
-
/* Class Type */
bool Type::build(Variant &data, Logger &logger,
@@ -41,15 +32,13 @@ bool Type::build(Variant &data, Logger &logger,
{
// If the given variant is marked as "magic", try to resolve the real value
if (data.isMagic()) {
- Rooted<Constant> constant;
- if (resolveCallback(
- false, &RttiTypes::Constant, Utils::split(data.asMagic(), '.'),
- [&constant](Handle<Node> resolved, Handle<Node> owner,
- Logger &logger) mutable {
- // Copy the resolution result out of this function
- constant = resolved.cast<Constant>();
- })) {
- // Check whether the inner type of the constant is correct
+ // Try to resolve a constant
+ Rooted<Constant> constant =
+ resolveCallback(&RttiTypes::Constant,
+ Utils::split(data.asMagic(), '.')).cast<Constant>();
+
+ // Check whether the inner type of the constant is correct
+ if (constant != nullptr) {
Rooted<Type> constantType = constant->getType();
if (!constantType->checkIsa(this)) {
logger.error(