MCPcopy Create free account
hub / github.com/DFHack/dfhack / command

Function command

plugins/devel/check-structures-sanity/main.cpp:53–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53static command_result command(color_ostream & out, std::vector<std::string> & parameters)
54{
55 uint8_t perturb_byte = check_malloc_perturb();
56 if (!perturb_byte)
57 out.printerr("check-structures-sanity: MALLOC_PERTURB_ not set. Some checks may be bypassed or fail.\n");
58
59 Checker checker(out);
60 checker.perturb_byte = perturb_byte;
61
62 // check parameters with values first
63#define VAL_PARAM(name, expr_using_value) \
64 auto name ## _idx = std::find(parameters.begin(), parameters.end(), "-" #name); \
65 if (name ## _idx != parameters.end()) \
66 { \
67 if (name ## _idx + 1 == parameters.end()) \
68 { \
69 return CR_WRONG_USAGE; \
70 } \
71 try \
72 { \
73 auto value = std::move(*(name ## _idx + 1)); \
74 parameters.erase((name ## _idx + 1)); \
75 parameters.erase(name ## _idx); \
76 checker.name = (expr_using_value); \
77 } \
78 catch (std::exception & ex) \
79 { \
80 out.printerr("check-structures-sanity: argument to -{}: {}\n", #name, ex.what()); \
81 return CR_WRONG_USAGE; \
82 } \
83 }
84 VAL_PARAM(maxerrors, std::stoul(value));
85#undef VAL_PARAM
86
87#define BOOL_PARAM(name) \
88 auto name ## _idx = std::find(parameters.begin(), parameters.end(), "-" #name); \
89 if (name ## _idx != parameters.end()) \
90 { \
91 checker.name = true; \
92 parameters.erase(name ## _idx); \
93 }
94 BOOL_PARAM(enums);
95 BOOL_PARAM(sizes);
96 BOOL_PARAM(unnamed);
97 BOOL_PARAM(failfast);
98 BOOL_PARAM(noprogress);
99 BOOL_PARAM(maybepointer);
100#undef BOOL_PARAM
101
102 if (parameters.size() > 1)
103 {
104 return CR_WRONG_USAGE;
105 }
106
107 if (parameters.empty())
108 {
109 checker.queue_globals();
110 }

Callers

nothing calls this directly

Calls 12

check_malloc_perturbFunction · 0.85
PushModulePublicFunction · 0.85
PushFunction · 0.85
SafeCallFunction · 0.85
lua_touserdataFunction · 0.85
lua_getfieldFunction · 0.85
CheckedStructureClass · 0.85
queue_globalsMethod · 0.80
queue_itemMethod · 0.80
process_queueMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected