diff options
Diffstat (limited to 'src/core/parser/ParserScope.hpp')
-rw-r--r-- | src/core/parser/ParserScope.hpp | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index 2378967..e01acfe 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -50,14 +50,18 @@ class ParserScope; * Callback function type used for creating a dummy object while no correct * object is available for resolution. */ -using ResolutionImposterCallback = std::function<Rooted<Node>()>; +using ResolutionImposterCallback = Rooted<Node>(*)(); /** * Callback function type called whenever the result of a resolution is * available. + * + * @param resolved is the new, resolved node. + * @param owner is the node that was passed as "owner". + * @param logger is the logger to which errors should be logged. */ -using ResolutionResultCallback = - std::function<void(Handle<Node>, Logger &logger)>; +using ResolutionResultCallback = void (*)(Handle<Node> resolved, + Handle<Node> owner, Logger &logger); /** * Base class for the @@ -90,14 +94,14 @@ public: * Tries to resolve a node for the given type and path for all nodes that * are currently in the stack, starting with the topmost node on the stack. * - * @param path is the path for which a node should be resolved. * @param type is the type of the node that should be resolved. + * @param path is the path for which a node should be resolved. * @param logger is the logger instance into which resolution problems * should be logged. * @return a reference at a resolved node or nullptr if no node could be * found. */ - Rooted<Node> resolve(const std::vector<std::string> &path, const Rtti &type, + Rooted<Node> resolve(const Rtti &type, const std::vector<std::string> &path, Logger &logger); }; @@ -396,8 +400,9 @@ public: * temporary) and another time if the resolution turned out to be * successful at a later point in time. * - * @param path is the path for which a node should be resolved. * @param type 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 logger is the logger instance into which resolution problems * should be logged. * @param imposterCallback is the callback function that is called if @@ -410,15 +415,14 @@ public: * the resolved object directly when this function is called. If the * resolution was not successful the first time, it may be called another * time later in the context of the "performDeferredResolution" function. - * @param owner is the node for which the resolution takes place. * @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 resolve(const std::vector<std::string> &path, const Rtti &type, - Logger &logger, ResolutionImposterCallback imposterCallback, - ResolutionResultCallback resultCallback, - Handle<Node> owner = nullptr); + bool resolve(const Rtti &type, const std::vector<std::string> &path, + Handle<Node> owner, Logger &logger, + ResolutionImposterCallback imposterCallback, + ResolutionResultCallback resultCallback); /** * Tries to resolve a node for the given type and path for all nodes @@ -426,21 +430,21 @@ public: * The "resultCallback" is called when the resolution was successful, which * may be at a later point in time. * - * @param path is the path for which a node should be resolved. * @param type 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 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. - * @param owner is the node for which the resolution takes place. * @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 resolve(const std::vector<std::string> &path, const Rtti &type, - Logger &logger, ResolutionResultCallback resultCallback, - Handle<Node> owner = nullptr); + bool resolve(const Rtti &type, const std::vector<std::string> &path, + Handle<Node> owner, Logger &logger, + ResolutionResultCallback resultCallback); /** * Tries to resolve a node for the given type and path for all nodes @@ -453,6 +457,7 @@ public: * * @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 logger is the logger instance into which resolution problems * should be logged. * @param imposterCallback is the callback function that is called if @@ -465,24 +470,17 @@ public: * resolved object directly when this function is called. If the resolution * was not successful the first time, it may be called another time later * in the context of the "performDeferredResolution" function. - * @param owner is the node for which the resolution takes place. * @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. */ template <class T> - bool resolve(const std::vector<std::string> &path, Logger &logger, - std::function<Rooted<T>()> imposterCallback, - std::function<void(Handle<T>, Logger &)> resultCallback, - Handle<Node> owner = nullptr) + bool resolve(const std::vector<std::string> &path, Handle<Node> owner, + Logger &logger, ResolutionImposterCallback imposterCallback, + ResolutionResultCallback resultCallback) { - return resolve( - path, typeOf<T>(), logger, - [imposterCallback]() -> Rooted<Node> { return imposterCallback(); }, - [resultCallback](Handle<Node> node, Logger &logger) { - resultCallback(node.cast<T>(), logger); - }, - owner); + return resolve(typeOf<T>(), path, owner, logger, imposterCallback, + resultCallback); } /** @@ -493,26 +491,21 @@ public: * * @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 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. - * @param owner is the node for which the resolution takes place. * @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. */ template <class T> - bool resolve(const std::vector<std::string> &path, Logger &logger, - std::function<void(Handle<T>, Logger &)> resultCallback, - Handle<Node> owner = nullptr) + bool resolve(const std::vector<std::string> &path, Handle<Node> owner, + Logger &logger, ResolutionResultCallback resultCallback) { - return resolve(path, typeOf<T>(), logger, - [resultCallback](Handle<Node> node, Logger &logger) { - resultCallback(node.cast<T>(), logger); - }, - owner); + return resolve(typeOf<T>(), path, owner, logger, resultCallback); } /** @@ -527,6 +520,7 @@ public: * @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. * @param logger is the logger instance into which resolution problems * should be logged. * @param imposterCallback is the callback function that is called if @@ -539,19 +533,17 @@ public: * resolved object directly when this function is called. If the resolution * was not successful the first time, it may be called another time later * in the context of the "performDeferredResolution" function. - * @param owner is the node for which the resolution takes place. * @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. */ template <class T> - bool resolve(const std::string &name, Logger &logger, - std::function<Rooted<T>()> imposterCallback, - std::function<void(Handle<T>, Logger &)> resultCallback, - Handle<Node> owner = nullptr) + bool resolve(const std::string &name, Handle<Node> owner, Logger &logger, + ResolutionImposterCallback imposterCallback, + ResolutionResultCallback resultCallback) { - return resolve<T>(Utils::split(name, '.'), logger, imposterCallback, - resultCallback, owner); + return resolve<T>(Utils::split(name, '.'), owner, logger, + imposterCallback, resultCallback); } /** @@ -574,12 +566,11 @@ public: * later. */ template <class T> - bool resolve(const std::string &name, Logger &logger, - std::function<void(Handle<T>, Logger &)> resultCallback, - Handle<Node> owner = nullptr) + bool resolve(const std::string &name, Handle<Node> owner, Logger &logger, + ResolutionResultCallback resultCallback) { - return resolve<T>(Utils::split(name, '.'), logger, resultCallback, - owner); + return resolve<T>(Utils::split(name, '.'), owner, logger, + resultCallback); } /** |