]> git.draconx.ca Git - gob-dx.git/commitdiff
Release 0.93.5 v0.93.5
authorGeorge Lebl <jirka@5z.com>
Sun, 21 May 2000 11:30:00 +0000 (03:30 -0800)
committerNick Bowler <nbowler@draconx.ca>
Tue, 19 Feb 2019 17:19:48 +0000 (12:19 -0500)
18 files changed:
ChangeLog
NEWS
configure
configure.in
doc/gob.1.in
gob.spec
src/checks.c
src/checks.h
src/main.c
src/main.h
src/parse.c
src/parse.y
src/test.gob
src/treefuncs.c
src/treefuncs.def
src/treefuncs.h
src/util.c
src/util.h

index 46b19045c1d9a14cb24131dd431501de68ab5237..50ec2308b3d316d6cc37adbcaf08347adee8f3fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,60 @@
+Sat May 20 18:22:33 2000  George Lebl <jirka@5z.com>
+
+       * Release 0.93.5
+
+Sat May 20 18:22:23 2000  George Lebl <jirka@5z.com>
+
+       * src/{main.c,checks.[ch]}: check for duplicate overrides, it is
+         different from checking symbol names as they don't conflict with
+         other symbols AND they only conflict if both the name and their
+         type match
+
+Sat May 20 16:38:06 2000  George Lebl <jirka@5z.com>
+
+       * src/{main.[ch],util.[ch],checks.c}: Add underscore removal for
+         non-override methods.  This means that local aliases will include
+         prepended underscores, but when the full name is generated, or
+         when the method name is added to class structure, the underscore
+         is removed.
+
+       * src/checks.c: overrides no longer checked for uniqueness, a more
+         complex logic is needed.
+
+       * src/{main.c,treefuncs.def,parse.y}:  override naming is done
+         with a unique id, so that we handle cases where two classes have
+         the same method name.
+
+       * doc/gob.1.in: update for the above.
+
+Sat May 20 14:42:00 2000  George Lebl <jirka@5z.com>
+
+       * src/main.c: the private structure is now freed in finalize again and
+         thus do the same dance around finalize as we do around destroy. 
+         Clean up some code.  NULL all things being destroyed.  The arbitary
+         destructor uses memset as those things might not be just pointers.
+
+Thu May 11 23:48:44 2000  George Lebl <jirka@5z.com>
+
+       * src/main.[ch]: provide the Self and SelfClass typedefs in addition
+         to SELF, IS_SELF, SELF_CLASS macros.  All of these can now be
+         disabled with the --no-self-alias option
+
+       * doc/gob.1.in: update
+
+       * configure.in: raise version
+
+Tue May 09 23:18:16 2000  George Lebl <jirka@5z.com>
+
+       * src/parse.y: fix segfault on parse error and give better error
+         message
+
+Tue May 09 21:54:10 2000  George Lebl <jirka@5z.com>
+
+       * doc/gob.1.in, src/main.c:  Add destruction code into the destroy
+         handler rather then finalize.  Setup an extra function if
+         neccessary to handle returns correctly as this must be called
+         after any user code.
+
 Sat Apr 29 14:41:42 2000  George Lebl <jirka@5z.com>
 
        * Release 0.93.4
diff --git a/NEWS b/NEWS
index 4d7bebd4d34adc2d66a72a6554118d9e0ed85941..64aaa463935a28f7a1b983bab9ed62f36708d38f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+0.93.5
+       * destructors run after destroy, not before finalize, 
+       * zero out data after destruction
+       * added Self typedef to complement the SELF macros
+       * initial underscore removal from full names, to help to avoid
+         name conflicts
+       
 0.93.4
        * classwide (global) datamembers
        * private header file always generated by default
index 697bf968b08090e9a25d317687872deded7ea8ac..1ae471ea089682d47c18ce51a4720a660a821cad 100755 (executable)
--- a/configure
+++ b/configure
@@ -703,7 +703,7 @@ fi
 
 PACKAGE=gob
 
-VERSION=0.93.4
+VERSION=0.93.5
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
index 857752609f3f15af899dae983f9ba4846b552aa4..2072a16a73fd098e14ec48092365b6b8342e6cf0 100644 (file)
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.2)
 AC_INIT(src/treefuncs.h)
 AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(gob,0.93.4)
+AM_INIT_AUTOMAKE(gob,0.93.5)
 
 if test -f ../NOINST_GOB ; then
   DOINSTGOB=
index 5afe3bbc9b5a2313af6818de8614bac7b55f40fd..34ad853aff95c1a080d3bc73961bf9cc2beffa2b 100644 (file)
@@ -74,6 +74,17 @@ the class definition begins.  This option implicitly negates
 .TP
 .B --no-write
 Do not write any output files, just check syntax of the input file.
+.TP
+.B --no-lines
+Do not print out the '#line' statements into the output.  Useful for debugging
+the autogenerated generated code.
+.TP
+.B --no-self-alias
+Do not create the Self and SelfClass type aliases and the SELF, IS_SELF
+and SELF_CLASS macros.
+.TP
+.B --no-kill-underscores
+Do not remove the initial underscore from method names.
 
 .SH TYPENAMES
 .PP
@@ -223,13 +234,21 @@ where 'h' is the private data member (as in the above example):
 .fi
 The _priv structure is defined in the \fB<basename>-private.h\fR.
 This file is automatically included if you don't include it yourself.  You
-should always explicitly include it if you explicitly also include the main
-header file.
+should always explicitly include it in your .gob file if you explicitly also
+include the main header file.  The reason it is a separate header file is
+that you can also include it in other places that need to access this objects
+private data, such as if you have the majority of functionality of an object
+in a separate .c file.  Or if a derived object needs to access the protected
+methods.
 .PP
 In case you use the \fB--no-private-header\fR option, no
 private header file is created and you can only access the _priv pointer
 below the class definition in the .gob file.
 .PP
+Also note that this structure is dynamically allocated, and is freed in the
+finalize handler.  If you override the finalized handler, your code will be
+run first and only then will the _priv structure be freed.
+.PP
 Classwide data members:
 .PP
 Sometimes you want a datamember to be shared by all objects.  You then need
@@ -281,8 +300,8 @@ places.  Unlike many other places, gob will not enforce any kind of type
 safety here so be a little bit more careful.  Any function you give it will
 be called as a "void function(void *)".  It will in fact be cast into such
 a form before called.  This is to avoid spurious warnings for gtk calls to
-subclass methods.  The function needs not be of that form, it just has to
-take one argument which is the pointer to the data.  You should also not
+subclass methods.  The function needs not be of that form exactly, it just has
+to take one argument which is the pointer to the data.  You should also not
 define this on any non-pointer data as the results may be undefined.
 Example:
 .nf
@@ -294,13 +313,14 @@ Example:
 
 .fi
 Note that the function name you give must be a real function and not macro.
-Also note that this is always called in the "finalize" method of GtkObject.
+Also note that this is always called in the "destroy" method of GtkObject.
+It is always called after any user defined body of the destroy handler.
 .PP
 Sometimes you may want to run arbitrary code on destruction.  While this can
 be perfectly well done in the destroy handler.  Depending on the style you
 may want to include all destruction/initialization code together with the
 definition of the data member.  Thus you may want to put arbitrary code which
-will then be inserted into the "finalize" method of GtkObject.  This can be
+will then be inserted into the "destroy" method of GtkObject.  This can be
 done with the "destroy" keyword followed by arbitrary code in curly braces.  
 Inside this code a macro called VAR will be define which refers to your
 variable.  So for example destroying a GString can be either done with
@@ -319,6 +339,14 @@ Also defining a helper routine that will do the destruction will be a nicer
 thing to do if that's a possibility.  The "destroy" keyword with code does
 take up more space in the file and it may become more cluttered.
 .PP
+The data is zeroed out after being destroyed.  This is to make debugging easier
+in case your code might try to access an already destroyed object.  In case
+you have overriden the destroy method, your code will be run first and
+only then will the destructors be called.  You should not however make any
+assumptions about the order at which the destructors are called.  If you have
+interdependencies between destructors for different data members, you will
+have to do this in your own destroy override function.
+.PP
 GTK+ Arguments:
 .PP
 The fourth type of a data member an argument type.  It is a named data member
