summaryrefslogtreecommitdiff
path: root/src/core/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/parser')
-rw-r--r--src/core/parser/ParserScope.cpp36
-rw-r--r--src/core/parser/ParserScope.hpp41
2 files changed, 74 insertions, 3 deletions
diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp
index 9c0b729..3929abf 100644
--- a/src/core/parser/ParserScope.cpp
+++ b/src/core/parser/ParserScope.cpp
@@ -19,6 +19,7 @@
#include <core/common/Exceptions.hpp>
#include <core/common/Utils.hpp>
#include <core/common/VariantWriter.hpp>
+#include <core/model/Domain.hpp>
#include <core/model/Typesystem.hpp>
#include "ParserScope.hpp"
@@ -472,5 +473,40 @@ bool ParserScope::performDeferredResolution(Logger &logger)
deferred.clear();
return false;
}
+
+bool ParserScope::resolveFieldDescriptor(
+ const std::vector<std::string> &path, Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback)
+{
+ // if the last element of the path is the default field name, we want to
+ // resolve the parent descriptor first.
+ if (path.back() == DEFAULT_FIELD_NAME) {
+ std::vector<std::string> descPath;
+ descPath.insert(descPath.end(), path.begin(), path.end() - 1);
+ return resolve(&RttiTypes::Descriptor, descPath, owner, logger,
+ [resultCallback](Handle<Node> resolved,
+ Handle<Node> owner, Logger &logger) {
+ if (resolved != nullptr) {
+ resultCallback(
+ resolved.cast<Descriptor>()->getFieldDescriptor(), owner,
+ logger);
+ } else {
+ resultCallback(nullptr, owner, logger);
+ }
+ });
+ }
+
+ // If it is not the default field, we can just forward to resolve
+ return resolve(&RttiTypes::FieldDescriptor, path, owner, logger,
+ resultCallback);
+}
+
+bool ParserScope::resolveFieldDescriptor(
+ const std::string &name, Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback)
+{
+ return resolveFieldDescriptor(Utils::split(name, '.'), owner, logger,
+ resultCallback);
+}
}
diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp
index bd6a29f..58fc037 100644
--- a/src/core/parser/ParserScope.hpp
+++ b/src/core/parser/ParserScope.hpp
@@ -679,7 +679,6 @@ public:
* Resolves a typesystem type. Makes sure an array type is returned if an
* array type is requested.
*
- * @tparam T is the type of the node that should be resolved.
* @param name is the path for which a node should be resolved. The name is
* split at '.' to form a path.
* @param owner is the node for which the resolution takes place.
@@ -715,7 +714,6 @@ public:
* Resolves a type and makes sure the corresponding value is of the correct
* type.
*
- * @tparam T is the type of the node that should be resolved.
* @param path is the path for which a node should be resolved.
* @param owner is the node for which the resolution takes place.
* @param value is a reference at the Variant that represents the value for
@@ -739,7 +737,6 @@ public:
* Resolves a type and makes sure the corresponding value is of the correct
* type.
*
- * @tparam T is the type of the node that should be resolved.
* @param name is the path for which a node should be resolved. The name is
* split at '.' to form a path.
* @param owner is the node for which the resolution takes place.
@@ -760,6 +757,44 @@ public:
ResolutionResultCallback resultCallback);
/**
+ * Resolves a FieldDescriptor. Makes sure that the default field can be
+ * handled.
+ *
+ * @param path is the path for which a node should be resolved.
+ * @param owner is the node for which the resolution takes place.
+ * @param logger is the logger instance into which resolution problems
+ * should be logged.
+ * @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.
+ */
+ bool resolveFieldDescriptor(const std::vector<std::string> &path,
+ Handle<Node> owner, Logger &logger,
+ ResolutionResultCallback resultCallback);
+
+ /**
+ * Resolves a FieldDescriptor. Makes sure that the default field can be
+ * handled.
+ *
+ * @param name is the path for which a node should be resolved. The name is
+ * split at '.' to form a path.
+ * @param owner is the node for which the resolution takes place.
+ * @param logger is the logger instance into which resolution problems
+ * should be logged.
+ * @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.
+ */
+ bool resolveFieldDescriptor(const std::string &name, Handle<Node> owner,
+ Logger &logger,
+ ResolutionResultCallback resultCallback);
+ /**
* Tries to resolve all currently deferred resolution steps. The list of
* pending deferred resolutions is cleared after this function has run.
*