use commandn in a few places

master
Daniel Kolesa 2016-07-30 21:02:00 +01:00
parent 72b4251e90
commit 2ecef3cbbb
1 changed files with 16 additions and 14 deletions

30
main.cc
View File

@ -422,26 +422,28 @@ struct ObState: CsState {
} }
void register_rulecmds() { void register_rulecmds() {
add_command("rule", "sseN", [](ObState &os, const char *tgt, add_commandn("rule", "sseN", [](ObState &os, cscript::TvalRange args) {
const char *dep, Uint32 *body, auto tgt = args[0].get_str();
int *numargs) { auto dep = args[1].get_str();
os.rule_add(tgt, dep, (*numargs > 2) ? body : nullptr); int nargs = args[3].get_int();
Uint32 *body = (nargs > 2) ? const_cast<Uint32 *>(args[2].code) : nullptr;
os.rule_add(tgt.iter(), dep.iter(), body);
}); });
add_command("action", "se", [](ObState &os, const char *an, add_commandn("action", "se", [](ObState &os, cscript::TvalRange args) {
Uint32 *body) { os.rule_add(args[0].get_str().iter(), nullptr,
os.rule_add(an, nullptr, body, true); const_cast<Uint32 *>(args[1].code), true);
}); });
add_command("depend", "ss", [](ObState &os, const char *file, add_commandn("depend", "ss", [](ObState &os, cscript::TvalRange args) {
const char *deps) { os.rule_add(args[0].get_str().iter(), args[1].get_str().iter(), nullptr);
os.rule_add(file, deps, nullptr);
}); });
add_command("duprule", "sssN", [](ObState &os, const char *tgt, add_commandn("duprule", "sssN", [](ObState &os, cscript::TvalRange args) {
const char *ptgt, const char *dep, auto tgt = args[0].get_str();
int *numargs) { auto ptgt = args[1].get_str();
os.rule_dup(tgt, ptgt, dep, *numargs <= 2); auto dep = args[2].get_str();
os.rule_dup(tgt.iter(), ptgt.iter(), dep.iter(), args[3].get_int() <= 2);
}); });
} }