@@ -35,13 +35,17 @@ namespace tivars
3535
3636// Wrap the makeDataFromStr function by one that adds the type/subtype in the options
3737// Ideally, the handlers would parse the string and select the correct handler to dispatch...
38- #define GenericHandlerPair (which, type ) make_pair([](const std::string& str, const options_t & options, const TIVarFile* _ctx) -> data_t { \
39- options_t options_withType = options; \
40- options_withType[" _type" ] = type; \
41- return (TypeHandlers::TH_Generic##which::makeDataFromString)(str, options_withType, _ctx); \
42- }, &TypeHandlers::TH_Generic##which::makeStringFromData)
38+ #define GenericHandlerTuple (which, type ) TypeHandlersTuple{ \
39+ [](const std::string& str, const options_t & options, const TIVarFile* _ctx) -> data_t { \
40+ options_t options_withType = options; \
41+ options_withType[" _type" ] = type; \
42+ return (TypeHandlers::TH_Generic##which::makeDataFromString)(str, options_withType, _ctx); \
43+ }, \
44+ &(TypeHandlers::TH_Generic##which::makeStringFromData), \
45+ &(TypeHandlers::TH_Generic##which::getMinVersionFromData), \
46+ }
4347
44- void TIVarTypes::insertType (const std::string& name, int id, const std::vector<std::string>& exts, const handler_pair_t & handlers)
48+ void TIVarTypes::insertType (const std::string& name, int id, const std::vector<std::string>& exts, const TypeHandlersTuple & handlers)
4549 {
4650 const TIVarType varType (id, name, exts, handlers);
4751 types[name] = varType;
@@ -67,44 +71,44 @@ namespace tivars
6771 const std::string _;
6872
6973 /* Standard types */
70- insertType (" Real" , 0x00 , {" 82n" , " 83n" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" }, GenericHandlerPair (Real, 0x00 ) );
71- insertType (" RealList" , 0x01 , {" 82l" , " 83l" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" }, GenericHandlerPair (List, 0x00 ) );
72- insertType (" Matrix" , 0x02 , {" 82m" , " 83m" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" }, make_handler_pair (TH_Matrix) );
73- insertType (" Equation" , 0x03 , {" 82y" , " 83y" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" }, make_handler_pair (TH_Tokenized) );
74- insertType (" String" , 0x04 , {" 82s" , " 83s" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" }, make_handler_pair (TH_Tokenized) );
75- insertType (" Program" , 0x05 , {" 82p" , " 83p" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" }, make_handler_pair (TH_Tokenized) );
76- insertType (" ProtectedProgram" , 0x06 , {" 82p" , " 83p" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" }, make_handler_pair (TH_Tokenized) );
74+ insertType (" Real" , 0x00 , {" 82n" , " 83n" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" }, GenericHandlerTuple (Real, 0x00 ) );
75+ insertType (" RealList" , 0x01 , {" 82l" , " 83l" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" }, GenericHandlerTuple (List, 0x00 ) );
76+ insertType (" Matrix" , 0x02 , {" 82m" , " 83m" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" , " 8xm" }, SpecificHandlerTuple (TH_Matrix) );
77+ insertType (" Equation" , 0x03 , {" 82y" , " 83y" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" }, SpecificHandlerTuple (TH_Tokenized) );
78+ insertType (" String" , 0x04 , {" 82s" , " 83s" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" , " 8xs" }, SpecificHandlerTuple (TH_Tokenized) );
79+ insertType (" Program" , 0x05 , {" 82p" , " 83p" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" }, SpecificHandlerTuple (TH_Tokenized) );
80+ insertType (" ProtectedProgram" , 0x06 , {" 82p" , " 83p" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" , " 8xp" }, SpecificHandlerTuple (TH_Tokenized) );
7781 insertType (" Picture" , 0x07 , {" 82i" , " 83i" , " 8xi" , " 8xi" , " 8xi" , " 8ci" , " 8ci" , " 8ci" , " 8ci" });
78- insertType (" GraphDataBase" , 0x08 , {" 82d" , " 83d" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" }, make_handler_pair (TH_GDB ) );
82+ insertType (" GraphDataBase" , 0x08 , {" 82d" , " 83d" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" , " 8xd" }, SpecificHandlerTuple (TH_GDB ) );
7983 // insertType("Unknown", 0x09, { _ , _ , _ , _ , _ , _ , _ , _ , _ });
8084 // insertType("UnknownEqu", 0x0A, { _ , _ , _ , _ , _ , _ , _ , _ , _ });
81- insertType (" SmartEquation" , 0x0B , {" 82y" , " 83y" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" }, make_handler_pair (TH_Tokenized) ); // aka "New Equation"
82- insertType (" Complex" , 0x0C , { _ , " 83c" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" }, GenericHandlerPair (Complex, 0x0C ) );
83- insertType (" ComplexList" , 0x0D , { _ , " 83l" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" }, GenericHandlerPair (List, 0x0C ) );
85+ insertType (" SmartEquation" , 0x0B , {" 82y" , " 83y" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" , " 8xy" }, SpecificHandlerTuple (TH_Tokenized) ); // aka "New Equation"
86+ insertType (" Complex" , 0x0C , { _ , " 83c" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" , " 8xc" }, GenericHandlerTuple (Complex, 0x0C ) );
87+ insertType (" ComplexList" , 0x0D , { _ , " 83l" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" , " 8xl" }, GenericHandlerTuple (List, 0x0C ) );
8488 // insertType("Undef", 0x0E, { _ , _ , _ , _ , _ , _ , _ , _ , _ });
8589 insertType (" WindowSettings" , 0x0F , {" 82w" , " 83w" , " 8xw" , " 8xw" , " 8xw" , " 8xw" , " 8xw" , " 8xw" , " 8xw" });
8690 insertType (" RecallWindow" , 0x10 , {" 82z" , " 83z" , " 8xz" , " 8xz" , " 8xz" , " 8xz" , " 8xz" , " 8xz" , " 8xz" });
8791 insertType (" TableRange" , 0x11 , {" 82t" , " 83t" , " 8xt" , " 8xt" , " 8xt" , " 8xt" , " 8xt" , " 8xt" , " 8xt" });
8892 insertType (" ScreenImage" , 0x12 , { _ , _ , _ , _ , _ , _ , _ , _ , _ });
8993 insertType (" Backup" , 0x13 , {" 82b" , " 83b" , " 8xb" , _ , " 8xb" , " 8cb" , _ , _ , _ });
9094 insertType (" App" , 0x14 , { _ , _ , _ , _ , _ , _ , _ , _ , _ });
91- insertType (" AppVar" , 0x15 , { _ , _ , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" }, GenericHandlerPair (AppVar, 0x15 ) );
92- insertType (" PythonAppVar" , 0x15 , { _ , _ , _ , _ , _ , _ , " 8xv" , " 8xv" , " 8xv" }, make_handler_pair (STH_PythonAppVar) );
95+ insertType (" AppVar" , 0x15 , { _ , _ , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" , " 8xv" }, GenericHandlerTuple (AppVar, 0x15 ) );
96+ insertType (" PythonAppVar" , 0x15 , { _ , _ , _ , _ , _ , _ , " 8xv" , " 8xv" , " 8xv" }, SpecificHandlerTuple (STH_PythonAppVar) );
9397 insertType (" TemporaryItem" , 0x16 , { _ , _ , _ , _ , _ , _ , _ , _ , _ });
9498 insertType (" GroupObject" , 0x17 , {" 82g" , " 83g" , " 8xg" , " 8xg" , " 8xg" , " 8xg" , " 8cg" , " 8cg" , " 8cg" });
95- insertType (" RealFraction" , 0x18 , { _ , _ , _ , _ , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" }, GenericHandlerPair (Real, 0x18 ) );
99+ insertType (" RealFraction" , 0x18 , { _ , _ , _ , _ , " 8xn" , " 8xn" , " 8xn" , " 8xn" , " 8xn" }, GenericHandlerTuple (Real, 0x18 ) );
96100 insertType (" MixedFraction" , 0x19 , { _ , _ , _ , _ , _ , _ , _ , _ , _ });
97101 insertType (" Image" , 0x1A , { _ , _ , _ , _ , _ , _ , " 8ca" , " 8ca" , " 8ca" });
98102
99103 /* Exact values (TI-83 Premium CE [Edition Python] and TI-82 Advanced Edition Python) */
100104 /* See https://docs.google.com/document/d/1P_OUbnZMZFg8zuOPJHAx34EnwxcQZ8HER9hPeOQ_dtI and especially this lib's implementation */
101- insertType (" ExactComplexFrac" , 0x1B , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerPair (Complex, 0x1B ) );
102- insertType (" ExactRealRadical" , 0x1C , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerPair (Real, 0x1C ) );
103- insertType (" ExactComplexRadical" , 0x1D , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerPair (Complex, 0x1D ) );
104- insertType (" ExactComplexPi" , 0x1E , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerPair (Complex, 0x1E ) );
105- insertType (" ExactComplexPiFrac" , 0x1F , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerPair (Complex, 0x1F ) );
106- insertType (" ExactRealPi" , 0x20 , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerPair (Real, 0x20 ) );
107- insertType (" ExactRealPiFrac" , 0x21 , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerPair (Real, 0x21 ) );
105+ insertType (" ExactComplexFrac" , 0x1B , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerTuple (Complex, 0x1B ) );
106+ insertType (" ExactRealRadical" , 0x1C , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerTuple (Real, 0x1C ) );
107+ insertType (" ExactComplexRadical" , 0x1D , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerTuple (Complex, 0x1D ) );
108+ insertType (" ExactComplexPi" , 0x1E , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerTuple (Complex, 0x1E ) );
109+ insertType (" ExactComplexPiFrac" , 0x1F , { _ , _ , _ , _ , _ , _ , _ , " 8xc" , " 8xc" }, GenericHandlerTuple (Complex, 0x1F ) );
110+ insertType (" ExactRealPi" , 0x20 , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerTuple (Real, 0x20 ) );
111+ insertType (" ExactRealPiFrac" , 0x21 , { _ , _ , _ , _ , _ , _ , _ , " 8xn" , " 8xn" }, GenericHandlerTuple (Real, 0x21 ) );
108112
109113 /* System/Flash-related things */
110114 // 0x22 - IDList (68k calcs)
0 commit comments