Skip to content

Commit 9891efa

Browse files
adriwebcodex
andcommitted
[WIP] TI-84 Evo file format support + conversion API
Co-Authored-By: Codex CLI <codex@openai.com>
1 parent b422850 commit 9891efa

103 files changed

Lines changed: 4178 additions & 10 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [master,evo]
66
pull_request:
77
branches: [master]
88

TIVarsLib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TIVarsLib.wasm

182 KB
Binary file not shown.

cli/cli.cpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ enum FileType
2626
enum FileType getType(const cxxopts::ParseResult& options, const string& filename, const string& option);
2727
bool isFlashType(const TIVarType& type);
2828
bool isFlashExtension(const string& extension);
29+
bool isEvoVarExtension(const string& extension);
30+
bool isLegacyVarExtension(const string& extension);
31+
string extensionOf(const string& path);
2932
string lowercase(string value);
3033

3134
int main(int argc, char** argv)
@@ -250,6 +253,10 @@ int main(int argc, char** argv)
250253
return 1;
251254
}
252255
}
256+
else if (oformat == VARFILE && isEvoVarExtension(extensionOf(opath)))
257+
{
258+
requestedModel = TIModel{"84Evo"};
259+
}
253260

254261
TIVarFile file = iformat == VARFILE
255262
? TIVarFile::loadFromFile(ipath)
@@ -263,7 +270,15 @@ int main(int argc, char** argv)
263270
}
264271
if (result.count("calc"))
265272
{
266-
file.setCalcModel(requestedModel);
273+
file.convertToModel(requestedModel);
274+
}
275+
else if (oformat == VARFILE && isEvoVarExtension(extensionOf(opath)) && !file.isEvoFormat())
276+
{
277+
file.convertToModel(TIModel{"84Evo"});
278+
}
279+
else if (oformat == VARFILE && isLegacyVarExtension(extensionOf(opath)) && file.isEvoFormat())
280+
{
281+
file.convertToModel(TIModel{"84+CE"});
267282
}
268283
}
269284

@@ -411,6 +426,16 @@ string lowercase(string value)
411426
return value;
412427
}
413428

429+
string extensionOf(const string& path)
430+
{
431+
const auto pos = path.find_last_of('.');
432+
if (pos == string::npos)
433+
{
434+
return "";
435+
}
436+
return lowercase(path.substr(pos + 1));
437+
}
438+
414439
bool isFlashExtension(const string& extension)
415440
{
416441
const string lowered = lowercase(extension);
@@ -424,6 +449,40 @@ bool isFlashExtension(const string& extension)
424449
return false;
425450
}
426451

452+
bool isEvoVarExtension(const string& extension)
453+
{
454+
const string lowered = lowercase(extension);
455+
if (!TIVarTypes::isValidName(lowered))
456+
{
457+
return false;
458+
}
459+
460+
const TIVarType type{lowered};
461+
const auto& exts = type.getExts();
462+
return exts.size() > 9 && lowercase(exts[9]) == lowered;
463+
}
464+
465+
bool isLegacyVarExtension(const string& extension)
466+
{
467+
const string lowered = lowercase(extension);
468+
if (!TIVarTypes::isValidName(lowered))
469+
{
470+
return false;
471+
}
472+
473+
const TIVarType type{lowered};
474+
const auto& exts = type.getExts();
475+
const size_t legacyExtCount = std::min<size_t>(9, exts.size());
476+
for (size_t i = 0; i < legacyExtCount; i++)
477+
{
478+
if (!exts[i].empty() && lowercase(exts[i]) == lowered)
479+
{
480+
return true;
481+
}
482+
}
483+
return false;
484+
}
485+
427486
static unordered_map<string, FileType> const fileTypes = {
428487
{"raw", RAW},
429488
{"readable", READABLE},

0 commit comments

Comments
 (0)