#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <stdlib.h>
#include <sys/stat.h>
#include "tree.h"
extern GList *include_files;
+extern GHashTable *gtk_doc_hash;
+
char *filebase;
static char *funcbase;
static char *pfuncbase;
return s;
}
+static char *
+get_gtk_doc(char *id)
+{
+ char *val, *s;
+
+ if(!gtk_doc_hash)
+ return NULL;
+
+ 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);
+ 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);
+ return NULL;
+}
+
static void
print_type(FILE *fp, Type *t, gboolean postfix_to_stars)
{
static void
print_method(FILE *fp, char *typeprefix, char *nameprefix,
- char *namepostfix,char *postfix, Method *m,
+ char *subnameprefix,
+ char *namepostfix, char *postfix, Method *m,
+ gboolean one_arg_per_line,
gboolean no_funcbase)
{
GList *li;
out_printf(fp,"%s",typeprefix);
print_type(fp,m->mtype,TRUE);
if(no_funcbase)
- out_printf(fp,"%s%s%s(",
- nameprefix,m->id,namepostfix);
+ out_printf(fp,"%s%s%s%s(",
+ nameprefix,subnameprefix,m->id,namepostfix);
else
- out_printf(fp,"%s%s_%s%s(",
- nameprefix,funcbase,m->id,namepostfix);
+ out_printf(fp,"%s%s_%s%s%s(",
+ nameprefix,funcbase,subnameprefix,m->id,
+ namepostfix);
if(m->args) {
for(li=m->args;li;li=g_list_next(li)) {
FuncArg *arg = li->data;
print_type(fp,arg->atype,FALSE);
if(li->next)
- out_printf(fp,"%s%s, ",arg->name,
+ out_printf(fp,"%s%s,%s",arg->name,
arg->atype->postfix?
- arg->atype->postfix:"");
+ arg->atype->postfix:"",
+ one_arg_per_line?"\n\t\t\t\t\t":" ");
else
out_printf(fp,"%s%s",arg->name,
arg->atype->postfix?
arg->atype->postfix:"");
}
if(m->vararg)
- out_printf(fp,", ...");
+ out_printf(fp,",%s...",
+ one_arg_per_line?"\n\t\t\t\t\t":" ");
} else {
out_printf(fp,"void");
}
if(for_cpp && strcmp(m->id,"new")==0)
continue;
- print_method(out,"static ","(* ",") ","",m,TRUE);
+ print_method(out,"static ","(* ","",") ","",m,FALSE,TRUE);
out_printf(out," = %s_%s;\n",funcbase,m->id);
made_aliases = TRUE;
m->method != VIRTUAL_METHOD)
return;
- print_method(outh,"\t","(* ",") ",";\n",m,TRUE);
+ /* if a signal mark it as such */
+ if(m->method != VIRTUAL_METHOD)
+ print_method(outh,"\t/*signal*/","(* ","",") ",";\n",m,
+ FALSE,TRUE);
+ else
+ print_method(outh,"\t","(* ","",") ",";\n",m,FALSE,TRUE);
}
static void
if(m->scope != PUBLIC_SCOPE)
return;
- print_method(outh,"","\t","\t",";\n",m,FALSE);
+ print_method(outh,"","\t","","\t",";\n",m,TRUE,FALSE);
}
+/* I'm starting not to like this idea */
+#if 0
+static void
+put_signal_connect(Method *m)
+{
+ if(m->method != SIGNAL_LAST_METHOD &&
+ m->method != SIGNAL_FIRST_METHOD)
+ return;
+
+ out_printf(outh, "guint \t%s_%s__connect_full\t(%s *object,\n"
+ "\t\t\t\t\tconst char *name,\n"
+ "\t\t\t\t\tGtkSignalFunc func,\n"
+ "\t\t\t\t\tGtkCallbackMarshal marshal,\n"
+ "\t\t\t\t\tgpointer data,\n"
+ "\t\t\t\t\tGtkDestroyNotify destroy_func,\n"
+ "\t\t\t\t\tgboolean object_signal,\n"
+ "\t\t\t\t\tgboolean after);\n",
+ funcbase, m->id, typebase);
+
+ out_printf(outh, "#define %s_%s__connect(object,name,func,data) "
+ "%s_%s__connect_full((object),(name),(func),NULL,"
+ "(data),NULL,FALSE,FALSE)\n",
+ funcbase, m->id, funcbase, m->id);
+ out_printf(outh, "#define %s_%s__connect_after(object,name,func,data) "
+ "%s__connect_%s_full((object),(name),(func),NULL,"
+ "(data),NULL,FALSE,TRUE)\n",
+ funcbase, m->id, funcbase, m->id);
+
+ out_printf(outh, "guint \t%s_%s__connect_while_alive\t(%s *object,\n"
+ "\t\t\t\t\tconst char *name,\n"
+ "\t\t\t\t\tGtkSignalFunc func,\n"
+ "\t\t\t\t\tgpointer data,\n"
+ "\t\t\t\t\tGtkObject *alive_object);\n\n",
+ funcbase, m->id, typebase);
+}
+#endif
+
+
static void
put_prot_method(Method *m)
{
return;
if(outph)
- print_method(outph,"","\t","\t",";\n",m,FALSE);
+ print_method(outph,"","\t","","\t",";\n",m,FALSE,FALSE);
else
- print_method(out,"","\t","\t",";\n",m,FALSE);
+ print_method(out,"","\t","","\t",";\n",m,FALSE,FALSE);
}
static void
m->method == SIGNAL_FIRST_METHOD ||
m->method == VIRTUAL_METHOD) {
if(m->cbuf)
- print_method(out,"static ","___real_"," ",";\n",m,FALSE);
+ print_method(out,
+ "static ", "___real_", "", " ", ";\n",
+ m, FALSE, FALSE);
}
if(m->scope == PRIVATE_SCOPE ||
m->method == CLASS_INIT_METHOD ||
(m->method == OVERRIDE_METHOD &&
m->cbuf))
- print_method(out,"static ",""," ",
- no_gnu?";\n":" ___NO_UNUSED_WARNING;\n"
- ,m,FALSE);
+ print_method(out, "static ", "", "", " ",
+ no_gnu?";\n":" G_GNUC_UNUSED;\n",
+ m, FALSE, FALSE);
}
static GList *
GHashTable *done;
char *s;
- done = g_hash_table_new(g_str_hash,g_str_equal);
+ done = g_hash_table_new(g_str_hash, g_str_equal);
if(did_gtk_obj) {
s = g_strdup("GtkObject"); /* This was already done */
- g_hash_table_insert(done,s,s);
+ g_hash_table_insert(done, s, s);
}
- for(li=c->nodes;li;li=g_list_next(li)) {
+ for(li=c->nodes; li; li=g_list_next(li)) {
Node *n = li->data;
char *f;
Method *m = (Method *)n;
if(m->method == INIT_METHOD) {
if(m->line_no>0)
out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n"," ","\n",m,FALSE);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
if(m->line_no>0)
out_addline_outfile(out);
out_printf(out,"{\n");
}
} else if(m->method == CLASS_INIT_METHOD) {
if(m->line_no>0)
- out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n"," ","\n",m,FALSE);
+ out_addline_infile(out, m->line_no);
+ print_method(out, "static ", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
if(m->line_no>0)
out_addline_outfile(out);
out_printf(out,"{\n");
static void
put_method(Method *m)
{
- char *s,*args;
+ char *s,*args,*doc;
gboolean is_void;
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);
+ }
switch(m->method) {
case REGULAR_METHOD:
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);
+ print_method(out,"static ","\n",""," ","\n",
+ m,FALSE,FALSE);
else /* PUBLIC, PROTECTED */
- print_method(out,"","\n"," ","\n",m,FALSE);
+ print_method(out, "", "\n", "", " ", "\n",
+ m, FALSE, FALSE);
print_method_body(m,TRUE);
break;
case SIGNAL_FIRST_METHOD:
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);
- else
- print_method(out,"","\n"," ","\n",m,FALSE);
+ print_method(out,"static ","\n",""," ","\n",
+ m,FALSE,FALSE);
+ else /* PUBLIC, PROTECTED */
+ print_method(out,"","\n",""," ","\n",m,FALSE,FALSE);
out_addline_outfile(out);
out_printf(out,"{\n");
s = g_strdup(m->id);
break;
if(m->line_no>0)
out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n___real_"," ","\n",m,FALSE);
+ print_method(out,"static ","\n___real_",""," ","\n",
+ m,FALSE,FALSE);
print_method_body(m,FALSE);
break;
case VIRTUAL_METHOD:
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);
- else
- print_method(out,"","\n"," ","\n",m,FALSE);
+ print_method(out,"static ","\n",""," ","\n",
+ m,FALSE,FALSE);
+ else /* PUBLIC, PROTECTED */
+ print_method(out,"","\n",""," ","\n",m,FALSE,FALSE);
out_addline_outfile(out);
out_printf(out,"{\n"
"\t%sClass *klass;\n",typebase);
break;
if(m->line_no>0)
out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n___real_"," ","\n",m,FALSE);
+ print_method(out,"static ","\n___real_",""," ","\n",
+ m,FALSE,FALSE);
print_method_body(m,FALSE);
break;
case OVERRIDE_METHOD:
break;
if(m->line_no>0)
out_addline_infile(out,m->line_no);
- print_method(out,"static ","\n"," ","\n",m,FALSE);
+ print_method(out,"static ","\n",""," ","\n",
+ m,FALSE,FALSE);
s = replace_sep(m->otype,'_');
g_strup(s);
args = get_arg_names_for_macro(m);
"gpointer c; "
"} ___threepointertype;\n");
- out_printf(outh,"\n#define %s\t"
+ out_printf(outh, "\n/*\n"
+ " * Type checking and casting macros\n"
+ " */\n");
+ out_printf(outh,"#define %s\t"
"(%s_get_type())\n",
macrotype,funcbase);
out_printf(outh,"#define %s(obj)\t"
"GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
macrois,funcbase);
- /* argument wrapping macros */
- if(arguments>0 && !no_gnu) {
- out_printf(outh,"\n#ifdef __GNUC__\n");
- put_argument_gnu_wrappers(c);
- out_printf(outh,"#else /* __GNUC__ */\n");
- put_argument_nongnu_wrappers(c);
- out_printf(outh,"#endif /* __GNUC__ */\n\n");
- } else if(arguments>0 && no_gnu) {
- put_argument_nongnu_wrappers(c);
+ if(privates>0) {
+ out_printf(outh, "\n/* Private structure type */\n");
+ out_printf(outh,"typedef struct _%sPrivate %sPrivate;\n",
+ typebase,typebase);
}
- if(privates>0)
- out_printf(outh,"\ntypedef struct _%sPrivate %sPrivate;\n",typebase,typebase);
-
+ out_printf(outh, "\n/*\n"
+ " * Main object structure\n"
+ " */\n");
s = replace_sep(c->otype,'_');
g_strup(s);
out_printf(outh,"#ifndef __TYPEDEF_%s__\n"
out_printf(outfp,"};\n");
}
- out_printf(outh,"\ntypedef struct _%sClass %sClass;\n",
+ out_printf(outh, "\n/*\n"
+ " * Class definition\n"
+ " */\n");
+ out_printf(outh,"typedef struct _%sClass %sClass;\n",
typebase,typebase);
out_printf(outh,
"struct _%sClass {\n\t%sClass __parent__;\n",
}
out_printf(outh,"};\n\n");
- out_printf(outh,"guint\t%s_get_type\t(void);\n",funcbase);
-
out_printf(out,"/* here are local prototypes */\n");
- if(!no_gnu) {
- out_printf(out,"#ifdef __GNUC__\n"
- "#define ___NO_UNUSED_WARNING "
- "__attribute__ ((__unused__))\n"
- "#else /* __GNUC__ */\n"
- "#define ___NO_UNUSED_WARNING\n"
- "#endif /* __GNUC__ */\n");
- }
if(arguments>0) {
out_printf(out,"static void ___object_set_arg "
"(GtkObject *object, GtkArg *arg, "
"guint arg_id);\n");
}
+ out_printf(outh, "\n/*\n"
+ " * Public methods\n"
+ " */\n");
+
+ out_printf(outh,"guint\t%s_get_type\t(void);\n",funcbase);
for(l=c->nodes;l;l=g_list_next(l)) {
Node *n = l->data;
if(n->type == METHOD_NODE) {
}
}
+/* this idea is less and less apealing to me */
+#if 0
+ if(!no_signal_connect) {
+ if(signals>0) {
+ out_printf(outh, "\n/*\n"
+ " * Signal connection methods\n"
+ " */\n");
+ }
+
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE)
+ put_signal_connect((Method *)n);
+ }
+ }
+#endif
+
+
+ /* argument wrapping macros */
+ if(arguments>0 && !no_gnu) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ out_printf(outh,"#ifdef __GNUC__\n");
+ put_argument_gnu_wrappers(c);
+ out_printf(outh,"#else /* __GNUC__ */\n");
+ put_argument_nongnu_wrappers(c);
+ out_printf(outh,"#endif /* __GNUC__ */\n\n");
+ } else if(arguments>0 && no_gnu) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ put_argument_nongnu_wrappers(c);
+ }
+
if(signals>0) {
for(l=c->nodes;l;l=g_list_next(l)) {
Node *n = l->data;
}
}
- if(!no_gnu)
- out_printf(out,"#undef ___NO_UNUSED_WARNING\n");
-
add_enums(c);
add_get_type();