Clean up enqueueInit
FossilOrigin-Name: d4f57c85c46e6b41cafd3531e032fc55cbedf2596170a2929c0a264c6e99649a
This commit is contained in:
parent
866e81fcde
commit
ce5944a7b1
3 changed files with 13 additions and 13 deletions
10
src/cube.h
10
src/cube.h
|
@ -397,7 +397,7 @@ enum // function signatures for script functions, see command.cpp
|
||||||
#define COMMANDN(name, fun, nargs) \
|
#define COMMANDN(name, fun, nargs) \
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
{ \
|
{ \
|
||||||
enqueueInit(#name, ^{ \
|
enqueueInit(^{ \
|
||||||
addcommand(#name, (void (*)())fun, nargs); \
|
addcommand(#name, (void (*)())fun, nargs); \
|
||||||
}); \
|
}); \
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ enum // function signatures for script functions, see command.cpp
|
||||||
int name; \
|
int name; \
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
{ \
|
{ \
|
||||||
enqueueInit(#name, ^{ \
|
enqueueInit(^{ \
|
||||||
name = \
|
name = \
|
||||||
variable(#name, min, cur, max, &name, NULL, true); \
|
variable(#name, min, cur, max, &name, NULL, true); \
|
||||||
}); \
|
}); \
|
||||||
|
@ -415,7 +415,7 @@ enum // function signatures for script functions, see command.cpp
|
||||||
int name; \
|
int name; \
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
{ \
|
{ \
|
||||||
enqueueInit(#name, ^{ \
|
enqueueInit(^{ \
|
||||||
name = variable( \
|
name = variable( \
|
||||||
#name, min, cur, max, &name, NULL, false); \
|
#name, min, cur, max, &name, NULL, false); \
|
||||||
}); \
|
}); \
|
||||||
|
@ -425,7 +425,7 @@ enum // function signatures for script functions, see command.cpp
|
||||||
static int name; \
|
static int name; \
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
{ \
|
{ \
|
||||||
enqueueInit(#name, ^{ \
|
enqueueInit(^{ \
|
||||||
name = variable( \
|
name = variable( \
|
||||||
#name, min, cur, max, &name, var_##name, false); \
|
#name, min, cur, max, &name, var_##name, false); \
|
||||||
}); \
|
}); \
|
||||||
|
@ -436,7 +436,7 @@ enum // function signatures for script functions, see command.cpp
|
||||||
static int name; \
|
static int name; \
|
||||||
OF_CONSTRUCTOR() \
|
OF_CONSTRUCTOR() \
|
||||||
{ \
|
{ \
|
||||||
enqueueInit(#name, ^{ \
|
enqueueInit(^{ \
|
||||||
name = variable( \
|
name = variable( \
|
||||||
#name, min, cur, max, &name, var_##name, true); \
|
#name, min, cur, max, &name, var_##name, true); \
|
||||||
}); \
|
}); \
|
||||||
|
|
14
src/init.mm
14
src/init.mm
|
@ -3,22 +3,22 @@
|
||||||
#import "cube.h"
|
#import "cube.h"
|
||||||
#import "protos.h"
|
#import "protos.h"
|
||||||
|
|
||||||
static std::vector<void (^)(void)> *queue;
|
static OFMutableArray<void (^)(void)> *queue;
|
||||||
|
|
||||||
void
|
void
|
||||||
enqueueInit(const char *name, void (^init)(void))
|
enqueueInit(void (^init)(void))
|
||||||
{
|
{
|
||||||
if (queue == NULL)
|
if (queue == nil)
|
||||||
queue = new std::vector<void (^)(void)>();
|
queue = [[OFMutableArray alloc] init];
|
||||||
|
|
||||||
queue->push_back(init);
|
[queue addObject:init];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
processInitQueue(void)
|
processInitQueue(void)
|
||||||
{
|
{
|
||||||
for (auto &init : *queue)
|
for (void (^init)(void) in queue)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
queue->clear();
|
[queue removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern char *getcurcommand();
|
||||||
extern void writebinds(FILE *f);
|
extern void writebinds(FILE *f);
|
||||||
|
|
||||||
// init
|
// init
|
||||||
extern void enqueueInit(const char *name, void (^init)(void));
|
extern void enqueueInit(void (^init)(void));
|
||||||
extern void processInitQueue(void);
|
extern void processInitQueue(void);
|
||||||
|
|
||||||
// menus
|
// menus
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue