moved SPF_GetIncludeDependencies to json
This commit is contained in:
@@ -1308,13 +1308,12 @@ int SPF_GetIntrinsics(void*& context, short *&result)
|
||||
return (int)resVal.size() + 1;
|
||||
}
|
||||
|
||||
extern map<string, set<string>> includeDependencies;
|
||||
extern map<string, vector<pair<int, string>>> includeDependencies;
|
||||
int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, short *projName, short *&result, short*& output, int*& outputSize,
|
||||
short*& outputMessage, int*& outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
string resVal = "";
|
||||
|
||||
setOptions(options);
|
||||
int retSize = 0;
|
||||
@@ -1322,23 +1321,28 @@ int SPF_GetIncludeDependencies(void*& context, int winHandler, short *options, s
|
||||
{
|
||||
runPassesForVisualizer(projName, { BUILD_INCLUDE_DEPENDENCIES });
|
||||
|
||||
int i = 0;
|
||||
for (auto &deps : includeDependencies)
|
||||
json inc_array = json::array();
|
||||
for (const auto& deps : includeDependencies)
|
||||
{
|
||||
if (i != 0)
|
||||
resVal += "@";
|
||||
resVal += deps.first + "@";
|
||||
int k = 0;
|
||||
for (auto &incl : deps.second)
|
||||
json includes;
|
||||
includes["file"] = deps.first;
|
||||
|
||||
json array = json::array();
|
||||
for (const auto& [line, incl] : deps.second)
|
||||
{
|
||||
if (k != 0)
|
||||
resVal += "|";
|
||||
resVal += incl;
|
||||
++k;
|
||||
json elem;
|
||||
elem["line"] = line;
|
||||
elem["dependencyFileName"] = incl;
|
||||
array.push_back(elem);
|
||||
}
|
||||
++i;
|
||||
includes["includes"] = array;
|
||||
inc_array.push_back(includes);
|
||||
}
|
||||
|
||||
json allIncludes;
|
||||
allIncludes["allIncludes"] = inc_array;
|
||||
string resVal = allIncludes.dump();
|
||||
|
||||
copyStringToShort(result, resVal);
|
||||
retSize = (int)resVal.size() + 1;
|
||||
}
|
||||
@@ -2171,36 +2175,41 @@ int SPF_InlineProcedures(void*& context, int winHandler, short* options, short*
|
||||
}
|
||||
|
||||
|
||||
extern map<string, set<string>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *filesToInclude,
|
||||
extern map<string, vector<pair<int, string>>> filesToInclude;
|
||||
int SPF_InsertIncludesPass(void*& context, int winHandler, short *options, short *projName, short *folderName, char *visFilesToInclude,
|
||||
short *&output, int *&outputSize, short *&outputMessage, int *&outputMessageSize)
|
||||
{
|
||||
MessageManager::clearCache();
|
||||
MessageManager::setWinHandler(winHandler);
|
||||
|
||||
if (filesToInclude == NULL)
|
||||
if (visFilesToInclude == NULL)
|
||||
return -2;
|
||||
|
||||
vector<string> splited;
|
||||
//printf("%s\n", conv);
|
||||
splitString(filesToInclude, '|', splited);
|
||||
splitString(visFilesToInclude, '|', splited);
|
||||
|
||||
if (splited.size() == 0)
|
||||
return -3;
|
||||
|
||||
::filesToInclude.clear();
|
||||
filesToInclude.clear();
|
||||
for (int i = 0; i < splited.size(); ++i)
|
||||
{
|
||||
string file = splited[i];
|
||||
int num = 0;
|
||||
if (sscanf(splited[i + 1].c_str(), "%d", &num) == -1)
|
||||
return -3;
|
||||
return -4;
|
||||
|
||||
__spf_print(1, "file = %s:\n", file.c_str());
|
||||
for (int k = i + 2; k < i + 2 + num; ++k)
|
||||
for (int k = i + 2; k < i + 2 + 2 * num; k += 2)
|
||||
{
|
||||
::filesToInclude[file].insert(splited[k]);
|
||||
__spf_print(1, " include = %s\n", splited[k].c_str());
|
||||
int line = 0;
|
||||
if (sscanf(splited[k].c_str(), "%d", &line) == -1)
|
||||
return -5;
|
||||
|
||||
auto pair = make_pair(line, splited[k + 1]);
|
||||
filesToInclude[file].push_back(pair);
|
||||
__spf_print(1, " include = [%d %s]\n", pair.first, pair.second.c_str());
|
||||
}
|
||||
i += 1 + num;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user