From 714b58ab4606ed4d40cec3702cb378938f8c883f Mon Sep 17 00:00:00 2001 From: George Lebl Date: Mon, 26 Feb 2001 00:10:00 -0800 Subject: [PATCH] Release 1.0.7 --- ChangeLog | 11 +++++++++++ NEWS | 3 +++ TODO | 4 ++++ configure | 2 +- configure.in | 2 +- doc/gob.1.in | 18 ++++++++++++++++++ gob.spec | 2 +- src/checks.c | 24 ++++++++++++++++++++++++ src/checks.h | 1 + src/main.c | 9 ++++++--- src/test.gob | 25 +++++++++++++++++++++++++ 11 files changed, 95 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 944435a..b4190e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sun Feb 25 17:17:46 2001 George Lebl + + * Release 1.0.7 + +Sun Feb 25 16:57:45 2001 George Lebl + + * src/main.c, src/checks.c: to make doing BonoboXObjects possible + allow overriding the _get_type function. + + * doc/gob.1.in: document the above + Sun Feb 11 16:33:07 2001 George Lebl * Release 1.0.6 diff --git a/NEWS b/NEWS index f851976..045c60f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.0.7 + * allow overriding of get_type (allows BonoboXObject) + 1.0.6 * works with new gcc better * signal connection typesafety macros diff --git a/TODO b/TODO index 99f0ab3..24bf3e0 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,7 @@ Allow math expressions in array definition test out the possibility of doing the static typesafe downcasts, at least for gob objects. + +override geT_type + +Support BonoboXObject directly diff --git a/configure b/configure index 84cca28..d013f62 100755 --- a/configure +++ b/configure @@ -703,7 +703,7 @@ fi PACKAGE=gob -VERSION=1.0.6 +VERSION=1.0.7 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; } diff --git a/configure.in b/configure.in index 7f075ca..91e1277 100644 --- a/configure.in +++ b/configure.in @@ -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,1.0.6) +AM_INIT_AUTOMAKE(gob,1.0.7) dnl dnl An utter hack to allow embedding of gob inside other packages. diff --git a/doc/gob.1.in b/doc/gob.1.in index d5d817b..81aa107 100644 --- a/doc/gob.1.in +++ b/doc/gob.1.in @@ -824,6 +824,24 @@ use the full name of the method inside your code. Also note that gob does not use any C++ features, this option will just make the generated code compile with a C++ compiler. +.SH OVERRIDING THE GET_TYPE METHOD +.PP +The get_type is not really a method, but a function which initializes your +object. Recently objects appeared which require you to make a custom +get_type function (BonoboXObject currently). So in 1.0.7 it is now possible +to override this function. To do so, just define a new public method called +get_type, with no arguments. Example: +.nf + + public GtkType + get_type (void) + { + /* code goes here */ + return some_type; + } + +.fi + .SH IDENTIFIER CONFLICTS .PP Gob will need to define some local variables and functions in the generated diff --git a/gob.spec b/gob.spec index 5301909..06064db 100644 --- a/gob.spec +++ b/gob.spec @@ -1,4 +1,4 @@ -%define ver 1.0.6 +%define ver 1.0.7 %define rel 1 %define prefix /usr diff --git a/src/checks.c b/src/checks.c index 2bb3b69..062d635 100644 --- a/src/checks.c +++ b/src/checks.c @@ -582,3 +582,27 @@ count_initializers(Class *c) } return num; } + +gboolean +find_get_type (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 && + strcmp (m->id, "get_type") == 0) { + if (m->method != REGULAR_METHOD || + m->scope != PUBLIC_SCOPE || + m->args != NULL) { + error_printf (GOB_ERROR, m->line_no, + "get_type method must be a " + "regular public method with " + "no arguments"); + } + return TRUE; + } + } + + return FALSE; +} diff --git a/src/checks.h b/src/checks.h index ef71b47..7966f17 100644 --- a/src/checks.h +++ b/src/checks.h @@ -43,5 +43,6 @@ int count_privates(Class *c); int count_protecteds(Class *c); int count_destructors(Class *c); int count_initializers(Class *c); +gboolean find_get_type (Class *c); #endif diff --git a/src/main.c b/src/main.c index 6b233d7..d94361a 100644 --- a/src/main.c +++ b/src/main.c @@ -67,6 +67,7 @@ static int privates = 0; /* number of private data members */ static int protecteds = 0; /* number of protected methods */ static int destructors = 0; /* number of variable destructors */ static int initializers = 0; /* number of variable initializers */ +static gboolean overrode_get_type = FALSE; /* provided your won _get_type */ static gboolean made_aliases = FALSE; /* if we made any shorthand aliases and need the REALLY UGLY HACK to @@ -818,8 +819,8 @@ add_get_type(void) "GtkType\n" "%s_get_type (void)\n" "{\n" - "\tstatic guint type = 0;\n\n" - "\tif ( ! type) {\n" + "\tstatic GtkType type = 0;\n\n" + "\tif (type == 0) {\n" "\t\tstatic const GtkTypeInfo info = {\n" "\t\t\t\"%s\",\n" "\t\t\tsizeof (%s),\n" @@ -2358,7 +2359,8 @@ print_class_block(Class *c) add_enums(c); - add_get_type(); + if ( ! overrode_get_type) + add_get_type(); if(any_method_to_alias(c)) { if( ! no_gnu) { @@ -2773,6 +2775,7 @@ main(int argc, char *argv[]) protecteds = count_protecteds((Class *)class); destructors = count_destructors((Class *)class); initializers = count_initializers((Class *)class); + overrode_get_type = find_get_type((Class *)class); make_bases(); make_inits((Class *)class); diff --git a/src/test.gob b/src/test.gob index 432f471..9ea1d90 100644 --- a/src/test.gob +++ b/src/test.gob @@ -60,6 +60,7 @@ void bubu(void); %} class Gtk:Weird:Button from Gtk:Button { + public int test_array[TEST_ARRAY]; public int i; argument INT i set { self->i = ARG; } get { ARG = self->i; } ; @@ -406,6 +407,30 @@ class Gtk:Weird:Button from Gtk:Button { method_with_no_arguments (); } + /* this is to test custom get_type */ + /*public GtkType + get_type (void) + { + static guint type = 0; + + if ( ! type) { + static const GtkTypeInfo info = { + "GtkWeirdButton", + sizeof (GtkWeirdButton), + sizeof (GtkWeirdButtonClass), + (GtkClassInitFunc) gtk_weird_button_class_init, + (GtkObjectInitFunc) gtk_weird_button_init, + NULL, + NULL, + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (gtk_button_get_type(), &info); + } + + return type; + }*/ + /* testing empty statements */ ; -- 2.43.0