[apps/code] The console marks imported script for the var box

After lauching the console, if we fetch a script we mark it as fetched.
When the variable box displays variables from imported scripts, it scans
all the variables from the scripts marked as fetched.
This commit is contained in:
Léa Saviot
2020-04-29 16:54:28 +02:00
committed by Émilie Feral
parent 9e973adbab
commit d1c8bbdaf7
13 changed files with 66 additions and 42 deletions

View File

@@ -25,16 +25,27 @@ bool ScriptStore::isFull() {
return Ion::Storage::sharedStorage()->availableSize() < k_fullFreeSpaceSizeLimit;
}
const char * ScriptStore::contentOfScript(const char * name) {
const char * ScriptStore::contentOfScript(const char * name, bool markAsFetched) {
Script script = ScriptNamed(name);
if (script.isNull()) {
return nullptr;
}
if (markAsFetched) {
script.setContentFetchedFromConsole(true);
}
return script.scriptContent();
}
void ScriptStore::clearFetchInformation() {
// TODO optimize fetches
const int scriptsCount = numberOfScripts();
for (int i = 0; i < scriptsCount; i++) {
scriptAtIndex(i).setContentFetchedFromConsole(false);
}
}
Script::ErrorStatus ScriptStore::addScriptFromTemplate(const ScriptTemplate * scriptTemplate) {
size_t valueSize = strlen(scriptTemplate->content())+1+1;// scriptcontent size + 1 char for the importation status
size_t valueSize = Script::InformationSize() + strlen(scriptTemplate->content()) + 1; // (auto importation status + content fetched status) + scriptcontent size + null-terminating char
assert(Script::nameCompliant(scriptTemplate->name()));
Script::ErrorStatus err = Ion::Storage::sharedStorage()->createRecordWithFullName(scriptTemplate->name(), scriptTemplate->value(), valueSize);
assert(err != Script::ErrorStatus::NonCompliantName);