summaryrefslogtreecommitdiff
path: root/src/ModuleCache.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-05-27 05:08:31 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-05-27 05:08:31 (GMT)
commit37dc9342a14206f5862447eb9d3d5049ec67f638 (patch)
tree17e5a57dfa154821918094cab47476189771ce00 /src/ModuleCache.cc
parent6742ad55f4cf335fc767ab65784aab81e06b61d0 (diff)
parent0967a26bff45951d7b86fe628e8b1156e6e40ede (diff)
Merge branch 'master' of github.com:openscad/openscad into issue125
Diffstat (limited to 'src/ModuleCache.cc')
-rw-r--r--src/ModuleCache.cc26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index 4944495..505015e 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -14,32 +14,32 @@
#include <time.h>
#include <sys/stat.h>
+//#include "parsersettings.h"
/*!
FIXME: Implement an LRU scheme to avoid having an ever-growing module cache
*/
ModuleCache *ModuleCache::inst = NULL;
-static bool is_modified(const std::string &filename, const time_t &mtime)
-{
- struct stat st;
- memset(&st, 0, sizeof(struct stat));
- stat(filename.c_str(), &st);
- return (st.st_mtime > mtime);
-}
+/*!
+ Reevaluate the given file and recompile if necessary.
+ Returns NULL on any error (e.g. compile error or file not found)
+ If the given filename is relative, it means that the module hasn't been
+ previously located.
+*/
FileModule *ModuleCache::evaluate(const std::string &filename)
{
FileModule *lib_mod = NULL;
- // Create cache ID
+ // Create cache ID
struct stat st;
memset(&st, 0, sizeof(struct stat));
stat(filename.c_str(), &st);
std::string cache_id = str(boost::format("%x.%x") % st.st_mtime % st.st_size);
- // Lookup in cache
+ // Lookup in cache
if (this->entries.find(filename) != this->entries.end() &&
this->entries[filename].cache_id == cache_id) {
#ifdef DEBUG
@@ -48,15 +48,15 @@ FileModule *ModuleCache::evaluate(const std::string &filename)
#endif
lib_mod = &(*this->entries[filename].module);
- BOOST_FOREACH(const FileModule::IncludeContainer::value_type &item, lib_mod->includes) {
- if (is_modified(item.first, item.second)) {
+ BOOST_FOREACH(const FileModule::IncludeContainer::value_type &include, lib_mod->includes) {
+ if (lib_mod->include_modified(include.second)) {
lib_mod = NULL;
break;
}
}
}
- // If cache lookup failed (non-existing or old timestamp), compile module
+ // If cache lookup failed (non-existing or old timestamp), compile module
if (!lib_mod) {
#ifdef DEBUG
if (this->entries.find(filename) != this->entries.end()) {
@@ -91,7 +91,7 @@ FileModule *ModuleCache::evaluate(const std::string &filename)
if (lib_mod) {
// We defer deletion so we can ensure that the new module won't
- // have the same address as the old
+ // have the same address as the old
delete oldmodule;
this->entries[filename].module = lib_mod;
} else {
contact: Jan Huwald // Impressum