@@ -652,9 +680,9 @@ If the function has a return value, then PARENT_HANDLER is an expression that
 you can use.  It will return whatever the parent handler returned, or the
 "onerror" expression if there was no parent handler.
 .PP
-Calling methods:
+Method names:
 .PP
-Inside the code, pointers are set for the methods, so that you don't
+Inside the code, aliases are set for the methods, so that you don't
 have to type the class name before each call, just the name of the method.
 Example:
 .nf
@@ -673,6 +701,37 @@ Example:
 
 .fi
 .PP
+Underscore removal (0.93.5+):
+.PP
+Sometimes this causes conflicts with other libraries.  For example a library
+might have already used the identifier foo.  You can prepend an underscore to
+the name in the .gob file.  This will make the local short alias have an
+initial underscore, but it will not change the name of the actual name of the
+function.  For example:
+.nf
+  class My:Object from Gtk:Object {
+          public void
+          _foo(self) {
+                  /* foo body */
+          }
+          public void
+          bar(self) {
+                  /* short calling convention */
+                  _foo(self);
+                  /* long calling convention */
+                  my_object_foo(self);
+          }
+  }
+.fi
+Thus you see that the "_foo" method still generates the method "my_object_foo"
+just as "foo" would generate.  You can turn off this behaviour if you depend
+on the old (pre 0.93.5) behaviour with the --no-kill-underscores option.  This
+also means that if both "_foo" and "foo" are defined, it is treated as a
+conflict.
+.PP
+This does not apply to override methods.  Override methods are special beasts
+and this is not neccessary and would make the code behave in weird ways.
+.PP
 Making new objects:
 .PP
 You should define a new method which should be a normal public method.  Inside
@@ -689,13 +748,22 @@ will fetch a new object, so a fairly standard new method would look like:
 
 .fi
 .PP
-Casts:
+Self alias casts:
 .PP
 There are some standard casts defined for you.  Instead of using the full
 macros inside the .c file, you can use SELF, IS_SELF and SELF_CLASS.  Using
-these makes it easier to for example change classnames around.  There is
-however no self type, so if you're declaring a pointer to your object, you
-still have to use the full type.
+these makes it easier to for example change classnames around.
+.PP
+Self alias types:
+.PP
+Since 0.93.5, there have also been defined the Self and SelfClass types inside
+your .c file.  These serve the same function as the above, they make it easier
+to type and easier to change typenames around which can help a lot during
+prototyping stage.  However you should note that the Self type should not be
+used in function prototypes as one of the arguments or as a return value type.
+This is because this is a simple C typedef which is only available inside you
+.c file.  You can disable both the self casting macros and the self type
+aliases by passing --no-self-alias to
 
 .SH DEALING WITH DIFFERENT GOB VERSIONS
 .PP
@@ -755,10 +823,21 @@ argument lists and virtual and signal method names as it might confuse the
 PARENT_HANDLER macro.  In fact avoiding all names with three underscores is
 the best policy when working with gob.
 .PP
+Also note that starting with version 0.93.5, method names that start with a
+an underscore are eqivalent to the names without the initial underscore.  This
+is done to avoid conflicts with the aliases.  Thus you can define the method
+as "_name", if "name" happens to be some standard library function.  This is
+the same as defining it as "name" except that the local alias will be "_name"
+rather then "name".
+.PP
 There are a couple of defines which you shouldn't be redefining in the code
 or other headers.  These are SELF, IS_SELF, SELF_CLASS, ARG, VAR,
 PARENT_HANDLER, GET_NEW, GOB_VERSION_MAJOR, GOB_VERSION_MINOR and
 GOB_VERSION_PATCHLEVEL.
+.PP
+As for types, there are Self and SelfClass types which are only defined in your
+source files.  Their generation (just like the generation of the SELF macros)
+can be turned off, see command line options.
 
 .SH USING GTK-DOC STYLE INLINE DOCUMENTATION
 .PP
index d715d37e2e960dc3ab3b26ec7cabe735cfd6afb2..ecefba420a7f0a774defa99cd25c066bb5011783 100644 (file)
--- a/gob.spec
+++ b/gob.spec
@@ -1,4 +1,4 @@
-%define  ver     0.93.4
+%define  ver     0.93.5
 %define  rel     1
 %define  prefix  /usr
 
index 726dad91957c50d354a4919e2372f3cac36d8e3a..7ce3bea967e83f2e2e2a26961a46781c13174c0b 100644 (file)
@@ -1,5 +1,6 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
  *
  * Author: George Lebl
  *
 #include "checks.h"
 
 static void
-check_duplicate(Class *c, Node *node, char *id, int line_no)
+check_duplicate(Class *c, Node *node, char *id, int line_no,
+               gboolean underscore)
 {
        GList *l;
        for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                char *nid;
                int nline_no;
+               gboolean here_underscore = FALSE;
                char *s;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
-                       nid = m->id;
+
+                       /* override methods are checked separately */
+                       if(m->method == OVERRIDE_METHOD)
+                               continue;
+
+                       nid = get_real_id(m->id);
                        nline_no = m->line_no;
+
+                       if(m->id[0] == '_' && m->id[1] != '\0')
+                               here_underscore = TRUE;
                } else if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
                        nid = v->id;
@@ -50,14 +61,24 @@ check_duplicate(Class *c, Node *node, char *id, int line_no)
                } else
                        continue;
                if(n == node ||
-                  line_no >= nline_no ||
-                  strcmp(nid, id) != 0 ||
-                  n->type != node->type)
+                  line_no > nline_no ||
+                  n->type != node->type ||
+                  strcmp(nid, id) != 0)
                        continue;
-               s = g_strdup_printf("symbol '%s' redefined, "
-                                   "first defined on line %d",
-                                   id, line_no);
+               /* this can only happen if the things were methods and
+                * one had an underscore and the other one didn't */
+               if(!no_kill_underscores && underscore != here_underscore)
+                       s = g_strdup_printf("symbol '%s' ('_%s') redefined, "
+                                           "first defined on line %d. "
+                                           "Note that '%s' and '_%s' are "
+                                           "eqivalent.",
+                                           id, id, line_no, id, id);
+               else
+                       s = g_strdup_printf("symbol '%s' redefined, "
+                                           "first defined on line %d",
+                                           id, line_no);
                print_error(FALSE, s, nline_no);
+               g_free(s);
        }
 }
 
@@ -69,14 +90,60 @@ check_duplicate_symbols(Class *c)
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
-                       check_duplicate(c, n, m->id, m->line_no);
+                       gboolean underscore = FALSE;
+                       /* override methods are checked separately */
+                       if(m->method == OVERRIDE_METHOD)
+                               continue;
+                       if(m->id[0] == '_' && m->id[1] != '\0')
+                               underscore = TRUE;
+                       check_duplicate(c, n, get_real_id(m->id), m->line_no,
+                                       underscore);
                } else if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
-                       check_duplicate(c, n, v->id, v->line_no);
+                       check_duplicate(c, n, v->id, v->line_no, FALSE);
                }
        }
 }
 
