From ce5944a7b1ac9c11c16866b1198c755a9004f708 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 2 Mar 2025 14:56:47 +0000 Subject: [PATCH] Clean up enqueueInit FossilOrigin-Name: d4f57c85c46e6b41cafd3531e032fc55cbedf2596170a2929c0a264c6e99649a --- src/cube.h | 10 +++++----- src/init.mm | 14 +++++++------- src/protos.h | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cube.h b/src/cube.h index ce82bb9..d2c0234 100644 --- a/src/cube.h +++ b/src/cube.h @@ -397,7 +397,7 @@ enum // function signatures for script functions, see command.cpp #define COMMANDN(name, fun, nargs) \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(^{ \ addcommand(#name, (void (*)())fun, nargs); \ }); \ } @@ -406,7 +406,7 @@ enum // function signatures for script functions, see command.cpp int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(^{ \ name = \ variable(#name, min, cur, max, &name, NULL, true); \ }); \ @@ -415,7 +415,7 @@ enum // function signatures for script functions, see command.cpp int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, NULL, false); \ }); \ @@ -425,7 +425,7 @@ enum // function signatures for script functions, see command.cpp static int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, var_##name, false); \ }); \ @@ -436,7 +436,7 @@ enum // function signatures for script functions, see command.cpp static int name; \ OF_CONSTRUCTOR() \ { \ - enqueueInit(#name, ^{ \ + enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, var_##name, true); \ }); \ diff --git a/src/init.mm b/src/init.mm index e599ca8..ead364f 100644 --- a/src/init.mm +++ b/src/init.mm @@ -3,22 +3,22 @@ #import "cube.h" #import "protos.h" -static std::vector *queue; +static OFMutableArray *queue; void -enqueueInit(const char *name, void (^init)(void)) +enqueueInit(void (^init)(void)) { - if (queue == NULL) - queue = new std::vector(); + if (queue == nil) + queue = [[OFMutableArray alloc] init]; - queue->push_back(init); + [queue addObject:init]; } void processInitQueue(void) { - for (auto &init : *queue) + for (void (^init)(void) in queue) init(); - queue->clear(); + [queue removeAllObjects]; } diff --git a/src/protos.h b/src/protos.h index 1d80a0b..b4c510f 100644 --- a/src/protos.h +++ b/src/protos.h @@ -24,7 +24,7 @@ extern char *getcurcommand(); extern void writebinds(FILE *f); // init -extern void enqueueInit(const char *name, void (^init)(void)); +extern void enqueueInit(void (^init)(void)); extern void processInitQueue(void); // menus