mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 00:00:44 +01:00
[ion] Ion::Storage is not a global variable anymore
This commit is contained in:
@@ -4,8 +4,7 @@
|
||||
#include "variable_box_controller.h"
|
||||
#include <apps/code/app.h>
|
||||
#include <escher/metric.h>
|
||||
|
||||
extern Ion::Storage storage;
|
||||
#include <ion.h>
|
||||
|
||||
namespace Code {
|
||||
|
||||
@@ -28,7 +27,7 @@ void EditorController::setScript(Script script) {
|
||||
m_script = script;
|
||||
const char * scriptBody = m_script.readContent();
|
||||
size_t scriptBodySize = strlen(scriptBody)+1;
|
||||
size_t availableScriptSize = scriptBodySize + storage.availableSize();
|
||||
size_t availableScriptSize = scriptBodySize + Ion::Storage::sharedStorage()->availableSize();
|
||||
assert(m_areaBuffer == nullptr);
|
||||
m_areaBuffer = new char[availableScriptSize];
|
||||
strlcpy(m_areaBuffer, scriptBody, scriptBodySize);
|
||||
|
||||
@@ -26,7 +26,7 @@ void ScriptStore::deleteAllScripts() {
|
||||
}
|
||||
|
||||
bool ScriptStore::isFull() {
|
||||
return (numberOfScripts() >= k_maxNumberOfScripts || storage.availableSize() < k_fullFreeSpaceSizeLimit);
|
||||
return (numberOfScripts() >= k_maxNumberOfScripts || Ion::Storage::sharedStorage()->availableSize() < k_fullFreeSpaceSizeLimit);
|
||||
}
|
||||
|
||||
void ScriptStore::scanScriptsForFunctionsAndVariables(void * context, ScanCallback storeFunction, ScanCallback storeVariable) {
|
||||
@@ -124,7 +124,7 @@ Script::ErrorStatus ScriptStore::addScriptFromTemplate(const ScriptTemplate * sc
|
||||
char * body = new char[scriptSize+Script::k_importationStatusSize];
|
||||
body[0] = 1;
|
||||
strlcpy(body+Script::k_importationStatusSize, scriptTemplate->content(), scriptSize);
|
||||
Script::ErrorStatus err = storage.createRecord(scriptTemplate->name(), body, scriptSize+Script::k_importationStatusSize);
|
||||
Script::ErrorStatus err = Ion::Storage::sharedStorage()->createRecord(scriptTemplate->name(), body, scriptSize+Script::k_importationStatusSize);
|
||||
assert(err != Script::ErrorStatus::NonCompliantName);
|
||||
delete[] body;
|
||||
return err;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef CODE_SCRIPT_STORE_H
|
||||
#define CODE_SCRIPT_STORE_H
|
||||
|
||||
#include <ion.h>
|
||||
#include "script.h"
|
||||
#include "script_template.h"
|
||||
#include <python/port/port.h>
|
||||
@@ -8,8 +9,6 @@ extern "C" {
|
||||
#include "py/parse.h"
|
||||
}
|
||||
|
||||
extern Ion::Storage storage;
|
||||
|
||||
namespace Code {
|
||||
|
||||
class ScriptStore : public MicroPython::ScriptProvider {
|
||||
@@ -20,13 +19,13 @@ public:
|
||||
|
||||
ScriptStore();
|
||||
Script scriptAtIndex(int index) {
|
||||
return Script(storage.recordWithExtensionAtIndex(k_scriptExtension, index));
|
||||
return Script(Ion::Storage::sharedStorage()->recordWithExtensionAtIndex(k_scriptExtension, index));
|
||||
}
|
||||
Script scriptNamed(const char * name) {
|
||||
return Script(storage.recordNamed(name));
|
||||
return Script(Ion::Storage::sharedStorage()->recordNamed(name));
|
||||
}
|
||||
int numberOfScripts() {
|
||||
return storage.numberOfRecordsWithExtension(k_scriptExtension);
|
||||
return Ion::Storage::sharedStorage()->numberOfRecordsWithExtension(k_scriptExtension);
|
||||
}
|
||||
Ion::Storage::Record::ErrorStatus addNewScript() {
|
||||
return addScriptFromTemplate(ScriptTemplate::Empty());
|
||||
|
||||
Reference in New Issue
Block a user