+static void
+check_duplicate_override(Class *c, Method *method)
+{
+       GList *l;
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
+               Node *n = l->data;
+               Method *m = (Method *)n;
+               char *s;
+               if(n->type != METHOD_NODE ||
+                  m->method != OVERRIDE_METHOD)
+                       continue;
+
+               if(method == m ||
+                  method->line_no > m->line_no ||
+                  strcmp(m->id, method->id) != 0 ||
+                  strcmp(m->otype, method->otype) != 0)
+                       continue;
+               s = g_strdup_printf("override '%s(%s)' redefined, "
+                                   "first defined on line %d",
+                                   m->id, m->otype, method->line_no);
+               print_error(FALSE, s, m->line_no);
+               g_free(s);
+       }
+}
+
+void
+check_duplicate_overrides(Class *c)
+{
+       GList *l;
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
+               Node *n = l->data;
+               Method *m = (Method *)n;
+               if(n->type != METHOD_NODE ||
+                  m->method != OVERRIDE_METHOD)
+                       continue;
+               check_duplicate_override(c, m);
+       }
+}
+
 void
 check_bad_symbols(Class *c)
 {
index e2933d2cd17411217ac9a3b1447a0cb0603a1883..8d2030066a1896fae6bdf6c011baa99d564313d6 100644 (file)
@@ -1,5 +1,6 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
  *
  * Author: George Lebl
  *
@@ -23,6 +24,7 @@
 #define _CHECKS_H_
 
 void check_duplicate_symbols(Class *c);
+void check_duplicate_overrides(Class *c);
 void check_bad_symbols(Class *c);
 void check_duplicate_signals_args(Class *c);
 void check_public_new(Class *c);
index cdbfa42859f79a2ae5dd8d4daecc9df4be2dc3b7..6ab2cb9d92aac54eb07518a0afef6ec77cf365c4 100644 (file)
@@ -1,5 +1,6 @@
 /* GOB C Preprocessor
- * Copyright (C) 1999 the Free Software Foundation.
+ * Copyright (C) 1999,2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
  *
  * Author: George Lebl
  *
@@ -74,6 +75,12 @@ static gboolean made_aliases = FALSE;  /* if we made any shorthand aliases
 static gboolean special_array[SPECIAL_LAST] = {0};
 static gboolean any_special = FALSE;
 
+static gboolean need_destroy = FALSE;
+static Method * destroy_handler = NULL;
+
+static gboolean need_finalize = FALSE;
+static Method * finalize_handler = NULL;
+
 FILE *out = NULL;
 FILE *outh = NULL;
 FILE *outph = NULL;
@@ -89,6 +96,10 @@ gint private_header = PRIVATE_HEADER_ALWAYS;
 gboolean no_extern_c = FALSE;
 gboolean no_write = FALSE;
 gboolean no_lines = FALSE;
+gboolean no_self_alias = FALSE;
+gboolean no_kill_underscores = FALSE;
+
+int method_unique_id = 1;
 
 static void
 make_bases(void)
@@ -156,13 +167,13 @@ get_gtk_doc(char *id)
        val = g_hash_table_lookup(gtk_doc_hash, id);
        if(val)
                return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
-                                      funcbase, id, val);
-       s = g_strconcat(funcbase, "_", id, NULL);
+                                      funcbase, get_real_id(id), val);
+       s = g_strconcat(funcbase, "_", get_real_id(id), NULL);
        val = g_hash_table_lookup(gtk_doc_hash, s);
        g_free(s);
        if(val)
                return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
-                                      funcbase, id, val);
+                                      funcbase, get_real_id(id), val);
        return NULL;
 }
 
@@ -182,18 +193,26 @@ print_method(FILE *fp, char *typeprefix, char *nameprefix,
             char *subnameprefix,
             char *namepostfix, char *postfix, Method *m,
             gboolean one_arg_per_line,
-            gboolean no_funcbase)
+            gboolean no_funcbase,
+            gboolean kill_underscore)
 {
        GList *li;
+       char *id;
 
        out_printf(fp, "%s", typeprefix); 
        print_type(fp, m->mtype, TRUE);
+
+       if(kill_underscore)
+               id = get_real_id(m->id);
+       else
+               id = m->id;
+
        if(no_funcbase)
                out_printf(fp, "%s%s%s%s(",
-                          nameprefix, subnameprefix, m->id, namepostfix); 
+                          nameprefix, subnameprefix, id, namepostfix); 
        else
                out_printf(fp, "%s%s_%s%s%s(",
-                          nameprefix, funcbase, subnameprefix, m->id,
+                          nameprefix, funcbase, subnameprefix, id,
                           namepostfix); 
        
        if(m->args) {
@@ -262,10 +281,11 @@ make_method_gnu_aliases(Class *c)
 
                        out_printf(out, "static const typeof(&%s_%s) %s "
                                   "__attribute__ ((__unused__)) "
-                                  "= %s_%s;\n", funcbase, m->id, m->id,
-                                  funcbase, m->id);
+                                  "= %s_%s;\n", funcbase, get_real_id(m->id),
+                                  m->id, funcbase, get_real_id(m->id));
                        out_printf(out, "#define %s(args...) "
-                                  "%s_%s(##args)\n", m->id, funcbase, m->id);
+                                  "%s_%s(##args)\n", m->id,
+                                  funcbase, get_real_id(m->id));
                }
        }
 }
@@ -290,8 +310,9 @@ make_method_nongnu_aliases(Class *c)
                                continue;
 
                        print_method(out, "static ", "(* ", "", ") ", "",
-                                    m, FALSE, TRUE);
-                       out_printf(out, " = %s_%s;\n", funcbase, m->id);
+                                    m, FALSE, TRUE, FALSE);
+                       out_printf(out, " = %s_%s;\n", funcbase,
+                                  get_real_id(m->id));
 
                        made_aliases = TRUE;
                }
@@ -366,10 +387,11 @@ put_vs_method(Method *m)
 
        /* if a signal mark it as such */
        if(m->method != VIRTUAL_METHOD)
-               print_method(outh, "\t/*signal*/", "(* ", "", ") ", ";\n", m,
-                            FALSE, TRUE);
+               print_method(outh, "\t/*signal*/", "(* ", "", ") ", ";\n",
+                            m, FALSE, TRUE, TRUE);
        else
-               print_method(outh, "\t", "(* ", "", ") ", ";\n", m, FALSE, TRUE);
+               print_method(outh, "\t", "(* ", "", ") ", ";\n",
+                            m, FALSE, TRUE, TRUE);
 }
 
 static void
@@ -378,7 +400,7 @@ put_pub_method(Method *m)
        if(m->scope != PUBLIC_SCOPE)
                return;
 
-       print_method(outh, "", "\t", "", "\t", ";\n", m, TRUE, FALSE);
+       print_method(outh, "", "\t", "", "\t", ";\n", m, TRUE, FALSE, TRUE);
 }
 
 /* I'm starting not to like this idea */
@@ -426,9 +448,11 @@ put_prot_method(Method *m)
                return;
 
        if(outph)
-               print_method(outph, "", "\t", "", "\t", ";\n", m, FALSE, FALSE);
+               print_method(outph, "", "\t", "", "\t", ";\n",
+                            m, FALSE, FALSE, TRUE);
        else
-               print_method(out, "", "\t", "", "\t", ";\n", m, FALSE, FALSE);
+               print_method(out, "", "\t", "", "\t", ";\n",
+                            m, FALSE, FALSE, TRUE);
 }
 
 static void
@@ -440,17 +464,25 @@ put_priv_method_prot(Method *m)
                if(m->cbuf)
                        print_method(out,
                                     "static ", "___real_", "", " ", ";\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
        }
+       /* no else, here, it might still have a private prototype, it's not
+        * exclusive */
 
-       if(m->scope == PRIVATE_SCOPE ||
+       if((m->method == OVERRIDE_METHOD &&
+           m->cbuf)) {
+               /* add unique ID */
+               char *s = g_strdup_printf("___%x_", (guint)m->unique_id);
+               print_method(out, "static ", s, "", " ",
+                            no_gnu?";\n":" G_GNUC_UNUSED;\n",
+                            m, FALSE, FALSE, FALSE);
+               g_free(s);
+       } else if(m->scope == PRIVATE_SCOPE ||
           m->method == INIT_METHOD ||
-          m->method == CLASS_INIT_METHOD ||
-          (m->method == OVERRIDE_METHOD &&
-           m->cbuf))
+          m->method == CLASS_INIT_METHOD)
                print_method(out, "static ", "", "", " ",
                             no_gnu?";\n":" G_GNUC_UNUSED;\n",
-                            m, FALSE, FALSE);
+                            m, FALSE, FALSE, TRUE);
 }
 
 static GList *
@@ -497,7 +529,8 @@ make_inits(Class *cl)
                                  (Type *)new_type(0, g_strdup("void"), NULL),
                                  NULL, NULL, NULL, g_strdup("class_init"),
                                  make_func_arg(cl->otype, TRUE, g_strdup("c")),
