[anjuta] am-project: Use properties for AC_INIT parameters
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am-project: Use properties for AC_INIT parameters
- Date: Sat, 5 Nov 2011 20:57:45 +0000 (UTC)
commit 8f494329015e6cf54be0fb29eded2a2a37854c48
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Wed Nov 2 19:48:01 2011 +0100
am-project: Use properties for AC_INIT parameters
plugins/am-project/ac-writer.c | 33 ++++++++++++++++++++++++++----
plugins/am-project/am-project-private.h | 3 --
plugins/am-project/am-project.c | 11 +---------
3 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index fd65bdf..db51589 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -179,6 +179,25 @@ skip_comment (AnjutaToken *token)
}
}
+/* Find an already existing property using the same token */
+static AmpProperty *
+find_similar_property (AnjutaProjectNode *node, AmpProperty *property)
+{
+ GList *item;
+
+ for (item = anjuta_project_node_get_custom_properties (node); item != NULL; item = g_list_next (item))
+ {
+ AmpProperty *prop = (AmpProperty *)item->data;
+
+ if ((prop->token_type == property->token_type) && (prop->token != NULL))
+ {
+ return prop;
+ }
+ }
+
+ return NULL;
+}
+
/* Public functions
*---------------------------------------------------------------------------*/
@@ -187,13 +206,18 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
{
AnjutaToken *token;
AnjutaToken *arg;
+ AnjutaToken *args;
+ AmpProperty *prop;
guint pos;
const gchar *value;
pos = ((AmpProperty *)property)->position;
value = ((AmpProperty *)property)->base.value;
- if (project->ac_init == NULL)
+ prop = find_similar_property (ANJUTA_PROJECT_NODE (project), (AmpProperty *)property);
+ args = prop != NULL ? prop->token : NULL;
+
+ if (args == NULL)
{
gint types[] = {AC_TOKEN_AC_PREREQ, 0};
AnjutaToken *group;
@@ -214,9 +238,8 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
}
token = anjuta_token_insert_before (token, anjuta_token_new_string (AC_TOKEN_AC_INIT | ANJUTA_TOKEN_ADDED, "AC_INIT("));
- project->ac_init = token;
group = anjuta_token_insert_after (token, anjuta_token_new_static (ANJUTA_TOKEN_LIST | ANJUTA_TOKEN_ADDED, NULL));
- project->args = group;
+ args = group;
token = anjuta_token_insert_after (group, anjuta_token_new_static (ANJUTA_TOKEN_LAST | ANJUTA_TOKEN_ADDED, NULL));
anjuta_token_merge (group, token);
anjuta_token_insert_after (token, anjuta_token_new_string (END_OF_LINE | ANJUTA_TOKEN_ADDED, "\n"));
@@ -228,12 +251,12 @@ amp_project_update_ac_property (AmpProject *project, AnjutaProjectProperty *prop
token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, value);
arg = anjuta_token_insert_before (token, anjuta_token_new_static (ANJUTA_TOKEN_ITEM | ANJUTA_TOKEN_ADDED, NULL));
anjuta_token_merge (arg, token);
- anjuta_token_replace_nth_word (project->args, pos, arg);
+ anjuta_token_replace_nth_word (args, pos, arg);
//fprintf(stdout, "ac_init after replace\n");
//anjuta_token_dump (project->args);
//fprintf(stdout, "ac_init after replace link\n");
//anjuta_token_dump_link (project->args);
- anjuta_token_style_format (project->arg_list, project->args);
+ anjuta_token_style_format (project->arg_list, args);
//fprintf(stdout, "ac_init after update link\n");
//anjuta_token_dump (project->args);
amp_project_update_configure (project, token);
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index e340736..1408d6d 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -58,9 +58,6 @@ struct _AmpProject {
/* File monitor */
GFileMonitor *monitor;
- AnjutaToken *ac_init;
- AnjutaToken *args;
-
/* Project file list */
GList *files;
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 2d8c131..e74aa3c 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -579,9 +579,6 @@ amp_project_update_root (AmpProject *project, AmpProject *new_project)
new_project->configure_file = NULL;
project->configure_token = new_project->configure_token;
- project->ac_init = new_project->ac_init;
- project->args = new_project->args;
-
hash = project->groups;
project->groups = new_project->groups;
new_project->groups = hash;
@@ -676,9 +673,6 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
{
GList *item;
- project->ac_init = macro;
- project->args = args;
-
for (item = anjuta_project_node_get_native_properties (ANJUTA_PROJECT_NODE (project)); item != NULL; item = g_list_next (item))
{
AmpProperty *prop = (AmpProperty *)item->data;
@@ -693,7 +687,7 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
{
amp_property_free (new_prop);
}
- new_prop = amp_property_new (NULL, prop->token_type, prop->position, NULL, macro);
+ new_prop = amp_property_new (NULL, prop->token_type, prop->position, NULL, args);
arg = anjuta_token_nth_word (args, prop->position);
if ((new_prop->value != NULL) && (new_prop->value != prop->base.value))
{
@@ -2509,9 +2503,6 @@ amp_project_init (AmpProject *project)
project->configure_file = NULL;
project->configure_token = NULL;
- project->ac_init = NULL;
- project->args = NULL;
-
/* Hash tables */
project->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
project->files = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]