[anjuta] class-gen: Always generate GObject private structure
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] class-gen: Always generate GObject private structure
- Date: Wed, 6 Feb 2013 21:10:47 +0000 (UTC)
commit 86ebdf42783d2578a68187e768854a41a128150c
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Sun Feb 3 19:51:27 2013 +0100
class-gen: Always generate GObject private structure
Having a private structure generated is often what you want even though you
haven't defined any private members in the dialog.
Also don't generate the _GET_PRIVATE() macro anymore but instead just
initialize the ->priv pointer in instance init.
Also remove unused parent_class variable in the generated
class_init function.
https://bugzilla.gnome.org/show_bug.cgi?id=693213
plugins/class-gen/templates/go-header.tpl | 4 ++--
plugins/class-gen/templates/go-source.tpl | 16 +++++-----------
2 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/plugins/class-gen/templates/go-header.tpl b/plugins/class-gen/templates/go-header.tpl
index 8f0656f..010f8a2 100644
--- a/plugins/class-gen/templates/go-header.tpl
+++ b/plugins/class-gen/templates/go-header.tpl
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
typedef struct _[+ClassName+]Class [+ClassName+]Class;
typedef struct _[+ClassName+] [+ClassName+];
-[+IF (not (=(get "PrivateVariableCount") "0"))+]typedef struct _[+ClassName+]Private [+ClassName+]Private;[+ENDIF+]
+typedef struct _[+ClassName+]Private [+ClassName+]Private;
struct _[+ClassName+]Class
@@ -60,7 +60,7 @@ IF (not (=(get "PublicVariableCount") "0"))+]
ENDFOR+][+
ENDIF+]
-[+IF (not (=(get "PrivateVariableCount") "0"))+] [+ClassName+]Private *priv;[+ENDIF+]
+ [+ClassName+]Private *priv;
};
GType [+FuncPrefix+]_get_type (void) G_GNUC_CONST;[+
diff --git a/plugins/class-gen/templates/go-source.tpl b/plugins/class-gen/templates/go-source.tpl
index 5761e11..b93bf0e 100644
--- a/plugins/class-gen/templates/go-source.tpl
+++ b/plugins/class-gen/templates/go-source.tpl
@@ -10,8 +10,8 @@
[+INVOKE LICENSE-DESCRIPTION PFX=" * " PROGRAM=(get "ProjectName") OWNER=(get "AuthorName") \+]
*/
-#include "[+HeaderFile+]"[+
-IF (not (=(get "PrivateVariableCount") "0"))+]
+#include "[+HeaderFile+]"
+
struct _[+ClassName+]Private
{[+
FOR Members +][+
@@ -24,10 +24,7 @@ struct _[+ClassName+]Private
ENDIF+][+
ENDFOR+]
};
-
-#define [+TypePrefix+]_[+TypeSuffix+]_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), [+TypePrefix+]_TYPE_[+TypeSuffix+], [+ClassName+]Private))[+
-
-ENDIF+][+IF (not (=(get "Properties[0].Name") ""))+]
+[+IF (not (=(get "Properties[0].Name") ""))+]
enum
{
@@ -72,7 +69,7 @@ G_DEFINE_TYPE ([+ClassName+], [+FuncPrefix+], [+BaseTypePrefix+]_TYPE_[+BaseType
static void
[+FuncPrefix+]_init ([+ClassName+] *[+FuncPrefix+])
{
-[+IF (not (=(get "PrivateVariableCount") "0"))+] [+ClassName+]Private *priv = [+TypePrefix+]_[+TypeSuffix+]_GET_PRIVATE([+FuncPrefix+]);[+ENDIF+]
+ [+FuncPrefix+]->priv = G_TYPE_INSTANCE_GET_PRIVATE ([+FuncPrefix+], [+TypePrefix+]_TYPE_[+TypeSuffix+], [+ClassName+]Private);
/* TODO: Add initialization code here */
}
@@ -138,11 +135,8 @@ static void
[+FuncPrefix+]_class_init ([+ClassName+]Class *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
- [+BaseClass+]Class* parent_class = [+BaseTypePrefix+]_[+BaseTypeSuffix+]_CLASS (klass);[+
-IF (not (=(get "PrivateVariableCount") "0"))+]
- g_type_class_add_private (klass, sizeof ([+ClassName+]Private));[+
-ENDIF+]
+ g_type_class_add_private (klass, sizeof ([+ClassName+]Private));
object_class->finalize = [+FuncPrefix+]_finalize;[+
IF (not (=(get "Properties[0].Name") "")) +]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]