-                                 NULL, NULL, NULL, 0, 0, FALSE);
+                                 NULL, NULL, NULL, 0, 0, FALSE,
+                                 method_unique_id++);
                cl->nodes = g_list_prepend(cl->nodes, node);
        }
        if(!got_init) {
@@ -505,44 +538,77 @@ make_inits(Class *cl)
                                  (Type *)new_type(0, g_strdup("void"), NULL),
                                  NULL, NULL, NULL, g_strdup("init"),
                                  make_func_arg(cl->otype, FALSE, g_strdup("o")),
-                                 NULL, NULL, NULL, 0, 0, FALSE);
+                                 NULL, NULL, NULL, 0, 0, FALSE,
+                                 method_unique_id++);
                cl->nodes = g_list_prepend(cl->nodes, node);
        }
 }
 
 static void
-make_finalize(Class *cl)
+find_destroy(Class *cl)
 {
-       int got_finalize = FALSE;
        GList *li;
        Node *node;
+
+       destroy_handler = NULL;
        for(li=cl->nodes;li;li=g_list_next(li)) {
                Node *n = li->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
                        if(m->method == OVERRIDE_METHOD &&
-                          strcmp(m->id, "finalize")==0) {
-                               if(strcmp(m->otype, "Gtk:Object")==0) {
-                                       got_finalize = TRUE;
-                                       break;
+                          strcmp(m->id, "destroy")==0) {
+                               if(strcmp(m->otype, "Gtk:Object") != 0) {
+                                       print_error(FALSE,
+                                                   "destroy method override "
+                                                   "of class other then "
+                                                   "Gtk:Object",
+                                                   m->line_no);
                                }
-                               print_error(FALSE, "finalize method override "
-                                           "of class other then Gtk:Object",
-                                           m->line_no);
+                               if(g_list_length(m->args) != 1) {
+                                       print_error(FALSE,
+                                                   "destroy method override "
+                                                   "with more then one "
+                                                   "parameter",
+                                                   m->line_no);
+                               }
+                               destroy_handler = m;
+                               break;
                        }
                }
        }
-       if(!got_finalize) {
-               node = new_method(NO_SCOPE, OVERRIDE_METHOD,
-                                 (Type *)new_type(0, g_strdup("void"), NULL),
-                                 g_strdup("Gtk:Object"),
-                                 NULL, NULL, g_strdup("finalize"),
-                                 make_func_arg("Gtk:Object", FALSE, g_strdup("o")),
-                                 NULL, NULL,
-                                 g_strdup("PARENT_HANDLER (o);\n"),
-                                 0, 0, FALSE);
-               cl->nodes = g_list_append(cl->nodes, node);
-               overrides++;
+}
+
+static void
+find_finalize(Class *cl)
+{
+       GList *li;
+       Node *node;
+
+       finalize_handler = NULL;
+       for(li=cl->nodes;li;li=g_list_next(li)) {
+               Node *n = li->data;
+               if(n->type == METHOD_NODE) {
+                       Method *m = (Method *)n;
+                       if(m->method == OVERRIDE_METHOD &&
+                          strcmp(m->id, "finalize")==0) {
+                               if(strcmp(m->otype, "Gtk:Object") != 0) {
+                                       print_error(FALSE,
+                                                   "finalize method override "
+                                                   "of class other then "
+                                                   "Gtk:Object",
+                                                   m->line_no);
+                               }
+                               if(g_list_length(m->args) != 1) {
+                                       print_error(FALSE,
+                                                   "finalize method override "
+                                                   "with more then one "
+                                                   "parameter",
+                                                   m->line_no);
+                               }
+                               finalize_handler = m;
+                               break;
+                       }
+               }
        }
 }
 
@@ -686,7 +752,7 @@ add_enums(Class *c)
                                Method *m = (Method *)n;
                                if(m->method == SIGNAL_LAST_METHOD ||
                                   m->method == SIGNAL_FIRST_METHOD) {
-                                       char *s = g_strdup(m->id);
+                                       char *s = g_strdup(get_real_id(m->id));
                                        g_strup(s);
                                        out_printf(out, "\t%s_SIGNAL,\n", s);
                                        g_free(s);
@@ -763,7 +829,7 @@ add_overrides(Class *c, char *oname, gboolean did_gtk_obj)
                if(n->type != METHOD_NODE ||
                   m->method != OVERRIDE_METHOD)
                        continue;
-               
+
                s = remove_sep(m->otype);
                
                if(g_hash_table_lookup(done, s)) {
@@ -776,7 +842,7 @@ add_overrides(Class *c, char *oname, gboolean did_gtk_obj)
                g_strdown(f);
 
                out_printf(out, "\t%sClass *%s_class = (%sClass *)%s;\n",
-                       s, f, s, oname);
+                          s, f, s, oname);
                
                g_free(f);
        }
@@ -866,8 +932,8 @@ add_signals(Class *c)
                        mar = g_strdup("gtk_signal_default_marshaller");
                
                is_none = (strcmp(m->gtktypes->next->data, "NONE")==0);
-               
-               sig = g_strdup(m->id);
+
+               sig = g_strdup(get_real_id(m->id));
                g_strup(sig);
                flags = make_run_signal_flags(m, last);
                out_printf(out, "\tobject_signals[%s_SIGNAL] =\n"
@@ -877,9 +943,10 @@ add_signals(Class *c)
                        "\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
                        "\t\t\t%s,\n"
                        "\t\t\tGTK_TYPE_%s, %d",
-                       sig, m->id,
+                       sig, get_real_id(m->id),
                        flags,
-                       typebase, m->id, mar, (char *)m->gtktypes->data,
+                       typebase, get_real_id(m->id), mar,
+                       (char *)m->gtktypes->data,
                        is_none?0:g_list_length(m->gtktypes->next));
                g_free(mar);
                g_free(sig);
@@ -905,9 +972,11 @@ set_def_handlers(Class *c, char *oname)
        gboolean set_line = FALSE;
 
        out_printf(out, "\n");
-       for(li=c->nodes;li;li=g_list_next(li)) {
+       for(li = c->nodes; li; li = g_list_next(li)) {
                Node *n = li->data;
                Method *m = (Method *)n;
+               char *id;
+
                if(n->type != METHOD_NODE ||
                   (m->method != SIGNAL_FIRST_METHOD &&
                    m->method != SIGNAL_LAST_METHOD &&
@@ -923,23 +992,38 @@ set_def_handlers(Class *c, char *oname)
                        set_line = FALSE;
                }
 
+
                if(m->method == OVERRIDE_METHOD) {
                        char *s;
                        s = replace_sep(m->otype, '_');
                        g_strdown(s);
-                       if(m->cbuf)
-                               out_printf(out, "\t%s_class->%s = %s_%s;\n",
-                                          s, m->id, funcbase, m->id);
+
+                       if(need_destroy &&
+                          destroy_handler &&
+                          strcmp(m->id, "destroy") == 0)
+                               out_printf(out, "\tgtk_object_class->destroy "
+                                          "= ___destroy;\n");
+                       else if(need_finalize &&
+                               finalize_handler &&
+                               strcmp(m->id, "finalize") == 0)
+                               out_printf(out, "\tgtk_object_class->finalize "
+                                          "= ___finalize;\n");
+                       else if(m->cbuf)
+                               out_printf(out,
+                                          "\t%s_class->%s = ___%x_%s_%s;\n",
+                                          s, m->id, (guint)m->unique_id,
+                                          funcbase, m->id);
                        else
                                out_printf(out, "\t%s_class->%s = NULL;\n",
                                           s, m->id);
                } else {
                        if(m->cbuf)
                                out_printf(out, "\t%s->%s = ___real_%s_%s;\n",
-                                       oname, m->id, funcbase, m->id);
+                                       oname, get_real_id(m->id),
+                                       funcbase, get_real_id(m->id));
                        else
                                out_printf(out, "\t%s->%s = NULL;\n",
-                                       oname, m->id);
+                                       oname, get_real_id(m->id));
                }
        }
        if(set_line)
@@ -1046,6 +1130,114 @@ print_initializer(Method *m, Variable *v)
        g_free(root);
 }
 
