+Sun Feb 25 17:17:46 2001 George Lebl <jirka@5z.com>
+
+ * Release 1.0.7
+
+Sun Feb 25 16:57:45 2001 George Lebl <jirka@5z.com>
+
+ * 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 <jirka@5z.com>
* Release 1.0.6
+1.0.7
+ * allow overriding of get_type (allows BonoboXObject)
+
1.0.6
* works with new gcc better
* signal connection typesafety macros
test out the possibility of doing the static typesafe downcasts, at least
for gob objects.
+
+override geT_type
+
+Support BonoboXObject directly
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; }
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.
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
-%define ver 1.0.6
+%define ver 1.0.7
%define rel 1
%define prefix /usr
}
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;
+}
int count_protecteds(Class *c);
int count_destructors(Class *c);
int count_initializers(Class *c);
+gboolean find_get_type (Class *c);
#endif
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
"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"
add_enums(c);
- add_get_type();
+ if ( ! overrode_get_type)
+ add_get_type();
if(any_method_to_alias(c)) {
if( ! no_gnu) {
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);
%}
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; } ;
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 */
;