void amp_group_node_update_node (AmpGroupNode *group, AmpGroupNode *new_group) { gint i; GHashTable *hash; if (group->monitor != NULL) { g_object_unref (group->monitor); group->monitor = NULL; } if (group->makefile != NULL) { g_object_unref (group->makefile); group->monitor = NULL; } if (group->preset_token != NULL) { anjuta_token_free (group->preset_token); group->preset_token = NULL; } if (group->tfile) anjuta_token_file_free (group->tfile); for (i = 0; i < AM_GROUP_TOKEN_LAST; i++) { if (group->tokens[i] != NULL) g_list_free (group->tokens[i]); } if (group->variables) g_hash_table_remove_all (group->variables); group->dist_only = new_group->dist_only; group->makefile = new_group->makefile; new_group->makefile = NULL; group->tfile = new_group->tfile; new_group->tfile = NULL; group->make_token = new_group->make_token; new_group->make_token = NULL; group->preset_token = new_group->preset_token; new_group->preset_token = NULL; memcpy (group->tokens, new_group->tokens, sizeof (group->tokens)); memset (new_group->tokens, 0, sizeof (new_group->tokens)); hash = group->variables; group->variables = new_group->variables; new_group->variables = hash; if (group->makefile != NULL) { group->monitor = g_file_monitor_file (group->makefile, G_FILE_MONITOR_NONE, NULL, NULL); if (group->monitor != NULL) { g_signal_connect (G_OBJECT (group->monitor), "changed", G_CALLBACK (on_group_monitor_changed), group); } } }
static void amp_group_node_dispose (GObject *object) { AmpGroupNode *node = AMP_GROUP_NODE (object); if (node->monitor) g_object_unref (node->monitor); node->monitor = NULL; if (node->preset_token) anjuta_token_free (node->preset_token); node->preset_token = NULL; G_OBJECT_CLASS (amp_group_node_parent_class)->dispose (object); }
/** * anjuta_token_stream_tokenize: * @stream: a #AnjutaTokenStream object. * @type: a token type. * @length: the token length in character. * * Create a token of type from the last length characters previously read and * append it in the output stream. The characters are not copied in the output * stream, the new token uses the same characters. * * Return value: The created token. */ AnjutaToken* anjuta_token_stream_tokenize (AnjutaTokenStream *stream, gint type, gsize length) { AnjutaToken *frag; AnjutaToken *end; frag = anjuta_token_new_static (type, NULL); for (end = stream->start; end != NULL;) { if ((anjuta_token_get_type (end) < ANJUTA_TOKEN_PARSED) || (anjuta_token_get_length (end) == 0)) { gint toklen = anjuta_token_get_length (end); AnjutaToken *copy = anjuta_token_cut (end, stream->begin, length); if (toklen >= (length + stream->begin)) { if (end == stream->start) { /* Get whole token */ anjuta_token_free (frag); anjuta_token_set_type (copy, type); frag = copy; } else { /* Get several token */ anjuta_token_insert_after (frag, copy); anjuta_token_merge (frag, copy); } if (toklen == (length + stream->begin)) { stream->start = anjuta_token_next (end); stream->begin = 0; } else { stream->start = end; stream->begin += length; } break; } else { anjuta_token_insert_after (frag, copy); anjuta_token_merge (frag, copy); length -= toklen - stream->begin; end = anjuta_token_next (end); stream->begin = 0; } } else { end = anjuta_token_next (end); stream->begin = 0; } } anjuta_token_stream_append_token (stream, frag); return frag; }
static void amp_group_node_update_preset_variable (AmpGroupNode *group) { gchar *path; AnjutaToken *value; AmpVariable *var; GFile *root; GFile *file; AnjutaProjectNode *node; if (group->preset_token != NULL) anjuta_token_free (group->preset_token); group->preset_token = anjuta_token_new_static (ANJUTA_TOKEN_FILE, NULL); /* Get project root */ for (node = ANJUTA_PROJECT_NODE (group); anjuta_project_node_parent (node) != NULL; node = anjuta_project_node_parent (node)); root = anjuta_project_node_get_file (node); /* Set source directory variables */ file = anjuta_project_node_get_file (group); value = anjuta_token_insert_token_list (FALSE, NULL, ANJUTA_TOKEN_LIST, NULL, ANJUTA_TOKEN_ARGUMENT, NULL, ANJUTA_TOKEN_CONTENT, ".", NULL); anjuta_token_append_child (group->preset_token, value); var = amp_variable_new ("srcdir", 0, value); g_hash_table_insert (group->variables, var->name, var); var = amp_variable_new ("builddir", 0, value); g_hash_table_insert (group->variables, var->name, var); path = g_file_get_path (file); value = anjuta_token_insert_token_list (FALSE, NULL, ANJUTA_TOKEN_LIST, NULL, ANJUTA_TOKEN_ARGUMENT, NULL, ANJUTA_TOKEN_CONTENT, path, NULL); g_free (path); anjuta_token_append_child (group->preset_token, value); var = amp_variable_new ("abs_srcdir", 0, value); g_hash_table_insert (group->variables, var->name, var); var = amp_variable_new ("abs_builddir", 0, value); g_hash_table_insert (group->variables, var->name, var); path = get_relative_path (file, root); value = anjuta_token_insert_token_list (FALSE, NULL, ANJUTA_TOKEN_LIST, NULL, ANJUTA_TOKEN_ARGUMENT, NULL, ANJUTA_TOKEN_CONTENT, path, NULL); g_free (path); anjuta_token_append_child (group->preset_token, value); var = amp_variable_new ("top_srcdir", 0, value); g_hash_table_insert (group->variables, var->name, var); var = amp_variable_new ("top_builddir", 0, value); g_hash_table_insert (group->variables, var->name, var); path = g_file_get_path (root); value = anjuta_token_insert_token_list (FALSE, NULL, ANJUTA_TOKEN_LIST, NULL, ANJUTA_TOKEN_ARGUMENT, NULL, ANJUTA_TOKEN_CONTENT, path, NULL); g_free (path); anjuta_token_append_child (group->preset_token, value); var = amp_variable_new ("abs_top_srcdir", 0, value); g_hash_table_insert (group->variables, var->name, var); var = amp_variable_new ("abs_top_builddir", 0, value); g_hash_table_insert (group->variables, var->name, var); }