HAMIGAKI_BJAM_DECL string_list import(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& src_module = ctx.get_module(args[0].try_front()); const string_list& src_rules = args[1]; const boost::optional<std::string>& tgt_module_name = args[2].try_front(); module& tgt_module = ctx.get_module(tgt_module_name); const string_list& tgt_rules = args[3]; const bool localize = !args[4].empty(); if (src_rules.size() != tgt_rules.size()) throw std::runtime_error("the count of rule names mismatch"); // FIXME for (std::size_t i = 0, size = src_rules.size(); i < size; ++i) { rule_definition def = src_module.rules.get_rule_definition(src_rules[i]); if (localize) def.module_name = tgt_module_name; def.exported = false; tgt_module.rules.set_rule_definition(tgt_rules[i], def); } return string_list(); }
HAMIGAKI_BJAM_DECL string_list user_module(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const string_list& modules = args[0]; module& m = ctx.get_module(args[0].try_front()); for (std::size_t i = 0, size = modules.size(); i < size; ++i) { module& m = ctx.get_module(modules[i]); m.user_module = true; } return string_list(); }
HAMIGAKI_BJAM_DECL string_list native_rule(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const std::string& module_name = args[0][0]; const std::string& rule_name = args[1][0]; typedef std::map<std::string,bjam::native_rule> table_type; typedef table_type::const_iterator iter_type; module& m = ctx.get_module(module_name); const table_type& table = m.native_rules; iter_type it = table.find(rule_name); if (it == table.end()) throw rule_not_found(rule_name); const bjam::native_rule& rule = it->second; rule_definition def; def.parameters = rule.parameters; def.native = rule.native; def.module_name = module_name; def.exported = true; m.rules.set_native_rule(rule_name, def); return string_list(); }
HAMIGAKI_BJAM_DECL string_list instance(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& instance_module = ctx.get_module(args[0][0]); instance_module.class_module = args[1][0]; return string_list(); }
HAMIGAKI_BJAM_DECL string_list delete_module(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0].try_front()); m.rules.clear(); m.variables.clear(); return string_list(); }
HAMIGAKI_BJAM_DECL string_list imported_modules(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0].try_front()); return string_list( m.imported_modules.begin(), m.imported_modules.end() ); }
HAMIGAKI_BJAM_DECL string_list import_module(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const string_list& imported = args[0]; module& tgt_module = ctx.get_module(args[1].try_front()); tgt_module.imported_modules.insert(imported.begin(), imported.end()); return string_list(); }
HAMIGAKI_BJAM_DECL void set_regex_rules(context& ctx) { module& m = ctx.get_module(std::string("regex")); { native_rule rule; rule.parameters.push_back(boost::assign::list_of("list")("*")); rule.parameters.push_back(boost::assign::list_of("pattern")); rule.parameters.push_back(boost::assign::list_of("indices")("*")); rule.native = ®ex::transform; rule.version = 2; m.native_rules["transform"] = rule; } }
HAMIGAKI_BJAM_DECL string_list has_native_rule(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0][0]); const std::string& rule_name = args[1][0]; int version = std::atoi(args[2][0].c_str()); typedef std::map<std::string,bjam::native_rule> table_type; typedef table_type::const_iterator iter_type; const table_type& table = m.native_rules; iter_type it = table.find(rule_name); if ((it != table.end()) && (it->second.version == version)) return string_list(std::string("true")); return string_list(); }
HAMIGAKI_BJAM_DECL string_list export_(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0].try_front()); const string_list& rules = args[1]; for (std::size_t i = 0, size = rules.size(); i < size; ++i) { rule_definition* def = m.rules.get_rule_definition_ptr(rules[i]); if (!def) throw rule_not_found(rules[i]); def->exported = true; } return string_list(); }
HAMIGAKI_BJAM_DECL std::string make_class( context& ctx, const std::string& name, const string_list& bases) { check_bases(ctx, bases); const std::string& module_name = bjam::class_module_name(name); module& m = ctx.get_module(module_name); if (!m.variables.get_values("__name__").empty()) throw already_defined_class(name); m.variables.set_values("__name__", string_list(name)); m.variables.set_values("__bases__", bases); import_bases(ctx, m, module_name, bases); return module_name; }
HAMIGAKI_BJAM_DECL string_list var_names(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const string_list& arg1 = args[0]; boost::optional<std::string> name; if (!arg1.empty()) name = arg1[0]; module& m = ctx.get_module(name); variable_table::iterator beg, end; boost::tie(beg, end) = m.variables.entries(); return string_list( make_first_iterator(beg), make_first_iterator(end) ); }