Exemplo n.º 1
0
void function_add(const function_data_t &data, const parser_t &parser)
{
    ASSERT_IS_MAIN_THREAD();

    CHECK(! data.name.empty(),);
    CHECK(data.definition,);
    scoped_lock lock(functions_lock);

    /* Remove the old function */
    function_remove(data.name);

    /* Create and store a new function */
    const wchar_t *filename = reader_current_filename();

    int def_offset = -1;
    if (parser.current_block() != NULL)
    {
        def_offset = parser.line_number_of_character_at_offset(parser.current_block()->tok_pos);
    }

    const function_map_t::value_type new_pair(data.name, function_info_t(data, filename, def_offset, is_autoload));
    loaded_functions.insert(new_pair);

    /* Add event handlers */
    for (std::vector<event_t>::const_iterator iter = data.events.begin(); iter != data.events.end(); ++iter)
    {
        event_add_handler(*iter);
    }
}
Exemplo n.º 2
0
bool function_copy(const wcstring &name, const wcstring &new_name)
{
    bool result = false;
    scoped_lock lock(functions_lock);
    function_map_t::const_iterator iter = loaded_functions.find(name);
    if (iter != loaded_functions.end()) {
		// This new instance of the function shouldn't be tied to the definition file of the original, so pass NULL filename, etc.
        const function_map_t::value_type new_pair(new_name, function_info_t(iter->second, NULL, 0, false));
        loaded_functions.insert(new_pair);
        result = true;
    }
	return result;
}
Exemplo n.º 3
0
void function_add(const function_data_t &data, const parser_t &parser, int definition_line_offset) {
    ASSERT_IS_MAIN_THREAD();

    CHECK(!data.name.empty(), );
    CHECK(data.definition, );
    scoped_lock locker(functions_lock);

    // Remove the old function.
    function_remove(data.name);

    // Create and store a new function.
    const wchar_t *filename = reader_current_filename();

    const function_map_t::value_type new_pair(
        data.name, function_info_t(data, filename, definition_line_offset, is_autoload));
    loaded_functions.insert(new_pair);

    // Add event handlers.
    for (std::vector<event_t>::const_iterator iter = data.events.begin(); iter != data.events.end();
         ++iter) {
        event_add_handler(*iter);
    }
}