Overview
Comment: | Clean up enqueueInit |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d4f57c85c46e6b41cafd3531e032fc55 |
User & Date: | js on 2025-03-02 14:56:47 |
Other Links: | manifest | tags |
Context
2025-03-02
| ||
19:52 | Migrate more strings check-in: 0d125c31da user: js tags: trunk | |
14:56 | Clean up enqueueInit check-in: d4f57c85c4 user: js tags: trunk | |
14:42 | Migrate to OFOptionsParser check-in: f642e9dfbf user: js tags: trunk | |
Changes
Modified src/cube.h from [9f2d7242ba] to [d8a1a5267e].
︙ | ︙ | |||
393 394 395 396 397 398 399 | }; // nasty macros for registering script functions, abuses globals to avoid // excessive infrastructure #define COMMANDN(name, fun, nargs) \ OF_CONSTRUCTOR() \ { \ | | | | | | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | }; // nasty macros for registering script functions, abuses globals to avoid // excessive infrastructure #define COMMANDN(name, fun, nargs) \ OF_CONSTRUCTOR() \ { \ enqueueInit(^{ \ addcommand(#name, (void (*)())fun, nargs); \ }); \ } #define COMMAND(name, nargs) COMMANDN(name, name, nargs) #define VARP(name, min, cur, max) \ int name; \ OF_CONSTRUCTOR() \ { \ enqueueInit(^{ \ name = \ variable(#name, min, cur, max, &name, NULL, true); \ }); \ } #define VAR(name, min, cur, max) \ int name; \ OF_CONSTRUCTOR() \ { \ enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, NULL, false); \ }); \ } #define VARF(name, min, cur, max, body) \ void var_##name(); \ static int name; \ OF_CONSTRUCTOR() \ { \ enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, var_##name, false); \ }); \ } \ void var_##name() { body; } #define VARFP(name, min, cur, max, body) \ void var_##name(); \ static int name; \ OF_CONSTRUCTOR() \ { \ enqueueInit(^{ \ name = variable( \ #name, min, cur, max, &name, var_##name, true); \ }); \ } \ void var_##name() { body; } #define ATOI(s) strtol(s, NULL, 0) // supports hexadecimal numbers |
︙ | ︙ |
Modified src/init.mm from [18cd3f3736] to [79aa5cd4bd].
1 2 3 4 5 | #include <vector> #import "cube.h" #import "protos.h" | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <vector> #import "cube.h" #import "protos.h" static OFMutableArray<void (^)(void)> *queue; void enqueueInit(void (^init)(void)) { if (queue == nil) queue = [[OFMutableArray alloc] init]; [queue addObject:init]; } void processInitQueue(void) { for (void (^init)(void) in queue) init(); [queue removeAllObjects]; } |
Modified src/protos.h from [615b9acb31] to [9cae557fce].
︙ | ︙ | |||
20 21 22 23 24 25 26 | extern void keypress(int code, bool isdown, int cooked); extern void renderconsole(); extern void conoutf(OFString *s, ...); extern char *getcurcommand(); extern void writebinds(FILE *f); // init | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | extern void keypress(int code, bool isdown, int cooked); extern void renderconsole(); extern void conoutf(OFString *s, ...); extern char *getcurcommand(); extern void writebinds(FILE *f); // init extern void enqueueInit(void (^init)(void)); extern void processInitQueue(void); // menus extern bool rendermenu(); extern void menuset(int menu); extern void menumanual(int m, int n, char *text); extern void sortmenu(int start, int num); |
︙ | ︙ |