From 586b4486f4661681b8fe0c639830bd9db3986d5a Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Wed, 15 Apr 2015 20:42:01 +0200 Subject: Simplify resolution callback, move NullResolveCallback to ResolutionCallbacks.cpp --- src/core/parser/ParserScope.cpp | 23 +++++++++-------------- src/core/parser/ParserScope.hpp | 4 +--- 2 files changed, 10 insertions(+), 17 deletions(-) (limited to 'src/core/parser') diff --git a/src/core/parser/ParserScope.cpp b/src/core/parser/ParserScope.cpp index 5e4b37f..7a7cb74 100644 --- a/src/core/parser/ParserScope.cpp +++ b/src/core/parser/ParserScope.cpp @@ -409,20 +409,15 @@ bool ParserScope::resolveType(const std::string &name, Handle owner, return resolveType(Utils::split(name, '.'), owner, logger, resultCallback); } -bool ParserScope::resolveValue(Variant &data, Handle owner, - Handle type, Logger &logger) +bool ParserScope::resolveValue(Variant &data, Handle type, Logger &logger) { - return type->build(data, logger, - [&](bool async, const Rtti *rttiType, - const std::vector &path, - ResolutionResultCallback resultCallback) mutable { - if (!async) { - Rooted resolved = ParserScopeBase::resolve(rttiType, path, logger); - resultCallback(resolved, owner, logger); - return resolved != nullptr; - } - return resolve(rttiType, path, type, logger, resultCallback); - }); + // Run the build function + return type->build( + data, logger, + [&logger, this](const Rtti *rttiType, + const std::vector &path) mutable { + return ParserScopeBase::resolve(rttiType, path, logger); + }); } bool ParserScope::resolveTypeWithValue(const std::vector &path, @@ -440,7 +435,7 @@ bool ParserScope::resolveTypeWithValue(const std::vector &path, [=](Handle resolved, Handle owner, Logger &logger) mutable { if (resolved != nullptr) { Rooted type = resolved.cast(); - scope.resolveValue(*valuePtr, owner, type, logger); + scope.resolveValue(*valuePtr, type, logger); } // Call the result callback with the type diff --git a/src/core/parser/ParserScope.hpp b/src/core/parser/ParserScope.hpp index eec4751..b4ce037 100644 --- a/src/core/parser/ParserScope.hpp +++ b/src/core/parser/ParserScope.hpp @@ -700,14 +700,12 @@ public: * @param data is a reference at a variant that may contain magic values * (even in inner structures). The data will be passed to the "build" * function of the given type. - * @param owner is the node for which the resolution takes place. * @param type is the Typesystem type the data should be interpreted with. * @param logger is the logger instance into which resolution problems * should be logged. * @return true if the value was successfully built. */ - bool resolveValue(Variant &data, Handle owner, Handle type, - Logger &logger); + bool resolveValue(Variant &data, Handle type, Logger &logger); /** * Resolves a type and makes sure the corresponding value is of the correct -- cgit v1.2.3