[anjuta] mk-project: Add object node
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] mk-project: Add object node
- Date: Sat, 4 Jun 2011 15:06:49 +0000 (UTC)
commit 7fbf410187fb48f3f1a33d0748d37c6d5299a7aa
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Jun 4 16:12:00 2011 +0200
mk-project: Add object node
plugins/mk-project/mk-project-private.h | 1 +
plugins/mk-project/mk-project.c | 37 ++++++++++++++-
plugins/mk-project/mk-project.h | 9 ++++
plugins/mk-project/mk-rule.c | 72 ++++++++++++++++++++-----------
4 files changed, 91 insertions(+), 28 deletions(-)
---
diff --git a/plugins/mk-project/mk-project-private.h b/plugins/mk-project/mk-project-private.h
index 4e11011..90cc46b 100644
--- a/plugins/mk-project/mk-project-private.h
+++ b/plugins/mk-project/mk-project-private.h
@@ -75,6 +75,7 @@ gchar *mkp_project_token_evaluate (MkpProject *project, AnjutaToken *token);
AnjutaProjectNode* mkp_target_new (const gchar *name, AnjutaProjectNodeType type);
void mkp_target_free (MkpTarget *node);
void mkp_target_add_token (MkpTarget *node, AnjutaToken *token);
+AnjutaProjectNode* mkp_object_new (const gchar *name);
AnjutaProjectNode* mkp_source_new (GFile *file);
G_END_DECLS
diff --git a/plugins/mk-project/mk-project.c b/plugins/mk-project/mk-project.c
index 60f49ba..65dc5d7 100644
--- a/plugins/mk-project/mk-project.c
+++ b/plugins/mk-project/mk-project.c
@@ -196,7 +196,7 @@ file_type (GFile *file, const gchar *filename)
return type;
}
-/* Group objects
+/* Group node
*---------------------------------------------------------------------------*/
static AnjutaProjectNode*
@@ -229,7 +229,7 @@ mkp_group_init (MkpGroup *obj)
G_DEFINE_TYPE (MkpGroup, mkp_group, ANJUTA_TYPE_PROJECT_NODE);
-/* Target objects
+/* Target node
*---------------------------------------------------------------------------*/
void
@@ -272,7 +272,38 @@ mkp_target_init (MkpTarget *obj)
G_DEFINE_TYPE (MkpTarget, mkp_target, ANJUTA_TYPE_PROJECT_NODE);
-/* Source objects
+/* Object node
+ *---------------------------------------------------------------------------*/
+
+AnjutaProjectNode*
+mkp_object_new (const gchar *name)
+{
+ MkpObject *node = NULL;
+
+ node = g_object_new (MKP_TYPE_OBJECT, NULL);
+ node->base.name = g_strdup (name);
+ node->base.type = ANJUTA_PROJECT_OBJECT;
+ node->base.state = 0;
+
+ return ANJUTA_PROJECT_NODE(node);
+}
+
+static void
+mkp_object_class_init (MkpObjectClass *klass)
+{
+
+}
+
+static void
+mkp_object_init (MkpObject *obj)
+{
+
+}
+
+G_DEFINE_TYPE (MkpObject, mkp_object, ANJUTA_TYPE_PROJECT_NODE);
+
+
+/* Source node
*---------------------------------------------------------------------------*/
AnjutaProjectNode*
diff --git a/plugins/mk-project/mk-project.h b/plugins/mk-project/mk-project.h
index dcd193a..306c7aa 100644
--- a/plugins/mk-project/mk-project.h
+++ b/plugins/mk-project/mk-project.h
@@ -43,11 +43,14 @@ G_BEGIN_DECLS
#define MKP_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MKP_TYPE_GROUP, MkpGroup))
#define MKP_TYPE_TARGET (mkp_target_get_type ())
#define MKP_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MKP_TYPE_TARGET, MkpTarget))
+#define MKP_TYPE_OBJECT (mkp_object_get_type ())
+#define MKP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MKP_TYPE_OBJECT, MkpObject))
#define MKP_TYPE_SOURCE (mkp_source_get_type ())
#define MKP_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MKP_TYPE_SOURCE, MkpSource))
GType mkp_source_get_type (void) G_GNUC_CONST;
+GType mkp_object_get_type (void) G_GNUC_CONST;
GType mkp_target_get_type (void) G_GNUC_CONST;
GType mkp_group_get_type (void) G_GNUC_CONST;
GType mkp_project_get_type (void) G_GNUC_CONST;
@@ -57,12 +60,14 @@ typedef struct _MkpProjectClass MkpProjectClass;
typedef struct _MkpGroup MkpGroup;
typedef struct _MkpTarget MkpTarget;
+typedef struct _MkpObject MkpObject;
typedef struct _MkpSource MkpSource;
typedef struct _MkpProperty MkpProperty;
typedef struct _MkpVariable MkpVariable;
typedef struct _MkpRule MkpRule;
typedef struct _MkpNodeClass MkpSourceClass;
+typedef struct _MkpNodeClass MkpObjectClass;
typedef struct _MkpNodeClass MkpTargetClass;
typedef struct _MkpNodeClass MkpGroupClass;
@@ -81,6 +86,10 @@ struct _MkpTarget {
GList* tokens;
};
+struct _MkpObject {
+ AnjutaProjectNode base;
+};
+
struct _MkpSource {
AnjutaProjectNode base;
AnjutaToken* token;
diff --git a/plugins/mk-project/mk-rule.c b/plugins/mk-project/mk-rule.c
index d2e4566..86ee6b6 100644
--- a/plugins/mk-project/mk-rule.c
+++ b/plugins/mk-project/mk-rule.c
@@ -68,11 +68,11 @@ mkp_rule_free (MkpRule *rule)
/* Private functions
*---------------------------------------------------------------------------*/
-/* Find a source for target checking pattern rule. If no source is found,
+/* Find all dependencies for target checking pattern rule. If no source is found,
* return target, else free target and return a newly allocated source name */
-static gchar *
-mkp_project_find_source (MkpProject *project, gchar *target, AnjutaProjectNode *parent, guint backtrack)
+static GList *
+mkp_project_find_dependencies (MkpProject *project, gchar *target, AnjutaProjectNode *parent, guint backtrack)
{
GFile *child;
gboolean exist;
@@ -88,6 +88,7 @@ mkp_project_find_source (MkpProject *project, gchar *target, AnjutaProjectNode *
if (rule->pattern)
{
gchar *source;
+ GList *dependencies;
if (rule->part == NULL)
{
@@ -113,14 +114,12 @@ mkp_project_find_source (MkpProject *project, gchar *target, AnjutaProjectNode *
}
}
- source = mkp_project_find_source (project, source, parent, backtrack + 1);
-
- if (source != NULL)
+ dependencies = mkp_project_find_dependencies (project, source, parent, backtrack + 1);
+ if (dependencies != NULL)
{
- g_free (target);
-
- return source;
+ return g_list_prepend (dependencies, target);
}
+ g_free (source);
}
}
}
@@ -132,12 +131,11 @@ mkp_project_find_source (MkpProject *project, gchar *target, AnjutaProjectNode *
if (!exist)
{
- g_free (target);
return NULL;
}
else
{
- return target;
+ return g_list_prepend (NULL, target);
}
}
@@ -337,29 +335,53 @@ mkp_project_enumerate_targets (MkpProject *project, AnjutaProjectNode *parent)
/* Add prerequisite */
for (arg = anjuta_token_first_word (prerequisite); arg != NULL; arg = anjuta_token_next_word (arg))
{
- MkpSource *source;
- GFile *src_file;
+ AnjutaProjectNode *node;
gchar *name;
+ GList *dependencies;
name = anjuta_token_evaluate (arg);
if (name != NULL)
{
name = g_strstrip (name);
- name = mkp_project_find_source (project, name, parent, 0);
- }
-
- if (name != NULL)
- {
- src_file = g_file_get_child (project->root_file, name);
- source = MKP_SOURCE(mkp_source_new (src_file));
- source->base.type = ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT;
- g_object_unref (src_file);
- anjuta_project_node_append (ANJUTA_PROJECT_NODE(target), ANJUTA_PROJECT_NODE(source));
+ dependencies = mkp_project_find_dependencies (project, name, parent, 0);
+ if (dependencies == NULL)
+ {
+ /* Add only one object node */
+ node = mkp_object_new (name);
+ node->type = ANJUTA_PROJECT_OBJECT | ANJUTA_PROJECT_PROJECT;
+ anjuta_project_node_append (ANJUTA_PROJECT_NODE(target), ANJUTA_PROJECT_NODE(node));
+ g_free (name);
+ }
+ else
+ {
+ GFile *src_file;
+ gchar *name;
+
+ AnjutaProjectNode *parent = target;
+ while (g_list_next (dependencies) != NULL)
+ {
+ /* Create object nodes */
+ name = (gchar *)dependencies->data;
+ node = mkp_object_new (name);
+ node->type = ANJUTA_PROJECT_OBJECT | ANJUTA_PROJECT_PROJECT;
+ anjuta_project_node_append (parent, node);
+ g_free (name);
+ parent = node;
+ dependencies = g_list_delete_link (dependencies, dependencies);
+ }
- g_free (name);
+ /* Create source node */
+ name = (gchar *)dependencies->data;
+ src_file = g_file_get_child (project->root_file, name);
+ node = mkp_source_new (src_file);
+ node->type = ANJUTA_PROJECT_SOURCE | ANJUTA_PROJECT_PROJECT;
+ g_object_unref (src_file);
+ anjuta_project_node_append (parent, node);
+ g_free (name);
+ g_list_free (dependencies);
+ }
}
}
-
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]