api updates

master
Daniel Kolesa 2016-09-02 18:03:42 +01:00
parent 7f900e12af
commit d99d1829b0
1 changed files with 11 additions and 11 deletions

22
main.cc
View File

@ -540,21 +540,21 @@ struct ObState: CsState {
} }
void register_rulecmds() { void register_rulecmds() {
add_command("rule", "sse", [this](CsValueRange args, CsValue &) { new_command("rule", "sse", [this](CsValueRange args, CsValue &) {
rule_add( rule_add(
args[0].get_strr(), args[1].get_strr(), args[2].get_code() args[0].get_strr(), args[1].get_strr(), args[2].get_code()
); );
}); });
add_command("action", "se", [this](CsValueRange args, CsValue &) { new_command("action", "se", [this](CsValueRange args, CsValue &) {
rule_add(args[0].get_strr(), nullptr, args[1].get_code(), true); rule_add(args[0].get_strr(), nullptr, args[1].get_code(), true);
}); });
add_command("depend", "ss", [this](CsValueRange args, CsValue &) { new_command("depend", "ss", [this](CsValueRange args, CsValue &) {
rule_add(args[0].get_strr(), args[1].get_strr(), nullptr); rule_add(args[0].get_strr(), args[1].get_strr(), nullptr);
}); });
add_command("duprule", "sssN", [this](CsValueRange args, CsValue &) { new_command("duprule", "sssN", [this](CsValueRange args, CsValue &) {
rule_dup( rule_dup(
args[0].get_strr(), args[1].get_strr(), args[0].get_strr(), args[1].get_strr(),
args[2].get_strr(), args[3].get_int() <= 2 args[2].get_strr(), args[3].get_int() <= 2
@ -588,7 +588,7 @@ int main(int argc, char **argv) {
int jobs = 1; int jobs = 1;
int ncpus = ostd::Thread::hardware_concurrency(); int ncpus = ostd::Thread::hardware_concurrency();
os.add_ident<cscript::CsIvar>("numcpus", 4096, 1, ncpus); os.new_ivar("numcpus", 4096, 1, ncpus);
ConstCharRange fcont; ConstCharRange fcont;
ConstCharRange deffile = "obuild.cfg"; ConstCharRange deffile = "obuild.cfg";
@ -633,14 +633,14 @@ int main(int argc, char **argv) {
} }
} }
os.add_ident<cscript::CsIvar>("numjobs", 4096, 1, jobs); os.new_ivar("numjobs", 4096, 1, jobs);
ThreadPool tpool; ThreadPool tpool;
tpool.init(jobs); tpool.init(jobs);
os.register_rulecmds(); os.register_rulecmds();
os.add_command("shell", "C", [&os, &tpool]( os.new_command("shell", "C", [&os, &tpool](
CsValueRange args, CsValue &res CsValueRange args, CsValue &res
) { ) {
auto cnt = os.counters.back(); auto cnt = os.counters.back();
@ -655,7 +655,7 @@ int main(int argc, char **argv) {
res.set_int(0); res.set_int(0);
}); });
os.add_command("getenv", "ss", [&os](CsValueRange args, CsValue &res) { os.new_command("getenv", "ss", [&os](CsValueRange args, CsValue &res) {
if (os.ignore_env) { if (os.ignore_env) {
res.set_cstr(""); res.set_cstr("");
return; return;
@ -665,7 +665,7 @@ int main(int argc, char **argv) {
)); ));
}); });
os.add_command("extreplace", "sss", [&os](CsValueRange args, CsValue &res) { os.new_command("extreplace", "sss", [&os](CsValueRange args, CsValue &res) {
ConstCharRange lst = args[0].get_strr(); ConstCharRange lst = args[0].get_strr();
ConstCharRange oldext = args[1].get_strr(); ConstCharRange oldext = args[1].get_strr();
ConstCharRange newext = args[2].get_strr(); ConstCharRange newext = args[2].get_strr();
@ -693,11 +693,11 @@ int main(int argc, char **argv) {
res.set_str(ostd::move(ret)); res.set_str(ostd::move(ret));
}); });
os.add_command("invoke", "s", [&os](CsValueRange args, CsValue &res) { os.new_command("invoke", "s", [&os](CsValueRange args, CsValue &res) {
res.set_int(os.exec_main(args[0].get_strr())); res.set_int(os.exec_main(args[0].get_strr()));
}); });
os.add_command("glob", "C", [&os](CsValueRange args, CsValue &res) { os.new_command("glob", "C", [&os](CsValueRange args, CsValue &res) {
auto fnames = cscript::util::list_explode(args[0].get_strr()); auto fnames = cscript::util::list_explode(args[0].get_strr());
res.set_str(ostd::move(ob_expand_globs(fnames))); res.set_str(ostd::move(ob_expand_globs(fnames)));
}); });