Ejemplo n.º 1
0
HAMIGAKI_BJAM_DECL string_list calc(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const string_list& arg1 = args[0];

    if (arg1.size() < 3u)
        return string_list();

    long lhs = arg1[0].empty() ? 0 : std::atoi(arg1[0].c_str()); // FIXME
    char op = arg1[1][0];
    long rhs = arg1[2].empty() ? 0 : std::atoi(arg1[2].c_str()); // FIXME

    long value;
    if (op == '+')
        value = lhs + rhs;
    else if (op == '-')
        value = lhs - rhs;
    else
        return string_list();

    std::ostringstream os;
    os.imbue(std::locale::classic());
    os << value;
    return string_list(os.str());
}
Ejemplo n.º 2
0
HAMIGAKI_BJAM_DECL string_list check_if_file(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const std::string& file = args[0][0];

    fs::path ph(file);
    fs::path work(ctx.working_directory());
    ph = fs::complete(ph, work);
    if (fs::is_regular(ph))
        return string_list(std::string("true"));
    else
        return string_list();
}
Ejemplo n.º 3
0
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();
}
Ejemplo n.º 4
0
HAMIGAKI_BJAM_DECL string_list normalize_path(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    return string_list(bjam::normalize_path(args[0]));
}
Ejemplo n.º 5
0
void
op_for(void)
{
    Var		idx, list;
    
    idx = pop();
    list = pop();
    
    if( list.type == MAP)
    {
	list.v.list = map_keys( list.v.map );
	list.type = LIST;
    }
    if( list.type == STR)
    {
	list.v.list = string_list( list.v.str );
	list.type = LIST;
    }
    if (list.type != LIST) {
	var_free(list);
	raise(E_FOR);
    } else if (idx.v.num >= list.v.list->len) {	/* loop is complete */
	var_free(list);
	frame.pc = frame.m->code[frame.pc + 1];	/* skip to end */
    } else {
	var_assign_local(frame.stack, frame.m->code[frame.pc],
		var_dup(list.v.list->el[idx.v.num]));
	idx.v.num++;
	push(list);		/* push list */
	push(idx);		/* push new index */
	pushpc(frame.pc - 1);	/* push address of FOR statement */
	frame.pc += 2;		/* go to first instruction in loop */
    }
}
Ejemplo n.º 6
0
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();
}
Ejemplo n.º 7
0
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();
}
Ejemplo n.º 8
0
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();
}
Ejemplo n.º 9
0
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();
}
Ejemplo n.º 10
0
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();
}
Ejemplo n.º 11
0
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()
    );
}
Ejemplo n.º 12
0
HAMIGAKI_BJAM_DECL string_list file_open(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const std::string& name = args[0][0];
    const std::string& mode = args[1][0];

    int fd;
    if (mode == "w")
        fd = ::open(name.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666);
    else
        fd = ::open(name.c_str(), O_RDONLY);

    if (fd == -1)
        return string_list();

    std::ostringstream os;
    os.imbue(std::locale::classic());
    os << fd;
    return string_list(os.str());
}
Ejemplo n.º 13
0
void
show_help(struct statics * stp)

{
	static char *fullhelp;
	char	   *p = NULL;
	char	   *q = NULL;

	if (fullhelp == NULL)
	{
		/* set it up first time thru */
		if (stp->order_names != NULL)
		{
			p = string_list(stp->order_names);
		}
		if (p == NULL)
		{
			p = "not supported";
		}
		if (stp->order_names != NULL)
		{
			q = string_list(stp->order_names_io);
		}
		if (q == NULL)
		{
			q = "not supported";
		}
		fullhelp = (char *) malloc(strlen(help_text) + strlen(p) + strlen(q) +
				2);
		sprintf(fullhelp, help_text, p, q);
	}

	display_pager("Top version ");
	display_pager(version_string());
	display_pager(", ");
	display_pager(copyright);
	display_pager("\n");
	display_pager(fullhelp);
}
Ejemplo n.º 14
0
HAMIGAKI_BJAM_DECL string_list pad(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    std::string str = args[0][0];
    std::size_t width = static_cast<std::size_t>(std::atoi(args[1][0].c_str()));

    if (str.size() < width)
        str.resize(width, ' ');

    return string_list(str);
}
Ejemplo n.º 15
0
HAMIGAKI_BJAM_DECL string_list caller_module(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();
    const string_list& arg1 = args[0];

    int level = 0;
    if (!arg1.empty())
        level = std::atoi(arg1[0].c_str());

    // skip root and current
    level += 2;
    if (level < 0)
        return string_list();

    const boost::optional<std::string>& name =
        ctx.caller_module_name(static_cast<std::size_t>(level));

    if (name)
        return string_list(*name);
    else
        return string_list();
}
Ejemplo n.º 16
0
void string_list_sup_call()
  {
  int id,v;
  OBJREC *p;

  id=o_aktual->id;
  p=o_aktual;
  v=f_get_value(0,id);
  v=string_list(*(char **)(o_aktual->userptr),v);
  if (v+1) c_set_value(0,id,v);
  o_aktual=p;
  p->events[3]();
  o_aktual=o_start;
   }
