[anjuta/newproject] pm: Implement project node with GObject, quite fragile at the moment
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] pm: Implement project node with GObject, quite fragile at the moment
- Date: Wed, 22 Sep 2010 20:36:34 +0000 (UTC)
commit 50f4eda9d33927f72b7592e5608967348c81caa7
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Sep 19 19:59:32 2010 +0200
pm: Implement project node with GObject, quite fragile at the moment
libanjuta/anjuta-project.c | 841 ++++++++++++++++++++++++------
libanjuta/anjuta-project.h | 103 +++--
plugins/Makefile.am | 1 -
plugins/am-project/Makefile.am | 4 +-
plugins/am-project/am-project-private.h | 89 ++++-
plugins/am-project/am-project.c | 869 ++++---------------------------
plugins/am-project/am-project.h | 67 ++--
plugins/am-project/am-scanner.h | 2 +-
plugins/am-project/am-scanner.l | 5 +-
plugins/am-project/am-writer.c | 2 +-
plugins/am-project/projectparser.c | 133 +-----
plugins/dir-project/Makefile.am | 4 +-
plugins/dir-project/dir-node.c | 221 ++++++++
plugins/dir-project/dir-node.h | 63 +++
plugins/dir-project/dir-project.c | 241 +--------
plugins/dir-project/dir-project.h | 7 +-
plugins/mk-project/mk-project.c | 2 +-
plugins/project-manager/dialogs.c | 8 +-
plugins/project-manager/plugin.c | 20 +-
plugins/project-manager/project-model.c | 14 +-
plugins/project-manager/project-util.c | 4 +-
plugins/project-manager/project-view.c | 2 +-
plugins/project-manager/project.c | 24 +-
plugins/project-manager/tree-data.c | 12 +-
24 files changed, 1337 insertions(+), 1401 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index a77592e..b003200 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -50,18 +50,12 @@
*/
/* convenient shortcut macro the get the AnjutaProjectNode from a GNode */
-#define NODE_DATA(node) ((node) != NULL ? (AnjutaProjectNodeData *)((node)->data) : NULL)
+#define NODE_DATA(node) node
#define PROXY_DATA(node) ((node) != NULL ? (AnjutaProjectProxyData *)((node)->data) : NULL)
/* Properties functions
*---------------------------------------------------------------------------*/
-typedef struct {
- AnjutaProjectNodeData base;
- AnjutaProjectNode *node;
- guint reference;
-} AnjutaProjectProxyData;
-
/* Properties functions
*---------------------------------------------------------------------------*/
@@ -207,99 +201,330 @@ anjuta_project_property_foreach (AnjutaProjectProperty *list, GFunc func, gpoint
AnjutaProjectNode *
anjuta_project_node_parent(AnjutaProjectNode *node)
{
+ g_return_val_if_fail (node != NULL, NULL);
+
return node->parent;
}
AnjutaProjectNode *
anjuta_project_node_first_child(AnjutaProjectNode *node)
{
- return g_node_first_child (node);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return node->children;
}
AnjutaProjectNode *
anjuta_project_node_last_child(AnjutaProjectNode *node)
{
- return g_node_last_child (node);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ node = node->children;
+ if (node)
+ while (node->next)
+ node = node->next;
+
+ return node;
}
AnjutaProjectNode *
anjuta_project_node_next_sibling (AnjutaProjectNode *node)
{
- return g_node_next_sibling (node);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return node->next;
}
AnjutaProjectNode *
anjuta_project_node_prev_sibling (AnjutaProjectNode *node)
{
- return g_node_prev_sibling (node);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return node->prev;
}
AnjutaProjectNode *anjuta_project_node_nth_child (AnjutaProjectNode *node, guint n)
{
- return g_node_nth_child (node, n);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ node = node->children;
+ if (node)
+ while ((n-- > 0) && node)
+ node = node->next;
+
+ return node;
}
-typedef struct
+static AnjutaProjectNode *
+anjuta_project_node_post_order_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data)
{
- AnjutaProjectNodeFunc func;
- gpointer data;
-} AnjutaProjectNodePacket;
+ AnjutaProjectNode *child;
+
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
-static gboolean
-anjuta_project_node_traverse_func (GNode *node, gpointer data)
+ current = child;
+ child = current->next;
+ current = anjuta_project_node_post_order_traverse (current, func, data);
+ if (current != NULL)
+ {
+ return current;
+ }
+ }
+
+ return func (node, data) ? node : NULL;
+}
+
+static AnjutaProjectNode *
+anjuta_project_node_pre_order_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data)
{
- AnjutaProjectNodePacket *pack = (AnjutaProjectNodePacket *)data;
+ AnjutaProjectNode *child;
+
+ if (func (node, data))
+ {
+ return node;
+ }
- pack->func ((AnjutaProjectNode *)node, pack->data);
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
- return FALSE;
+ current = child;
+ child = current->next;
+ current = anjuta_project_node_pre_order_traverse (current, func, data);
+ if (current != NULL)
+ {
+ return current;
+ }
+ }
+
+ return NULL;
}
-void
-anjuta_project_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data)
+
+AnjutaProjectNode *
+anjuta_project_node_traverse (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeTraverseFunc func, gpointer data)
+{
+ g_return_val_if_fail (node != NULL, NULL);
+ g_return_val_if_fail (func != NULL, NULL);
+ g_return_val_if_fail ((order != G_PRE_ORDER) || (order != G_POST_ORDER), NULL);
+
+ switch (order)
+ {
+ case G_PRE_ORDER:
+ return anjuta_project_node_pre_order_traverse (node, func, data);
+ case G_POST_ORDER:
+ return anjuta_project_node_post_order_traverse (node, func, data);
+ default:
+ return NULL;
+ }
+}
+
+AnjutaProjectNode *
+anjuta_project_node_children_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data)
+{
+ AnjutaProjectNode *child;
+
+ g_return_val_if_fail (node != NULL, NULL);
+
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
+
+ current = child;
+ child = current->next;
+ if (func (current, data))
+ {
+ return current;
+ }
+ }
+
+ return NULL;
+}
+
+static void
+anjuta_project_node_post_order_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data)
{
- AnjutaProjectNodePacket pack = {func, data};
+ AnjutaProjectNode *child;
- /* POST_ORDER is important when deleting the node, children has to be
- * deleted first */
- g_node_traverse (node, G_POST_ORDER, G_TRAVERSE_ALL, -1, anjuta_project_node_traverse_func, &pack);
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
+
+ current = child;
+ child = current->next;
+ anjuta_project_node_post_order_foreach (current, func, data);
+ }
+
+ func (node, data);
+}
+
+static void
+anjuta_project_node_pre_order_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data)
+{
+ AnjutaProjectNode *child;
+
+ func (node, data);
+
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
+
+ current = child;
+ child = current->next;
+ anjuta_project_node_pre_order_foreach (current, func, data);
+ }
}
+
void
-anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data)
+anjuta_project_node_foreach (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeForeachFunc func, gpointer data)
{
- g_node_children_foreach (node, G_TRAVERSE_ALL, func, data);
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (func != NULL);
+ g_return_if_fail ((order != G_PRE_ORDER) || (order != G_POST_ORDER));
+
+ switch (order)
+ {
+ case G_PRE_ORDER:
+ anjuta_project_node_pre_order_foreach (node, func, data);
+ break;
+ case G_POST_ORDER:
+ anjuta_project_node_post_order_foreach (node, func, data);
+ break;
+ default:
+ break;
+ }
+}
+
+void
+anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data)
+{
+ AnjutaProjectNode *child;
+
+ g_return_if_fail (node != NULL);
+
+ child = node->children;
+ while (child != NULL)
+ {
+ AnjutaProjectNode *current;
+
+ current = child;
+ child = current->next;
+ func (current, data);
+ }
}
AnjutaProjectNode *
anjuta_project_node_append (AnjutaProjectNode *parent, AnjutaProjectNode *node)
-{
- return g_node_append (parent, node);
+{
+ return anjuta_project_node_insert_before (parent, NULL, node);
}
AnjutaProjectNode *
anjuta_project_node_insert_before (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node)
{
- /* node->parent is filled by the new function */
- if (node->parent != NULL) node->parent = NULL;
- return g_node_insert_before (parent, sibling, node);
+ g_return_val_if_fail (node != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, node);
+
+ /* FIXME: Try to avoid filling parent member to allow these checks
+ g_return_val_if_fail (node->parent == NULL)
+ if (sibling)
+ g_return_val_if_fail (sibling->parent == parent, node);*/
+
+ node->parent = parent;
+ if (sibling)
+ {
+ if (sibling->prev)
+ {
+ node->prev = sibling->prev;
+ node->prev->next = node;
+ node->next = sibling;
+ sibling->prev = node;
+ }
+ else
+ {
+ node->parent->children = node;
+ node->next = sibling;
+ sibling->prev = node;
+ }
+ }
+ else
+ {
+ if (parent->children)
+ {
+ sibling = parent->children;
+ while (sibling->next)
+ sibling = sibling->next;
+ node->prev = sibling;
+ sibling->next = node;
+ }
+ else
+ {
+ node->parent->children = node;
+ }
+ }
+
+ return node;
}
AnjutaProjectNode *
anjuta_project_node_insert_after (AnjutaProjectNode *parent, AnjutaProjectNode *sibling, AnjutaProjectNode *node)
{
- /* node->parent is filled by the new function */
- if (node->parent != NULL) node->parent = NULL;
- return g_node_insert_after (parent, sibling, node);
+ g_return_val_if_fail (node != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, node);
+
+ /* FIXME: Try to avoid filling parent member to allow these checks
+ g_return_val_if_fail (node->parent == NULL)
+ if (sibling)
+ g_return_val_if_fail (sibling->parent == parent, node);*/
+
+ node->parent = parent;
+ if (sibling)
+ {
+ if (sibling->next)
+ {
+ sibling->next->prev = node;
+ }
+ node->next = sibling->next;
+ node->prev = sibling;
+ sibling->next = node;
+ }
+ else
+ {
+ if (parent->children)
+ {
+ node->next = parent->children;
+ parent->children->prev = node;
+ }
+ parent->children = node;
+ }
+
+ return node;
}
AnjutaProjectNode *
anjuta_project_node_remove (AnjutaProjectNode *node)
{
- if (node->parent != NULL)
+ g_return_val_if_fail (node != NULL, NULL);
+
+ if (node->prev)
+ node->prev->next = node->next;
+ else if (node->parent)
+ node->parent->children = node->next;
+ node->parent = NULL;
+ if (node->next)
{
- g_node_unlink (node);
+ node->next->prev = node->prev;
+ node->next = NULL;
}
+ node->prev = NULL;
return node;
}
@@ -309,8 +534,8 @@ anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replace
{
if (node->parent != NULL)
{
- g_node_insert_after (node->parent, node, replacement);
- g_node_unlink (node);
+ anjuta_project_node_insert_after (node->parent, node, replacement);
+ anjuta_project_node_remove (node);
}
return replacement;
@@ -319,46 +544,46 @@ anjuta_project_node_replace (AnjutaProjectNode *node, AnjutaProjectNode *replace
AnjutaProjectNode *
anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement)
{
- GNode *marker = g_node_new (NULL);
- GNode *child;
- GNode *sibling;
- GNode *next;
+ AnjutaProjectNode *marker = g_object_new (ANJUTA_TYPE_PROJECT_NODE, NULL);
+ AnjutaProjectNode *child;
+ AnjutaProjectNode *sibling;
+ AnjutaProjectNode *next;
if (node->parent != NULL)
{
- g_node_insert_after (node->parent, node, marker);
- g_node_unlink (node);
+ anjuta_project_node_insert_after (node->parent, node, marker);
+ anjuta_project_node_remove (node);
}
if (replacement->parent != NULL)
{
- g_node_insert_after (replacement->parent, replacement, node);
- g_node_unlink (replacement);
+ anjuta_project_node_insert_after (replacement->parent, replacement, node);
+ anjuta_project_node_remove (node);
}
if (marker->parent != NULL)
{
- g_node_insert_after (marker->parent, marker, replacement);
- g_node_unlink (marker);
+ anjuta_project_node_insert_after (marker->parent, marker, replacement);
+ anjuta_project_node_remove (marker);
}
- g_node_destroy (marker);
+ g_object_unref (marker);
/* Move all children from node to replacement */
sibling = NULL;
- for (child = g_node_first_child (node); child != NULL; child = next)
+ for (child = anjuta_project_node_first_child (node); child != NULL; child = next)
{
- next = g_node_next_sibling (child);
- g_node_unlink (child);
- sibling = g_node_insert_after (replacement, sibling, child);
+ next = anjuta_project_node_next_sibling (child);
+ anjuta_project_node_remove (child);
+ sibling = anjuta_project_node_insert_after (replacement, sibling, child);
child = next;
}
/* Move all children from replacement to node */
- child = g_node_next_sibling (sibling);
+ child = anjuta_project_node_next_sibling (sibling);
sibling = NULL;
for (; child != NULL; child = next)
{
- next = g_node_next_sibling (child);
- g_node_unlink (child);
- sibling = g_node_insert_after (node, sibling, child);
+ next = anjuta_project_node_next_sibling (child);
+ anjuta_project_node_remove (child);
+ sibling = anjuta_project_node_insert_after (node, sibling, child);
child = next;
}
@@ -371,16 +596,16 @@ anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode
AnjutaProjectNode *child;
AnjutaProjectNode *sibling;
- sibling = g_node_last_child (parent);
+ sibling = anjuta_project_node_last_child (parent);
- for (child = g_node_first_child (node); child != NULL;)
+ for (child = anjuta_project_node_first_child (node); child != NULL;)
{
AnjutaProjectNode *remove;
remove = child;
- child = g_node_next_sibling (child);
- g_node_unlink (remove);
- sibling = g_node_insert_after (parent, sibling, remove);
+ child = anjuta_project_node_next_sibling (child);
+ anjuta_project_node_remove (remove);
+ sibling = anjuta_project_node_insert_after (parent, sibling, remove);
}
return parent;
@@ -390,7 +615,7 @@ anjuta_project_node_grab_children (AnjutaProjectNode *parent, AnjutaProjectNode
AnjutaProjectNode *
anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node)
{
- return g_node_prepend (parent, node);
+ return anjuta_project_node_insert_before (parent, parent->children, node);
}
gboolean
@@ -416,7 +641,7 @@ anjuta_project_node_get_state (const AnjutaProjectNode *node)
}
AnjutaProjectNodeType
-anjuta_project_node_get_type (const AnjutaProjectNode *node)
+anjuta_project_node_get_node_type (const AnjutaProjectNode *node)
{
return node == NULL ? ANJUTA_PROJECT_UNKNOWN : (NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK);
}
@@ -477,9 +702,7 @@ anjuta_project_node_get_uri (AnjutaProjectNode *node)
GFile*
anjuta_project_node_get_file (AnjutaProjectNode *node)
{
- AnjutaProjectNodeData *data = NODE_DATA (node);
-
- if ((data->file == NULL) && (data->name != NULL))
+ if ((NODE_DATA (node)->file == NULL) && (NODE_DATA (node)->name != NULL))
{
/* Try to create a file */
AnjutaProjectNode *parent;
@@ -487,11 +710,11 @@ anjuta_project_node_get_file (AnjutaProjectNode *node)
parent = anjuta_project_node_parent (node);
if ((parent != NULL) && (NODE_DATA (parent)->file != NULL))
{
- data->file = g_file_get_child (NODE_DATA (parent)->file, data->name);
+ NODE_DATA (node)->file = g_file_get_child (NODE_DATA (parent)->file, NODE_DATA (node)->name);
}
}
- return data->file;
+ return NODE_DATA (node)->file;
}
AnjutaProjectProperty *
@@ -649,14 +872,12 @@ anjuta_project_group_get_directory (const AnjutaProjectNode *group)
}
static gboolean
-anjuta_project_group_compare (GNode *node, gpointer data)
+anjuta_project_group_compare (AnjutaProjectNode *node, gpointer data)
{
- GFile *file = *(GFile **)data;
+ GFile *file = (GFile *)data;
if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_GROUP) && g_file_equal (NODE_DATA(node)->file, file))
{
- *(AnjutaProjectNode **)data = node;
-
return TRUE;
}
else
@@ -668,12 +889,11 @@ anjuta_project_group_compare (GNode *node, gpointer data)
AnjutaProjectNode *
anjuta_project_group_get_node_from_file (const AnjutaProjectNode *root, GFile *directory)
{
- GFile *data;
-
- data = directory;
- g_node_traverse ((GNode *)root, G_PRE_ORDER, G_TRAVERSE_ALL, -1, anjuta_project_group_compare, &data);
+ AnjutaProjectNode *node;
+
+ node = anjuta_project_node_traverse (root, G_PRE_ORDER, anjuta_project_group_compare, directory);
- return (data == directory) ? NULL : (AnjutaProjectNode *)data;
+ return node;
}
AnjutaProjectNode *
@@ -689,14 +909,12 @@ anjuta_project_group_get_node_from_uri (const AnjutaProjectNode *root, const gch
}
static gboolean
-anjuta_project_target_compare (GNode *node, gpointer data)
+anjuta_project_target_compare (AnjutaProjectNode *node, gpointer data)
{
- const gchar *name = *(gchar **)data;
+ const gchar *name = (gchar *)data;
if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET) && (strcmp (NODE_DATA(node)->name, name) == 0))
{
- *(AnjutaProjectNode **)data = node;
-
return TRUE;
}
else
@@ -708,23 +926,20 @@ anjuta_project_target_compare (GNode *node, gpointer data)
AnjutaProjectNode *
anjuta_project_target_get_node_from_name (const AnjutaProjectNode *parent, const gchar *name)
{
- const gchar *data;
-
- data = name;
- g_node_traverse ((GNode *)parent, G_PRE_ORDER, G_TRAVERSE_ALL, 2, anjuta_project_target_compare, &data);
+ AnjutaProjectNode *node;
+
+ node = anjuta_project_node_traverse (parent, G_PRE_ORDER, anjuta_project_target_compare, name);
- return (data == name) ? NULL : (AnjutaProjectNode *)data;
+ return node;
}
static gboolean
-anjuta_project_source_compare (GNode *node, gpointer data)
+anjuta_project_source_compare (AnjutaProjectNode *node, gpointer data)
{
- GFile *file = *(GFile **)data;
+ GFile *file = (GFile *)data;
if (((NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_SOURCE) && g_file_equal (NODE_DATA(node)->file, file))
{
- *(AnjutaProjectNode **)data = node;
-
return TRUE;
}
else
@@ -736,12 +951,12 @@ anjuta_project_source_compare (GNode *node, gpointer data)
AnjutaProjectNode *
anjuta_project_source_get_node_from_file (const AnjutaProjectNode *parent, GFile *file)
{
- GFile *data;
-
- data = file;
- g_node_traverse ((GNode *)parent, G_PRE_ORDER, G_TRAVERSE_ALL, 2, anjuta_project_source_compare, &data);
+ AnjutaProjectNode *node;
- return (data == file) ? NULL : (AnjutaProjectNode *)data;
+
+ node = anjuta_project_node_traverse (parent, G_PRE_ORDER, anjuta_project_source_compare, file);
+
+ return node;
}
AnjutaProjectNode *
@@ -795,36 +1010,281 @@ anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info)
return info->type;
}
-/* Proxy node functions
+/* Implement GObject
+ *---------------------------------------------------------------------------*/
+
+enum
+{
+ UPDATED,
+ LOADED,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_NONE,
+ PROP_NAME,
+ PROP_FILE,
+ PROP_STATE,
+ PROP_TYPE,
+ PROP_DATA
+};
+
+
+static unsigned int anjuta_project_node_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (AnjutaProjectNode, anjuta_project_node, G_TYPE_OBJECT);
+
+static void
+anjuta_project_node_init (AnjutaProjectNode *node)
+{
+ node->next = NULL;
+ node->prev = NULL;
+ node->parent = NULL;
+ node->children = NULL;
+
+ node->type = 0;
+ node->state = 0;
+ node->properties = NULL;
+ node->file = NULL;
+ node->name = NULL;
+}
+
+static void
+anjuta_project_node_dispose (GObject *object)
+{
+ AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+
+ //g_message ("anjuta_project_node_dispose node %p children %p parent %p prev %p name %s file %s", node, node->children, node->parent, node->prev, node->name, node->file != NULL ? g_file_get_path (node->file) : "no file");
+
+ anjuta_project_node_remove (node);
+
+ if (node->file != NULL) g_object_unref (node->file);
+ node->file = NULL;
+
+ while (node->children != NULL)
+ {
+ AnjutaProjectNode *child;
+
+ child = anjuta_project_node_remove (node->children);
+ g_object_unref (child);
+ }
+
+ G_OBJECT_CLASS (anjuta_project_node_parent_class)->dispose (object);
+}
+
+static void
+anjuta_project_node_finalize (GObject *object)
+{
+ AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+
+ if (node->name != NULL) g_free (node->name);
+
+ G_OBJECT_CLASS (anjuta_project_node_parent_class)->finalize (object);
+}
+
+static void
+anjuta_project_node_get_gobject_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+}
+
+static void
+anjuta_project_node_set_gobject_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+}
+
+static void
+anjuta_project_node_class_init (AnjutaProjectNodeClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = anjuta_project_node_finalize;
+ object_class->dispose = anjuta_project_node_dispose;
+ object_class->get_property = anjuta_project_node_get_gobject_property;
+ object_class->set_property = anjuta_project_node_set_gobject_property;
+
+ /*Change both signal to use marshal_VOID__POINTER_BOXED
+ adding a AnjutaProjectNode pointer corresponding to the
+ loaded node => done
+ Such marshal doesn't exist as glib marshal, so look in the
+ symbol db plugin how to add new marshal => done
+ ToDo :
+ This new argument can be used in the plugin object in
+ order to add corresponding shortcut when the project
+ is loaded and a new node is loaded.
+ The plugin should probably get the GFile from the
+ AnjutaProjectNode object and then use a function
+ in project-view.c to create the corresponding shortcut*/
+
+ anjuta_project_node_signals[UPDATED] = g_signal_new ("updated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (AnjutaProjectNodeClass, updated),
+ NULL, NULL,
+ anjuta_cclosure_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_ERROR);
+
+ anjuta_project_node_signals[LOADED] = g_signal_new ("loaded",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (AnjutaProjectNodeClass, loaded),
+ NULL, NULL,
+ anjuta_cclosure_marshal_VOID__STRING_BOXED,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER,
+ G_TYPE_ERROR);
+
+ g_object_class_install_property
+ (G_OBJECT_CLASS (klass), PROP_TYPE,
+ g_param_spec_pointer ("type",
+ "Type",
+ "Node type",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (G_OBJECT_CLASS (klass), PROP_STATE,
+ g_param_spec_pointer ("state",
+ "Stroject",
+ "GbfProject Object",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (G_OBJECT_CLASS (klass), PROP_DATA,
+ g_param_spec_pointer ("project",
+ "Project",
+ "GbfProject Object",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (G_OBJECT_CLASS (klass), PROP_NAME,
+ g_param_spec_string ("name",
+ "Name",
+ "GbfProject Object",
+ "",
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (G_OBJECT_CLASS (klass), PROP_FILE,
+ g_param_spec_object ("file",
+ "PDroject",
+ "GbfProject Object",
+ G_TYPE_FILE,
+ G_PARAM_READWRITE));
+
+}
+
+
+
+/* Proxy node object
*---------------------------------------------------------------------------*/
+#define ANJUTA_TYPE_PROJECT_PROXY_NODE (anjuta_project_proxy_node_get_type ())
+#define ANJUTA_PROJECT_PROXY_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PROJECT_PROXY_NODE, AnjutaProjectProxyNode))
+
+typedef struct _AnjutaProjectProxyNode AnjutaProjectProxyNode;
+GType anjuta_project_proxy_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaProjectProxyNode{
+ AnjutaProjectNode base;
+ AnjutaProjectNode *node;
+ guint reference;
+};
+
+
AnjutaProjectNode *
anjuta_project_proxy_new (AnjutaProjectNode *node)
{
- AnjutaProjectProxyData *proxy;
- AnjutaProjectNodeData *data;
+ AnjutaProjectNode *proxy;
+ GTypeQuery node_type_info;
+ GTypeQuery base_type_info;
+ guint extra_size;
+
+
+ /* Clone node object */
+ proxy = g_object_new (G_TYPE_FROM_INSTANCE (node), NULL);
+
+ /* Swap specific data */
+ g_type_query (G_TYPE_FROM_INSTANCE (node), &node_type_info);
+ g_type_query (ANJUTA_TYPE_PROJECT_NODE, &base_type_info);
+
+ extra_size = node_type_info.instance_size - base_type_info.instance_size;
+ if (extra_size > 0)
+ {
+ gchar *data;
+
+ data = g_new (gchar , extra_size);
+ memcpy (data, ((gchar *)node) + base_type_info.instance_size, extra_size);
+ memcpy (((gchar *)node) + base_type_info.instance_size, ((gchar *)proxy) + base_type_info.instance_size, extra_size);
+ memcpy (((gchar *)proxy) + base_type_info.instance_size, data, extra_size);
+ g_free (data);
+ }
+
+ /* Copy node data */
+ proxy->type = node->type;
+ proxy->file = node->file != NULL ? g_file_dup (node->file) : NULL;
+ proxy->name = g_strdup (node->name);
+ proxy->state = node->state;
+
+ /* Shallow copy of all properties */
+ if ((node->properties == NULL) || (((AnjutaProjectPropertyInfo *)node->properties->data)->override == NULL))
+ {
+ proxy->properties = node->properties;
+ }
+ else
+ {
+ GList *item;
+
+ proxy->properties = node->properties;
+ node->properties = g_list_copy (proxy->properties);
+ for (item = g_list_first (node->properties); item != NULL; item = g_list_next (item))
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+ AnjutaProjectPropertyInfo *new_info;
+
+ new_info = g_slice_new0(AnjutaProjectPropertyInfo);
+ new_info->name = g_strdup (info->name);
+ new_info->type = info->type;
+ new_info->value = g_strdup (info->value);
+ new_info->override = info->override;
+ item->data = new_info;
+ }
+ }
+#if 0
/* If the node is already a proxy get original node */
node = anjuta_project_proxy_get_node (node);
- data = NODE_DATA (node);
/* Create proxy node */
- proxy = g_slice_new0(AnjutaProjectProxyData);
+ proxy = g_object_new (ANJUTA_TYPE_PROJECT_PROXY_NODE, NULL);
proxy->reference = 1;
proxy->node = node;
- proxy->base.type = data->type | ANJUTA_PROJECT_PROXY;
- proxy->base.file = data->file != NULL ? g_object_ref (data->file) : NULL;
- proxy->base.name = g_strdup (data->name);
+ proxy->base.type = node->type | ANJUTA_PROJECT_PROXY;
+ proxy->base.file = node->file != NULL ? g_object_ref (node->file) : NULL;
+ proxy->base.name = g_strdup (node->name);
/* Shallow copy of all properties */
- if ((data->properties == NULL) || (((AnjutaProjectPropertyInfo *)data->properties->data)->override == NULL))
+ if ((node->properties == NULL) || (((AnjutaProjectPropertyInfo *)node->properties->data)->override == NULL))
{
- proxy->base.properties = data->properties;
+ proxy->base.properties = node->properties;
}
else
{
GList *item;
- proxy->base.properties = g_list_copy (data->properties);
+ proxy->base.properties = g_list_copy (node->properties);
for (item = g_list_first (proxy->base.properties); item != NULL; item = g_list_next (item))
{
AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
@@ -838,57 +1298,132 @@ anjuta_project_proxy_new (AnjutaProjectNode *node)
item->data = new_info;
}
}
-
- node = g_node_new (proxy);
-
- return node;
+#endif
+ return ANJUTA_PROJECT_NODE (proxy);
}
AnjutaProjectNode *
anjuta_project_proxy_unref (AnjutaProjectNode *node)
{
- if (NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY)
- {
- PROXY_DATA (node)->reference--;
+ g_object_unref (G_OBJECT (node));
- if (PROXY_DATA (node)->reference == 0)
- {
- AnjutaProjectProxyData *proxy = PROXY_DATA (node);
+ return node;
+}
+
+/* GObjet implementation
+ *---------------------------------------------------------------------------*/
- if (proxy->base.file) g_object_unref (proxy->base.file);
- g_free (proxy->base.name);
- if ((proxy->base.properties != NULL) && (((AnjutaProjectPropertyInfo *)proxy->base.properties->data)->override != NULL))
- {
- GList *item;
+typedef struct _AnjutaProjectProxyNodeClass AnjutaProjectProxyNodeClass;
+
+struct _AnjutaProjectProxyNodeClass {
+ AnjutaProjectNodeClass parent_class;
+};
+
+G_DEFINE_TYPE (AnjutaProjectProxyNode, anjuta_project_proxy_node, ANJUTA_TYPE_PROJECT_NODE);
+
+static void
+anjuta_project_proxy_node_init (AnjutaProjectProxyNode *node)
+{
+}
+
+static void
+anjuta_project_proxy_node_finalize (GObject *object)
+{
+ AnjutaProjectProxyNode *proxy = ANJUTA_PROJECT_PROXY_NODE (object);
+
+ if (proxy->base.file) g_object_unref (proxy->base.file);
+ g_free (proxy->base.name);
+
+ if ((proxy->base.properties != NULL) && (((AnjutaProjectPropertyInfo *)proxy->base.properties->data)->override != NULL))
+ {
+ GList *item;
- for (item = g_list_first (proxy->base.properties); item != NULL; item = g_list_next (item))
- {
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
-
- g_free (info->name);
- g_free (info->value);
- g_slice_free (AnjutaProjectPropertyInfo, info);
- }
- g_list_free (proxy->base.properties);
- }
- g_slice_free (AnjutaProjectProxyData, proxy);
- g_node_destroy (node);
- node = NULL;
+ for (item = g_list_first (proxy->base.properties); item != NULL; item = g_list_next (item))
+ {
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+
+ g_free (info->name);
+ g_free (info->value);
+ g_slice_free (AnjutaProjectPropertyInfo, info);
}
+ g_list_free (proxy->base.properties);
}
+
+ G_OBJECT_CLASS (anjuta_project_proxy_node_parent_class)->finalize (object);
+}
- return node;
+
+static void
+anjuta_project_proxy_node_class_init (AnjutaProjectProxyNodeClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = anjuta_project_proxy_node_finalize;
+}
+
+
+/* Proxy node functions
+ *---------------------------------------------------------------------------*/
+
+static void
+reparent_children (AnjutaProjectNode *node, gpointer data)
+{
+ node->parent = ANJUTA_PROJECT_NODE (data);
+}
+
+static void
+free_node_property (gpointer data, gpointer user_data)
+{
+ g_slice_free (AnjutaProjectPropertyInfo, data);
}
AnjutaProjectNode *
-anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode *node)
+anjuta_project_proxy_exchange (AnjutaProjectNode *proxy, AnjutaProjectNode *node)
{
+ GTypeQuery node_type_info;
+ GTypeQuery base_type_info;
+ guint extra_size;
+ AnjutaProjectNode *other;
+
+
+ /* Swap specific data */
+ g_type_query (G_TYPE_FROM_INSTANCE (node), &node_type_info);
+ g_type_query (ANJUTA_TYPE_PROJECT_NODE, &base_type_info);
+
+ extra_size = node_type_info.instance_size - base_type_info.instance_size;
+ if (extra_size > 0)
+ {
+ gchar *data;
+
+ data = g_new (gchar , extra_size);
+ memcpy (data, ((gchar *)node) + base_type_info.instance_size, extra_size);
+ memcpy (((gchar *)node) + base_type_info.instance_size, ((gchar *)proxy) + base_type_info.instance_size, extra_size);
+ memcpy (((gchar *)proxy) + base_type_info.instance_size, data, extra_size);
+ g_free (data);
+ }
+
+ /* Exchange link */
+ other = proxy->children;
+ proxy->children = node->children;
+ node->children = other;
+ anjuta_project_node_children_foreach (proxy, reparent_children, proxy);
+ anjuta_project_node_children_foreach (node, reparent_children, node);
+
+ /* Delete node temporary properties */
+ if ((node->properties != NULL) && (((AnjutaProjectPropertyInfo *)node->properties->data)->override != NULL))
+ {
+ g_list_foreach (node->properties, free_node_property, NULL);
+ }
+ node->properties = proxy->properties;
+ proxy->properties = NULL;
+
+#if 0
AnjutaProjectNodeData *data;
data = proxy->data;
proxy->data = node->data;
node->data = data;
-
+#endif
return proxy;
}
@@ -897,9 +1432,9 @@ anjuta_project_proxy_get_node (AnjutaProjectNode *node)
{
g_return_val_if_fail (node != NULL, FALSE);
- if (NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY)
+ if (ANJUTA_PROJECT_NODE (node)->type & ANJUTA_PROJECT_PROXY)
{
- return (PROXY_DATA (node)->node);
+ return ANJUTA_PROJECT_PROXY_NODE (node)->node;
}
else
{
@@ -915,6 +1450,7 @@ anjuta_project_node_is_proxy (AnjutaProjectNode *node)
return NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY ? TRUE : FALSE;
}
+#if 0
typedef struct {
AnjutaProjectNodeData base;
gpointer data;
@@ -1011,23 +1547,6 @@ anjuta_project_introspection_node_get_user_data (AnjutaProjectNode *node)
/* Implement GObject
*---------------------------------------------------------------------------*/
-enum
-{
- UPDATED,
- LOADED,
- LAST_SIGNAL
-};
-
-enum {
- PROP_NONE,
- PROP_NAME,
- PROP_FILE,
- PROP_STATE,
- PROP_TYPE,
- PROP_DATA
-};
-
-
static unsigned int signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (AnjutaProjectGObjectNode, anjuta_project_gobject_node, G_TYPE_OBJECT);
@@ -1283,4 +1802,4 @@ anjuta_project_boxed_node_get_type (void)
return type_id;
}
-
+#endif
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index e685f67..de3de56 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -25,10 +25,17 @@
G_BEGIN_DECLS
-#define ANJUTA_IS_PROJECT_GROUP(obj) (((AnjutaProjectNodeData *)obj->data)->type == ANJUTA_PROJECT_GROUP)
-#define ANJUTA_IS_PROJECT_TARGET(obj) (((AnjutaProjectNodeData *)obj->data)->type == ANJUTA_PROJECT_TARGET)
-#define ANJUTA_IS_PROJECT_NODE(obj) (1)
-#define ANJUTA_IS_PROJECT_PROPERTY(obj) (1)
+#define ANJUTA_TYPE_PROJECT_NODE (anjuta_project_node_get_type ())
+#define ANJUTA_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNode))
+#define ANJUTA_PROJECT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
+#define ANJUTA_IS_PROJECT_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PROJECT_NODE))
+#define ANJUTA_IS_PROJECT_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_PROJECT_NODE))
+#define ANJUTA_PROJECT_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_PROJECT_NODE, AnjutaProjectNodeClass))
+
+
+typedef struct _AnjutaProjectNode AnjutaProjectNode;
+typedef struct _AnjutaProjectNodeClass AnjutaProjectNodeClass;
+
typedef enum
{
@@ -108,6 +115,8 @@ typedef struct
typedef GList AnjutaProjectProperty;
+#define ANJUTA_IS_PROJECT_PROPERTY
+
typedef struct
{
AnjutaProjectProperty *property;
@@ -125,46 +134,45 @@ typedef struct
AnjutaProjectNodeState state;
} AnjutaProjectNodeData;
-#if 0
-typedef struct {
- AnjutaProjectNodeData node;
- GFile *directory;
-} AnjutaProjectGroupData;
-
-typedef struct {
- AnjutaProjectNodeData node;
- gchar *name;
- AnjutaProjectTargetType type;
-} AnjutaProjectTargetData;
-typedef struct {
- AnjutaProjectNodeData node;
- GFile *file;
-} AnjutaProjectSourceData;
-#endif
+#define ANJUTA_PROJECT_NODE_DATA(node) (node)
-typedef GNode AnjutaProjectNode;
-#if 0
-typedef GNode AnjutaProjectGroup;
-typedef GNode AnjutaProjectTarget;
-typedef GNode AnjutaProjectSource;
-#endif
+typedef gboolean (*AnjutaProjectNodeTraverseFunc) (AnjutaProjectNode *node, gpointer data);
+typedef void (*AnjutaProjectNodeForeachFunc) (AnjutaProjectNode *node, gpointer data);
-#define ANJUTA_PROJECT_NODE_DATA(node) ((node) != NULL ? (AnjutaProjectNodeData *)((node)->data) : NULL)
-typedef void (*AnjutaProjectNodeFunc) (AnjutaProjectNode *node, gpointer data);
+/**
+ * AnjutaProjectNode:
+ *
+ * The #AnjutaProjectNode struct contains private data only, and should
+ * accessed using the functions below.
+ */
+struct _AnjutaProjectNode
+{
+ GObject object;
-/* Temporary function for introspection */
-AnjutaProjectNode * anjuta_project_introspection_node_new (AnjutaProjectNodeType type, GFile *file, const gchar *name, gpointer user_data);
-AnjutaProjectNode * anjuta_project_introspection_node_new0 (void);
-gpointer anjuta_project_introspection_node_get_user_data (AnjutaProjectNode *node);
-void anjuta_project_introspection_node_free (AnjutaProjectNode *node);
+ AnjutaProjectNode *next;
+ AnjutaProjectNode *prev;
+ AnjutaProjectNode *parent;
+ AnjutaProjectNode *children;
+
+ AnjutaProjectNodeType type;
+ AnjutaProjectNodeState state;
+
+ AnjutaProjectProperty *properties;
+ GFile *file;
+ gchar *name;
+};
-void anjuta_project_boxed_node_register (void);
-AnjutaProjectNode *anjuta_project_boxed_node_new (AnjutaProjectNodeType type, GFile *file, const gchar *name, gpointer user_data);
-GType anjuta_project_boxed_node_get_type (void);
+struct _AnjutaProjectNodeClass
+{
+ GObjectClass parent_class;
+
+ void (*updated) (GError *error);
+ void (*loaded) (GError *error);
+};
-#define ANJUTA_TYPE_PROJECT_BOXED_NODE (anjuta_project_boxed_node_get_type ())
+GType anjuta_project_node_get_type (void) G_GNUC_CONST;
AnjutaProjectProperty *anjuta_project_property_next (AnjutaProjectProperty *list);
@@ -193,13 +201,15 @@ AnjutaProjectNode *anjuta_project_node_grab_children (AnjutaProjectNode *parent,
AnjutaProjectNode *anjuta_project_node_exchange (AnjutaProjectNode *node, AnjutaProjectNode *replacement);
AnjutaProjectNode *anjuta_project_node_remove (AnjutaProjectNode *node);
-void anjuta_project_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
-void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
+void anjuta_project_node_foreach (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeForeachFunc func, gpointer data);
+void anjuta_project_node_children_foreach (AnjutaProjectNode *node, AnjutaProjectNodeForeachFunc func, gpointer data);
+AnjutaProjectNode *anjuta_project_node_traverse (AnjutaProjectNode *node, GTraverseType order, AnjutaProjectNodeTraverseFunc func, gpointer data);
+AnjutaProjectNode *anjuta_project_node_children_traverse (AnjutaProjectNode *node, AnjutaProjectNodeTraverseFunc func, gpointer data);
gboolean anjuta_project_node_set_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
gboolean anjuta_project_node_clear_state (AnjutaProjectNode *node, AnjutaProjectNodeState state);
-AnjutaProjectNodeType anjuta_project_node_get_type (const AnjutaProjectNode *node);
+AnjutaProjectNodeType anjuta_project_node_get_node_type (const AnjutaProjectNode *node);
AnjutaProjectNodeType anjuta_project_node_get_full_type (const AnjutaProjectNode *node);
AnjutaProjectNodeState anjuta_project_node_get_state (const AnjutaProjectNode *node);
gchar *anjuta_project_node_get_name (const AnjutaProjectNode *node);
@@ -231,12 +241,23 @@ AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo
AnjutaProjectNode *anjuta_project_proxy_new (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_unref (AnjutaProjectNode *node);
-AnjutaProjectNode *anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_proxy_exchange (AnjutaProjectNode *proxy, AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_get_node (AnjutaProjectNode *proxy);
gboolean anjuta_project_node_is_proxy (AnjutaProjectNode *node);
+/* Temporary function for introspection */
+AnjutaProjectNode * anjuta_project_introspection_node_new (AnjutaProjectNodeType type, GFile *file, const gchar *name, gpointer user_data);
+AnjutaProjectNode * anjuta_project_introspection_node_new0 (void);
+gpointer anjuta_project_introspection_node_get_user_data (AnjutaProjectNode *node);
+void anjuta_project_introspection_node_free (AnjutaProjectNode *node);
+
+void anjuta_project_boxed_node_register (void);
+AnjutaProjectNode *anjuta_project_boxed_node_new (AnjutaProjectNodeType type, GFile *file, const gchar *name, gpointer user_data);
+GType anjuta_project_boxed_node_get_type (void);
+
+#define ANJUTA_TYPE_PROJECT_BOXED_NODE (anjuta_project_boxed_node_get_type ())
#define ANJUTA_TYPE_PROJECT_GOBJECT_NODE (anjuta_project_gobject_node_get_type ())
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 4882d66..824a385 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -32,7 +32,6 @@ SUBDIRS = . \
run-program \
starter \
am-project \
- mk-project \
dir-project \
js-debugger \
language-support-js \
diff --git a/plugins/am-project/Makefile.am b/plugins/am-project/Makefile.am
index d2e2dd9..3a569d0 100644
--- a/plugins/am-project/Makefile.am
+++ b/plugins/am-project/Makefile.am
@@ -44,7 +44,9 @@ libam_project_la_SOURCES = \
am-writer.c \
am-project-private.h \
am-properties.c \
- am-properties.h
+ am-properties.h \
+ am-node.c \
+ am-node.h
libam_project_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 0fb893f..50791bd 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -61,7 +61,7 @@ struct _AmpProject {
AnjutaToken *ac_init;
AnjutaToken *args;
- AmpGroup *root_node; /* tree containing project data;
+ AnjutaAmGroupNode *root_node; /* tree containing project data;
* each GNode's data is a
* AmpNode, and the root of
* the tree is the root group. */
@@ -82,6 +82,93 @@ struct _AmpProject {
AnjutaTokenStyle *arg_list;
};
+#define ANJUTA_TYPE_AM_ROOT_NODE (anjuta_am_root_node_get_type ())
+#define ANJUTA_AM_ROOT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_ROOT_NODE, AnjutaAmRootNode))
+
+GType anjuta_am_root_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaAmRootNode {
+ AnjutaProjectNode base;
+ AnjutaTokenFile *configure_file; /* Corresponding configure file */
+};
+
+
+
+#define ANJUTA_TYPE_AM_MODULE_NODE (anjuta_am_module_node_get_type ())
+#define ANJUTA_AM_MODULE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_MODULE_NODE, AnjutaAmModuleNode))
+
+GType anjuta_am_module_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaAmModuleNode {
+ AnjutaProjectNode base;
+ AnjutaToken *module;
+};
+
+
+#define ANJUTA_TYPE_AM_PACKAGE_NODE (anjuta_am_package_node_get_type ())
+#define ANJUTA_AM_PACKAGE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_PACKAGE_NODE, AnjutaAmPackageNode))
+
+GType anjuta_am_package_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaAmPackageNode {
+ AnjutaProjectNode base;
+ gchar *version;
+};
+
+
+#define ANJUTA_TYPE_AM_GROUP_NODE (anjuta_am_group_node_get_type ())
+#define ANJUTA_AM_GROUP_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_GROUP_NODE, AnjutaAmGroupNode))
+
+GType anjuta_am_group_node_get_type (void) G_GNUC_CONST;
+
+typedef enum {
+ AM_GROUP_TOKEN_CONFIGURE,
+ AM_GROUP_TOKEN_SUBDIRS,
+ AM_GROUP_TOKEN_DIST_SUBDIRS,
+ AM_GROUP_TARGET,
+ AM_GROUP_TOKEN_LAST
+} AmpGroupTokenCategory;
+
+struct _AnjutaAmGroupNode {
+ AnjutaProjectNode base;
+ gboolean dist_only; /* TRUE if the group is distributed but not built */
+ GFile *makefile; /* GFile corresponding to group makefile */
+ AnjutaTokenFile *tfile; /* Corresponding Makefile */
+ GList *tokens[AM_GROUP_TOKEN_LAST]; /* List of token used by this group */
+ AnjutaToken *make_token;
+ GHashTable *variables;
+ GFileMonitor *monitor; /* File monitor */
+ GObject *project; /* Project used by file monitor */
+};
+
+
+
+#define ANJUTA_TYPE_AM_TARGET_NODE (anjuta_am_target_node_get_type ())
+#define ANJUTA_AM_TARGET_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_TARGET_NODE, AnjutaAmTargetNode))
+
+GType anjuta_am_target_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaAmTargetNode {
+ AnjutaProjectNode base;
+ gchar *install;
+ gint flags;
+ GList* tokens;
+};
+
+
+
+#define ANJUTA_TYPE_AM_SOURCE_NODE (anjuta_am_source_node_get_type ())
+#define ANJUTA_AM_SOURCE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_AM_SOURCE_NODE, AnjutaAmSourceNode))
+
+GType anjuta_am_source_node_get_type (void) G_GNUC_CONST;
+
+struct _AnjutaAmSourceNode {
+ AnjutaProjectNode base;
+ AnjutaToken* token;
+};
+
+
+
G_END_DECLS
#endif /* _AM_PROJECT_PRIVATE_H_ */
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 17d56d3..927ef1c 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -27,6 +27,7 @@
#include "am-project.h"
#include "am-project-private.h"
+#include "am-node.h"
#include <libanjuta/interfaces/ianjuta-project.h>
#include <libanjuta/anjuta-debug.h>
@@ -62,101 +63,18 @@
static const gchar *valid_am_makefiles[] = {"GNUmakefile.am", "makefile.am", "Makefile.am", NULL};
/* convenient shortcut macro the get the AnjutaProjectNode from a GNode */
-#define AMP_NODE_DATA(node) ((node) != NULL ? (AnjutaProjectNodeData *)((node)->data) : NULL)
-#define AMP_GROUP_DATA(node) ((node) != NULL ? (AmpGroupData *)((node)->data) : NULL)
-#define AMP_TARGET_DATA(node) ((node) != NULL ? (AmpTargetData *)((node)->data) : NULL)
-#define AMP_SOURCE_DATA(node) ((node) != NULL ? (AmpSourceData *)((node)->data) : NULL)
-#define AMP_PACKAGE_DATA(node) ((node) != NULL ? (AmpPackageData *)((node)->data) : NULL)
-#define AMP_MODULE_DATA(node) ((node) != NULL ? (AmpModuleData *)((node)->data) : NULL)
-#define AMP_ROOT_DATA(node) ((node) != NULL ? (AmpRootData *)((node)->data) : NULL)
+#define AMP_NODE_DATA(node) ((AnjutaProjectNode *)node)
+#define AMP_GROUP_DATA(node) ((AnjutaAmGroupNode *)node)
+#define AMP_TARGET_DATA(node) ((AnjutaAmTargetNode *)node)
+#define AMP_SOURCE_DATA(node) ((AnjutaAmSourceNode *)node)
+#define AMP_PACKAGE_DATA(node) ((AnjutaAmPackageNode *)node)
+#define AMP_MODULE_DATA(node) ((AnjutaAmModuleNode *)node)
+#define AMP_ROOT_DATA(node) ((AnjutaAmRootNode *)node)
#define STR_REPLACE(target, source) \
{ g_free (target); target = source == NULL ? NULL : g_strdup (source);}
-/*typedef struct _AmpPackage AmpPackage;
-
-typedef struct _AmpModule AmpModule;*/
-
-typedef enum {
- AM_GROUP_TOKEN_CONFIGURE,
- AM_GROUP_TOKEN_SUBDIRS,
- AM_GROUP_TOKEN_DIST_SUBDIRS,
- AM_GROUP_TARGET,
- AM_GROUP_TOKEN_LAST
-} AmpGroupTokenCategory;
-
-typedef struct _AmpVariable AmpVariable;
-
-struct _AmpVariable {
- gchar *name;
- AnjutaTokenType assign;
- AnjutaToken *value;
-};
-
-typedef struct _AmpRootData AmpRootData;
-
-struct _AmpRootData {
- AnjutaProjectNodeData base; /* Common node data */
- AnjutaTokenFile *configure_file; /* Corresponding configure file */
-};
-
-typedef struct _AmpGroupData AmpGroupData;
-
-struct _AmpGroupData {
- AnjutaProjectNodeData base; /* Common node data */
- gboolean dist_only; /* TRUE if the group is distributed but not built */
- GFile *makefile; /* GFile corresponding to group makefile */
- AnjutaTokenFile *tfile; /* Corresponding Makefile */
- GList *tokens[AM_GROUP_TOKEN_LAST]; /* List of token used by this group */
- AnjutaToken *make_token;
- GHashTable *variables;
- GFileMonitor *monitor; /* File monitor */
- AmpProject *project; /* Project used by file monitor */
-};
-
-typedef enum _AmpTargetFlag
-{
- AM_TARGET_CHECK = 1 << 0,
- AM_TARGET_NOINST = 1 << 1,
- AM_TARGET_DIST = 1 << 2,
- AM_TARGET_NODIST = 1 << 3,
- AM_TARGET_NOBASE = 1 << 4,
- AM_TARGET_NOTRANS = 1 << 5,
- AM_TARGET_MAN = 1 << 6,
- AM_TARGET_MAN_SECTION = 31 << 7
-} AmpTargetFlag;
-
-typedef struct _AmpTargetData AmpTargetData;
-
-struct _AmpTargetData {
- AnjutaProjectNodeData base;
- gchar *install;
- gint flags;
- GList* tokens;
-};
-
-typedef struct _AmpSourceData AmpSourceData;
-
-struct _AmpSourceData {
- AnjutaProjectNodeData base;
- AnjutaToken* token;
-};
-
-typedef struct _AmpModuleData AmpModuleData;
-
-struct _AmpModuleData {
- AnjutaProjectNodeData base;
- AnjutaToken *module;
-};
-
-typedef struct _AmpPackageData AmpPackageData;
-
-struct _AmpPackageData {
- AnjutaProjectNodeData base;
- gchar *version;
-};
-
typedef struct _AmpConfigFile AmpConfigFile;
struct _AmpConfigFile {
@@ -317,31 +235,6 @@ enum {
static GObject *parent_class;
-/* Helper functions
- *---------------------------------------------------------------------------*/
-
-static void
-error_set (GError **error, gint code, const gchar *message)
-{
- if (error != NULL) {
- if (*error != NULL) {
- gchar *tmp;
-
- /* error already created, just change the code
- * and prepend the string */
- (*error)->code = code;
- tmp = (*error)->message;
- (*error)->message = g_strconcat (message, "\n\n", tmp, NULL);
- g_free (tmp);
-
- } else {
- *error = g_error_new_literal (IANJUTA_PROJECT_ERROR,
- code,
- message);
- }
- }
-}
-
/* Work even if file is not a descendant of parent */
static gchar*
get_relative_path (GFile *parent, GFile *file)
@@ -564,7 +457,7 @@ amp_target_property_buffer_free (AmpTargetPropertyBuffer *buffer)
}
void
-amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AmpSource *source)
+amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AnjutaAmSourceNode *source)
{
buffer->sources = g_list_prepend (buffer->sources, source);
}
@@ -623,134 +516,15 @@ amp_config_file_free (AmpConfigFile *config)
}
}
-/* Root node object
- *---------------------------------------------------------------------------*/
-
-static AnjutaProjectNode*
-amp_root_new (GFile *file, GError **error)
-{
- AmpRootData *root = NULL;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- root = g_slice_new0(AmpRootData);
- root->base.type = ANJUTA_PROJECT_ROOT;
- root->base.properties = amp_get_project_property_list();
- root->base.file = g_file_dup (file);
- root->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
- ANJUTA_PROJECT_CAN_ADD_MODULE,
- ANJUTA_PROJECT_CAN_SAVE;
-
- return g_node_new (root);
-}
-
-static void
-amp_root_free (AnjutaProjectNode *node)
-{
- AmpRootData *root = AMP_ROOT_DATA (node);
-
- if (root->configure_file != NULL) anjuta_token_file_free (root->configure_file);
-
- if (root->base.file != NULL) g_object_unref (root->base.file);
- g_free (root->base.name);
- amp_property_free (root->base.properties);
- g_slice_free (AmpRootData, root);
-
- g_node_destroy (node);
-}
-
-static AnjutaTokenFile*
-amp_root_set_configure (AnjutaProjectNode *node, GFile *configure)
-{
- AmpRootData *root;
-
- g_return_val_if_fail ((node != NULL) && (node->data != NULL), NULL);
-
- root = AMP_ROOT_DATA (node);
-
- if (root->configure_file != NULL) anjuta_token_file_free (root->configure_file);
-
- root->configure_file = anjuta_token_file_new (configure);
-
- return root->configure_file;
-}
/* Package objects
*---------------------------------------------------------------------------*/
-static void
-amp_package_set_version (AmpPackage *node, const gchar *compare, const gchar *version)
-{
- AmpPackageData *package= AMP_PACKAGE_DATA (node);
-
- g_return_if_fail (package != NULL);
- g_return_if_fail ((version == NULL) || (compare != NULL));
-
- g_free (package->version);
- package->version = version != NULL ? g_strconcat (compare, version, NULL) : NULL;
-}
-static AmpPackage*
-amp_package_new (const gchar *name, GError **error)
-{
- AmpPackageData *package = NULL;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- package = g_slice_new0(AmpPackageData);
- package->base.type = ANJUTA_PROJECT_PACKAGE;
- package->base.properties = amp_get_package_property_list();
- package->base.name = g_strdup (name);
- package->base.state = ANJUTA_PROJECT_CAN_REMOVE;
-
- return g_node_new (package);
-}
-
-static void
-amp_package_free (AmpPackage *node)
-{
- AmpPackageData *package = AMP_PACKAGE_DATA (node);
-
- if (package->base.file) g_object_unref (package->base.file);
- g_free (package->base.name);
- amp_property_free (package->base.properties);
- g_slice_free (AmpPackageData, package);
-
- g_node_destroy (node);
-}
/* Module objects
*---------------------------------------------------------------------------*/
-static AmpModule*
-amp_module_new (AnjutaToken *token, GError **error)
-{
- AmpModuleData *module;
-
- module = g_slice_new0(AmpModuleData);
- module->base.type = ANJUTA_PROJECT_MODULE;
- module->base.properties = amp_get_module_property_list();
- module->base.name = anjuta_token_evaluate (token);
- module->base.state = ANJUTA_PROJECT_CAN_ADD_PACKAGE |
- ANJUTA_PROJECT_CAN_REMOVE;
- module->module = token;
-
- return g_node_new (module);
-}
-
-static void
-amp_module_free (AmpModule *node)
-{
- AmpModuleData *module = AMP_MODULE_DATA (node);
-
- if (module->base.file) g_object_unref (module->base.file);
- g_free (module->base.name);
-
- g_slice_free (AmpModuleData, module);
-
- g_node_destroy (node);
-}
-
static void
amp_project_new_module_hash (AmpProject *project)
{
@@ -767,44 +541,6 @@ amp_project_free_module_hash (AmpProject *project)
}
}
-/* Variable object
- *---------------------------------------------------------------------------*/
-
-static const gchar *
-amp_variable_get_name (AmpVariable *variable)
-{
- return variable->name;
-}
-
-static gchar *
-amp_variable_evaluate (AmpVariable *variable, AmpProject *project)
-{
- return anjuta_token_evaluate (variable->value);
-}
-
-static AmpVariable*
-amp_variable_new (gchar *name, AnjutaTokenType assign, AnjutaToken *value)
-{
- AmpVariable *variable = NULL;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- variable = g_slice_new0(AmpVariable);
- variable->name = g_strdup (name);
- variable->assign = assign;
- variable->value = value;
-
- return variable;
-}
-
-static void
-amp_variable_free (AmpVariable *variable)
-{
- g_free (variable->name);
-
- g_slice_free (AmpVariable, variable);
-}
-
/* Group objects
*---------------------------------------------------------------------------*/
@@ -818,221 +554,21 @@ remove_config_file (gpointer data, GObject *object, gboolean is_last_ref)
}
}
-static void
-amp_group_add_token (AmpGroup *node, AnjutaToken *token, AmpGroupTokenCategory category)
-{
- AmpGroupData *group;
-
-
- g_return_if_fail ((node != NULL) && (node->data != NULL));
-
- group = AMP_GROUP_DATA (node);
- group->tokens[category] = g_list_prepend (group->tokens[category], token);
-}
-
-static GList *
-amp_group_get_token (AmpGroup *node, AmpGroupTokenCategory category)
-{
- AmpGroupData *group;
-
- g_return_val_if_fail ((node != NULL) && (node->data != NULL), NULL);
-
- group = AMP_GROUP_DATA (node);
- return group->tokens[category];
-}
-
-static AnjutaToken*
-amp_group_get_first_token (AmpGroup *node, AmpGroupTokenCategory category)
-{
- GList *list;
-
- list = amp_group_get_token (node, category);
- if (list == NULL) return NULL;
-
- return (AnjutaToken *)list->data;
-}
-
-static void
-amp_group_set_dist_only (AmpGroup *node, gboolean dist_only)
-{
- g_return_if_fail ((node != NULL) && (node->data != NULL));
-
- AMP_GROUP_DATA (node)->dist_only = dist_only;
-}
-
-static void
-on_group_monitor_changed (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer data)
-{
- AmpGroup *g_node = data;
-
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_DELETED:
- g_message ("node updated node %p group %p project %p", g_node, AMP_GROUP_DATA (g_node), AMP_GROUP_DATA (g_node)->project);
- /* project can be NULL, if the node is dummy node because the
- * original one is reloaded. */
- if (!(anjuta_project_node_get_full_type ((AnjutaProjectNode *)g_node) & ANJUTA_PROJECT_PROXY))
- {
- g_signal_emit_by_name (G_OBJECT (AMP_GROUP_DATA (g_node)->project), "node-updated", data);
- }
- else
- {
- g_message ("proxy changed");
- }
- g_message ("signal emitted");
- break;
- default:
- break;
- }
-}
-
-
-static AnjutaTokenFile*
-amp_group_set_makefile (AmpGroup *node, GFile *makefile, AmpProject* project)
-{
- AmpGroupData *group;
-
- g_return_val_if_fail ((node != NULL) && (node->data != NULL), NULL);
-
- group = AMP_GROUP_DATA (node);
- if (group->makefile != NULL) g_object_unref (group->makefile);
- if (group->tfile != NULL) anjuta_token_file_free (group->tfile);
- if (makefile != NULL)
- {
- AnjutaToken *token;
- AmpAmScanner *scanner;
-
- group->makefile = g_object_ref (makefile);
- group->tfile = anjuta_token_file_new (makefile);
-
- token = anjuta_token_file_load (group->tfile, NULL);
-
- scanner = amp_am_scanner_new (project, node);
- group->make_token = amp_am_scanner_parse_token (scanner, anjuta_token_new_static (ANJUTA_TOKEN_FILE, NULL), token, makefile, NULL);
- amp_am_scanner_free (scanner);
-
- group->monitor = g_file_monitor_file (makefile,
- G_FILE_MONITOR_NONE,
- NULL,
- NULL);
- if (group->monitor != NULL)
- {
- g_message ("add monitor %s node %p data %p project %p", g_file_get_path (makefile), node, group, project);
- group->project = project;
- g_signal_connect (G_OBJECT (group->monitor),
- "changed",
- G_CALLBACK (on_group_monitor_changed),
- node);
- }
- }
- else
- {
- group->makefile = NULL;
- group->tfile = NULL;
- group->make_token = NULL;
- if (group->monitor) g_object_unref (group->monitor);
- group->monitor = NULL;
- }
-
- return group->tfile;
-}
-
-static AmpGroup*
-amp_group_new (GFile *file, gboolean dist_only, GError **error)
-{
- AmpGroupData *group = NULL;
- gchar *name;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- /* Validate group name */
- name = g_file_get_basename (file);
- if (!name || strlen (name) <= 0)
- {
- g_free (name);
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Please specify group name"));
- return NULL;
- }
- {
- gboolean failed = FALSE;
- const gchar *ptr = name;
- while (*ptr) {
- if (!isalnum (*ptr) && *ptr != '.' && *ptr != '-' &&
- *ptr != '_')
- failed = TRUE;
- ptr++;
- }
- if (failed) {
- g_free (name);
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Group name can only contain alphanumeric, '_', '-' or '.' characters"));
- return NULL;
- }
- }
- g_free (name);
-
- group = g_slice_new0(AmpGroupData);
- group->base.type = ANJUTA_PROJECT_GROUP;
- group->base.properties = amp_get_group_property_list();
- group->base.file = g_object_ref (file);
- group->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
- ANJUTA_PROJECT_CAN_ADD_TARGET |
- ANJUTA_PROJECT_CAN_ADD_SOURCE |
- ANJUTA_PROJECT_CAN_REMOVE |
- ANJUTA_PROJECT_CAN_SAVE;
- group->dist_only = dist_only;
- group->variables = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)amp_variable_free);
-
- return g_node_new (group);
-}
-
-static void
-amp_group_free (AmpGroup *node)
-{
- AmpGroupData *group = (AmpGroupData *)node->data;
- gint i;
-
- if (group->base.file) g_object_unref (group->base.file);
- amp_property_free (group->base.properties);
- if (group->tfile) anjuta_token_file_free (group->tfile);
- if (group->makefile) g_object_unref (group->makefile);
- for (i = 0; i < AM_GROUP_TOKEN_LAST; i++)
- {
- if (group->tokens[i] != NULL) g_list_free (group->tokens[i]);
- }
- g_slice_free (AmpGroupData, group);
- if (group->variables) g_hash_table_destroy (group->variables);
-
- if (group->monitor) g_object_unref (group->monitor);
- group->monitor = NULL;
-
- g_node_destroy (node);
-}
-
static gboolean
-amp_group_fill_token (AmpProject *project, AmpGroup *group, GError **error)
+amp_group_fill_token (AmpProject *project, AnjutaAmGroupNode *group, GError **error)
{
- AmpGroup *last;
+ AnjutaAmGroupNode *last;
GFile *directory;
GFile *makefile;
AnjutaToken *list;
gchar *basename;
gchar *uri;
AnjutaTokenFile* tfile;
- AmpTarget *sibling;
- AmpGroup *parent;
+ AnjutaAmTargetNode *sibling;
+ AnjutaAmGroupNode *parent;
gboolean after;
gchar *name;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (parent != NULL, NULL);
-
/* Check that the new group doesn't already exist */
/*directory = g_file_get_child (AMP_GROUP_DATA (parent)->base.file, name);
uri = g_file_get_uri (directory);
@@ -1045,19 +581,19 @@ amp_group_fill_token (AmpProject *project, AmpGroup *group, GError **error)
}*/
/* Get parent target */
- parent = (AmpGroup *)(group->parent);
- name = anjuta_project_node_get_name (group);
- directory = g_file_get_child (AMP_GROUP_DATA (parent)->base.file, name);
+ parent = ANJUTA_AM_GROUP_NODE (anjuta_project_node_parent(ANJUTA_PROJECT_NODE (group)));
+ name = anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (group));
+ directory = g_file_get_child (anjuta_project_node_get_file (ANJUTA_PROJECT_NODE (parent)), name);
/* Find a sibling if possible */
- if (group->prev != NULL)
+ if (anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (group)) != NULL)
{
- sibling = group->prev;
+ sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (group));
after = TRUE;
}
- else if (group->next != NULL)
+ else if (anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (group)) != NULL)
{
- sibling = group->next;
+ sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (group));
after = FALSE;
}
else
@@ -1088,7 +624,7 @@ amp_group_fill_token (AmpProject *project, AmpGroup *group, GError **error)
if (sibling == NULL)
{
/* Find a sibling before */
- for (last = anjuta_project_node_prev_sibling (group); (last != NULL) && (anjuta_project_node_get_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_prev_sibling (last));
+ for (last = anjuta_project_node_prev_sibling (group); (last != NULL) && (anjuta_project_node_get_node_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_prev_sibling (last));
if (last != NULL)
{
sibling = last;
@@ -1097,7 +633,7 @@ amp_group_fill_token (AmpProject *project, AmpGroup *group, GError **error)
else
{
/* Find a sibling after */
- for (last = anjuta_project_node_next_sibling (group); (last != NULL) && (anjuta_project_node_get_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_next_sibling (last));
+ for (last = anjuta_project_node_next_sibling (group); (last != NULL) && (anjuta_project_node_get_node_type (last) != ANJUTA_PROJECT_GROUP); last = anjuta_project_node_next_sibling (last));
if (last != NULL)
{
sibling = last;
@@ -1211,7 +747,7 @@ amp_group_fill_token (AmpProject *project, AmpGroup *group, GError **error)
/* Target objects
*---------------------------------------------------------------------------*/
-static void
+static gboolean
find_target (AnjutaProjectNode *node, gpointer data)
{
if ((AMP_NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET)
@@ -1221,12 +757,14 @@ find_target (AnjutaProjectNode *node, gpointer data)
/* Find target, return node value in pointer */
*(AnjutaProjectNode **)data = node;
- return;
+ return TRUE;
}
}
+
+ return FALSE;
}
-static void
+static gboolean
find_canonical_target (AnjutaProjectNode *node, gpointer data)
{
if ((AMP_NODE_DATA (node)->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET)
@@ -1239,109 +777,16 @@ find_canonical_target (AnjutaProjectNode *node, gpointer data)
*(AnjutaProjectNode **)data = node;
g_free (canon_name);
- return;
+ return TRUE;
}
g_free (canon_name);
}
-}
-
-static void
-amp_target_add_token (AmpTarget *node, AnjutaToken *token)
-{
- AmpTargetData *target;
-
- g_return_if_fail ((node != NULL) && (node->data != NULL));
-
- target = AMP_TARGET_DATA (node);
- target->tokens = g_list_prepend (target->tokens, token);
-}
-
-static GList *
-amp_target_get_token (AmpTarget *node)
-{
- AmpTargetData *target;
-
- g_return_val_if_fail ((node != NULL) && (node->data != NULL), NULL);
-
- target = AMP_TARGET_DATA (node);
- return target->tokens;
-}
-
-
-static AmpTarget*
-amp_target_new (const gchar *name, AnjutaProjectNodeType type, const gchar *install, gint flags, GError **error)
-{
- AmpTargetData *target = NULL;
-
- /* Validate target name */
- if (!name || strlen (name) <= 0)
- {
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Please specify target name"));
- return NULL;
- }
- {
- gboolean failed = FALSE;
- const gchar *ptr = name;
- while (*ptr) {
- if (!isalnum (*ptr) && *ptr != '.' && *ptr != '-' &&
- *ptr != '_')
- failed = TRUE;
- ptr++;
- }
- if (failed) {
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Target name can only contain alphanumeric, '_', '-' or '.' characters"));
- return NULL;
- }
- }
- if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_SHAREDLIB) {
- if (strlen (name) < 7 ||
- strncmp (name, "lib", strlen("lib")) != 0 ||
- strcmp (&name[strlen(name) - 3], ".la") != 0) {
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Shared library target name must be of the form 'libxxx.la'"));
- return NULL;
- }
- }
- else if ((type & ANJUTA_PROJECT_ID_MASK) == ANJUTA_PROJECT_STATICLIB) {
- if (strlen (name) < 6 ||
- strncmp (name, "lib", strlen("lib")) != 0 ||
- strcmp (&name[strlen(name) - 2], ".a") != 0) {
- error_set (error, IANJUTA_PROJECT_ERROR_VALIDATION_FAILED,
- _("Static library target name must be of the form 'libxxx.a'"));
- return NULL;
- }
- }
-
- target = g_slice_new0(AmpTargetData);
- target->base.type = ANJUTA_PROJECT_TARGET | type;
- target->base.properties = amp_get_target_property_list(type);
- target->base.name = g_strdup (name);
- target->base.state = ANJUTA_PROJECT_CAN_ADD_MODULE |
- ANJUTA_PROJECT_CAN_ADD_SOURCE |
- ANJUTA_PROJECT_CAN_REMOVE;
- target->install = g_strdup (install);
- target->flags = flags;
-
- return g_node_new (target);
-}
-
-static void
-amp_target_free (AmpTarget *node)
-{
- AmpTargetData *target = AMP_TARGET_DATA (node);
-
- g_free (target->base.name);
- amp_property_free (target->base.properties);
- g_free (target->install);
- g_slice_free (AmpTargetData, target);
- g_node_destroy (node);
+ return FALSE;
}
static gboolean
-amp_target_fill_token (AmpProject *project, AmpTarget *target, GError **error)
+amp_target_fill_token (AmpProject *project, AnjutaAmTargetNode *target, GError **error)
{
AnjutaToken* token;
AnjutaToken *args;
@@ -1352,15 +797,15 @@ amp_target_fill_token (AmpProject *project, AmpTarget *target, GError **error)
gchar *find;
gchar *name;
GList *last;
- AmpTarget *sibling;
- AmpGroup *parent;
+ AnjutaAmTargetNode *sibling;
+ AnjutaAmGroupNode *parent;
gboolean after;
/* Get parent target */
- parent = (AmpGroup *)(target->parent);
+ parent = ANJUTA_AM_GROUP_NODE (anjuta_project_node_parent (ANJUTA_PROJECT_NODE (target)));
info = (AmpNodeInfo *)amp_project_get_type_info (project, anjuta_project_node_get_full_type (target));
- name = anjuta_project_node_get_name (target);
+ name = anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (target));
/* Check that the new target doesn't already exist */
/*find = name;
@@ -1375,14 +820,14 @@ amp_target_fill_token (AmpProject *project, AmpTarget *target, GError **error)
}*/
/* Find a sibling if possible */
- if (target->prev != NULL)
+ if (target->base.prev != NULL)
{
- sibling = target->prev;
+ sibling = target->base.prev;
after = TRUE;
}
- else if (target->next != NULL)
+ else if (target->base.next != NULL)
{
- sibling = target->next;
+ sibling = target->base.next;
after = FALSE;
}
else
@@ -1481,37 +926,11 @@ amp_target_fill_token (AmpProject *project, AmpTarget *target, GError **error)
/* Source objects
*---------------------------------------------------------------------------*/
-static AmpSource*
-amp_source_new (GFile *file, GError **error)
-{
- AmpSourceData *source = NULL;
-
- source = g_slice_new0(AmpSourceData);
- source->base.type = ANJUTA_PROJECT_SOURCE;
- source->base.properties = amp_get_source_property_list();
- source->base.file = g_object_ref (file);
- source->base.state = ANJUTA_PROJECT_CAN_REMOVE;
-
- return g_node_new (source);
-}
-
-void
-amp_source_free (AmpSource *node)
-{
- AmpSourceData *source = AMP_SOURCE_DATA (node);
-
- g_object_unref (source->base.file);
- amp_property_free (source->base.properties);
- g_slice_free (AmpSourceData, source);
-
- g_node_destroy (node);
-}
-
static gboolean
-amp_source_fill_token (AmpProject *project, AmpSource *source, GError **error)
+amp_source_fill_token (AmpProject *project, AnjutaAmSourceNode *source, GError **error)
{
- AmpGroup *group;
- AmpTarget *target;
+ AnjutaAmGroupNode *group;
+ AnjutaAmTargetNode *target;
gboolean after;
AnjutaToken *token;
AnjutaToken *prev;
@@ -1519,23 +938,23 @@ amp_source_fill_token (AmpProject *project, AmpSource *source, GError **error)
gchar *relative_name;
/* Get parent target */
- target = (AmpTarget *)(source->parent);
- if ((target == NULL) || (anjuta_project_node_get_type (target) != ANJUTA_PROJECT_TARGET)) return FALSE;
+ target = ANJUTA_AM_TARGET_NODE (anjuta_project_node_parent (ANJUTA_PROJECT_NODE (source)));
+ if ((target == NULL) || (anjuta_project_node_get_node_type (target) != ANJUTA_PROJECT_TARGET)) return FALSE;
- group = (AmpGroup *)(target->parent);
+ group = ANJUTA_AM_GROUP_NODE (anjuta_project_node_parent (ANJUTA_PROJECT_NODE (target)));
relative_name = g_file_get_relative_path (AMP_GROUP_DATA (group)->base.file, AMP_SOURCE_DATA (source)->base.file);
/* Add in Makefile.am */
/* Find a sibling if possible */
- if (source->prev != NULL)
+ if (source->base.prev != NULL)
{
- prev = AMP_SOURCE_DATA (source->prev)->token;
+ prev = AMP_SOURCE_DATA (source->base.prev)->token;
after = TRUE;
args = anjuta_token_list (prev);
}
- else if (source->next != NULL)
+ else if (source->base.next != NULL)
{
- prev = AMP_SOURCE_DATA (source->next)->token;
+ prev = AMP_SOURCE_DATA (source->base.next)->token;
after = FALSE;
args = anjuta_token_list (prev);
}
@@ -1625,81 +1044,6 @@ monitor_cb (GFileMonitor *monitor,
}
-static void
-monitor_add (AmpProject *project, GFile *file)
-{
- GFileMonitor *monitor = NULL;
-
- g_return_if_fail (project != NULL);
- g_return_if_fail (project->monitors != NULL);
-
- if (file == NULL)
- return;
-
- monitor = g_hash_table_lookup (project->monitors, file);
- if (!monitor) {
- gboolean exists;
-
- /* FIXME clarify if uri is uri, path or both */
- exists = g_file_query_exists (file, NULL);
-
- if (exists) {
- monitor = g_file_monitor_file (file,
- G_FILE_MONITOR_NONE,
- NULL,
- NULL);
- if (monitor != NULL)
- {
- g_signal_connect (G_OBJECT (monitor),
- "changed",
- G_CALLBACK (on_group_monitor_changed),
- project);
- g_hash_table_insert (project->monitors,
- g_object_ref (file),
- monitor);
- }
- }
- }
-}
-
-static void
-monitors_remove (AmpProject *project)
-{
- g_return_if_fail (project != NULL);
-
- if (project->monitors)
- g_hash_table_destroy (project->monitors);
- project->monitors = NULL;
-}
-
-static void
-group_hash_foreach_monitor (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- AmpGroup *group_node = value;
- AmpProject *project = user_data;
-
- monitor_add (project, AMP_GROUP_DATA(group_node)->base.file);
-}
-
-static void
-monitors_setup (AmpProject *project)
-{
- g_return_if_fail (project != NULL);
-
- monitors_remove (project);
-
- /* setup monitors hash */
- project->monitors = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
- (GDestroyNotify) g_file_monitor_cancel);
-
- monitor_add (project, anjuta_token_file_get_file (project->configure_file));
- if (project->groups)
- g_hash_table_foreach (project->groups, group_hash_foreach_monitor, project);
-}
-
-
/*
* ---------------- Data structures managment
*/
@@ -1770,8 +1114,9 @@ project_node_destroy (AmpProject *project, AnjutaProjectNode *g_node)
if (g_node) {
/* free each node's data first */
- anjuta_project_node_all_foreach (g_node,
- foreach_node_destroy, project);
+ foreach_node_destroy (g_node, project);
+ //anjuta_project_node_foreach (g_node, G_POST_ORDER,
+ // foreach_node_destroy, project);
/* now destroy the tree itself */
//g_node_destroy (g_node);
@@ -1847,7 +1192,7 @@ project_node_save (AmpProject *project, AnjutaProjectNode *g_node, GError **erro
break;
case ANJUTA_PROJECT_TARGET:
case ANJUTA_PROJECT_SOURCE:
- for (parent = g_node; anjuta_project_node_get_type (parent) != ANJUTA_PROJECT_GROUP; parent = anjuta_project_node_parent (parent));
+ for (parent = g_node; anjuta_project_node_get_node_type (parent) != ANJUTA_PROJECT_GROUP; parent = anjuta_project_node_parent (parent));
g_hash_table_insert (files, AMP_GROUP_DATA (parent)->tfile, NULL);
break;
case ANJUTA_PROJECT_MODULE:
@@ -1929,8 +1274,8 @@ amp_project_load_module (AmpProject *project, AnjutaToken *module_token)
AnjutaToken *list;
AnjutaToken *item;
gchar *value;
- AmpModule *module;
- AmpPackage *package;
+ AnjutaAmModuleNode *module;
+ AnjutaAmPackageNode *package;
gchar *compare;
@@ -2050,7 +1395,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
{
gchar *value;
gchar *canon_id;
- AmpTarget *target;
+ AnjutaAmTargetNode *target;
AmpTargetPropertyBuffer *buffer;
gchar *orig_key;
gpointer find;
@@ -2063,7 +1408,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
/* Check if target already exists */
find = value;
- anjuta_project_node_children_foreach (parent, find_target, &find);
+ anjuta_project_node_children_traverse (parent, find_target, &find);
if ((gchar *)find != value)
{
/* Find target */
@@ -2088,7 +1433,7 @@ project_load_target (AmpProject *project, AnjutaToken *name, AnjutaTokenType tok
sources = amp_target_property_buffer_steal_sources (buffer);
for (src = sources; src != NULL; src = g_list_next (src))
{
- AmpSource *source = src->data;
+ AnjutaAmSourceNode *source = src->data;
anjuta_project_node_prepend (target, source);
}
@@ -2140,8 +1485,7 @@ static AnjutaToken*
project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
{
AnjutaToken *arg;
- AmpGroupData *group = AMP_GROUP_DATA (parent);
- GFile *parent_file = g_object_ref (group->base.file);
+ GFile *parent_file = g_object_ref (anjuta_project_node_get_file (ANJUTA_PROJECT_NODE (parent)));
gchar *target_id = NULL;
AmpTargetPropertyBuffer *orphan = NULL;
@@ -2161,7 +1505,7 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
find = target_id;
DEBUG_PRINT ("search for canonical %s", target_id);
- anjuta_project_node_children_foreach (parent, find_canonical_target, &find);
+ anjuta_project_node_children_traverse (parent, find_canonical_target, &find);
parent = (gchar *)find != target_id ? (AnjutaProjectNode *)find : NULL;
/* Get orphan buffer if there is no target */
@@ -2182,7 +1526,7 @@ project_load_sources (AmpProject *project, AnjutaToken *name, AnjutaToken *list,
for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
{
gchar *value;
- AmpSource *source;
+ AnjutaAmSourceNode *source;
GFile *src_file;
value = anjuta_token_evaluate (arg);
@@ -2257,7 +1601,7 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, An
/* Check if target already exists */
find = target_id;
- anjuta_project_node_children_foreach (parent, find_target, &find);
+ anjuta_project_node_children_traverse (parent, find_target, &find);
if ((gchar *)find == target_id)
{
/* Create target */
@@ -2279,7 +1623,7 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, An
for (arg = anjuta_token_first_word (list); arg != NULL; arg = anjuta_token_next_word (arg))
{
gchar *value;
- AmpSource *source;
+ AnjutaAmSourceNode *source;
GFile *src_file;
value = anjuta_token_evaluate (arg);
@@ -2305,7 +1649,6 @@ project_load_data (AmpProject *project, AnjutaToken *name, AnjutaToken *list, An
static AnjutaToken*
project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectNode *parent, GHashTable *orphan_properties)
{
- AmpGroupData *group = AMP_GROUP_DATA (parent);
gchar *target_id = NULL;
target_id = anjuta_token_evaluate (name);
@@ -2327,7 +1670,7 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
find = target_id;
DEBUG_PRINT ("search for canonical %s", target_id);
- anjuta_project_node_children_foreach (parent, find_canonical_target, &find);
+ anjuta_project_node_children_traverse (parent, find_canonical_target, &find);
parent = (gchar *)find != target_id ? (AnjutaProjectNode *)find : NULL;
/* Create property */
@@ -2369,7 +1712,6 @@ project_load_target_properties (AmpProject *project, AnjutaToken *name, AnjutaTo
static AnjutaToken*
project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTokenType type, AnjutaToken *list, AnjutaProjectNode *parent)
{
- AmpGroupData *group = AMP_GROUP_DATA (parent);
gchar *value;
gchar *name;
AnjutaProjectProperty *prop;
@@ -2387,10 +1729,10 @@ project_load_group_properties (AmpProject *project, AnjutaToken *token, AnjutaTo
return NULL;
}
-static AmpGroup* project_load_makefile (AmpProject *project, AmpGroup *group);
+static AnjutaAmGroupNode* project_load_makefile (AmpProject *project, AnjutaAmGroupNode *group);
static void
-project_load_subdirs (AmpProject *project, AnjutaToken *list, AmpGroup *parent, gboolean dist_only)
+project_load_subdirs (AmpProject *project, AnjutaToken *list, AnjutaAmGroupNode *parent, gboolean dist_only)
{
AnjutaToken *arg;
@@ -2405,7 +1747,7 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AmpGroup *parent,
{
GFile *subdir;
gchar *group_id;
- AmpGroup *group;
+ AnjutaAmGroupNode *group;
subdir = g_file_resolve_relative_path (AMP_GROUP_DATA (parent)->base.file, value);
@@ -2434,8 +1776,8 @@ project_load_subdirs (AmpProject *project, AnjutaToken *list, AmpGroup *parent,
}
}
-static AmpGroup*
-project_load_makefile (AmpProject *project, AmpGroup *group)
+static AnjutaAmGroupNode*
+project_load_makefile (AmpProject *project, AnjutaAmGroupNode *group)
{
const gchar **filename;
AnjutaTokenFile *tfile;
@@ -2487,7 +1829,7 @@ project_load_makefile (AmpProject *project, AmpGroup *group)
}
void
-amp_project_set_am_variable (AmpProject* project, AmpGroup* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_properties)
+amp_project_set_am_variable (AmpProject* project, AnjutaAmGroupNode* group, AnjutaTokenType variable, AnjutaToken *name, AnjutaToken *list, GHashTable *orphan_properties)
{
switch (variable)
{
@@ -2566,7 +1908,7 @@ amp_project_load_root (AmpProject *project, AnjutaProjectNode *node, GError **er
{
AmpAcScanner *scanner;
AnjutaToken *arg;
- AmpGroup *group;
+ AnjutaAmGroupNode *group;
GFile *root_file;
GFile *configure_file;
gboolean ok = TRUE;
@@ -2723,7 +2065,7 @@ amp_project_load_package (AmpProject *project, AnjutaProjectNode *node, GError *
for (file = g_list_first (children); file != NULL; file = g_list_next (file))
{
/* Create a source for files */
- AmpSource *source;
+ AnjutaAmSourceNode *source;
source = project_node_new (project, ANJUTA_PROJECT_SOURCE, (GFile *)file->data, NULL, NULL);
anjuta_project_node_append (node, source);
@@ -2762,7 +2104,7 @@ amp_project_load_group (AmpProject *project, AnjutaProjectNode *node, GError **e
AnjutaProjectNode *
amp_project_load_node (AmpProject *project, AnjutaProjectNode *node, GError **error)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
return amp_project_load_root (project, node, error);
@@ -2795,8 +2137,6 @@ amp_project_load (AmpProject *project,
void
amp_project_unload (AmpProject *project)
{
- monitors_remove (project);
-
/* project data */
//project_node_destroy (project, project->root_node);
project->root_node = NULL;
@@ -2889,12 +2229,12 @@ amp_project_get_token_location (AmpProject *project, AnjutaTokenFileLocation *lo
void
amp_project_remove_group (AmpProject *project,
- AmpGroup *group,
+ AnjutaAmGroupNode *group,
GError **error)
{
GList *token_list;
- if (anjuta_project_node_get_type (group) != ANJUTA_PROJECT_GROUP) return;
+ if (anjuta_project_node_get_node_type (group) != ANJUTA_PROJECT_GROUP) return;
for (token_list = amp_group_get_token (group, AM_GROUP_TOKEN_CONFIGURE); token_list != NULL; token_list = g_list_next (token_list))
{
@@ -2914,12 +2254,12 @@ amp_project_remove_group (AmpProject *project,
void
amp_project_remove_target (AmpProject *project,
- AmpTarget *target,
+ AnjutaAmTargetNode *target,
GError **error)
{
GList *token_list;
- if (anjuta_project_node_get_type (target) != ANJUTA_PROJECT_TARGET) return;
+ if (anjuta_project_node_get_node_type (target) != ANJUTA_PROJECT_TARGET) return;
for (token_list = amp_target_get_token (target); token_list != NULL; token_list = g_list_next (token_list))
{
@@ -2931,11 +2271,11 @@ amp_project_remove_target (AmpProject *project,
void
amp_project_remove_source (AmpProject *project,
- AmpSource *source,
+ AnjutaAmSourceNode *source,
GError **error)
{
amp_dump_node (source);
- if (anjuta_project_node_get_type (source) != ANJUTA_PROJECT_SOURCE) return;
+ if (anjuta_project_node_get_node_type (source) != ANJUTA_PROJECT_SOURCE) return;
anjuta_token_remove_word (AMP_SOURCE_DATA (source)->token, NULL);
@@ -2999,7 +2339,7 @@ foreach_node_move (AnjutaProjectNode *g_node, gpointer data)
GFile *relative;
GFile *new_file;
- switch (anjuta_project_node_get_type (g_node))
+ switch (anjuta_project_node_get_node_type (g_node))
{
case ANJUTA_PROJECT_GROUP:
relative = get_relative_path (old_root_file, AMP_GROUP_DATA (g_node)->base.file);
@@ -3048,7 +2388,7 @@ amp_project_move (AmpProject *project, const gchar *path)
/* Change project root directory in groups */
old_hash = project->groups;
project->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- anjuta_project_node_all_foreach (project->root_node, foreach_node_move, &packet);
+ anjuta_project_node_foreach (project->root_node, G_POST_ORDER, foreach_node_move, &packet);
g_hash_table_destroy (old_hash);
/* Change all files */
@@ -3100,49 +2440,49 @@ amp_project_new (void)
/* Project access functions
*---------------------------------------------------------------------------*/
-AmpGroup *
+AnjutaAmRootNode *
amp_project_get_root (AmpProject *project)
{
- AmpGroup *g_node = NULL;
+ AnjutaAmRootNode *g_node = NULL;
if (project->root_file != NULL)
{
gchar *id = g_file_get_uri (project->root_file);
- g_node = (AmpGroup *)g_hash_table_lookup (project->groups, id);
+ g_node = ANJUTA_AM_ROOT_NODE (g_hash_table_lookup (project->groups, id));
g_free (id);
}
return g_node;
}
-AmpGroup *
+AnjutaAmGroupNode *
amp_project_get_group (AmpProject *project, const gchar *id)
{
- return (AmpGroup *)g_hash_table_lookup (project->groups, id);
+ return (AnjutaAmGroupNode *)g_hash_table_lookup (project->groups, id);
}
-AmpTarget *
+AnjutaAmTargetNode *
amp_project_get_target (AmpProject *project, const gchar *id)
{
- AmpTarget **buffer;
- AmpTarget *target;
+ AnjutaAmTargetNode **buffer;
+ AnjutaAmTargetNode *target;
gsize dummy;
- buffer = (AmpTarget **)g_base64_decode (id, &dummy);
+ buffer = (AnjutaAmTargetNode **)g_base64_decode (id, &dummy);
target = *buffer;
g_free (buffer);
return target;
}
-AmpSource *
+AnjutaAmSourceNode *
amp_project_get_source (AmpProject *project, const gchar *id)
{
- AmpSource **buffer;
- AmpSource *source;
+ AnjutaAmSourceNode **buffer;
+ AnjutaAmSourceNode *source;
gsize dummy;
- buffer = (AmpSource **)g_base64_decode (id, &dummy);
+ buffer = (AnjutaAmSourceNode **)g_base64_decode (id, &dummy);
source = *buffer;
g_free (buffer);
@@ -3186,7 +2526,7 @@ amp_project_get_node_id (AmpProject *project, const gchar *path)
}
}
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_GROUP:
return g_file_get_uri (AMP_GROUP_DATA (node)->base.file);
@@ -3294,7 +2634,7 @@ iproject_load_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
static AnjutaProjectNode *
iproject_save_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **error)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
if (!amp_project_save (AMP_PROJECT (obj), error))
@@ -3389,25 +2729,25 @@ iproject_iface_init(IAnjutaProjectIface* iface)
*---------------------------------------------------------------------------*/
GFile*
-amp_group_get_directory (AmpGroup *group)
+amp_group_get_directory (AnjutaAmGroupNode *group)
{
return AMP_GROUP_DATA (group)->base.file;
}
GFile*
-amp_group_get_makefile (AmpGroup *group)
+amp_group_get_makefile (AnjutaAmGroupNode *group)
{
return AMP_GROUP_DATA (group)->makefile;
}
gchar *
-amp_group_get_id (AmpGroup *group)
+amp_group_get_id (AnjutaAmGroupNode *group)
{
return g_file_get_uri (AMP_GROUP_DATA (group)->base.file);
}
void
-amp_group_update_variable (AmpGroup *group, AnjutaToken *variable)
+amp_group_update_variable (AnjutaAmGroupNode *group, AnjutaToken *variable)
{
AnjutaToken *arg;
char *name = NULL;
@@ -3434,7 +2774,7 @@ amp_group_update_variable (AmpGroup *group, AnjutaToken *variable)
}
AnjutaToken*
-amp_group_get_variable_token (AmpGroup *group, AnjutaToken *variable)
+amp_group_get_variable_token (AnjutaAmGroupNode *group, AnjutaToken *variable)
{
guint length;
const gchar *string;
@@ -3461,13 +2801,13 @@ amp_group_get_variable_token (AmpGroup *group, AnjutaToken *variable)
*---------------------------------------------------------------------------*/
const gchar *
-amp_target_get_name (AmpTarget *target)
+amp_target_get_name (AnjutaAmTargetNode *target)
{
return AMP_TARGET_DATA (target)->base.name;
}
gchar *
-amp_target_get_id (AmpTarget *target)
+amp_target_get_id (AnjutaAmTargetNode *target)
{
return g_base64_encode ((guchar *)&target, sizeof (target));
}
@@ -3476,13 +2816,13 @@ amp_target_get_id (AmpTarget *target)
*---------------------------------------------------------------------------*/
gchar *
-amp_source_get_id (AmpSource *source)
+amp_source_get_id (AnjutaAmSourceNode *source)
{
return g_base64_encode ((guchar *)&source, sizeof (source));
}
GFile*
-amp_source_get_file (AmpSource *source)
+amp_source_get_file (AnjutaAmSourceNode *source)
{
return AMP_SOURCE_DATA (source)->base.file;
}
@@ -3534,4 +2874,3 @@ amp_project_class_init (AmpProjectClass *klass)
ANJUTA_TYPE_BEGIN(AmpProject, amp_project, G_TYPE_OBJECT);
ANJUTA_TYPE_ADD_INTERFACE(iproject, IANJUTA_TYPE_PROJECT);
ANJUTA_TYPE_END;
-//GBF_BACKEND_BOILERPLATE (AmpProject, amp_project);
diff --git a/plugins/am-project/am-project.h b/plugins/am-project/am-project.h
index 6a45f89..03be24b 100644
--- a/plugins/am-project/am-project.h
+++ b/plugins/am-project/am-project.h
@@ -37,11 +37,6 @@ G_BEGIN_DECLS
#define AMP_IS_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AMP_TYPE_PROJECT))
#define AMP_IS_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), AMP_TYPE_PROJECT))
-#define AMP_GROUP(obj) ((AmpGroup *)obj)
-#define AMP_TARGET(obj) ((AmpTarget *)obj)
-#define AMP_SOURCE(obj) ((AmpSource *)obj)
-
-
typedef struct _AmpProject AmpProject;
typedef struct _AmpProjectClass AmpProjectClass;
@@ -49,11 +44,13 @@ struct _AmpProjectClass {
GObjectClass parent_class;
};
-typedef AnjutaProjectNode AmpGroup;
-typedef AnjutaProjectNode AmpTarget;
-typedef AnjutaProjectNode AmpSource;
-typedef AnjutaProjectNode AmpModule;
-typedef AnjutaProjectNode AmpPackage;
+typedef struct _AnjutaAmRootNode AnjutaAmRootNode;
+typedef struct _AnjutaAmModuleNode AnjutaAmModuleNode;
+typedef struct _AnjutaAmPackageNode AnjutaAmPackageNode;
+typedef struct _AnjutaAmGroupNode AnjutaAmGroupNode;
+typedef struct _AnjutaAmTargetNode AnjutaAmTargetNode;
+typedef struct _AnjutaAmSourceNode AnjutaAmSourceNode;
+
typedef struct _AmpProperty AmpProperty;
typedef enum {
@@ -75,7 +72,7 @@ AmpProject *amp_project_new (void);
AmpTargetPropertyBuffer* amp_target_property_buffer_new (void);
void amp_target_property_buffer_free (AmpTargetPropertyBuffer *buffer);
-void amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AmpSource *source);
+void amp_target_property_buffer_add_source (AmpTargetPropertyBuffer *buffer, AnjutaAmSourceNode *source);
void amp_target_property_buffer_add_property (AmpTargetPropertyBuffer *buffer, AnjutaProjectProperty *prop);
GList *amp_target_property_buffer_steal_sources (AmpTargetPropertyBuffer *buffer);
GList *amp_target_property_buffer_steal_properties (AmpTargetPropertyBuffer *buffer);
@@ -89,10 +86,10 @@ void amp_project_load_config (AmpProject *project, AnjutaToken *arg_list);
void amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToken *list);
void amp_project_load_module (AmpProject *project, AnjutaToken *module);
-AmpGroup *amp_project_get_root (AmpProject *project);
-AmpGroup *amp_project_get_group (AmpProject *project, const gchar *id);
-AmpTarget *amp_project_get_target (AmpProject *project, const gchar *id);
-AmpSource *amp_project_get_source (AmpProject *project, const gchar *id);
+AnjutaAmRootNode *amp_project_get_root (AmpProject *project);
+AnjutaAmGroupNode *amp_project_get_group (AmpProject *project, const gchar *id);
+AnjutaAmTargetNode *amp_project_get_target (AmpProject *project, const gchar *id);
+AnjutaAmSourceNode *amp_project_get_source (AmpProject *project, const gchar *id);
gboolean amp_project_get_token_location (AmpProject *project, AnjutaTokenFileLocation *location, AnjutaToken *token);
gboolean amp_project_move (AmpProject *project, const gchar *path);
@@ -101,17 +98,17 @@ gboolean amp_project_save (AmpProject *project, GError **error);
gchar * amp_project_get_uri (AmpProject *project);
GFile* amp_project_get_file (AmpProject *project);
-AmpGroup* amp_project_add_group (AmpProject *project, AmpGroup *parent, const gchar *name, GError **error);
-AmpGroup* amp_project_add_sibling_group (AmpProject *project, AmpGroup *parent, const gchar *name, gboolean after, AmpGroup *sibling, GError **error);
-void amp_project_remove_group (AmpProject *project, AmpGroup *group, GError **error);
+AnjutaAmGroupNode* amp_project_add_group (AmpProject *project, AnjutaAmGroupNode *parent, const gchar *name, GError **error);
+AnjutaAmGroupNode* amp_project_add_sibling_group (AmpProject *project, AnjutaAmGroupNode *parent, const gchar *name, gboolean after, AnjutaAmGroupNode *sibling, GError **error);
+void amp_project_remove_group (AmpProject *project, AnjutaAmGroupNode *group, GError **error);
-AmpTarget* amp_project_add_target (AmpProject *project, AmpGroup *parent, const gchar *name, AnjutaProjectNodeType type, GError **error);
-AmpTarget* amp_project_add_sibling_target (AmpProject *project, AmpGroup *parent, const gchar *name, AnjutaProjectNodeType type, gboolean after, AmpTarget *sibling, GError **error);
-void amp_project_remove_target (AmpProject *project, AmpTarget *target, GError **error);
+AnjutaAmTargetNode* amp_project_add_target (AmpProject *project, AnjutaAmGroupNode *parent, const gchar *name, AnjutaProjectNodeType type, GError **error);
+AnjutaAmTargetNode* amp_project_add_sibling_target (AmpProject *project, AnjutaAmGroupNode *parent, const gchar *name, AnjutaProjectNodeType type, gboolean after, AnjutaAmTargetNode *sibling, GError **error);
+void amp_project_remove_target (AmpProject *project, AnjutaAmTargetNode *target, GError **error);
-AmpSource* amp_project_add_source (AmpProject *project, AmpTarget *parent, GFile *file, GError **error);
-AmpSource* amp_project_add_sibling_source (AmpProject *project, AmpTarget *parent, GFile *file, gboolean after, AmpSource *sibling, GError **error);
-void amp_project_remove_source (AmpProject *project, AmpSource *source, GError **error);
+AnjutaAmSourceNode* amp_project_add_source (AmpProject *project, AnjutaAmTargetNode *parent, GFile *file, GError **error);
+AnjutaAmSourceNode* amp_project_add_sibling_source (AmpProject *project, AnjutaAmTargetNode *parent, GFile *file, gboolean after, AnjutaAmSourceNode *sibling, GError **error);
+void amp_project_remove_source (AmpProject *project, AnjutaAmSourceNode *source, GError **error);
AnjutaProjectNodeInfo *amp_project_get_type_info (AmpProject *project, AnjutaProjectNodeType type);
GList *amp_project_get_node_info (AmpProject *project, GError **error);
@@ -133,20 +130,20 @@ AnjutaProjectNode *amp_node_last_child (AnjutaProjectNode *node);
AnjutaProjectNode *amp_node_next_sibling (AnjutaProjectNode *node);
AnjutaProjectNode *amp_node_prev_sibling (AnjutaProjectNode *node);
AnjutaProjectNodeType amp_node_get_type (AnjutaProjectNode *node);
-void amp_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
+//void amp_node_all_foreach (AnjutaProjectNode *node, AnjutaProjectNodeFunc func, gpointer data);
-GFile *amp_group_get_directory (AmpGroup *group);
-GFile *amp_group_get_makefile (AmpGroup *group);
-gchar *amp_group_get_id (AmpGroup *group);
-void amp_group_update_variable (AmpGroup *group, AnjutaToken *variable);
-AnjutaToken* amp_group_get_variable_token (AmpGroup *group, AnjutaToken *variable);
+GFile *amp_group_get_directory (AnjutaAmGroupNode *group);
+GFile *amp_group_get_makefile (AnjutaAmGroupNode *group);
+gchar *amp_group_get_id (AnjutaAmGroupNode *group);
+void amp_group_update_variable (AnjutaAmGroupNode *group, AnjutaToken *variable);
+AnjutaToken* amp_group_get_variable_token (AnjutaAmGroupNode *group, AnjutaToken *variable);
-const gchar *amp_target_get_name (AmpTarget *target);
-gchar *amp_target_get_id (AmpTarget *target);
+const gchar *amp_target_get_name (AnjutaAmTargetNode *target);
+gchar *amp_target_get_id (AnjutaAmTargetNode *target);
-void amp_source_free (AmpSource *node);
-gchar *amp_source_get_id (AmpSource *source);
-GFile *amp_source_get_file (AmpSource *source);
+void amp_source_free (AnjutaAmSourceNode *node);
+gchar *amp_source_get_id (AnjutaAmSourceNode *source);
+GFile *amp_source_get_file (AnjutaAmSourceNode *source);
G_END_DECLS
diff --git a/plugins/am-project/am-scanner.h b/plugins/am-project/am-scanner.h
index 59eb367..5eec6e4 100644
--- a/plugins/am-project/am-scanner.h
+++ b/plugins/am-project/am-scanner.h
@@ -36,7 +36,7 @@ G_BEGIN_DECLS
typedef struct _AmpAmScanner AmpAmScanner;
-AmpAmScanner *amp_am_scanner_new (AmpProject *project, AmpGroup *group);
+AmpAmScanner *amp_am_scanner_new (AmpProject *project, AnjutaAmGroupNode *group);
void amp_am_scanner_free (AmpAmScanner *scanner);
AnjutaToken *amp_am_scanner_parse_token (AmpAmScanner *scanner, AnjutaToken *root, AnjutaToken *content, GFile *filename, GError **error);
diff --git a/plugins/am-project/am-scanner.l b/plugins/am-project/am-scanner.l
index 440ee29..9c22e29 100644
--- a/plugins/am-project/am-scanner.l
+++ b/plugins/am-project/am-scanner.l
@@ -21,6 +21,7 @@
#include "am-scanner.h"
#include "am-parser.h"
+#include "am-node.h"
#include "libanjuta/anjuta-debug.h"
#include "libanjuta/anjuta-token-stream.h"
@@ -49,7 +50,7 @@ struct _AmpAmScanner
AnjutaTokenStream *stream;
AmpProject *project;
- AmpGroup *group;
+ AnjutaAmGroupNode *group;
GHashTable *orphan_properties;
gboolean eof;
};
@@ -348,7 +349,7 @@ free_source_list (GList *source_list)
}
AmpAmScanner *
-amp_am_scanner_new (AmpProject *project, AmpGroup *group)
+amp_am_scanner_new (AmpProject *project, AnjutaAmGroupNode *group)
{
AmpAmScanner *scanner;
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index 2168137..f260cb8 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -89,7 +89,7 @@ amp_project_write_config_list (AmpProject *project)
}
AnjutaToken *
-amp_project_write_subdirs_list (AmpGroup *project)
+amp_project_write_subdirs_list (AnjutaAmGroupNode *project)
{
AnjutaToken *pos;
AnjutaToken *token;
diff --git a/plugins/am-project/projectparser.c b/plugins/am-project/projectparser.c
index c0b95dd..1259da7 100644
--- a/plugins/am-project/projectparser.c
+++ b/plugins/am-project/projectparser.c
@@ -99,7 +99,7 @@ list_group (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNode
gchar *rel_path;
parent = anjuta_project_node_parent (group);
- if (anjuta_project_node_get_type (parent) == ANJUTA_PROJECT_ROOT)
+ if (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_ROOT)
{
GFile *root;
@@ -180,7 +180,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNo
count = 0;
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if (anjuta_project_node_get_type (node) == ANJUTA_PROJECT_MODULE)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_MODULE)
{
gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
list_module (project, root, node, indent, child_path);
@@ -192,7 +192,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNo
count = 0;
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if (anjuta_project_node_get_type (node) == ANJUTA_PROJECT_PACKAGE)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_PACKAGE)
{
gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
list_package (project, root, node, indent, child_path);
@@ -204,7 +204,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNo
count = 0;
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if (anjuta_project_node_get_type (node) == ANJUTA_PROJECT_GROUP)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_GROUP)
{
gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
list_group (project, root, node, indent, child_path);
@@ -216,7 +216,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNo
count = 0;
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if (anjuta_project_node_get_type (node) == ANJUTA_PROJECT_TARGET)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_TARGET)
{
gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
list_target (project, root, node, indent, child_path);
@@ -228,7 +228,7 @@ list_children (IAnjutaProject *project, AnjutaProjectNode *root, AnjutaProjectNo
count = 0;
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if (anjuta_project_node_get_type (node) == ANJUTA_PROJECT_SOURCE)
+ if (anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_SOURCE)
{
gchar *child_path = g_strdup_printf ("%s%s%d", path != NULL ? path : "", path != NULL ? ":" : "", count);
list_source (project, root, node, indent, child_path);
@@ -354,127 +354,6 @@ get_project_property (AmpProject *project, AnjutaProjectNode *parent, const gcha
return prop;
}
-
-#define NUM_NODE 1000000
-#define NUM_TRY 4
-
-void benchmark(void)
-{
- GTimer *timer;
- AnjutaProjectNode *nodes[NUM_NODE];
- guint i,j;
- gdouble all_new[NUM_TRY + 1];
- gdouble all_free[NUM_TRY + 1];
- gdouble all_both[NUM_TRY + 1] ;
-
- timer = g_timer_new ();
-
- for (j = 0; j < NUM_TRY; j++)
- {
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- nodes[i] = anjuta_project_introspection_node_new (ANJUTA_PROJECT_ROOT, NULL, "noname", timer);
- }
- g_timer_stop (timer);
- all_new[j] = g_timer_elapsed (timer, NULL);
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- anjuta_project_introspection_node_free (nodes[i]);
- }
- g_timer_stop (timer);
- all_free[j] = g_timer_elapsed (timer, NULL);
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- nodes[0] = anjuta_project_introspection_node_new (ANJUTA_PROJECT_ROOT, NULL, "noname", timer);
- anjuta_project_introspection_node_free (nodes[0]);
- }
- g_timer_stop (timer);
- all_both[j] = g_timer_elapsed (timer, NULL);
- }
- all_new[NUM_TRY] = 0;
- all_free[NUM_TRY] = 0;
- all_both[NUM_TRY] = 0;
-
- printf ("all_new ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_new[j]);
- all_new[NUM_TRY] += all_new[j];
- }
- printf (" %g\n", all_new[NUM_TRY] / NUM_TRY);
- printf ("all_free ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_free[j]);
- all_free[NUM_TRY] += all_free[j];
- }
- printf (" %g\n", all_free[NUM_TRY] / NUM_TRY);
- printf ("all_both ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_both[j]);
- all_both[NUM_TRY] += all_both[j];
- }
- printf (" %g\n", all_both[NUM_TRY] / NUM_TRY);
-
-
- for (j = 0; j < NUM_TRY; j++)
- {
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- nodes[i] = anjuta_project_gobject_node_new (ANJUTA_PROJECT_ROOT, NULL, "noname", timer);
- }
- g_timer_stop (timer);
- all_new[j] = g_timer_elapsed (timer, NULL);
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- anjuta_project_gobject_node_free (nodes[i]);
- }
- g_timer_stop (timer);
- all_free[j] = g_timer_elapsed (timer, NULL);
- g_timer_start (timer);
- for (i = 0; i < NUM_NODE; i++)
- {
- nodes[0] = anjuta_project_gobject_node_new (ANJUTA_PROJECT_ROOT, NULL, "noname", timer);
- anjuta_project_gobject_node_free (nodes[0]);
- }
- g_timer_stop (timer);
- all_both[j] = g_timer_elapsed (timer, NULL);
- }
- all_new[NUM_TRY] = 0;
- all_free[NUM_TRY] = 0;
- all_both[NUM_TRY] = 0;
-
- printf ("all_new ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_new[j]);
- all_new[NUM_TRY] += all_new[j];
- }
- printf (" %g\n", all_new[NUM_TRY] / NUM_TRY);
- printf ("all_free ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_free[j]);
- all_free[NUM_TRY] += all_free[j];
- }
- printf (" %g\n", all_free[NUM_TRY] / NUM_TRY);
- printf ("all_both ");
- for (j = 0; j < NUM_TRY; j++)
- {
- printf ("%g ", all_both[j]);
- all_both[NUM_TRY] += all_both[j];
- }
- printf (" %g\n", all_both[NUM_TRY] / NUM_TRY);
-
- exit (1);
-}
-
/* Automake parsing function
*---------------------------------------------------------------------------*/
diff --git a/plugins/dir-project/Makefile.am b/plugins/dir-project/Makefile.am
index bd35cb6..8a1b5a3 100644
--- a/plugins/dir-project/Makefile.am
+++ b/plugins/dir-project/Makefile.am
@@ -35,7 +35,9 @@ libdir_project_la_SOURCES = \
plugin.c \
plugin.h \
dir-project.c \
- dir-project.h
+ dir-project.h \
+ dir-node.c \
+ dir-node.h
libdir_project_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
diff --git a/plugins/dir-project/dir-node.c b/plugins/dir-project/dir-node.c
new file mode 100644
index 0000000..e9e3716
--- /dev/null
+++ b/plugins/dir-project/dir-node.c
@@ -0,0 +1,221 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
+/* dir-node.c
+ *
+ * Copyright (C) 2009 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "dir-node.h"
+
+#include <libanjuta/interfaces/ianjuta-project.h>
+#include <libanjuta/anjuta-debug.h>
+
+
+
+/* Root objects
+ *---------------------------------------------------------------------------*/
+
+struct _AnjutaDirRootNode {
+ AnjutaProjectNode base;
+};
+
+AnjutaProjectNode*
+dir_root_node_new (GFile *file)
+{
+ AnjutaDirRootNode *root = NULL;
+
+ root = g_object_new (ANJUTA_TYPE_DIR_ROOT_NODE, NULL);
+ root->base.type = ANJUTA_PROJECT_ROOT;
+ root->base.properties = NULL;
+ root->base.file = g_file_dup (file);
+ root->base.name = NULL;
+
+ return ANJUTA_PROJECT_NODE (root);
+}
+
+/* GObjet implementation
+ *---------------------------------------------------------------------------*/
+
+typedef struct _AnjutaDirRootNodeClass AnjutaDirRootNodeClass;
+
+struct _AnjutaDirRootNodeClass {
+ AnjutaProjectNodeClass parent_class;
+};
+
+G_DEFINE_TYPE (AnjutaDirRootNode, anjuta_dir_root_node, ANJUTA_TYPE_PROJECT_NODE);
+
+static void
+anjuta_dir_root_node_init (AnjutaDirRootNode *node)
+{
+}
+
+static void
+anjuta_dir_root_node_class_init (AnjutaDirRootNodeClass *klass)
+{
+}
+
+
+
+/* Group objects
+ *---------------------------------------------------------------------------*/
+
+struct _AnjutaDirGroupNode {
+ AnjutaProjectNode base;
+ GFileMonitor *monitor;
+ GObject *emitter;
+};
+
+static void
+on_file_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer data)
+{
+ if (!anjuta_project_node_is_proxy (ANJUTA_PROJECT_NODE (data)))
+ {
+ switch (event_type) {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_DELETED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ g_signal_emit_by_name (ANJUTA_DIR_GROUP_NODE (data)->emitter, "node-updated", data);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+AnjutaProjectNode*
+dir_group_node_new (GFile *file, GObject *emitter)
+{
+ AnjutaDirGroupNode *group = NULL;
+
+ group = g_object_new (ANJUTA_TYPE_DIR_GROUP_NODE, NULL);
+ group->base.type = ANJUTA_PROJECT_GROUP;
+ group->base.properties = NULL;
+ group->base.file = g_object_ref (file);
+ group->base.name = NULL;
+ group->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
+ ANJUTA_PROJECT_CAN_ADD_SOURCE |
+ ANJUTA_PROJECT_CAN_REMOVE |
+ ANJUTA_PROJECT_REMOVE_FILE;
+
+ group->emitter = emitter;
+
+ /* Connect monitor if file exist */
+ if (g_file_query_exists (file, NULL))
+ {
+ group->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
+
+ g_signal_connect (G_OBJECT (group->monitor),
+ "changed",
+ G_CALLBACK (on_file_changed),
+ group);
+ }
+
+ return ANJUTA_PROJECT_NODE (group);
+}
+
+/* GObjet implementation
+ *---------------------------------------------------------------------------*/
+
+
+typedef struct _AnjutaDirGroupNodeClass AnjutaDirGroupNodeClass;
+
+struct _AnjutaDirGroupNodeClass {
+ AnjutaProjectNodeClass parent_class;
+};
+
+G_DEFINE_TYPE (AnjutaDirGroupNode, anjuta_dir_group_node, ANJUTA_TYPE_PROJECT_NODE);
+
+static void
+anjuta_dir_group_node_init (AnjutaDirGroupNode *node)
+{
+ node->monitor = NULL;
+ node->emitter = NULL;
+}
+
+static void
+anjuta_dir_group_node_finalize (GObject *object)
+{
+ AnjutaDirGroupNode *node = ANJUTA_DIR_GROUP_NODE (object);
+
+ if (node->monitor != NULL) g_file_monitor_cancel (node->monitor);
+
+ G_OBJECT_CLASS (anjuta_dir_group_node_parent_class)->finalize (object);
+}
+
+static void
+anjuta_dir_group_node_class_init (AnjutaDirGroupNodeClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = anjuta_dir_group_node_finalize;
+}
+
+
+/* Source object
+ *---------------------------------------------------------------------------*/
+
+struct _AnjutaDirSourceNode {
+ AnjutaProjectNode base;
+};
+
+
+AnjutaProjectNode*
+dir_source_node_new (GFile *file)
+{
+ AnjutaDirSourceNode *source = NULL;
+
+ source = g_object_new (ANJUTA_TYPE_DIR_SOURCE_NODE, NULL);
+ source->base.type = ANJUTA_PROJECT_SOURCE;
+ source->base.properties = NULL;
+ source->base.name = NULL;
+ source->base.file = g_file_dup (file);
+ source->base.state = ANJUTA_PROJECT_CAN_REMOVE |
+ ANJUTA_PROJECT_REMOVE_FILE;
+
+ return ANJUTA_PROJECT_NODE (source);
+}
+
+/* GObjet implementation
+ *---------------------------------------------------------------------------*/
+
+typedef struct _AnjutaDirSourceNodeClass AnjutaDirSourceNodeClass;
+
+struct _AnjutaDirSourceNodeClass {
+ AnjutaProjectNodeClass parent_class;
+};
+
+G_DEFINE_TYPE (AnjutaDirSourceNode, anjuta_dir_source_node, ANJUTA_TYPE_PROJECT_NODE);
+
+static void
+anjuta_dir_source_node_init (AnjutaDirSourceNode *node)
+{
+}
+
+static void
+anjuta_dir_source_node_class_init (AnjutaDirSourceNodeClass *klass)
+{
+}
+
diff --git a/plugins/dir-project/dir-node.h b/plugins/dir-project/dir-node.h
new file mode 100644
index 0000000..3aca209
--- /dev/null
+++ b/plugins/dir-project/dir-node.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
+/* dir-node.h
+ *
+ * Copyright (C) 2010 Sébastien Granjoux
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _DIR_NODE_H_
+#define _DIR_NODE_H_
+
+#include <glib-object.h>
+
+#include <libanjuta/anjuta-project.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_DIR_ROOT_NODE (anjuta_dir_root_node_get_type ())
+#define ANJUTA_DIR_ROOT_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_DIR_ROOT_NODE, AnjutaDirRootNode))
+
+typedef struct _AnjutaDirRootNode AnjutaDirRootNode;
+GType anjuta_dir_root_node_get_type (void) G_GNUC_CONST;
+
+
+#define ANJUTA_TYPE_DIR_GROUP_NODE (anjuta_dir_group_node_get_type ())
+#define ANJUTA_DIR_GROUP_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_DIR_GROUP_NODE, AnjutaDirGroupNode))
+
+typedef struct _AnjutaDirGroupNode AnjutaDirGroupNode;
+GType anjuta_dir_group_node_get_type (void) G_GNUC_CONST;
+
+
+
+#define ANJUTA_TYPE_DIR_SOURCE_NODE (anjuta_dir_source_node_get_type ())
+#define ANJUTA_DIR_SOURCE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_DIR_SOURCE_NODE, AnjutaDirSourceNode))
+
+typedef struct _AnjutaDirSourceNode AnjutaDirSourceNode;
+GType anjuta_dir_source_node_get_type (void) G_GNUC_CONST;
+
+
+
+AnjutaProjectNode* dir_root_node_new (GFile *file);
+
+AnjutaProjectNode *dir_group_node_new (GFile *file, GObject *emitter);
+
+AnjutaProjectNode *dir_source_node_new (GFile *file);
+
+
+G_END_DECLS
+
+#endif /* _DIR_NODE_H_ */
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index d0070ca..5e5a7a0 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
-/* am-project.c
+/* dir-project.c
*
* Copyright (C) 2009 Sébastien Granjoux
*
@@ -26,6 +26,8 @@
#include "dir-project.h"
+#include "dir-node.h"
+
#include <libanjuta/interfaces/ianjuta-project.h>
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/anjuta-utils.h>
@@ -59,39 +61,6 @@ struct _DirProject {
GList *sources;
};
-/* convenient shortcut macro the get the AnjutaProjectNode from a GNode */
-#define NODE_DATA(node) ((node) != NULL ? (AnjutaProjectNodeData *)((node)->data) : NULL)
-#define DIR_GROUP_DATA(node) ((node) != NULL ? (DirGroupData *)((node)->data) : NULL)
-#define DIR_TARGET_DATA(node) ((node) != NULL ? (DirTargetData *)((node)->data) : NULL)
-#define DIR_SOURCE_DATA(node) ((node) != NULL ? (DirSourceData *)((node)->data) : NULL)
-
-
-typedef struct _DirRootData DirRootData;
-
-struct _DirRootData {
- AnjutaProjectNodeData base;
-};
-
-typedef struct _DirGroupData DirGroupData;
-
-struct _DirGroupData {
- AnjutaProjectNodeData base;
- GFileMonitor *monitor;
- GObject *emitter;
-};
-
-typedef struct _DirTargetData DirTargetData;
-
-struct _DirTargetData {
- AnjutaProjectNodeData base;
-};
-
-typedef struct _DirSourceData DirSourceData;
-
-struct _DirSourceData {
- AnjutaProjectNodeData base;
-};
-
/* A file or directory name part of a path */
typedef struct _DirMatchString DirMatchString;
@@ -138,171 +107,13 @@ static GObject *parent_class;
*---------------------------------------------------------------------------*/
static void
-on_file_changed (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer data)
-{
- AnjutaProjectNode *node = data;
-
- if (!anjuta_project_node_is_proxy (node))
- {
- switch (event_type) {
- case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_DELETED:
- case G_FILE_MONITOR_EVENT_CREATED:
- g_signal_emit_by_name (DIR_GROUP_DATA (node)->emitter, "node-updated", node);
- break;
- default:
- break;
- }
- }
-}
-
-/* Root objects
- *---------------------------------------------------------------------------*/
-
-static AnjutaProjectNode*
-dir_root_new (GFile *file)
-{
- DirRootData *root = NULL;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- root = g_slice_new0(DirRootData);
- root->base.type = ANJUTA_PROJECT_ROOT;
- root->base.properties = NULL;
- root->base.file = g_file_dup (file);
-
- return g_node_new (root);
-}
-
-static void
-dir_root_free (AnjutaProjectNode *node)
-{
- AnjutaProjectNodeData *data = NODE_DATA (node);
-
- if (data->file != NULL) g_object_unref (data->file);
- g_free (data->name);
- g_slice_free (DirRootData, (DirRootData *)data);
-
- g_node_destroy (node);
-}
-
-/* Group objects
- *---------------------------------------------------------------------------*/
-
-static DirGroup*
-dir_group_new (GFile *file, GObject *emitter)
-{
- DirGroupData *group = NULL;
- DirGroup *node;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- group = g_slice_new0(DirGroupData);
- group->base.type = ANJUTA_PROJECT_GROUP;
- group->base.file = g_object_ref (file);
- group->base.state = ANJUTA_PROJECT_CAN_ADD_GROUP |
- ANJUTA_PROJECT_CAN_ADD_SOURCE |
- ANJUTA_PROJECT_CAN_REMOVE |
- ANJUTA_PROJECT_REMOVE_FILE;
-
- group->emitter = emitter;
-
- node = g_node_new (group);
-
- /* Connect monitor if file exist */
- if (g_file_query_exists (file, NULL))
- {
- group->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL);
-
- g_signal_connect (G_OBJECT (group->monitor),
- "changed",
- G_CALLBACK (on_file_changed),
- node);
- }
-
- return node;
-}
-
-static void
-dir_group_free (DirGroup *node)
-{
- DirGroupData *group = (DirGroupData *)node->data;
-
- if (group->monitor != NULL) g_file_monitor_cancel (group->monitor);
- if (group->base.file) g_object_unref (group->base.file);
- g_slice_free (DirGroupData, group);
- //g_message ("free group %p monitor %p", node, group->monitor);
-
- g_node_destroy (node);
-}
-
-/* Source objects
- *---------------------------------------------------------------------------*/
-
-static DirSource*
-dir_source_new (GFile *file)
-{
- DirSourceData *source = NULL;
-
- source = g_slice_new0(DirSourceData);
- source->base.type = ANJUTA_PROJECT_SOURCE;
- source->base.file = g_object_ref (file);
- source->base.state = ANJUTA_PROJECT_CAN_REMOVE |
- ANJUTA_PROJECT_REMOVE_FILE;
-
- return g_node_new (source);
-}
-
-static void
-dir_source_free (DirSource *node)
-{
- DirSourceData *source = DIR_SOURCE_DATA (node);
-
- g_object_unref (source->base.file);
- g_slice_free (DirSourceData, source);
-
- g_node_destroy (node);
-}
-
-
-static void
-foreach_node_destroy (AnjutaProjectNode *node,
- gpointer data)
-{
- gint type = NODE_DATA (node)->type;
-
- //g_message ("dir free node %p", node);
- switch (type & ANJUTA_PROJECT_TYPE_MASK)
- {
- case ANJUTA_PROJECT_GROUP:
- dir_group_free (node);
- break;
- case ANJUTA_PROJECT_SOURCE:
- dir_source_free (node);
- break;
- case ANJUTA_PROJECT_ROOT:
- dir_root_free (node);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-project_node_destroy (DirProject *project, AnjutaProjectNode *g_node)
+project_node_destroy (DirProject *project, AnjutaProjectNode *node)
{
g_return_if_fail (project != NULL);
g_return_if_fail (DIR_IS_PROJECT (project));
-
- if (g_node) {
- /* free each node's data first */
- anjuta_project_node_all_foreach (g_node,
- foreach_node_destroy, project);
+
+ if (node) {
+ g_object_unref (node);
}
}
@@ -326,13 +137,13 @@ project_node_new (DirProject *project, AnjutaProjectNode *parent, AnjutaProjectN
GFile *group_file;
group_file = g_file_get_child (anjuta_project_node_get_file (parent), name);
- node = dir_group_new (group_file, G_OBJECT (project));
+ node = dir_group_node_new (group_file, G_OBJECT (project));
g_object_unref (group_file);
}
}
else
{
- node = dir_group_new (file, G_OBJECT (project));
+ node = dir_group_node_new (file, G_OBJECT (project));
}
break;
case ANJUTA_PROJECT_SOURCE:
@@ -349,17 +160,17 @@ project_node_new (DirProject *project, AnjutaProjectNode *parent, AnjutaProjectN
GFile *source_file;
source_file = g_file_get_child (anjuta_project_node_get_file (parent), name);
- node = dir_source_new (source_file);
+ node = dir_source_node_new (source_file);
g_object_unref (source_file);
}
}
else
{
- node = dir_source_new (file);
+ node = dir_source_node_new (file);
}
break;
case ANJUTA_PROJECT_ROOT:
- node = dir_root_new (file);
+ node = dir_root_node_new (file);
break;
default:
g_assert_not_reached ();
@@ -367,8 +178,8 @@ project_node_new (DirProject *project, AnjutaProjectNode *parent, AnjutaProjectN
}
if (node != NULL)
{
- NODE_DATA (node)->type = type;
- node->parent = parent;
+ ANJUTA_PROJECT_NODE_DATA (node)->type = type;
+ ANJUTA_PROJECT_NODE_DATA (node)->parent = parent;
}
//g_message ("dir new node %p type %x", node, type);
@@ -663,7 +474,7 @@ dir_project_load_directory (DirProject *project, AnjutaProjectNode *parent, GErr
gboolean ok;
GFileEnumerator *enumerator;
- enumerator = g_file_enumerate_children (DIR_GROUP_DATA (parent)->base.file,
+ enumerator = g_file_enumerate_children (parent->file,
G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL,
@@ -680,7 +491,7 @@ dir_project_load_directory (DirProject *project, AnjutaProjectNode *parent, GErr
GFile *file;
name = g_file_info_get_name (info);
- file = g_file_get_child (DIR_GROUP_DATA (parent)->base.file, name);
+ file = g_file_get_child (parent->file, name);
g_object_unref (info);
/* Check if file is a source */
@@ -689,7 +500,7 @@ dir_project_load_directory (DirProject *project, AnjutaProjectNode *parent, GErr
if (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY)
{
/* Create a group for directory */
- DirGroup *group;
+ AnjutaProjectNode *group;
group = project_node_new (project, NULL, ANJUTA_PROJECT_GROUP, file, NULL, NULL);
g_hash_table_insert (project->groups, g_file_get_uri (file), group);
@@ -700,7 +511,7 @@ dir_project_load_directory (DirProject *project, AnjutaProjectNode *parent, GErr
else
{
/* Create a source for files */
- DirSource *source;
+ AnjutaProjectNode *source;
source = project_node_new (project, NULL, ANJUTA_PROJECT_SOURCE, file, NULL, NULL);
anjuta_project_node_append (parent, source);
@@ -718,7 +529,7 @@ dir_project_load_root (DirProject *project, AnjutaProjectNode *node, GError **er
{
GFile *root_file;
GFile *source_file;
- DirGroup *group;
+ AnjutaProjectNode *group;
root_file = g_object_ref (anjuta_project_node_get_file (node));
DEBUG_PRINT ("reload project %p root file %p", project, root_file);
@@ -754,7 +565,7 @@ dir_project_load_root (DirProject *project, AnjutaProjectNode *node, GError **er
AnjutaProjectNode *
dir_project_load_node (DirProject *project, AnjutaProjectNode *node, GError **error)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
return dir_project_load_root (project, node, error);
@@ -775,7 +586,7 @@ foreach_node_save (AnjutaProjectNode *node,
if (state & ANJUTA_PROJECT_MODIFIED)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_GROUP:
g_file_make_directory_with_parents (anjuta_project_node_get_file (node), NULL, NULL);
@@ -786,7 +597,7 @@ foreach_node_save (AnjutaProjectNode *node,
}
else if (state & ANJUTA_PROJECT_REMOVED)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_GROUP:
case ANJUTA_PROJECT_SOURCE:
@@ -807,7 +618,7 @@ AnjutaProjectNode *
dir_project_save_node (DirProject *project, AnjutaProjectNode *node, GError **error)
{
/* Save children */
- anjuta_project_node_all_foreach (node, foreach_node_save, project);
+ anjuta_project_node_foreach (node, G_POST_ORDER, foreach_node_save, project);
return node;
}
@@ -897,12 +708,6 @@ dir_project_get_node_info (DirProject *project, GError **error)
return info_list;
}
-static DirGroup *
-dir_project_get_root (DirProject *project)
-{
- return NULL;
-}
-
/* Public functions
*---------------------------------------------------------------------------*/
diff --git a/plugins/dir-project/dir-project.h b/plugins/dir-project/dir-project.h
index e82cf13..7fb11a0 100644
--- a/plugins/dir-project/dir-project.h
+++ b/plugins/dir-project/dir-project.h
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4; coding: utf-8 -*- */
-/* am-project.h
+/* dir-project.h
*
* Copyright (C) 2009 Sébastien Granjoux
*
@@ -46,11 +46,6 @@ struct _DirProjectClass {
GObjectClass parent_class;
};
-typedef AnjutaProjectNode DirGroup;
-typedef AnjutaProjectNode DirTarget;
-typedef AnjutaProjectNode DirSource;
-
-
GType dir_project_get_type (void);
DirProject *dir_project_new (void);
diff --git a/plugins/mk-project/mk-project.c b/plugins/mk-project/mk-project.c
index b6b8283..51b7add 100644
--- a/plugins/mk-project/mk-project.c
+++ b/plugins/mk-project/mk-project.c
@@ -1130,7 +1130,7 @@ mkp_project_load_root (MkpProject *project, AnjutaProjectNode *node, GError **er
AnjutaProjectNode *
mkp_project_load_node (MkpProject *project, AnjutaProjectNode *node, GError **error)
{
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
return mkp_project_load_root (project, node, error);
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 306ea5d..b821851 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -198,7 +198,7 @@ parent_filter_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
/* Current node can be used as parent */
visible = TRUE;
}
- else if (anjuta_project_node_get_type (node) == type)
+ else if (anjuta_project_node_get_node_type (node) == type)
{
/* Check if node can be used as sibling */
parent = anjuta_project_node_parent (node);
@@ -222,7 +222,7 @@ module_filter_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
node = gbf_tree_data_get_node (data);
if (node != NULL)
{
- AnjutaProjectNodeType type = anjuta_project_node_get_type (node);
+ AnjutaProjectNodeType type = anjuta_project_node_get_node_type (node);
visible = (type == ANJUTA_PROJECT_MODULE) || (type == ANJUTA_PROJECT_PACKAGE);
}
@@ -540,7 +540,7 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
/* Display node type only if several types are possible */
node_info = NULL;
single = TRUE;
- type = anjuta_project_node_get_type (node);
+ type = anjuta_project_node_get_node_type (node);
for (item = ianjuta_project_get_node_info (project, NULL); item != NULL; item = g_list_next (item))
{
AnjutaProjectNodeInfo* info = (AnjutaProjectNodeInfo *)item->data;
@@ -703,7 +703,7 @@ pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent
g_return_val_if_fail (node != NULL, FALSE);
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
title = _("Project properties");
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 6e44d9f..c8e3897 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1248,6 +1248,7 @@ add_primary_target (AnjutaProjectNode *node, gpointer data)
{
GList ** list = (GList **)data;
+ //g_message ("add_primary_target %s %x", anjuta_project_node_get_name (node), anjuta_project_node_get_full_type (node));
if (anjuta_project_node_get_full_type (node) & ANJUTA_PROJECT_PRIMARY)
{
gchar *path;
@@ -1256,6 +1257,7 @@ add_primary_target (AnjutaProjectNode *node, gpointer data)
*list = g_list_prepend (*list, g_strconcat ("C ", path, NULL));
g_free (path);
+ g_message (" added %s", anjuta_project_node_get_name (node));
}
}
@@ -1296,7 +1298,8 @@ on_project_updated (AnjutaPmProject *project, AnjutaProjectNode *node, GError *e
GList *list = NULL;
/* Add new shortcut for PRIMARY target */
- anjuta_project_node_all_foreach (node, add_primary_target, &list);
+ g_message ("add new shortcut on project_updated");
+ anjuta_project_node_foreach (node, G_POST_ORDER, add_primary_target, &list);
if (list != NULL)
{
@@ -1357,7 +1360,8 @@ on_project_loaded (AnjutaPmProject *project, AnjutaProjectNode *node, GError *er
GList *list = NULL;
/* Add new shortcut for PRIMARY target */
- anjuta_project_node_all_foreach (node, add_primary_target, &list);
+ g_message ("add new shortcut on project_loaded");
+ anjuta_project_node_foreach (node, G_POST_ORDER, add_primary_target, &list);
if (list != NULL)
{
@@ -1864,7 +1868,7 @@ get_element_file_from_node (ProjectManagerPlugin *plugin, AnjutaProjectNode *nod
NULL);
}
- switch (anjuta_project_node_get_type (node))
+ switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_GROUP:
file = g_object_ref (anjuta_project_group_get_directory (node));
@@ -1921,7 +1925,7 @@ get_element_type (ProjectManagerPlugin *plugin, GFile *element)
node = anjuta_pm_project_get_node_from_file (plugin->project, ANJUTA_PROJECT_UNKNOWN, element);
- return node == NULL ? ANJUTA_PROJECT_UNKNOWN : anjuta_project_node_get_type (node);
+ return node == NULL ? ANJUTA_PROJECT_UNKNOWN : anjuta_project_node_get_node_type (node);
}
static GList*
@@ -1969,7 +1973,7 @@ iproject_manager_get_target_type (IAnjutaProjectManager *project_manager,
if (target != NULL)
{
- return anjuta_project_node_get_type (target);
+ return anjuta_project_node_get_node_type (target);
}
else
{
@@ -2045,21 +2049,21 @@ iproject_manager_get_selected (IAnjutaProjectManager *project_manager,
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_SOURCE);
- if (node && anjuta_project_node_get_type (node) == ANJUTA_PROJECT_SOURCE)
+ if (node && anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_SOURCE)
{
return g_object_ref (anjuta_project_source_get_file (node));
}
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_TARGET);
- if (node && anjuta_project_node_get_type (node) == ANJUTA_PROJECT_TARGET)
+ if (node && anjuta_project_node_get_node_type (node) == ANJUTA_PROJECT_TARGET)
{
return get_element_file_from_node (plugin, node, IANJUTA_BUILDER_ROOT_URI);
}
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_GROUP);
- if (node && anjuta_project_node_get_type (node) == GBF_TREE_NODE_GROUP)
+ if (node && anjuta_project_node_get_node_type (node) == GBF_TREE_NODE_GROUP)
{
return g_object_ref (anjuta_project_group_get_directory (node));
}
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index a110ec1..65aff24 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -465,7 +465,7 @@ add_source (GbfProjectModel *model,
GtkTreeIter iter;
GbfTreeData *data;
- if ((!source) || (anjuta_project_node_get_type (source) != ANJUTA_PROJECT_SOURCE))
+ if ((!source) || (anjuta_project_node_get_node_type (source) != ANJUTA_PROJECT_SOURCE))
return;
data = gbf_tree_data_new_source (source);
@@ -600,7 +600,7 @@ add_package (GbfProjectModel *model,
GbfTreeData *data;
AnjutaProjectNode *node;
- if ((!package) || (anjuta_project_node_get_type (package) != ANJUTA_PROJECT_PACKAGE))
+ if ((!package) || (anjuta_project_node_get_node_type (package) != ANJUTA_PROJECT_PACKAGE))
return;
data = gbf_tree_data_new_package (package);
@@ -626,7 +626,7 @@ add_module (GbfProjectModel *model,
GtkTreeIter iter;
GbfTreeData *data;
- if ((!module) || (anjuta_project_node_get_type (module) != ANJUTA_PROJECT_MODULE))
+ if ((!module) || (anjuta_project_node_get_node_type (module) != ANJUTA_PROJECT_MODULE))
return;
data = gbf_tree_data_new_module (module);
@@ -652,7 +652,7 @@ add_target (GbfProjectModel *model,
GtkTreeIter iter;
GbfTreeData *data;
- if ((!target) || (anjuta_project_node_get_type (target) != ANJUTA_PROJECT_TARGET))
+ if ((!target) || (anjuta_project_node_get_node_type (target) != ANJUTA_PROJECT_TARGET))
return;
data = gbf_tree_data_new_target (target);
@@ -688,7 +688,7 @@ add_target_group (GbfProjectModel *model,
AnjutaProjectNode *node;
GbfTreeData *data;
- if ((!group) || (anjuta_project_node_get_type (group) != ANJUTA_PROJECT_GROUP))
+ if ((!group) || (anjuta_project_node_get_node_type (group) != ANJUTA_PROJECT_GROUP))
return;
data = gbf_tree_data_new_group (group);
@@ -730,7 +730,7 @@ add_root (GbfProjectModel *model,
AnjutaProjectNode *node;
GtkTreePath *root_path;
- if ((!root) || (anjuta_project_node_get_type (root) != ANJUTA_PROJECT_ROOT))
+ if ((!root) || (anjuta_project_node_get_node_type (root) != ANJUTA_PROJECT_ROOT))
return;
/* create root reference */
@@ -953,7 +953,7 @@ gbf_project_model_update_tree (GbfProjectModel *model, AnjutaProjectNode *parent
/* add the remaining sources, targets and groups */
for (node = nodes; node; node = node->next)
{
- switch (anjuta_project_node_get_type (node->data))
+ switch (anjuta_project_node_get_node_type (node->data))
{
case ANJUTA_PROJECT_GROUP:
add_target_group (model, node->data, iter);
diff --git a/plugins/project-manager/project-util.c b/plugins/project-manager/project-util.c
index fccc86b..70fd6cf 100644
--- a/plugins/project-manager/project-util.c
+++ b/plugins/project-manager/project-util.c
@@ -40,7 +40,7 @@ gbf_project_util_all_child (AnjutaProjectNode *parent, AnjutaProjectNodeType typ
for (node = anjuta_project_node_first_child (parent); node != NULL; node = anjuta_project_node_next_sibling (node))
{
- if ((type == ANJUTA_PROJECT_UNKNOWN) || (anjuta_project_node_get_type (node) == type))
+ if ((type == ANJUTA_PROJECT_UNKNOWN) || (anjuta_project_node_get_node_type (node) == type))
{
list = g_list_prepend (list, node);
}
@@ -68,7 +68,7 @@ gbf_project_util_node_all (AnjutaProjectNode *parent, AnjutaProjectNodeType type
{
GList *child_list;
- if (anjuta_project_node_get_type (node) == type_type)
+ if (anjuta_project_node_get_node_type (node) == type_type)
{
gint type;
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index 02f9d2a..35d9375 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -420,7 +420,7 @@ gbf_project_view_find_selected (GbfProjectView *view, AnjutaProjectNodeType type
node = gbf_project_model_get_node (GBF_PROJECT_MODEL (model), &iter);
/* walk up the hierarchy searching for a node of the given type */
- while ((node != NULL) && (type != ANJUTA_PROJECT_UNKNOWN) && (anjuta_project_node_get_type (node) != type))
+ while ((node != NULL) && (type != ANJUTA_PROJECT_UNKNOWN) && (anjuta_project_node_get_node_type (node) != type))
{
node = anjuta_project_node_parent (node);
}
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index d0b1658..eb79859 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -192,7 +192,7 @@ pm_project_compare_node (AnjutaProjectNode *old_node, AnjutaProjectNode *new_nod
file1 = anjuta_project_node_get_file (old_node);
file2 = anjuta_project_node_get_file (new_node);
- return (anjuta_project_node_get_type (old_node) == anjuta_project_node_get_type (new_node))
+ return (anjuta_project_node_get_node_type (old_node) == anjuta_project_node_get_node_type (new_node))
&& ((name1 == NULL) || (name2 == NULL) || (strcmp (name1, name2) == 0))
&& ((file1 == NULL) || (file2 == NULL) || g_file_equal (file1, file2)) ? 0 : 1;
}
@@ -432,8 +432,8 @@ pm_command_load_setup (AnjutaPmProject *project, PmJob *job)
g_return_val_if_fail (job->node != NULL, FALSE);
job->proxy = anjuta_project_proxy_new (job->node);
- anjuta_project_node_replace (job->node, job->proxy);
- anjuta_project_proxy_exchange_data (job->node, job->proxy);
+ /*anjuta_project_node_replace (job->node, job->proxy);
+ anjuta_project_proxy_exchange_data (job->node, job->proxy);*/
return TRUE;
}
@@ -481,8 +481,8 @@ check_queue (GQueue *queue, GHashTable *map)
static gboolean
pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
{
- anjuta_project_proxy_exchange_data (job->proxy, job->node);
- anjuta_project_node_exchange (job->proxy, job->node);
+ anjuta_project_proxy_exchange (job->proxy, job->node);
+ //anjuta_project_node_exchange (job->proxy, job->node);
g_message ("pm_command_load_complete");
if (job->error != NULL)
@@ -524,7 +524,7 @@ pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
if (project->incomplete_node == 0) load = TRUE;
}
anjuta_project_node_clear_state (job->node, ANJUTA_PROJECT_LOADING | ANJUTA_PROJECT_INCOMPLETE);
- anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)on_pm_project_load_incomplete, project);
+ anjuta_project_node_foreach (job->node, G_POST_ORDER, (AnjutaProjectNodeForeachFunc)on_pm_project_load_incomplete, project);
g_message ("emit node %p", job->node);
if (load && (project->incomplete_node == 0))
@@ -537,8 +537,9 @@ pm_command_load_complete (AnjutaPmProject *project, PmJob *job)
}
check_queue (project->job_queue, job->map);
}
-
- anjuta_project_node_all_foreach (job->proxy, (AnjutaProjectNodeFunc)pm_free_node, project->project);
+
+ pm_free_node (job->proxy, project->project);
+ //anjuta_project_node_foreach (job->proxy, G_POST_ORDER, (AnjutaProjectNodeForeachFunc)pm_free_node, project->project);
return TRUE;
}
@@ -593,7 +594,8 @@ pm_command_remove_complete (AnjutaPmProject *project, PmJob *job)
/* Remove node from node tree */
anjuta_project_node_remove (job->node);
- anjuta_project_node_all_foreach (job->node, (AnjutaProjectNodeFunc)pm_free_node, project->project);
+ pm_free_node (job->node, project->project);
+ //anjuta_project_node_foreach (job->node, G_POST_ORDER, (AnjutaProjectNodeForeachFunc)pm_free_node, project->project);
return TRUE;
}
@@ -899,13 +901,13 @@ anjuta_pm_project_get_packages (AnjutaPmProject *project)
for (module = anjuta_project_node_first_child (project->root); module != NULL; module = anjuta_project_node_next_sibling (module))
{
- if (anjuta_project_node_get_type(module) == ANJUTA_PROJECT_MODULE)
+ if (anjuta_project_node_get_node_type(module) == ANJUTA_PROJECT_MODULE)
{
AnjutaProjectNode *package;
for (package = anjuta_project_node_first_child (module); package != NULL; package = anjuta_project_node_next_sibling (package))
{
- if (anjuta_project_node_get_type (package) == ANJUTA_PROJECT_PACKAGE)
+ if (anjuta_project_node_get_node_type (package) == ANJUTA_PROJECT_PACKAGE)
{
g_hash_table_replace (all, anjuta_project_node_get_name (package), NULL);
}
diff --git a/plugins/project-manager/tree-data.c b/plugins/project-manager/tree-data.c
index 2f99071..6bd4c9b 100644
--- a/plugins/project-manager/tree-data.c
+++ b/plugins/project-manager/tree-data.c
@@ -126,11 +126,11 @@ gbf_tree_data_get_node (GbfTreeData *data)
void
gbf_tree_data_replace_node (GbfTreeData *data, AnjutaProjectNode *node)
{
- GFile *file = ((AnjutaProjectNodeData *)node->data)->file;
+ GFile *file = ANJUTA_PROJECT_NODE_DATA(node)->file;
/* Replace file to keep the same interface */
- ((AnjutaProjectNodeData *)node->data)->file = ((AnjutaProjectNodeData *)data->node->data)->file;
- ((AnjutaProjectNodeData *)data->node->data)->file = file;
+ ANJUTA_PROJECT_NODE_DATA(node)->file = ANJUTA_PROJECT_NODE_DATA(data->node)->file;
+ ANJUTA_PROJECT_NODE_DATA(data->node)->file = file;
data->node = node;
}
@@ -213,7 +213,7 @@ gbf_tree_data_equal_file (GbfTreeData *data, AnjutaProjectNodeType type, GFile *
if (node != NULL)
{
- if ((type == ANJUTA_PROJECT_UNKNOWN) || (type == anjuta_project_node_get_type (node)))
+ if ((type == ANJUTA_PROJECT_UNKNOWN) || (type == anjuta_project_node_get_node_type (node)))
{
if (g_file_equal (anjuta_project_node_get_file (node), file))
{
@@ -333,11 +333,11 @@ gbf_tree_data_new_source (AnjutaProjectNode *source)
}
parent = anjuta_project_node_parent (source);
- if (anjuta_project_node_get_type (parent) == ANJUTA_PROJECT_GROUP)
+ if (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_GROUP)
{
data->group = g_object_ref (anjuta_project_group_get_directory (parent));
}
- else if (anjuta_project_node_get_type (parent) == ANJUTA_PROJECT_TARGET)
+ else if (anjuta_project_node_get_node_type (parent) == ANJUTA_PROJECT_TARGET)
{
AnjutaProjectNode *group;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]