+static void
+print_destructor(Variable *v)
+{
+       char *root;
+
+       if(v->destructor == NULL)
+               return;
+
+       if(v->scope == PRIVATE_SCOPE)
+               root = "self->_priv";
+       else
+               root = "self";
+
+       if(v->destructor_simple) {
+               if(v->destructor_line > 0)
+                       out_addline_infile(out, v->destructor_line);
+
+               out_printf(out, "\tif(%s->%s) { "
+                          "((*(void (*)(void *))%s)) (%s->%s); "
+                          "%s->%s = NULL; }\n",
+                          root, v->id, v->destructor, root, v->id,
+                          root, v->id);
+
+               if(v->destructor_line > 0)
+                       out_addline_outfile(out);
+       } else {
+               out_printf(out, "#define VAR (%s->%s)\n", root, v->id);
+               out_printf(out, "\t{\n");
+               if(v->destructor_line > 0)
+                       out_addline_infile(out, v->destructor_line);
+
+               out_printf(out, "\t%s}\n", v->destructor);
+
+               if(v->destructor_line > 0)
+                       out_addline_outfile(out);
+               out_printf(out, "\tmemset(&VAR, 0, sizeof(VAR));\n");
+               out_printf(out, "#undef VAR\n");
+       }
+}
+
+static void
+add_destroy(Class *c)
+{
+       out_printf(out, "\nstatic void\n"
+                  "___destroy(GtkObject *obj_self)\n"
+                  "{\n");
+
+       if(destructors > 0) {
+               out_printf(out, "\t%s *self G_GNUC_UNUSED = %s (obj_self);\n",
+                          typebase, macrobase);
+       }
+
+       if(destroy_handler) {
+               /* so we get possible bad argument warning */
+               if(destroy_handler->line_no > 0)
+                       out_addline_infile(out, destroy_handler->line_no);
+               out_printf(out, "\t___%x_%s_destroy(obj_self);\n",
+                          (guint)destroy_handler->unique_id, funcbase);
+               if(destroy_handler->line_no > 0)
+                       out_addline_outfile(out);
+       }
+
+       if(destructors > 0) {
+               GList *li;
+               for(li = ((Class *)class)->nodes;
+                   li != NULL;
+                   li = li->next) {
+                       Node *n = li->data;
+                       Variable *v = (Variable *)n;
+                       if(n->type == VARIABLE_NODE &&
+                          v->scope != CLASS_SCOPE)
+                               print_destructor(v);
+               }
+       }
+
+       out_printf(out, "}\n\n");
+}
+
+static void
+add_finalize(Class *c)
+{
+       out_printf(out, "\nstatic void\n"
+                  "___finalize(GtkObject *obj_self)\n"
+                  "{\n");
+
+       if(privates > 0) {
+               out_printf(out, "\t%s *self = %s (obj_self);\n",
+                          typebase, macrobase);
+       }
+
+       if(finalize_handler) {
+               /* so we get possible bad argument warning */
+               if(finalize_handler->line_no > 0)
+                       out_addline_infile(out, finalize_handler->line_no);
+               out_printf(out, "\t___%x_%s_finalize(obj_self);\n",
+                          (guint)finalize_handler->unique_id, funcbase);
+               if(finalize_handler->line_no > 0)
+                       out_addline_outfile(out);
+       }
+
+       if(privates > 0) {
+               out_printf(out, "\tg_free (self->_priv);\n"
+                          "\tself->_priv = NULL;\n");
+       }
+
+       out_printf(out, "}\n\n");
+}
+
 static void
 add_inits(Class *c)
 {
@@ -1060,7 +1252,7 @@ add_inits(Class *c)
                        if(m->line_no > 0)
                                out_addline_infile(out, m->line_no);
                        print_method(out, "static ", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                        if(m->line_no > 0)
                                out_addline_outfile(out);
                        out_printf(out, "{\n");
@@ -1084,25 +1276,31 @@ add_inits(Class *c)
                                }
                        }
                } else if(m->method == CLASS_INIT_METHOD) {
+                       gboolean did_gtk_obj = FALSE;
+
                        if(m->line_no > 0)
                                out_addline_infile(out, m->line_no);
                        print_method(out, "static ", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                        if(m->line_no > 0)
                                out_addline_outfile(out);
                        out_printf(out, "{\n");
-                       if(signals>0 ||
-                          arguments>0)
+                       if(signals > 0 ||
+                          arguments > 0 ||
+                          need_destroy ||
+                          need_finalize) {
                                out_printf(out,
                                           "\tGtkObjectClass *"
                                           "gtk_object_class = "
                                           "(GtkObjectClass*) %s;\n",
                                           ((FuncArg *)m->args->data)->name);
+                               did_gtk_obj = TRUE;
+                       }
 
-                       if(overrides>0)
+                       if(overrides > 0)
                                add_overrides(c,
                                              ((FuncArg *)m->args->data)->name,
-                                             (signals>0 || arguments>0));
+                                             did_gtk_obj);
 
                        if(initializers > 0) {
                                GList *li;
@@ -1124,12 +1322,21 @@ add_inits(Class *c)
                        out_printf(out, "gtk_type_class (%s_get_type ());\n",
                                   pfuncbase);
 
-                       if(signals>0)
+                       if(signals > 0)
                                add_signals(c);
 
                        set_def_handlers(c, ((FuncArg *)m->args->data)->name);
+
+                       /* if there are no handlers for these things, we
+                        * need to set them up here */
+                       if(need_destroy && !destroy_handler)
+                               out_printf(out, "\tgtk_object_class->destroy "
+                                          "= ___destroy;\n");
+                       if(need_finalize && !finalize_handler)
+                               out_printf(out, "\tgtk_object_class->finalize "
+                                          "= ___finalize;\n");
                        
-                       if(arguments>0)
+                       if(arguments > 0)
                                make_arguments(c);
 
                } else
@@ -1312,80 +1519,6 @@ print_preconditions(Method *m)
                out_addline_outfile(out);
 }
 