Ejemplo n.º 17
0
HAMIGAKI_BJAM_DECL string_list update_now(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();
    const string_list& arg2 = args[1];
    const string_list& arg3 = args[2];

    const string_list& targets = args[0];
    const boost::optional<std::string>& log = arg2.try_front();
    const boost::optional<std::string>& force = arg3.try_front();

    // TODO: not implemented

    return string_list(std::string("ok"));
}
Ejemplo n.º 18
0
HAMIGAKI_BJAM_DECL string_list back_trace(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();
    const string_list& arg1 = args[0];

    int level = boost::integer_traits<int>::const_max;
    if (!arg1.empty())
        level = std::atoi(arg1[0].c_str());

    if (level <= 0)
        return string_list();

    return ctx.back_trace(static_cast<std::size_t>(level), 1u);
}
Ejemplo n.º 19
0
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();
}
Ejemplo n.º 20
0
	void Parser_XML::string_list(std::string& chaine, std::string& str)
	{
		const char current_token = read_current_token(chaine);
		
		if(current_token == ' ') {
			destroy_current_token(chaine, current_token);
			str.push_back(current_token);
			std::string current_word = word_grammar(chaine);
			str += current_word;
			
			string_list(chaine, str);
		} else if(current_token == '<') {
		} else {
			std::cerr << "Error when reading a string." << std::endl;
		}
	}
Ejemplo n.º 21
0
HAMIGAKI_BJAM_DECL string_list rebuilds(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const string_list& targets = args[0];
    const string_list& sources = args[1];

    for (std::size_t i = 0, size = targets.size(); i < size; ++i)
    {
        target& t = ctx.get_target(targets[i]);
        t.rebuilt_targets.insert(sources.begin(), sources.end());
    }

    return string_list();
}
Ejemplo n.º 22
0
HAMIGAKI_BJAM_DECL string_list echo(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();
    const string_list& arg1 = args[0];

    std::ostream& os = ctx.output_stream();

    std::copy(
        arg1.begin(), arg1.end(),
        hamigaki::ostream_iterator<std::string>(os, " ")
    );
    os << '\n';

    return string_list();
}
Ejemplo n.º 23
0
	/* Function which recognize a string with spaces characters */
	std::string Parser_XML::string(std::string& chaine)
	{
		std::string str;
		const char current_token = read_current_token(chaine);
		
		if(ASCII_WORD(current_token)) {
			std::string current_word = word_grammar(chaine);
			str += current_word;
			
			string_list(chaine, str);
		} else if(current_token == '<') {
		} else {
			std::cerr << "Error when reading a string." << std::endl;
		}

		return str;
	}
Ejemplo n.º 24
0
HAMIGAKI_BJAM_DECL string_list w32_getregnames(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const string_list& arg1 = args[0];
    const string_list& arg2 = args[1];

    const std::string& path = arg1[0];
    const std::string& result_type = arg2[0];

    if (result_type == "subkeys")
        return win32::registry_subkey_names(path);
    else if (result_type == "values")
        return win32::registry_value_names(path);
    else
        return string_list();
}
Ejemplo n.º 25
0
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();
}
Ejemplo n.º 26
0
  // Copy this into a new CubitSimpleAttrib
CubitSimpleAttrib FacetAttrib::get_CSA() const
{
    // Set initial list size
  std::vector<CubitString> string_list(numStrings);
  std::vector<int> int_list(numIntegers);
  std::vector<double> double_list(numDoubles);

    // Don't need to 'new' objects in DLIList because
    // CSA will make copies.  Just put addresses in list.
  int i;
  for( i = 0; i < numStrings; i++ )
    string_list[i] = stringArray[i];
  for( i = 0; i < numIntegers; i++ )
    int_list[i] = integerArray[i];
  for( i = 0; i < numDoubles; i++ )
    double_list[i] = doubleArray[i];

  return CubitSimpleAttrib( &string_list, &double_list, &int_list );
}
Ejemplo n.º 27
0
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;
}
Ejemplo n.º 28
0
HAMIGAKI_BJAM_DECL string_list search_for_target(context& ctx)
{
    frame& f = ctx.current_frame();
    const list_of_list& args = f.arguments();

    const string_list& targets = args[0];
    const string_list& path = args[1];

    const std::string& name = targets[0];

    path_components compo;
    split_path(compo, name);
    compo.grist.clear();
    compo.member.clear();

    bool found = false;
    std::string filename;

    for (std::size_t i = 0, size = path.size(); i < size; ++i)
    {
        compo.root = path[i];
        filename = make_path(compo);

        if (fs::exists(fs::path(filename)))
        {
            found = true;
            break;
        }
    }

    if (!found)
    {
        compo.root.clear();
        fs::path ph(make_path(compo));
        fs::path work(ctx.working_directory());
        filename = fs::complete(ph, work).file_string();
    }

    call_bind_rule(ctx, name, filename);

    return string_list(name);
}
Ejemplo n.º 29
0
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)
    );
}
Ejemplo n.º 30
0
HAMIGAKI_BJAM_DECL string_list nearest_user_location(context& ctx)
{
    frame& f = ctx.current_frame();

    frame* user_frame =
        f.current_module().user_module ? &f : f.prev_user_frame();
    if (!user_frame)
        return string_list();

    string_list result;
    result.push_back(user_frame->filename());
    {
        std::ostringstream os;
        os.imbue(std::locale::classic());
        os << user_frame->line();
        result.push_back(os.str());
    }

    return result;
}