FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Call load_callback for all includes, even cached by glankk · Pull Request #703 · cppcheck-opensource/simplecpp · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 11 additions & 4 deletions simplecpp.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3232,13 +3232,10 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::tryload(FileDat
mImpl->mIdMap.emplace(fileId, data);
mData.emplace_back(data);

if (mLoadCallback)
mLoadCallback(*data);

return {data, true};
}

std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get_private(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
{
if (isAbsolutePath(header)) {
auto ins = mNameMap.emplace(simplecpp::simplifyPath(header), nullptr);
Expand Down Expand Up @@ -3284,6 +3281,16 @@ std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::
return {nullptr, false};
}

std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList)
{
auto ret = get_private(sourcefile, header, dui, systemheader, filenames, outputList);

if (mLoadCallback && ret.first)
mLoadCallback(*ret.first, ret.second);

return ret;
}

void simplecpp::FileDataCache::clear()
{
mImpl->clear();
Expand Down
3 changes: 2 additions & 1 deletion simplecpp.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ namespace simplecpp {
return mData.cend();
}

using load_callback_type = std::function<void (FileData &)>;
using load_callback_type = std::function<void (FileData &, bool)>;

void set_load_callback(load_callback_type cb) {
mLoadCallback = std::move(cb);
Expand All @@ -524,6 +524,7 @@ namespace simplecpp {
using name_map_type = std::unordered_map<std::string, FileData *>;

std::pair<FileData *, bool> tryload(name_map_type::iterator &name_it, const DUI &dui, std::vector<std::string> &filenames, OutputList *outputList);
std::pair<FileData *, bool> get_private(const std::string &sourcefile, const std::string &header, const DUI &dui, bool systemheader, std::vector<std::string> &filenames, OutputList *outputList);

container_type mData;
name_map_type mNameMap;
Expand Down
Loading

Back | FazBrowse Home | New Git URL