-static void
-print_destructor(char *self_id, Variable *v)
-{
-       char *root;
-
-       if(v->destructor == NULL)
-               return;
-
-       if(v->scope == PRIVATE_SCOPE)
-               root = g_strconcat(self_id, "->_priv", NULL);
-       else
-               root = g_strdup(self_id);
-
-       if(v->destructor_simple) {
-               if(v->destructor_line > 0)
-                       out_addline_infile(out, v->destructor_line);
-
-               out_printf(out, "\tif(%s->%s) "
-                          "((*(void (*)(void *))%s)) (%s->%s);\n",
-                          root, v->id, v->destructor, root, v->id);
-
-               if(v->destructor_line > 0)
-                       out_addline_outfile(out);
-       } else {
-               out_printf(out, "#define VAR (%s->%s)\n", root, v->id);
-               out_printf(out, "\t{\n\t%s *self G_GNUC_UNUSED = %s;\n",
-                          typebase, self_id);
-               if(v->destructor_line > 0)
-                       out_addline_infile(out, v->destructor_line);
-
-               out_printf(out, "\t%s}\n", v->destructor);
-
-               if(v->destructor_line > 0)
-                       out_addline_outfile(out);
-               out_printf(out, "#undef VAR\n");
-       }
-
-       g_free(root);
-}
-
-/* put in code if it's needed */
-static void
-put_in_gen_code(Method *m)
-{
-       if(m->method == OVERRIDE_METHOD &&
-          strcmp(m->id, "finalize")==0) {
-               if(privates > 0 || destructors > 0) {
-                       out_printf(out, "\t%s *___self = %s (%s);\n",
-                                  typebase, macrobase,
-                                  ((FuncArg *)m->args->data)->name);
-               }
-               if(destructors > 0) {
-                       GList *li;
-                       for(li = ((Class *)class)->nodes;
-                           li != NULL;
-                           li = li->next) {
-                               Node *n = li->data;
-                               Variable *v = (Variable *)n;
-                               if(n->type == VARIABLE_NODE &&
-                                  v->scope != CLASS_SCOPE)
-                                       print_destructor("___self", v);
-                       }
-               }
-               if(privates > 0) {
-                       out_printf(out, "\tg_free (___self->_priv);\n"
-                                  "\t___self->_priv = NULL;\n",
-                                  macrobase,
-                                  ((FuncArg *)m->args->data)->name,
-                                  macrobase,
-                                  ((FuncArg *)m->args->data)->name);
-               }
-       }
-}
-
 static void
 print_method_body(Method *m, int pre)
 {
@@ -1393,8 +1526,6 @@ print_method_body(Method *m, int pre)
        if(pre)
                print_preconditions(m);
 
-       put_in_gen_code(m);
-
        /* Note: the trailing }'s are on one line, this is so
           that we get the no return warning correctly and point to
           the correct line in the .gob file, yes this is slightly
@@ -1457,35 +1588,39 @@ put_method(Method *m)
        is_void = (strcmp(m->mtype->name, "void")==0 &&
                   m->mtype->stars == 0);
        out_printf(out, "\n");
-       doc = get_gtk_doc(m->id);
-       if(doc) {
-               out_printf(out, "%s", doc);
-               g_free(doc);
+       if(m->method != OVERRIDE_METHOD) {
+               doc = get_gtk_doc(m->id);
+               if(doc) {
+                       out_printf(out, "%s", doc);
+                       g_free(doc);
+               }
        }
        switch(m->method) {
        case REGULAR_METHOD:
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
                if(m->scope == PRIVATE_SCOPE)
                        print_method(out, "static ", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                else /* PUBLIC, PROTECTED */
                        print_method(out, "", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                print_method_body(m, TRUE);
+               /* the outfile line was added above */
                break;
        case SIGNAL_FIRST_METHOD:
        case SIGNAL_LAST_METHOD:
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
                if(m->scope == PRIVATE_SCOPE)
                        print_method(out, "static ", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                else /* PUBLIC, PROTECTED */
-                       print_method(out, "", "\n", "", " ", "\n", m, FALSE, FALSE);
+                       print_method(out, "", "\n", "", " ", "\n",
+                                    m, FALSE, FALSE, TRUE);
                out_addline_outfile(out);
                out_printf(out, "{\n");
-               s = g_strdup(m->id);
+               s = g_strdup(get_real_id(m->id));
                g_strup(s);
                if(strcmp(m->mtype->name, "void")==0 &&
                   m->mtype->stars==0) {
@@ -1518,31 +1653,35 @@ put_method(Method *m)
 
                if(!m->cbuf)
                        break;
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
                print_method(out, "static ", "\n___real_", "", " ", "\n",
-                            m, FALSE, FALSE);
+                            m, FALSE, FALSE, TRUE);
                print_method_body(m, FALSE);
+               /* the outfile line was added above */
                break;
        case VIRTUAL_METHOD:
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
                if(m->scope==PRIVATE_SCOPE)
                        print_method(out, "static ", "\n", "", " ", "\n",
-                                    m, FALSE, FALSE);
+                                    m, FALSE, FALSE, TRUE);
                else /* PUBLIC, PROTECTED */
-                       print_method(out, "", "\n", "", " ", "\n", m, FALSE, FALSE);
+                       print_method(out, "", "\n", "", " ", "\n",
+                                    m, FALSE, FALSE, TRUE);
                out_addline_outfile(out);
                out_printf(out, "{\n"
                        "\t%sClass *klass;\n", typebase);
                print_preconditions(m);
                out_printf(out, "\tklass = %s_CLASS(GTK_OBJECT(%s)->klass);\n\n"
                        "\tif(klass->%s)\n",
-                       macrobase, ((FuncArg *)m->args->data)->name, m->id);
+                       macrobase, ((FuncArg *)m->args->data)->name,
+                       get_real_id(m->id));
                if(strcmp(m->mtype->name, "void")==0 &&
                   m->mtype->stars==0) {
                        GList *li;
-                       out_printf(out, "\t\t(*klass->%s)(%s", m->id,
+                       out_printf(out, "\t\t(*klass->%s)(%s",
+                                  get_real_id(m->id),
                                   ((FuncArg *)m->args->data)->name);
                        for(li=m->args->next;li;li=g_list_next(li)) {
                                FuncArg *fa = li->data;
@@ -1551,7 +1690,8 @@ put_method(Method *m)
                        out_printf(out, ");\n}\n");
                } else {
                        GList *li;
-                       out_printf(out, "\t\treturn (*klass->%s)(%s", m->id,
+                       out_printf(out, "\t\treturn (*klass->%s)(%s",
+                                  get_real_id(m->id),
                                   ((FuncArg *)m->args->data)->name);
                        for(li=m->args->next;li;li=g_list_next(li)) {
                                FuncArg *fa = li->data;
@@ -1571,19 +1711,23 @@ put_method(Method *m)
 
                if(!m->cbuf)
                        break;
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
                print_method(out, "static ", "\n___real_", "", " ", "\n",
-                            m, FALSE, FALSE);
+                            m, FALSE, FALSE, TRUE);
                print_method_body(m, FALSE);
+               /* the outfile line was added above */
                break;
        case OVERRIDE_METHOD:
                if(!m->cbuf)
                        break;
-               if(m->line_no>0)
+               if(m->line_no > 0)
                        out_addline_infile(out, m->line_no);
-               print_method(out, "static ", "\n", "", " ", "\n",
-                            m, FALSE, FALSE);
+               s = g_strdup_printf("\n___%x_", (guint)m->unique_id);
+               print_method(out, "static ", s, "", " ", "\n",
+                            m, FALSE, FALSE, FALSE);
+               g_free(s);
+               out_addline_outfile(out);
                s = replace_sep(m->otype, '_');
                g_strup(s);
                args = get_arg_names_for_macro(m);
@@ -1606,6 +1750,7 @@ put_method(Method *m)
                g_free(args);
                g_free(s);
                print_method_body(m, TRUE);
+               /* the outfile line was added above */
                out_printf(out, "#undef PARENT_HANDLER\n");
                break;
        default:
@@ -1845,12 +1990,19 @@ print_class_block(Class *c)
                   "GTK_CHECK_TYPE((obj),%s_get_type ())\n\n",
                   macrois, funcbase);
 
-       out_printf(out, "/* self casting macros */\n");
-       out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
-       out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
-       out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n", macrobase);
+       if(!no_self_alias) {
+               out_printf(out, "/* self casting macros */\n");
+               out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
+               out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
+               out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n",
+                          macrobase);
 
-       if(privates>0) {
+               out_printf(out, "/* self typedefs */\n");
+               out_printf(out, "typedef %s Self;\n", typebase);
+               out_printf(out, "typedef %sClass SelfClass;\n\n", typebase);
+       }
+
+       if(privates > 0) {
                out_printf(outh, "\n/* Private structure type */\n");
                out_printf(outh, "typedef struct _%sPrivate %sPrivate;\n",
                           typebase, typebase);
@@ -1901,7 +2053,7 @@ print_class_block(Class *c)
        }
        out_printf(outh, "};\n");
 
-       if(privates>0) {
+       if(privates > 0) {
                FILE *outfp;
 
                /* if we are to stick this into the private
@@ -2038,6 +2190,12 @@ print_class_block(Class *c)
                   "#define GET_NEW ((%s *)gtk_type_new(%s_get_type()))\n\n",
                   typebase, funcbase);
 
+       if(need_destroy)
+               add_destroy(c);
+
+       if(need_finalize)
+               add_finalize(c);
+
        add_inits(c);
 
        if(arguments>0) {
@@ -2086,6 +2244,10 @@ print_includes(void)
        gboolean found_header;
        char *p;
 
+       /* We may need string.h for memset */
+       if(destructors > 0)
+               out_printf(out, "#include <string.h> /* memset() */\n\n");
+
        p = g_strconcat(filebase, ".h", NULL);
        found_header = TRUE;
        if(!g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
@@ -2251,7 +2413,11 @@ print_help(void)
                                          "prototypes inside c file\n"
                "\t--no-write,-n           Don't write output files, just "
                                          "check syntax\n"
-               "\t--no-lines              Don't print '#line' to output\n");
+               "\t--no-lines              Don't print '#line' to output\n"
+               "\t--no-self-alias         Don't create self type and macro "
+                                         "aliases\n"
+               "\t--no-kill-underscores   Don't remove the leading underscore "
+                                         "from short id names");
 }
 
 static void
@@ -2301,6 +2467,10 @@ parse_options(int argc, char *argv[])
                        no_write = TRUE;
                } else if(strcmp(argv[i], "--no-lines")==0) {
                        no_lines = TRUE;
+               } else if(strcmp(argv[i], "--no-self-alias")==0) {
+                       no_self_alias = TRUE;
+               } else if(strcmp(argv[i], "--no-kill-underscores")==0) {
+                       no_kill_underscores = TRUE;
                } else if(strcmp(argv[i], "--")==0) {
                        /*further arguments are files*/
                        no_opts = TRUE;
@@ -2399,10 +2569,17 @@ main(int argc, char *argv[])
 
        make_bases();
        make_inits((Class *)class);
-       if(privates>0)
-               make_finalize((Class *)class);
+       if(destructors > 0) {
+               need_destroy = TRUE;
+               find_destroy((Class *)class);
+       }
+       if(privates > 0) {
+               need_finalize = TRUE;
+               find_finalize((Class *)class);
+       }
        check_bad_symbols((Class *)class);
        check_duplicate_symbols((Class *)class);
+       check_duplicate_overrides((Class *)class);
        check_duplicate_signals_args((Class *)class);
        check_public_new((Class *)class);
        check_vararg((Class *)class);
index 764e67841a7d01efb9ae147018d1c84dff22cebc..e5ac102e4103a2215dab333704f308c9f83fdedc 100644 (file)
@@ -1,3 +1,25 @@
+/* GOB C Preprocessor
+ * Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
+ *
+ * Author: George Lebl
+ *
+ * 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 _MAIN_H_
 #define _MAIN_H_
 
@@ -17,6 +39,8 @@ extern gint private_header;
 extern gboolean no_extern_c;
 extern gboolean no_write;
 extern gboolean no_lines;
+extern gboolean no_self_alias;
+extern gboolean no_kill_underscores;
 
 extern char *filename;
 extern char *filebase;
@@ -25,6 +49,7 @@ extern FILE *out;
 extern FILE *outh;
 extern FILE *outph;
 
+extern int method_unique_id;
 
 
 #endif
index 9b63335891798ffda0a061ce246777ca05c99a85..a3b796c8aab6d1db39d922a0e2fadf7544226b01 100644 (file)
@@ -189,7 +189,7 @@ push_function(int scope, int method, char *oid, char *id,
 
        node = new_method(scope, method, type, oid, gtktypes, flags,
                          id, funcargs, onerror, defreturn, c_cbuf, line_no,
-                         ccode_line, vararg);
+                         ccode_line, vararg, method_unique_id++);
 
        if(cbuf)
                g_string_free(cbuf,
@@ -442,9 +442,9 @@ static const short yyrline[] = { 0,
    662,   667,   670,   673,   676,   679,   684,   687,   690,   695,
    696,   700,   712,   718,   730,   742,   745,   751,   756,   759,
    764,   765,   769,   785,   801,   817,   833,   844,   850,   860,
-   881,   892,   911,   917,   918,   924,   925,   936,   946,   949,
-   950,   953,   954,   957,   960,   963,   971,   981,   982,   985,
-   998,  1002,  1006,  1010,  1014,  1018,  1024,  1025,  1029
+   883,   894,   913,   919,   920,   926,   927,   938,   948,   951,
+   952,   955,   956,   959,   962,   965,   973,   983,   984,   987,
+  1000,  1004,  1008,  1012,  1016,  1020,  1026,  1027,  1031
 };
 #endif
 
@@ -1964,14 +1964,16 @@ case 90:
                        } else {
                                g_free(yyvsp[-4].id);
                                g_free(yyvsp[-2].id);
-                               g_string_free(yyvsp[-2].cbuf,TRUE);
-                               yyerror(_("parse error"));
+                               g_string_free(yyvsp[0].cbuf,TRUE);
+                               yyerror(_("parse error "
+                                         "(untyped blocks must be init or "
+                                         "class_init)"));
                                YYERROR;
                        }
                                                ;
     break;}
 case 91:
-#line 881 "parse.y"
+#line 883 "parse.y"
 {
                        g_free(onerror); onerror = NULL;
                        g_free(defreturn); defreturn = NULL;
@@ -1985,7 +1987,7 @@ case 91:
                                        ;
     break;}
 case 92:
-#line 892 "parse.y"
+#line 894 "parse.y"
 {
                        g_free(onerror); onerror = NULL;
                        g_free(defreturn); defreturn = NULL;
@@ -2007,29 +2009,29 @@ case 92:
                                                ;
     break;}
 case 93:
-#line 911 "parse.y"
+#line 913 "parse.y"
 {
                        g_free(onerror); onerror = NULL;
                        g_free(defreturn); defreturn = NULL;
                                        ;
     break;}
 case 94:
-#line 917 "parse.y"
+#line 919 "parse.y"
 { yyval.id = yyvsp[0].id; ;
     break;}
 case 95:
-#line 918 "parse.y"
+#line 920 "parse.y"
 {
                        yyval.id = (yyvsp[1].cbuf)->str;
                        g_string_free(yyvsp[1].cbuf, FALSE);
                                        ;
     break;}
 case 96:
-#line 924 "parse.y"
+#line 926 "parse.y"
 { vararg = FALSE; has_self = FALSE; ;
     break;}
 case 97:
-#line 925 "parse.y"
+#line 927 "parse.y"
 {
                        vararg = FALSE;
                        has_self = TRUE;
@@ -2043,7 +2045,7 @@ case 97:
                                                ;
     break;}
 case 98:
-#line 936 "parse.y"
+#line 938 "parse.y"
 {
                        has_self = TRUE;
                        if(strcmp(yyvsp[-2].id,"self")==0)
@@ -2056,39 +2058,39 @@ case 98:
                                        ;
     break;}
 case 99:
-#line 946 "parse.y"
+#line 948 "parse.y"
 { has_self = FALSE; ;
     break;}
 case 100:
-#line 949 "parse.y"
+#line 951 "parse.y"
 { vararg = TRUE; ;
     break;}
 case 101:
-#line 950 "parse.y"
+#line 952 "parse.y"
 { vararg = FALSE; ;
     break;}
 case 102:
-#line 953 "parse.y"
+#line 955 "parse.y"
 { ; ;
     break;}
 case 103:
-#line 954 "parse.y"
+#line 956 "parse.y"
 { ; ;
     break;}
 case 104:
-#line 957 "parse.y"
+#line 959 "parse.y"
 {
                        push_funcarg(yyvsp[0].id,NULL);
                                                                ;
     break;}
 case 105:
-#line 960 "parse.y"
+#line 962 "parse.y"
 {
                        push_funcarg(yyvsp[-1].id,yyvsp[0].id);
                                                                ;
     break;}
 case 106:
-#line 963 "parse.y"
+#line 965 "parse.y"
 {
                        if(strcmp(yyvsp[-2].id,"check")!=0) {
                                yyerror(_("parse error"));
@@ -2099,7 +2101,7 @@ case 106:
                                                                ;
     break;}
 case 107:
-#line 971 "parse.y"
+#line 973 "parse.y"
 {
                        if(strcmp(yyvsp[-2].id,"check")!=0) {
                                yyerror(_("parse error"));
@@ -2110,15 +2112,15 @@ case 107:
                                                                ;
     break;}
 case 108:
-#line 981 "parse.y"
+#line 983 "parse.y"
 { ; ;
     break;}
 case 109:
-#line 982 "parse.y"
+#line 984 "parse.y"
 { ; ;
     break;}
 case 110:
-#line 985 "parse.y"
+#line 987 "parse.y"
 {
                        if(strcmp(yyvsp[0].id,"type")==0) {
                                Node *node = new_check(TYPE_CHECK,NULL);
@@ -2134,60 +2136,60 @@ case 110:
                                        ;
     break;}
 case 111:
-#line 998 "parse.y"
+#line 1000 "parse.y"
 {
                        Node *node = new_check(GT_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 112:
-#line 1002 "parse.y"
+#line 1004 "parse.y"
 {
                        Node *node = new_check(LT_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 113:
-#line 1006 "parse.y"
+#line 1008 "parse.y"
 {
                        Node *node = new_check(GE_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 114:
-#line 1010 "parse.y"
+#line 1012 "parse.y"
 {
                        Node *node = new_check(LE_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 115:
-#line 1014 "parse.y"
+#line 1016 "parse.y"
 {
                        Node *node = new_check(EQ_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 116:
-#line 1018 "parse.y"
+#line 1020 "parse.y"
 {
                        Node *node = new_check(NE_CHECK,yyvsp[0].id);
                        checks = g_list_append(checks,node);
                                        ;
     break;}
 case 117:
-#line 1024 "parse.y"
+#line 1026 "parse.y"
 { yyval.id = yyvsp[0].id; ;
     break;}
 case 118:
-#line 1025 "parse.y"
+#line 1027 "parse.y"
 {
                        yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
                        g_free(yyvsp[0].id);
                                        ;
     break;}
 case 119:
-#line 1029 "parse.y"
+#line 1031 "parse.y"
 { yyval.id = yyvsp[0].id; ;
     break;}
 }
@@ -2412,5 +2414,5 @@ yyerrhandle:
     }
   return 1;
 }
-#line 1032 "parse.y"
+#line 1034 "parse.y"
 
index 17ab2644b5c59afc5226e431d5694a2e2c78a4d8..f052991ab74f9e93db1be921efe0c17d6a132e15 100644 (file)
@@ -167,7 +167,7 @@ push_function(int scope, int method, char *oid, char *id,
 
        node = new_method(scope, method, type, oid, gtktypes, flags,
                          id, funcargs, onerror, defreturn, c_cbuf, line_no,
-                         ccode_line, vararg);
+                         ccode_line, vararg, method_unique_id++);
 
        if(cbuf)
                g_string_free(cbuf,
@@ -871,8 +871,10 @@ method:            SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc
                        } else {
                                g_free($<id>1);
                                g_free($<id>3);
-                               g_string_free($<cbuf>3,TRUE);
-                               yyerror(_("parse error"));
+                               g_string_free($<cbuf>5,TRUE);
+                               yyerror(_("parse error "
+                                         "(untyped blocks must be init or "
+                                         "class_init)"));
                                YYERROR;
                        }
                                                }
index 8447a9339b0cee51e47eb8dc827b799d40b7c828..d60393060d844f3ddc43716013561505cb2249b8 100644 (file)
@@ -105,7 +105,7 @@ class Gtk:Weird:Button from Gtk:Button {
 
                return ret;
        }
-       private int blah(self, Gtk:Widget * wid (check null type),
+       private int _blah(self, Gtk:Widget * wid (check null type),
                         int h (check > 0)) onerror -1 {
                gtk_container_add(GTK_CONTAINER(self),wid);
 
@@ -127,7 +127,7 @@ class Gtk:Weird:Button from Gtk:Button {
        signal last INT (POINTER, INT)
        int bleh(self, Gtk:Widget * wid (check null type),
                        int h (check > 0)) {
-               return blah(self,wid,h);
+               return _blah(self,wid,h);
        }
        /**
         * gtk_weird_button_bleh2:
@@ -193,8 +193,9 @@ class Gtk:Weird:Button from Gtk:Button {
        void googlegoogle2(self)
        {
                int array[5][8][9]={{{0}}};
+               Self *foo = self;
                puts("TEST2");
-               testprivvirtual(self,array);
+               testprivvirtual(foo, array);
        }
        private signal first NONE (NONE)
        void googlegoogle3(self)
@@ -259,6 +260,14 @@ class Gtk:Weird:Button from Gtk:Button {
        remove(Gtk:Container * self (check null type),
               Gtk:Widget * wid (check null type));
 
+       override(Gtk:Object)
+       void
+       destroy(Gtk:Object * self (check null type))
+       {
+               /* foo bar */
+               PARENT_HANDLER(self);
+       }
+
        protected
        int foobar(self) {
                /* just an empty function */
index e1b2be6db3ec4bf3248b69e476e4382a9bbdf864..7ed35010a7f5e3fca63dbcb822774abf0c2c35d3 100644 (file)
@@ -61,7 +61,7 @@ Node * new_funcarg (Type * atype, char * name, GList * checks)
        return (Node *)self;
 }
 
-Node * new_method (int scope, int method, Type * mtype, char * otype, GList * gtktypes, GList * flags, char * id, GList * args, char * onerror, char * defreturn, char * cbuf, int line_no, int ccode_line, gboolean vararg)
+Node * new_method (int scope, int method, Type * mtype, char * otype, GList * gtktypes, GList * flags, char * id, GList * args, char * onerror, char * defreturn, char * cbuf, int line_no, int ccode_line, gboolean vararg, int unique_id)
 {
        Method * self = g_new0(Method, 1);
        self->type = METHOD_NODE;
@@ -79,6 +79,7 @@ Node * new_method (int scope, int method, Type * mtype, char * otype, GList * gt
        self->line_no = line_no;
        self->ccode_line = ccode_line;
        self->vararg = vararg;
+       self->unique_id = unique_id;
        return (Node *)self;
 }
 
@@ -199,6 +200,7 @@ Method * copy_method (Method * self)
        new->line_no = self->line_no;
        new->ccode_line = self->ccode_line;
        new->vararg = self->vararg;
+       new->unique_id = self->unique_id;
        return new;
 }
 
index e393f7e43c05eb2b8aaa1fa559c62e711001da1c..dc720080b75dd7fcbe878a18ebbcf3dfc7123798 100644 (file)
@@ -98,6 +98,7 @@ CLASS Method
   INT          line_no
   INT          ccode_line
   BOOL         vararg
+  INT          unique_id       # A unique id for new methods
 ENDCLASS
 
 CLASS Variable
index e7c12d557ce9e288494b1b10583ff48217b4007b..974540a01ade1029319d14d6b83a886589862050 100644 (file)
@@ -128,6 +128,7 @@ struct _Method {
        int line_no;
        int ccode_line;
        gboolean vararg;
+       int unique_id;
 };
 
 struct _Type {
@@ -168,7 +169,7 @@ Node * new_ccode (int cctype, char * cbuf, int line_no);
 Node * new_check (int chtype, char * number);
 Node * new_class (char * otype, char * ptype, GList * nodes);
 Node * new_funcarg (Type * atype, char * name, GList * checks);
-Node * new_method (int scope, int method, Type * mtype, char * otype, GList * gtktypes, GList * flags, char * id, GList * args, char * onerror, char * defreturn, char * cbuf, int line_no, int ccode_line, gboolean vararg);
+Node * new_method (int scope, int method, Type * mtype, char * otype, GList * gtktypes, GList * flags, char * id, GList * args, char * onerror, char * defreturn, char * cbuf, int line_no, int ccode_line, gboolean vararg, int unique_id);
 Node * new_type (int stars, char * name, char * postfix);
 Node * new_variable (int scope, Type * vtype, char * id, int line_no, char * destructor, int destructor_line, gboolean destructor_simple, char * initializer, int initializer_line);
 
index 03f1b7135c21e801a101204446085cbdda762749..e47be5ef6110be81001f7c279afdb18571f843c9 100644 (file)
@@ -1,5 +1,6 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
  *
  * Author: George Lebl
  *
@@ -237,3 +238,15 @@ setup_special_array(Class *c, gboolean *special_array)
 
        return any_special;
 }
+
+/* get the id without the first underscore, but only if we're removing them */
+char *
+get_real_id(char *id)
+{
+       if(!no_kill_underscores &&
+          id[0] == '_' &&
+          id[1] != '\0')
+               return &id[1];
+       else
+               return id;
+}
index 8e84318096f107fc10b4d6216ef9a6a6b6685d72..72121ca30a632960b3eb2e58059d0a491614ff04 100644 (file)
@@ -1,5 +1,6 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999-2000 the Free Software Foundation.
+ * Copyright (C) 2000 Eazel, Inc.
  *
  * Author: George Lebl
  *
@@ -50,5 +51,8 @@ enum {
 /* returns TRUE if there are any special types at all */
 gboolean setup_special_array(Class *c, gboolean *special_array);
 
+/* get the id without the first underscore, but only if we're removing them */
+char *get_real_id(char *id);
+
 #endif