diff options
author | Marius Kintel <marius@kintel.net> | 2013-04-27 04:55:15 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-04-27 04:55:15 (GMT) |
commit | 6b3daa748543f13cc7cf8eff1c9efeebd6dc3a14 (patch) | |
tree | 8869b03872b42ce1ffb1755958d05925f9f0bcb4 /src/module.cc | |
parent | f0ee85e17d474ab9119f82ee6f802d4634743b12 (diff) | |
parent | 5f10c9f9c0a9805567ea8f9b560c6e0b50126119 (diff) |
Merge pull request #326 from openscad/issue217
Issue217
Diffstat (limited to 'src/module.cc')
-rw-r--r-- | src/module.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/module.cc b/src/module.cc index e6dcb57..322085b 100644 --- a/src/module.cc +++ b/src/module.cc @@ -32,6 +32,9 @@ #include "function.h" #include "printutils.h" +#include <boost/filesystem.hpp> +namespace fs = boost::filesystem; +#include "boosty.h" #include <boost/foreach.hpp> #include <sstream> #include <sys/stat.h> @@ -67,6 +70,19 @@ IfElseModuleInstantiation::~IfElseModuleInstantiation() BOOST_FOREACH (ModuleInstantiation *v, else_children) delete v; } +/*! + Returns the absolute path to the given filename, unless it's empty. + */ +std::string ModuleInstantiation::getAbsolutePath(const std::string &filename) const +{ + if (!filename.empty() && !boosty::is_absolute(fs::path(filename))) { + return boosty::absolute(fs::path(this->modpath) / filename).string(); + } + else { + return filename; + } +} + std::string ModuleInstantiation::dump(const std::string &indent) const { std::stringstream dump; @@ -152,15 +168,15 @@ AbstractNode *Module::evaluate(const Context *ctx, const ModuleInstantiation *in c.functions_p = &functions; c.modules_p = &modules; - + if (!usedlibs.empty()) c.usedlibs_p = &usedlibs; else c.usedlibs_p = NULL; - + BOOST_FOREACH(const std::string &var, assignments_var) { c.set_variable(var, assignments.at(var)->evaluate(&c)); - } + } AbstractNode *node = new AbstractNode(inst); for (size_t i = 0; i < children.size(); i++) { |