[anjuta] libanjuta, language-support-*: Move IAnjutaLanguageProviderProposalData to libanjuta
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] libanjuta, language-support-*: Move IAnjutaLanguageProviderProposalData to libanjuta
- Date: Fri, 27 Jul 2012 10:17:37 +0000 (UTC)
commit 3a3160b9332077d0f04ef98278e3badcfd0eb1af
Author: Johannes Schmid <jhs gnome org>
Date: Fri Jul 27 12:00:48 2012 +0200
libanjuta, language-support-*: Move IAnjutaLanguageProviderProposalData to libanjuta
Also rename it to AnjutaLanguageProposalData and make it a boxed type
libanjuta/anjuta-language-provider.c | 57 ++++++++++++++++++++++-
libanjuta/anjuta-language-provider.h | 27 +++++++++++
libanjuta/interfaces/libanjuta.idl | 17 -------
plugins/language-support-js/plugin.c | 5 +-
plugins/language-support-python/python-assist.c | 19 +++----
plugins/parser-cxx/parser-cxx-assist.c | 13 ++---
plugins/sourceview/sourceview.c | 3 +-
7 files changed, 100 insertions(+), 41 deletions(-)
---
diff --git a/libanjuta/anjuta-language-provider.c b/libanjuta/anjuta-language-provider.c
index 014fced..40b3262 100644
--- a/libanjuta/anjuta-language-provider.c
+++ b/libanjuta/anjuta-language-provider.c
@@ -432,7 +432,7 @@ anjuta_language_provider_activate (AnjutaLanguageProvider* lang_prov,
IAnjutaIterable* iter,
gpointer data)
{
- IAnjutaLanguageProviderProposalData *prop_data;
+ AnjutaLanguageProposalData *prop_data;
GString *assistance;
IAnjutaEditor *editor = IANJUTA_EDITOR (lang_prov->priv->iassist);
gboolean add_space_after_func = FALSE;
@@ -596,3 +596,58 @@ anjuta_language_provider_get_start_iter (AnjutaLanguageProvider* lang_prov)
{
return lang_prov->priv->start_iter;
}
+
+/* Boxed type for poposal data */
+static AnjutaLanguageProposalData*
+anjuta_language_proposal_data_copy (const AnjutaLanguageProposalData *src)
+{
+ AnjutaLanguageProposalData* cpy = anjuta_language_proposal_data_new (g_strdup(src->name));
+ cpy->info = src->info ? g_strdup(src->info) : NULL;
+ cpy->is_func = src->is_func;
+ cpy->has_para = src->has_para;
+ cpy->type = src->type;
+
+ return cpy;
+}
+
+/**
+ * anjuta_language_proposal_data_free:
+ * @data: a AnjutaLanguageProposalData
+ *
+ * Free the given proposal data
+ */
+void
+anjuta_language_proposal_data_free (AnjutaLanguageProposalData *data)
+{
+ g_free (data->name);
+ g_free (data->info);
+ g_free (data);
+}
+
+/**
+ * anjuta_language_proposal_data_new:
+ * @name: Name of the object
+ *
+ * Returns: Creates a new AnjutaLanguageProposalData object
+ */
+AnjutaLanguageProposalData*
+anjuta_language_proposal_data_new (gchar* name)
+{
+ AnjutaLanguageProposalData* data = g_new0(AnjutaLanguageProposalData, 1);
+ data->name = name;
+
+ return data;
+}
+
+GType
+anjuta_language_proposal_data_get_type ()
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("AnjutaLanguageProposalData",
+ (GBoxedCopyFunc) anjuta_language_proposal_data_copy,
+ (GBoxedFreeFunc) anjuta_language_proposal_data_free);
+ return type_id;
+}
+
diff --git a/libanjuta/anjuta-language-provider.h b/libanjuta/anjuta-language-provider.h
index 06e2154..b876087 100644
--- a/libanjuta/anjuta-language-provider.h
+++ b/libanjuta/anjuta-language-provider.h
@@ -26,9 +26,36 @@
#include <libanjuta/interfaces/ianjuta-editor-tip.h>
#include <libanjuta/interfaces/ianjuta-iterable.h>
#include <libanjuta/interfaces/ianjuta-provider.h>
+#include <libanjuta/interfaces/ianjuta-symbol.h>
G_BEGIN_DECLS
+#define ANJUTA_TYPE_LANGUAGE_PROPOSAL_DATA (anjuta_language_proposal_data_get_type ())
+#define ANJUTA_LANGUAGE_PROPOSAL_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_LANGUAGE_PROPOSAL_DATA, AnjutaLanguageProposalData))
+
+typedef struct _AnjutaLanguageProposalData AnjutaLanguageProposalData;
+
+/**
+ * AnjutaLanguageProposalData:
+ * @name: Name of the object
+ * @info: Info about the object
+ * @is_func: If this is a function
+ * @has_para: If the function has at least one parameters
+ * @type: Type of the object
+ */
+struct _AnjutaLanguageProposalData
+{
+ gchar* name;
+ gchar* info;
+ gboolean is_func;
+ gboolean has_para;
+ IAnjutaSymbolType type;
+};
+
+GType anjuta_language_proposal_data_get_type (void) G_GNUC_CONST;
+AnjutaLanguageProposalData* anjuta_language_proposal_data_new (gchar* name);
+void anjuta_language_proposal_data_free (AnjutaLanguageProposalData *data);
+
#define ANJUTA_TYPE_LANGUAGE_PROVIDER (anjuta_language_provider_get_type ())
#define ANJUTA_LANGUAGE_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_LANGUAGE_PROVIDER, AnjutaLanguageProvider))
#define ANJUTA_LANGUAGE_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_LANGUAGE_PROVIDER, AnjutaLanguageProviderClass))
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index 6ea56e6..444bc2a 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -2718,23 +2718,6 @@ interface IAnjutaProvider
* Boolean key, true is adding ')' after function call autocompletion
*/
#define PREF_AUTOCOMPLETE_CLOSEBRACE_AFTER_FUNC "completion-closebrace-after-func"
-
- /**
- * IAnjutaLanguageProviderProposalData:
- * @name: Name of the object
- * @info: Info about the object
- * @is_func: If this is a function
- * @has_para: If the function has at least one parameters
- * @type: Type of the object
- */
- struct ProposalData
- {
- gchar* name;
- gchar *info;
- gboolean is_func;
- gboolean has_para;
- IAnjutaSymbolType type;
- }
/**
* ianjuta_language_provider_get_calltip_cache:
diff --git a/plugins/language-support-js/plugin.c b/plugins/language-support-js/plugin.c
index a88f03d..1cbba4e 100644
--- a/plugins/language-support-js/plugin.c
+++ b/plugins/language-support-js/plugin.c
@@ -534,16 +534,15 @@ ilanguage_provider_populate (IAnjutaLanguageProvider* obj,
for (i = suggestions; i; i = g_list_next(i)) {
IAnjutaEditorAssistProposal* proposal;
- IAnjutaLanguageProviderProposalData* prop_data;
+ AnjutaLanguageProposalData* prop_data;
proposal = g_new0(IAnjutaEditorAssistProposal, 1);
- prop_data = g_new0 (IAnjutaLanguageProviderProposalData, 1);
if (!i->data)
continue;
proposal->label = i->data;
- prop_data->name = i->data;
+ prop_data = anjuta_language_proposal_data_new (i->data);
prop_data->is_func = code_completion_is_symbol_func (plugin, str);
/* TODO: Not implemented yet */
prop_data->has_para = TRUE;
diff --git a/plugins/language-support-python/python-assist.c b/plugins/language-support-python/python-assist.c
index b1893f9..229e874 100644
--- a/plugins/language-support-python/python-assist.c
+++ b/plugins/language-support-python/python-assist.c
@@ -93,15 +93,15 @@ struct _PythonAssistPriv {
static gchar*
completion_function (gpointer data)
{
- IAnjutaLanguageProviderProposalData * tag = (IAnjutaLanguageProviderProposalData*) data;
+ AnjutaLanguageProposalData * tag = ANJUTA_LANGUAGE_PROPOSAL_DATA(data);
return tag->name;
}
static gint
completion_compare (gconstpointer a, gconstpointer b)
{
- IAnjutaLanguageProviderProposalData * tag_a = (IAnjutaLanguageProviderProposalData*) a;
- IAnjutaLanguageProviderProposalData * tag_b = (IAnjutaLanguageProviderProposalData*) b;
+ AnjutaLanguageProposalData * tag_a = ANJUTA_LANGUAGE_PROPOSAL_DATA(a);
+ AnjutaLanguageProposalData * tag_b = ANJUTA_LANGUAGE_PROPOSAL_DATA(b);
gint cmp;
cmp = strcmp (tag_a->name, tag_b->name);
@@ -111,11 +111,9 @@ completion_compare (gconstpointer a, gconstpointer b)
}
static void
-python_assist_tag_destroy (IAnjutaLanguageProviderProposalData *tag)
+python_assist_tag_destroy (AnjutaLanguageProposalData *tag)
{
- g_free (tag->name);
- g_free (tag->info);
- g_free (tag);
+ anjuta_language_proposal_data_free (tag);
}
static void
@@ -171,7 +169,7 @@ python_assist_update_autocomplete (PythonAssist *assist)
for (node = completion_list; node != NULL; node = g_list_next (node))
{
- IAnjutaLanguageProviderProposalData *tag = node->data;
+ AnjutaLanguageProposalData *tag = ANJUTA_LANGUAGE_PROPOSAL_DATA(node->data);
IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);
if (tag->is_func)
@@ -275,7 +273,7 @@ on_autocomplete_finished (AnjutaLauncher* launcher,
/* Parse output and create completion list */
for (cur_comp = completions; *cur_comp != NULL; cur_comp++)
{
- IAnjutaLanguageProviderProposalData* tag;
+ AnjutaLanguageProposalData* tag;
GMatchInfo* match_info;
g_regex_match (regex, *cur_comp, 0, &match_info);
@@ -285,8 +283,7 @@ on_autocomplete_finished (AnjutaLauncher* launcher,
gchar* type = g_match_info_fetch (match_info, 3);
gchar* location = g_match_info_fetch (match_info, 4);
gchar* info = g_match_info_fetch (match_info, 5);
- tag = g_new0 (IAnjutaLanguageProviderProposalData, 1);
- tag->name = g_match_info_fetch (match_info, 1);
+ tag = anjuta_language_proposal_data_new (g_match_info_fetch (match_info, 1));
/* info will be set to "_" if there is no relevant info */
tag->info = NULL;
diff --git a/plugins/parser-cxx/parser-cxx-assist.c b/plugins/parser-cxx/parser-cxx-assist.c
index 53afe6f..fb46091 100644
--- a/plugins/parser-cxx/parser-cxx-assist.c
+++ b/plugins/parser-cxx/parser-cxx-assist.c
@@ -108,9 +108,8 @@ static IAnjutaEditorAssistProposal*
parser_cxx_assist_proposal_new (IAnjutaSymbol* symbol)
{
IAnjutaEditorAssistProposal* proposal = g_new0 (IAnjutaEditorAssistProposal, 1);
- IAnjutaLanguageProviderProposalData* data = g_new0 (IAnjutaLanguageProviderProposalData, 1);
-
- data->name = g_strdup (ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL));
+ AnjutaLanguageProposalData* data =
+ anjuta_language_proposal_data_new (g_strdup (ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL)));
data->type = ianjuta_symbol_get_sym_type (symbol, NULL);
switch (data->type)
{
@@ -151,10 +150,8 @@ parser_cxx_assist_proposal_new (IAnjutaSymbol* symbol)
static void
parser_cxx_assist_proposal_free (IAnjutaEditorAssistProposal* proposal)
{
- IAnjutaLanguageProviderProposalData* data = proposal->data;
- g_free (data->name);
- g_free (data->info);
- g_free (data);
+ AnjutaLanguageProposalData* data = proposal->data;
+ anjuta_language_proposal_data_free (data);
g_free (proposal->label);
g_free (proposal);
}
@@ -169,7 +166,7 @@ static gchar*
anjuta_proposal_completion_func (gpointer data)
{
IAnjutaEditorAssistProposal* proposal = data;
- IAnjutaLanguageProviderProposalData* prop_data = proposal->data;
+ AnjutaLanguageProposalData* prop_data = proposal->data;
return prop_data->name;
}
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index 5fb346a..542b9ea 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -27,6 +27,7 @@
#include <libanjuta/anjuta-preferences.h>
#include <libanjuta/anjuta-encodings.h>
#include <libanjuta/anjuta-shell.h>
+#include <libanjuta/anjuta-language-provider.h>
#include <libanjuta/interfaces/ianjuta-file.h>
#include <libanjuta/interfaces/ianjuta-file-savable.h>
#include <libanjuta/interfaces/ianjuta-markable.h>
@@ -2324,7 +2325,7 @@ iassist_proposals(IAnjutaEditorAssist* iassist,
if (pre_word && proposals && g_list_length (proposals) == 1)
{
IAnjutaEditorAssistProposal* proposal = proposals->data;
- IAnjutaLanguageProviderProposalData* data = proposal->data;
+ AnjutaLanguageProposalData* data = proposal->data;
if (g_str_equal (pre_word, data->name))
proposals = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]