From c38a2b5d3d315259aec1a629afb05549a3344521 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 21 May 2022 20:06:27 -0400 Subject: [PATCH] Add log2() to Quantity expression parser. --- src/Quantity.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Quantity.cpp b/src/Quantity.cpp index d3f126f3..d1fb5ea5 100644 --- a/src/Quantity.cpp +++ b/src/Quantity.cpp @@ -70,14 +70,14 @@ static void teVarsInit() { } } - // Build teVars - teVars.resize(teVariables.size()); + // Build teVars from teVariables + teVars.reserve(teVariables.size()); for (size_t i = 0; i < teVariables.size(); i++) { - teVars[i].name = teVariables[i].name.c_str(); - teVars[i].address = &teVariables[i].value; - teVars[i].type = TE_VARIABLE; - teVars[i].context = NULL; + teVars.push_back({teVariables[i].name.c_str(), &teVariables[i].value, TE_VARIABLE, NULL}); } + + // Add custom functions + teVars.push_back({"log2", (void*) log2, TE_FUNCTION1 | TE_FLAG_PURE, NULL}); } void Quantity::setDisplayValueString(std::string s) {