[anjuta/newproject] Implement project property write
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Implement project property write
- Date: Tue, 16 Feb 2010 22:00:37 +0000 (UTC)
commit d3faa49607a0501e8a84f99bd72df095408eff8e
Author: Sébastien Granjoux <seb sfo free fr>
Date: Tue Feb 16 23:00:25 2010 +0100
Implement project property write
Still as a hack
Needed for running automatic tests (coming soon)
libanjuta/anjuta-project.c | 2 +-
plugins/am-project/ac-writer.c | 49 +++++++-----------------------
plugins/am-project/ac-writer.h | 2 +-
plugins/am-project/am-project-private.h | 2 +
plugins/am-project/am-project.c | 5 +++
plugins/am-project/am-properties.c | 27 +++++++++++++++++
plugins/am-project/am-properties.h | 1 +
7 files changed, 49 insertions(+), 39 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index a7e10fd..4374131 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -118,7 +118,7 @@ anjuta_project_property_override (AnjutaProjectPropertyList *list, AnjutaProject
{
AnjutaProjectPropertyInfo *info;
- info = (AnjutaProjectPropertyInfo *)list->data;
+ info = (AnjutaProjectPropertyInfo *)item->data;
if (info->override == NULL)
{
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index 3c15199..503e56b 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -120,42 +120,18 @@ skip_comment (AnjutaToken *token)
/* Public functions
*---------------------------------------------------------------------------*/
-#if 0
gboolean
-amp_project_update_property (AmpProject *project, AmpPropertyType type)
+amp_project_update_property (AmpProject *project, AmpPropertyInfo *info)
{
AnjutaToken *token;
AnjutaToken *arg;
guint pos;
const gchar *value;
- g_return_val_if_fail (project->property != NULL, FALSE);
-
- switch (type)
- {
- case AMP_PROPERTY_NAME:
- pos = 0;
- value = project->property->name;
- break;
- case AMP_PROPERTY_VERSION:
- pos = 1;
- value = project->property->version;
- break;
- case AMP_PROPERTY_BUG_REPORT:
- pos = 2;
- value = project->property->bug_report;
- break;
- case AMP_PROPERTY_TARNAME:
- pos = 3;
- value = project->property->tarname;
- break;
- case AMP_PROPERTY_URL:
- pos = 4;
- value = project->property->url;
- break;
- }
+ pos = info->position;
+ value = info->base.value;
- if (project->property->ac_init == NULL)
+ if (project->ac_init == NULL)
{
gint types[] = {AC_TOKEN_AC_PREREQ, 0};
AnjutaToken *group;
@@ -174,9 +150,9 @@ amp_project_update_property (AmpProject *project, AmpPropertyType type)
}
token = anjuta_token_insert_before (token, anjuta_token_new_string (AC_TOKEN_AC_INIT | ANJUTA_TOKEN_ADDED, "AC_INIT("));
- project->property->ac_init = token;
+ project->ac_init = token;
group = anjuta_token_insert_after (token, anjuta_token_new_static (ANJUTA_TOKEN_LIST | ANJUTA_TOKEN_ADDED, NULL));
- project->property->args = group;
+ project->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 (EOL | ANJUTA_TOKEN_ADDED, "\n"));
@@ -184,20 +160,19 @@ amp_project_update_property (AmpProject *project, AmpPropertyType type)
anjuta_token_dump (project->configure_token);
}
fprintf(stdout, "ac_init before replace\n");
- anjuta_token_dump (project->property->args);
+ anjuta_token_dump (project->args);
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->property->args, pos, arg);
+ anjuta_token_replace_nth_word (project->args, pos, arg);
fprintf(stdout, "ac_init after replace\n");
- anjuta_token_dump (project->property->args);
+ anjuta_token_dump (project->args);
fprintf(stdout, "ac_init after replace link\n");
- anjuta_token_dump_link (project->property->args);
- anjuta_token_style_format (project->arg_list, project->property->args);
+ anjuta_token_dump_link (project->args);
+ anjuta_token_style_format (project->arg_list, project->args);
fprintf(stdout, "ac_init after update link\n");
- anjuta_token_dump (project->property->args);
+ anjuta_token_dump (project->args);
anjuta_token_file_update (project->configure_file, token);
return TRUE;
}
-#endif
diff --git a/plugins/am-project/ac-writer.h b/plugins/am-project/ac-writer.h
index 7a5c200..f17bb9e 100644
--- a/plugins/am-project/ac-writer.h
+++ b/plugins/am-project/ac-writer.h
@@ -29,7 +29,7 @@
G_BEGIN_DECLS
-gboolean amp_project_update_property (AmpProject *project, AmpPropertyType type);
+gboolean amp_project_update_property (AmpProject *project, AmpPropertyInfo *info);
G_END_DECLS
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index d07ec9f..0bf2375 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -68,6 +68,8 @@ struct _AmpProject {
//AmpProperty *property;
GList *properties;
+ AnjutaToken *ac_init;
+ AnjutaToken *args;
AmpGroup *root_node; /* tree containing project data;
* each GNode's data is a
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index f66e5b9..6eaa065 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1002,6 +1002,9 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
fprintf (stdout, "property list:\n");
anjuta_token_dump (args);
+ project->ac_init = macro;
+ project->args = args;
+
for (list = anjuta_project_property_first (project->properties); list != NULL; list = anjuta_project_property_next (list))
{
AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
@@ -3065,6 +3068,8 @@ amp_project_instance_init (AmpProject *project)
project->configure_token = NULL;
project->root_node = NULL;
project->properties = amp_get_project_property_list ();
+ project->ac_init = NULL;
+ project->args = NULL;
project->am_space_list = NULL;
project->ac_space_list = NULL;
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index 23c7110..8e9fe85 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -30,6 +30,7 @@
#include "ac-scanner.h"
#include "am-scanner.h"
+#include "ac-writer.h"
#include <glib/gi18n.h>
@@ -229,6 +230,32 @@ amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *prop)
return set;
}
+gboolean
+amp_project_property_set (AmpProject *project, AnjutaProjectPropertyItem *prop, const gchar* value)
+{
+ AnjutaProjectPropertyList **properties = &(project->properties);
+ AnjutaProjectPropertyItem *item;
+ AmpPropertyInfo *info;
+
+ item = anjuta_project_property_override (*properties, prop);
+ if (item != NULL)
+ {
+ info = (AmpPropertyInfo *)anjuta_project_property_get_info (item);
+ if ((info->base.value != NULL) && (info->base.value != ((AnjutaProjectPropertyInfo *)(info->base.override->data))->value)) g_free (info->base.value);
+ info->base.value = g_strdup (value);
+ }
+ else
+ {
+ info = (AmpPropertyInfo *)anjuta_project_property_get_info (prop);
+ info = (AmpPropertyInfo *)amp_property_new (NULL, info->token_type, info->position, value, NULL);
+ *properties = anjuta_project_property_insert (*properties, prop, (AnjutaProjectPropertyInfo *)info);
+ }
+
+ return amp_project_update_property (project, info);
+}
+
+
+
/* Get property list
*---------------------------------------------------------------------------*/
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
index a0b31e4..702e552 100644
--- a/plugins/am-project/am-properties.h
+++ b/plugins/am-project/am-properties.h
@@ -33,6 +33,7 @@ void amp_property_free (AnjutaProjectPropertyInfo *prop);
gboolean amp_node_property_set (AnjutaProjectNode *target, gint token_type, gint position, const gchar *value, AnjutaToken *token);
gboolean amp_node_property_add (AnjutaProjectNode *node, AmpPropertyInfo *info);
+gboolean amp_project_property_set (AmpProject *project, AnjutaProjectPropertyItem *prop, const gchar* value);
GList* amp_get_project_property_list (void);
GList* amp_get_group_property_list (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]