mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps] "(x)" is a static char[] of Shared::StorageFunction
This commit is contained in:
@@ -40,7 +40,7 @@ void StorageListController::renameSelectedFunction() {
|
||||
bool StorageListController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
|
||||
// Compute the new name
|
||||
size_t textLength = strlen(text);
|
||||
size_t argumentLength = strlen("(x)"); //TODO
|
||||
size_t argumentLength = StorageFunction::k_parenthesedArgumentLength;
|
||||
constexpr int maxBaseNameSize = StorageFunction::k_maxNameWithArgumentSize;
|
||||
char baseName[maxBaseNameSize];
|
||||
if (textLength <= argumentLength) {
|
||||
|
||||
@@ -8,6 +8,8 @@ using namespace Poincare;
|
||||
|
||||
namespace Shared {
|
||||
|
||||
char StorageFunction::k_parenthesedArgument[]("(x)");
|
||||
|
||||
uint32_t StorageFunction::checksum() {
|
||||
assert(!isNull());
|
||||
return checksum();
|
||||
@@ -28,16 +30,15 @@ void StorageFunction::setActive(bool active) {
|
||||
int StorageFunction::nameWithArgument(char * buffer, size_t bufferSize, char arg) {
|
||||
const char * functionName = fullName();
|
||||
size_t index = 0;
|
||||
const char ofXSring[4] = {'(',arg,')', 0};
|
||||
size_t ofXSringLength = strlen(ofXSring);
|
||||
k_parenthesedArgument[1] = arg;
|
||||
while (*functionName != Ion::Storage::k_dotChar
|
||||
&& index < bufferSize - ofXSringLength - 1)
|
||||
&& index < bufferSize - k_parenthesedArgumentLength - 1)
|
||||
{
|
||||
// We keep room to write the final "(x)" //TODO should we?
|
||||
assert(functionName < fullName() + strlen(fullName()));
|
||||
buffer[index++] = *functionName++;
|
||||
}
|
||||
return index + strlcpy(&buffer[index], ofXSring, bufferSize-index);
|
||||
return index + strlcpy(&buffer[index], k_parenthesedArgument, bufferSize-index);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -9,7 +9,9 @@ namespace Shared {
|
||||
|
||||
class StorageFunction : public StorageExpressionModel {
|
||||
public:
|
||||
constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + 4; /* Function name and null-terminating char + "(x)" */;
|
||||
constexpr static int k_parenthesedArgumentLength = 3;
|
||||
constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + k_parenthesedArgumentLength; /* Function name and null-terminating char + "(x)" */;
|
||||
|
||||
// Constructors
|
||||
StorageFunction(Ion::Storage::Record record) : StorageExpressionModel(record){}
|
||||
|
||||
@@ -44,6 +46,7 @@ protected:
|
||||
bool m_active;
|
||||
};
|
||||
private:
|
||||
static char k_parenthesedArgument[k_parenthesedArgumentLength+1];
|
||||
template<typename T> T templatedApproximateAtAbscissa(T x, Poincare::Context * context) const;
|
||||
FunctionRecordData * recordData() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user