gboolean exit_on_warn = FALSE;
gboolean exit_on_error = TRUE;
gboolean got_error = FALSE;
gboolean exit_on_warn = FALSE;
gboolean exit_on_error = TRUE;
gboolean got_error = FALSE;
gboolean no_extern_c = FALSE;
gboolean no_write = FALSE;
gboolean no_lines = FALSE;
gboolean no_extern_c = FALSE;
gboolean no_write = FALSE;
gboolean no_lines = FALSE;
" extentions to make saner, faster code */\n"
"static void\n"
"___%s_really_bad_hack_to_avoid_warnings(void)\n"
" extentions to make saner, faster code */\n"
"static void\n"
"___%s_really_bad_hack_to_avoid_warnings(void)\n"
- out_printf(fp,"\t");
- print_type(fp,v->vtype,FALSE);
- out_printf(fp,"%s%s;",v->id,
+ out_printf(fp, "\t");
+ print_type(fp, v->vtype, FALSE);
+ out_printf(fp, "%s%s;", v->id,
- print_method(outh,"\t/*signal*/","(* ","",") ",";\n",m,
- FALSE,TRUE);
+ print_method(outh, "\t/*signal*/", "(* ", "", ") ", ";\n", m,
+ FALSE, TRUE);
- print_method(outh,"\t","(* ","",") ",";\n",m,FALSE,TRUE);
+ print_method(outh, "\t", "(* ", "", ") ", ";\n", m, FALSE, TRUE);
- print_method(outh,"","\t","","\t",";\n",m,TRUE,FALSE);
+ print_method(outh, "", "\t", "", "\t", ";\n", m, TRUE, FALSE);
- print_method(outph,"","\t","","\t",";\n",m,FALSE,FALSE);
+ print_method(outph, "", "\t", "", "\t", ";\n", m, FALSE, FALSE);
- print_method(out,"","\t","","\t",";\n",m,FALSE,FALSE);
+ print_method(out, "", "\t", "", "\t", ";\n", m, FALSE, FALSE);
- type = new_type(1,tn,NULL);
- node = new_funcarg((Type *)type,name,NULL);
+ type = new_type(1, tn, NULL);
+ node = new_funcarg((Type *)type, name, NULL);
- (Type *)new_type(0, g_strdup("void"),NULL),
+ (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, g_strdup("class_init"),
make_func_arg(cl->otype, TRUE, g_strdup("c")),
NULL, NULL, NULL, 0, 0, FALSE);
- (Type *)new_type(0, g_strdup("void"),NULL),
+ (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, g_strdup("init"),
make_func_arg(cl->otype, FALSE, g_strdup("o")),
NULL, NULL, NULL, 0, 0, FALSE);
- (Type *)new_type(0,g_strdup("void"),NULL),
+ (Type *)new_type(0, g_strdup("void"), NULL),
g_strdup("Gtk:Object"),
NULL, NULL, g_strdup("finalize"),
g_strdup("Gtk:Object"),
NULL, NULL, g_strdup("finalize"),
- make_func_arg("Gtk:Object",FALSE,g_strdup("o")),
+ make_func_arg("Gtk:Object", FALSE, g_strdup("o")),
is_list_equal(GList *a, GList *b)
{
for(;a && b; a=a->next, b=b->next) {
is_list_equal(GList *a, GList *b)
{
for(;a && b; a=a->next, b=b->next) {
- for(i=0,li=m->gtktypes->next;li;
- i++,li=g_list_next(li)) {
+ for(i=0, li=m->gtktypes->next;li;
+ i++, li=g_list_next(li)) {
if(!for_cpp)
out_printf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
if(!for_cpp)
out_printf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
else {
out_printf(out, ",\n\t\t(%s)"
"GTK_VALUE_%s(args[%d])",
get_cast(li->data, FALSE),
else {
out_printf(out, ",\n\t\t(%s)"
"GTK_VALUE_%s(args[%d])",
get_cast(li->data, FALSE),
if(strcmp(m->gtktypes->data, "NONE")==0 &&
strcmp(m->gtktypes->next->data, "NONE")==0)
if(strcmp(m->gtktypes->data, "NONE")==0 &&
strcmp(m->gtktypes->next->data, "NONE")==0)
- s = g_hash_table_lookup(marsh,mm);
- g_hash_table_insert(marsh,m,s);
+ s = g_hash_table_lookup(marsh, mm);
+ g_hash_table_insert(marsh, m, s);
g_hash_table_insert(marsh, m, s);
eq_signal_methods = g_list_prepend(eq_signal_methods, m);
g_hash_table_insert(marsh, m, s);
eq_signal_methods = g_list_prepend(eq_signal_methods, m);
"___marshal_%s (GtkObject * object,\n"
"\tGtkSignalFunc func,\n"
"\tgpointer func_data,\n"
"\tGtkArg * args)\n"
"___marshal_%s (GtkObject * object,\n"
"\tGtkSignalFunc func,\n"
"\tgpointer func_data,\n"
"\tGtkArg * args)\n"
if(strcmp(m->gtktypes->data, "NONE")==0) {
out_printf(out, "\t___%s rfunc;\n\n"
if(strcmp(m->gtktypes->data, "NONE")==0) {
out_printf(out, "\t___%s rfunc;\n\n"
- out_printf(out,"\t%s_SIGNAL,\n",s);
+ out_printf(out, "\t%s_SIGNAL,\n", s);
for(li=c->nodes;li;li=g_list_next(li)) {
Node *n = li->data;
if(n->type == ARGUMENT_NODE) {
Argument *a = (Argument *)n;
char *s = g_strdup(a->name);
g_strup(s);
for(li=c->nodes;li;li=g_list_next(li)) {
Node *n = li->data;
if(n->type == ARGUMENT_NODE) {
Argument *a = (Argument *)n;
char *s = g_strdup(a->name);
g_strup(s);
- out_printf(out,",\n\tARG_%s",s);
+ out_printf(out, ",\n\tARG_%s", s);
"static guint object_signals[LAST_SIGNAL] = {0};\n\n");
out_printf(out, "/* pointer to the class of our parent */\n");
"static guint object_signals[LAST_SIGNAL] = {0};\n\n");
out_printf(out, "/* pointer to the class of our parent */\n");
- funcbase,typebase,typebase,typebase,
- funcbase,funcbase,pfuncbase);
+ funcbase, typebase, typebase, typebase,
+ funcbase, funcbase, pfuncbase);
if(g_hash_table_lookup(marsh, m))
mar = g_strconcat("___marshal_",
if(g_hash_table_lookup(marsh, m))
mar = g_strconcat("___marshal_",
"\t\tgtk_signal_new (\"%s\",\n"
"\t\t\t(GtkSignalRunType)(%s),\n"
"\t\t\tgtk_object_class->type,\n"
"\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
"\t\t\t%s,\n"
"\t\t\tGTK_TYPE_%s, %d",
"\t\tgtk_signal_new (\"%s\",\n"
"\t\t\t(GtkSignalRunType)(%s),\n"
"\t\t\tgtk_object_class->type,\n"
"\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
"\t\t\t%s,\n"
"\t\t\tGTK_TYPE_%s, %d",
- typebase,m->id,mar,(char *)m->gtktypes->data,
+ typebase, m->id, mar, (char *)m->gtktypes->data,
- out_printf(out,",\n\t\t\tGTK_TYPE_%s",
+ out_printf(out, ",\n\t\t\tGTK_TYPE_%s",
s, m->id, funcbase, m->id);
else
s, m->id, funcbase, m->id);
else
oname, m->id, funcbase, m->id);
else
oname, m->id, funcbase, m->id);
else
- if(strcmp(flag,"READWRITE")==0 ||
- strcmp(flag,"READABLE")==0 ||
- strcmp(flag,"WRITABLE")==0) {
- print_error(TRUE,"READWRITE, READABLE and "
+ if(strcmp(flag, "READWRITE")==0 ||
+ strcmp(flag, "READABLE")==0 ||
+ strcmp(flag, "WRITABLE")==0) {
+ print_error(TRUE, "READWRITE, READABLE and "
s = g_strdup_printf("Unknown flag '%s' used, "
"perhaps it was misspelled",
flag);
s = g_strdup_printf("Unknown flag '%s' used, "
"perhaps it was misspelled",
flag);
print_method(out, "static ", "\n", "", " ", "\n",
m, FALSE, FALSE);
if(m->line_no > 0)
out_addline_outfile(out);
print_method(out, "static ", "\n", "", " ", "\n",
m, FALSE, FALSE);
if(m->line_no > 0)
out_addline_outfile(out);
"g_new0 (%sPrivate, 1);\n",
((FuncArg *)m->args->data)->name,
typebase);
"g_new0 (%sPrivate, 1);\n",
((FuncArg *)m->args->data)->name,
typebase);
add_overrides(c,
((FuncArg *)m->args->data)->name,
(signals>0 || arguments>0));
add_overrides(c,
((FuncArg *)m->args->data)->name,
(signals>0 || arguments>0));
+
+ if(initializers > 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)
+ continue;
+ print_initializer(m, v);
+ }
+ }
- out_printf(out,"(%sClass *)",ptypebase);
- out_printf(out,"gtk_type_class (%s_get_type ());\n",
+ out_printf(out, "(%sClass *)", ptypebase);
+ out_printf(out, "gtk_type_class (%s_get_type ());\n",
- out_printf(out," {\n");
- out_addline_infile(out,m->ccode_line);
- out_printf(out,"%s\n",m->cbuf);
+ out_printf(out, " {\n");
+ out_addline_infile(out, m->ccode_line);
+ out_printf(out, "%s\n", m->cbuf);
- out_printf(out,"\nstatic void\n"
- "___object_%s_arg (GtkObject *object,\n"
- "\tGtkArg *arg,\n"
- "\tguint arg_id)\n"
- "{\n"
- "\t%s *self;\n\n"
- "\tself = %s (object);\n\n"
- "\tswitch (arg_id) {\n",
- is_set?"set":"get",typebase,macrobase);
+ out_printf(out, "\nstatic void\n"
+ "___object_%s_arg (GtkObject *object,\n"
+ "\tGtkArg *arg,\n"
+ "\tguint arg_id)\n"
+ "{\n"
+ "\t%s *self;\n\n"
+ "\tself = %s (object);\n\n"
+ "\tswitch (arg_id) {\n",
+ is_set?"set":"get", typebase, macrobase);
out_printf(out, "#define ARG "
"((%s)GTK_VALUE_%s(*arg))\n",
cast, a->gtktype);
out_printf(out, "#define ARG "
"((%s)GTK_VALUE_%s(*arg))\n",
cast, a->gtktype);
- out_printf(out,"%s < %s",fa->name,ch->number);
+ out_printf(out, "%s < %s", fa->name, ch->number);
- out_printf(out,"%s > %s",fa->name,ch->number);
+ out_printf(out, "%s > %s", fa->name, ch->number);
- out_printf(out,"%s <= %s",fa->name,ch->number);
+ out_printf(out, "%s <= %s", fa->name, ch->number);
- out_printf(out,"%s >= %s",fa->name,ch->number);
+ out_printf(out, "%s >= %s", fa->name, ch->number);
- out_printf(out,"%s == %s",fa->name,ch->number);
+ out_printf(out, "%s == %s", fa->name, ch->number);
- out_printf(out,"%s != %s",fa->name,ch->number);
+ out_printf(out, "%s != %s", fa->name, ch->number);
if(m->method == OVERRIDE_METHOD &&
strcmp(m->id, "finalize")==0) {
if(privates > 0 || destructors > 0) {
if(m->method == OVERRIDE_METHOD &&
strcmp(m->id, "finalize")==0) {
if(privates > 0 || destructors > 0) {
- if(n->type == VARIABLE_NODE)
- print_destructor("___self",
- (Variable *)n);
+ Variable *v = (Variable *)n;
+ if(n->type == VARIABLE_NODE &&
+ v->scope != CLASS_SCOPE)
+ print_destructor("___self", v);
"\t___self->_priv = NULL;\n",
macrobase,
((FuncArg *)m->args->data)->name,
"\t___self->_priv = NULL;\n",
macrobase,
((FuncArg *)m->args->data)->name,
- out_printf(out,",\n\t\t(%s)%s",cast,
+ out_printf(out, ",\n\t\t(%s)%s", cast,
doc = get_gtk_doc(m->id);
if(doc) {
out_printf(out, "%s", doc);
doc = get_gtk_doc(m->id);
if(doc) {
out_printf(out, "%s", doc);
- print_method(out,"static ","\n",""," ","\n",
- m,FALSE,FALSE);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
else /* PUBLIC, PROTECTED */
print_method(out, "", "\n", "", " ", "\n",
m, FALSE, FALSE);
else /* PUBLIC, PROTECTED */
print_method(out, "", "\n", "", " ", "\n",
m, FALSE, FALSE);
- print_method(out,"static ","\n",""," ","\n",
- m,FALSE,FALSE);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
- print_method(out,"","\n",""," ","\n",m,FALSE,FALSE);
+ print_method(out, "", "\n", "", " ", "\n", m, FALSE, FALSE);
- out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n___real_",""," ","\n",
- m,FALSE,FALSE);
- print_method_body(m,FALSE);
+ out_addline_infile(out, m->line_no);
+ print_method(out, "static ", "\n___real_", "", " ", "\n",
+ m, FALSE, FALSE);
+ print_method_body(m, FALSE);
- print_method(out,"static ","\n",""," ","\n",
- m,FALSE,FALSE);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
- print_method(out,"","\n",""," ","\n",m,FALSE,FALSE);
+ print_method(out, "", "\n", "", " ", "\n", m, FALSE, FALSE);
- out_printf(out,"\t\t(*klass->%s)(%s",m->id,
+ out_printf(out, "\t\t(*klass->%s)(%s", m->id,
- out_printf(out,",%s",fa->name);
+ out_printf(out, ",%s", fa->name);
- out_printf(out, "\t\treturn (*klass->%s)(%s",m->id,
+ out_printf(out, "\t\treturn (*klass->%s)(%s", m->id,
- out_printf(out,",%s",fa->name);
+ out_printf(out, ",%s", fa->name);
- out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n___real_",""," ","\n",
- m,FALSE,FALSE);
- print_method_body(m,FALSE);
+ out_addline_infile(out, m->line_no);
+ print_method(out, "static ", "\n___real_", "", " ", "\n",
+ m, FALSE, FALSE);
+ print_method_body(m, FALSE);
- out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n",""," ","\n",
- m,FALSE,FALSE);
- s = replace_sep(m->otype,'_');
+ out_addline_infile(out, m->line_no);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
+ s = replace_sep(m->otype, '_');
"\t{ if(%s_CLASS(parent_class)->%s) \\\n"
"\t\t(* %s_CLASS(parent_class)->%s)(%s); }\n",
"\t{ if(%s_CLASS(parent_class)->%s) \\\n"
"\t\t(* %s_CLASS(parent_class)->%s)(%s); }\n",
- args,s,m->id,s,m->id,args);
+ args, s, m->id, s, m->id, args);
- args,s,m->id,s,m->id,args);
- out_printf(out,"(");
- print_type(out,m->mtype,TRUE);
- out_printf(out,")%s))\n",
+ args, s, m->id, s, m->id, args);
+ out_printf(out, "(");
+ print_type(out, m->mtype, TRUE);
+ out_printf(out, ")%s))\n",
- print_method_body(m,TRUE);
- out_printf(out,"#undef PARENT_HANDLER\n");
+ print_method_body(m, TRUE);
+ out_printf(out, "#undef PARENT_HANDLER\n");
- outfileh = g_strconcat("#gob#",filebase,".h#gob#",NULL);
+ outfileh = g_strconcat("#gob#", filebase, ".h#gob#", NULL);
out_printf(outh, "\n/*\n"
" * Type checking and casting macros\n"
" */\n");
out_printf(outh, "\n/*\n"
" * Type checking and casting macros\n"
" */\n");
- macrotype,funcbase);
- out_printf(outh,"#define %s(obj)\t"
- "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n",
- macrobase,funcbase,typebase);
- out_printf(outh,"#define %s_CLASS(klass)\t"
+ macrotype, funcbase);
+ out_printf(outh, "#define %s(obj)\t"
+ "GTK_CHECK_CAST((obj), %s_get_type(),%s)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CLASS(klass)\t"
"GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n",
"GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n",
- macrobase,funcbase,typebase);
- out_printf(outh,"#define %s(obj)\t"
- "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
- macrois,funcbase);
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s(obj)\t"
+ "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, "/* self casting macros */\n");
out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
}
out_printf(outh, "\n/*\n"
" * Main object structure\n"
" */\n");
}
out_printf(outh, "\n/*\n"
" * Main object structure\n"
" */\n");
- out_printf(outh,"#ifndef __TYPEDEF_%s__\n"
- "#define __TYPEDEF_%s__\n",s,s);
+ out_printf(outh, "#ifndef __TYPEDEF_%s__\n"
+ "#define __TYPEDEF_%s__\n", s, s);
- out_printf(outh,"typedef struct _%s %s;\n"
- "#endif\n",typebase,typebase);
- out_printf(outh,"struct _%s {\n\t%s __parent__;\n",
- typebase,ptypebase);
+ out_printf(outh, "typedef struct _%s %s;\n"
+ "#endif\n", typebase, typebase);
+ out_printf(outh, "struct _%s {\n\t%s __parent__;\n",
+ typebase, ptypebase);
- out_printf(outh,"\t/*< private >*/\n");
- out_printf(outh,"\t%sPrivate *_priv;\n",typebase);
+ out_printf(outh, "\t/*< private >*/\n");
+ out_printf(outh, "\t%sPrivate *_priv;\n", typebase);
typebase);
for(l=c->nodes;l;l=l->next) {
Node *n = l->data;
Variable *v = (Variable *)n;
if(n->type == VARIABLE_NODE &&
v->scope == PRIVATE_SCOPE) {
typebase);
for(l=c->nodes;l;l=l->next) {
Node *n = l->data;
Variable *v = (Variable *)n;
if(n->type == VARIABLE_NODE &&
v->scope == PRIVATE_SCOPE) {
- out_addline_infile(outfp,v->line_no);
- put_variable(v,outfp);
+ out_addline_infile(outfp, v->line_no);
+ put_variable(v, outfp);
for(l=c->nodes;l;l=g_list_next(l)) {
Node *n = l->data;
if(n->type == METHOD_NODE)
put_vs_method((Method *)n);
}
for(l=c->nodes;l;l=g_list_next(l)) {
Node *n = l->data;
if(n->type == METHOD_NODE)
put_vs_method((Method *)n);
}
- out_printf(outh,"};\n\n");
+ /* put class scope variables */
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->data;
+ Variable *v = (Variable *)n;
+ if(n->type == VARIABLE_NODE &&
+ v->scope == CLASS_SCOPE)
+ put_variable((Variable *)n, outh);
+ }
+ out_printf(outh, "};\n\n");
"(GtkObject *object, GtkArg *arg, "
"guint arg_id);\n"
"static void ___object_get_arg "
"(GtkObject *object, GtkArg *arg, "
"guint arg_id);\n"
"static void ___object_get_arg "
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
" */\n");
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
" */\n");
} else if(arguments>0 && no_gnu) {
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
} else if(arguments>0 && no_gnu) {
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
if(outph) {
p = g_strconcat(filebase, "-private.h", NULL);
if(!g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
if(outph) {
p = g_strconcat(filebase, "-private.h", NULL);
if(!g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
- fprintf(stderr,"Gob version %s\n\n",VERSION);
- fprintf(stderr,"Options:\n"
+ fprintf(stderr, "Gob version %s\n\n", VERSION);
+ fprintf(stderr, "Options:\n"
"\t--help,-h,-? Display this help\n"
"\t--version Display version\n"
"\t--exit-on-warn,-w Exit with an error on warnings\n"
"\t--help,-h,-? Display this help\n"
"\t--version Display version\n"
"\t--exit-on-warn,-w Exit with an error on warnings\n"
"\t--no-private-header Don't create a private header, "
"put private\n"
"\t structure and protected "
"\t--no-private-header Don't create a private header, "
"put private\n"
"\t structure and protected "
fprintf(stderr, "Gob version %s\n", VERSION);
exit(0);
} else if(strcmp(argv[i], "--exit-on-warn")==0) {
fprintf(stderr, "Gob version %s\n", VERSION);
exit(0);
} else if(strcmp(argv[i], "--exit-on-warn")==0) {
} else if(strcmp(argv[i], "--no-gnu")==0) {
no_gnu = TRUE;
} else if(strcmp(argv[i], "--no-extern-c")==0) {
} else if(strcmp(argv[i], "--no-gnu")==0) {
no_gnu = TRUE;
} else if(strcmp(argv[i], "--no-extern-c")==0) {
} else if(strcmp(argv[i], "--")==0) {
/*further arguments are files*/
no_opts = TRUE;
} else if(strcmp(argv[i], "--")==0) {
/*further arguments are files*/
no_opts = TRUE;
char *hfnew = g_strconcat("#gob#", filebase, ".h#gob#", NULL);
char *hf = g_strconcat(filebase, ".h", NULL);
struct stat s;
char *hfnew = g_strconcat("#gob#", filebase, ".h#gob#", NULL);
char *hf = g_strconcat(filebase, ".h", NULL);
struct stat s;