G_TYPE_FLAG_ABSTRACT patch

View: New views
1 Messages — Rating Filter:   Alert me  

G_TYPE_FLAG_ABSTRACT patch

by Jean-Yves Lefort :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The attached patch provides G_TYPE_FLAG_ABSTRACT support:

class My:Foo from My:Bar (abstract) { ... }

Regards,
Jean-Yves Lefort

--
Jean-Yves Lefort

jylefort@...
http://lefort.be.eu.org/

--- src/main.c.orig Thu Dec  1 16:47:20 2005
+++ src/main.c Thu Dec  1 16:54:41 2005
@@ -1081,8 +1081,8 @@
  add_interface_infos ();
 
  out_printf (out,
-    "\t\ttype = g_type_register_static (%s, \"%s\", &info, (GTypeFlags)0);\n",
-    pmacrotype, typebase);
+    "\t\ttype = g_type_register_static (%s, \"%s\", &info, (GTypeFlags)%s);\n",
+    pmacrotype, typebase, ((Class *)class)->abstract ? "G_TYPE_FLAG_ABSTRACT" : "0");
 
  add_interfaces ();
 
--- src/parse.y.orig Thu Dec  1 16:43:23 2005
+++ src/parse.y Thu Dec  1 16:45:49 2005
@@ -44,6 +44,7 @@
 static GList *flag_vals = NULL;
 static GList *error_vals = NULL;
 
+static gboolean abstract = FALSE;
 static char *chunk_size = NULL;
 static char *bonobo_object_class = NULL;
 static int glade_xml = FALSE;
@@ -778,6 +779,7 @@
   "glade_xml", glade_xml,
   "interfaces:steal", interfaces,
   "chunk_size:steal", chunk_size,
+  "abstract", abstract,
   NULL);
  bonobo_object_class = NULL;
  glade_xml = FALSE;
@@ -787,6 +789,14 @@
  ;
 
 classflags:
+ | '(' TOKEN ')' classflags {
+ if(strcmp($<id>2,"abstract") == 0) {
+ abstract = TRUE;
+ } else {
+ yyerror(_("parse error"));
+ YYERROR;
+ }
+ }
  | '(' TOKEN TOKEN ')' classflags {
  if(strcmp($<id>2,"chunks") == 0) {
  g_free (chunk_size);
--- src/treefuncs.def.orig Thu Dec  1 16:46:14 2005
+++ src/treefuncs.def Thu Dec  1 16:47:08 2005
@@ -56,6 +56,7 @@
   STRING chunk_size # if the object should be allocated with mem_chunks
   STRINGLIST interfaces # GObject interfaces this class exports
   NODELIST nodes
+  BOOL abstract # if G_TYPE_FLAG_ABSTRACT should be used
 ENDCLASS
 
 CLASS Type


attachment0 (194 bytes) Download Attachment