summaryrefslogtreecommitdiff
path: root/tools/jsonproc/jsonproc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/jsonproc/jsonproc.cpp')
-rwxr-xr-xtools/jsonproc/jsonproc.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp
index efe48f39f..c0d6e9434 100755
--- a/tools/jsonproc/jsonproc.cpp
+++ b/tools/jsonproc/jsonproc.cpp
@@ -36,7 +36,14 @@ int main(int argc, char *argv[])
// Add custom command callbacks.
env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
- return "//\n// DO NOT MODIFY THIS FILE! IT IS AUTO-GENERATED FROM " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
+ return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
+ });
+
+ env.add_callback("subtract", 2, [](Arguments& args) {
+ int minuend = args.at(0)->get<int>();
+ int subtrahend = args.at(1)->get<int>();
+
+ return minuend - subtrahend;
});
env.add_callback("setVar", 2, [=](Arguments& args) {
@@ -51,6 +58,21 @@ int main(int argc, char *argv[])
return get_custom_var(key);
});
+ env.add_callback("trackVar", 2, [](Arguments& args) {
+ static int counter = 0;
+
+ int addValue = args.at(0)->get<int>();
+ int checkValue = args.at(1)->get<int>();
+
+ bool over = false;
+
+ counter = (counter + addValue) % (checkValue + 1);
+
+ if (counter <= addValue) over = true;
+
+ return over;
+ });
+
env.add_callback("concat", 2, [](Arguments& args) {
string first = args.at(0)->get<string>();
string second = args.at(1)->get<string>();
@@ -67,7 +89,6 @@ int main(int argc, char *argv[])
return rawValue.erase(0, prefix.length());
});
- // Add custom command callbacks.
env.add_callback("removeSuffix", 2, [](Arguments& args) {
string rawValue = args.at(0)->get<string>();
string suffix = args.at(1)->get<string>();