[gob] Fri Jul 10 12:23:39 2009 Jiri (George) Lebl <jirka 5z com>



commit 387294fa37fa7c2d0445db8f846b55bc77955f6f
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Fri Jul 10 12:23:44 2009 -0500

    Fri Jul 10 12:23:39 2009  Jiri (George) Lebl <jirka 5z com>
    
    	* src/main.c: add G_GNUC_CONST to _get_type, thanks to
    	  Jean-Yves Lefort jylefort at brutele dot be for pointing that
    	  out
    
    	* src/main.c: move #line sections past the opening brace of
    	  functions, enclose function declarations in #line sections
    	  to refer to the .gob file.  by Jean-Yves Lefort
    
    	* src/main.c, src/lexer.l, src/parse.y, src/str*, src/test.gob,
    	  doc/gob2.1.in:
    	  Partially back out the function attribute patch and rework it
    	  in a simpler, more flexible, though syntactically not as nice
    	  way.

 ChangeLog        |   16 ++++
 doc/gob2.1.in    |   20 +++--
 src/Makefile.str |    2 +-
 src/lexer.l      |    6 --
 src/main.c       |   46 ++++++----
 src/parse.y      |  254 +++++++++++++++++++-----------------------------------
 src/str.gob      |    8 +-
 src/test.gob     |   12 ++--
 8 files changed, 155 insertions(+), 209 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 29565e4..37bdf13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Fri Jul 10 12:23:39 2009  Jiri (George) Lebl <jirka 5z com>
+
+	* src/main.c: add G_GNUC_CONST to _get_type, thanks to
+	  Jean-Yves Lefort jylefort at brutele dot be for pointing that
+	  out
+
+	* src/main.c: move #line sections past the opening brace of
+	  functions, enclose function declarations in #line sections
+	  to refer to the .gob file.  by Jean-Yves Lefort
+
+	* src/main.c, src/lexer.l, src/parse.y, src/str*, src/test.gob,
+	  doc/gob2.1.in:
+	  Partially back out the function attribute patch and rework it
+	  in a simpler, more flexible, though syntactically not as nice
+	  way.
+
 Fri Jul 10 10:22:10 2009  Jiri (George) Lebl <jirka 5z com>
 
 	* doc/gob2.1.in: fix the _GET_CLASS documentation.  Thanks to
diff --git a/doc/gob2.1.in b/doc/gob2.1.in
index 663d56b..af8db64 100644
--- a/doc/gob2.1.in
+++ b/doc/gob2.1.in
@@ -605,30 +605,38 @@ to be more then 0 and less then 11, and a pointer to a GtkWidget object
 instance and it is checked for being null and the type will also be
 checked.
 .PP
-.B "Function attributes:
+.B "Function attributes:"
 .PP
 For method that aren't virtual, signal or override methods, and aren't
-init or class_init, the GLib function attribute macros G_GNUC_PRINTF,
+init or class_init, GLib function attribute macros G_GNUC_PRINTF,
 G_GNUC_SCANF, and G_GNUC_FORMAT can optionally be included after the
-argument list, for example:
+argument list.  Simply include an \'attr\' keyword and the C code to include
+in the file.  You have to include braces and anything inside the braces
+will be printed into the header file after the function declaration and
+before the trailing semicolon.  The braces themselves are not printed.
+For example:
 .nf
 
   public void
-  print (self, const char *format (check null), ...) G_GNUC_PRINTF(2, 3)
+  print (self, const char *format (check null), ...)
+    attr {G_GNUC_PRINTF(2, 3)}
 
 .fi
 .PP
 This will produce a prototype which will generate a warning at compile
 time if the contents of the format argument (argument number 2) aren't
 consistent with the types and number of the subsequent variadic
-arguments (the first of which is argument number 3).
+arguments (the first of which is argument number 3).  Only one \'attr\'
+keyword per method is allowed.
+If you have more than one attribute to include, you should
+put them all within the braces.
 .PP
 .B "Error return:"
 .PP
 Methods which have a return value, there also has to be something
 returned if there is an error, such as if a precondition is not met.
 The default is 0, casted to the type of the method.  If you need to
-return something else then you can specify an "onerror" keyword after
+return something else then you can specify an \'onerror\' keyword after
 the prototype and any optional function attribute macros, and after
 that a number, a token (an identifier) or a bit of C code enclosed in
 braces {}.  The braces will not be printed into the output, they just
diff --git a/src/Makefile.str b/src/Makefile.str
index b5bba61..f5ac688 100644
--- a/src/Makefile.str
+++ b/src/Makefile.str
@@ -1,7 +1,7 @@
 # This is a test makefile for the str_test to check string attributes stuff
 #
 
-FLAGS := -Wall $(shell pkg-config --cflags gobject-2.0 glib-2.0)
+CFLAGS := -Wall $(shell pkg-config --cflags gobject-2.0 glib-2.0)
 LDFLAGS := $(shell pkg-config --libs-only-other --libs-only-L \
                               gobject-2.0 glib-2.0)
 LDLIBS := $(shell pkg-config --libs-only-l gobject-2.0 glib-2.0)
diff --git a/src/lexer.l b/src/lexer.l
index 72a849a..b3b2d59 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -567,12 +567,6 @@ flags		{ return FLAGS; }
 				REJECT;
 			}
 		}
-
-<CLASS_CODE_I>G_GNUC_PRINTF|G_GNUC_SCANF|G_GNUC_FORMAT {
-                        yylval.id = g_strdup(yytext);
-                        return FUNCATTR;
-}
-
 <CLASS_CODE,CLASS_CODE_I,PROPERTY_CODE,PROPERTY_CODE_I,INITIAL>[A-Za-z_][A-Za-z0-9_]*(:[A-Za-z_][A-Za-z0-9_]*)+	{
 			/* this one is for a classname with a namespace */
 			yylval.id = g_strdup(yytext);
diff --git a/src/main.c b/src/main.c
index 7874014..c0d28c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999,2000 the Free Software Foundation.
  * Copyright (C) 2000 Eazel, Inc.
- * Copyright (C) 2001-2004 George (Jiri) Lebl
+ * Copyright (C) 2001-2009 George (Jiri) Lebl
  *
  * Author: George (Jiri) Lebl
  *
@@ -407,8 +407,10 @@ put_pub_method(const Method *m)
 	if(m->scope != PUBLIC_SCOPE)
 		return;
 
+	out_addline_infile(outh, m->line_no);
 	print_method(outh, "", "\t", "", "\t", "", ";\n", m,
 		     TRUE, TRUE, FALSE, TRUE, FALSE, FALSE);
+	out_addline_outfile(outh);
 }
 
 static void
@@ -531,15 +533,17 @@ put_local_signal_macros (const Class *c)
 static void
 put_prot_method(const Method *m)
 {
-	if(m->scope != PROTECTED_SCOPE)
-		return;
+	FILE *f;
 
-	if(outph)
-		print_method(outph, "", "\t", "", "\t", "", ";\n",
-			     m, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
-	else
-		print_method(out, "", "\t", "", "\t", "", ";\n",
-			     m, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
+ 	if(m->scope != PROTECTED_SCOPE)
+ 		return;
+ 
+	f = outph ? outph : out;
+
+	out_addline_infile(f, m->line_no);
+	print_method(f, "", "\t", "", "\t", "", ";\n",
+		     m, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
+	out_addline_outfile(f);
 }
 
 static void
@@ -560,9 +564,11 @@ put_priv_method_prot(const Method *m)
 	    m->cbuf)) {
 		/* add unique ID */
 		char *s = g_strdup_printf("___%x_", (guint)m->unique_id);
+		out_addline_infile(out, m->line_no);
 		print_method(out, "static ", s, "", " ", "",
 			     no_gnu?";\n":" G_GNUC_UNUSED;\n",
 			     m, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
+		out_addline_outfile(out);
 		g_free(s);
 	} else if(m->scope == PRIVATE_SCOPE ||
 		  m->method == INIT_METHOD ||
@@ -2309,9 +2315,10 @@ add_inits(Class *c)
 			print_method(out, "static ", "\n", "", " ", "", "\n",
 				     m, FALSE, FALSE, FALSE, TRUE, TRUE,
 				     FALSE);
+			out_printf(out, "{\n");
 			if(m->line_no > 0)
 				out_addline_outfile(out);
-			out_printf(out, "{\n"
+			out_printf(out,
 				   "#define __GOB_FUNCTION__ \"%s::init\"\n",
 				   c->otype);
 			if (privates > 0) {
@@ -2359,9 +2366,10 @@ add_inits(Class *c)
 			print_method(out, "static ", "\n", "", " ", "", "\n",
 				     m, FALSE, FALSE, FALSE, TRUE, TRUE,
 				     FALSE);
+			out_printf(out, "{\n");
 			if(m->line_no > 0)
 				out_addline_outfile(out);
-			out_printf(out, "{\n"
+			out_printf(out,
 				   "#define __GOB_FUNCTION__ \"%s::class_init\"\n",
 				   c->otype);
 			if (set_properties > 0 ||
@@ -2710,10 +2718,10 @@ print_preconditions(Method *m)
 static void
 print_method_body (Method *m, gboolean pre, gboolean unused_self)
 {
+	out_printf(out, "{\n");
 	if (m->line_no > 0)
 		out_addline_outfile(out);
-	out_printf(out, "{\n"
-		   "#define __GOB_FUNCTION__ \"%s::%s\"\n",
+	out_printf(out, "#define __GOB_FUNCTION__ \"%s::%s\"\n",
 		   ((Class *)class)->otype,
 		   m->id);
 	if (pre)
@@ -3014,9 +3022,9 @@ put_method(Method *m)
 		else /* PUBLIC, PROTECTED */
 			print_method(out, "", "\n", "", " ", "", "\n",
 				     m, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE);
+		out_printf(out, "{\n");
 		out_addline_outfile(out);
-		out_printf(out, "{\n"
-			"\t%sClass *klass;\n", typebase);
+		out_printf(out, "\t%sClass *klass;\n", typebase);
 		print_preconditions(m);
 		out_printf(out, "\tklass = %s_GET_CLASS(%s);\n\n"
 			"\tif(klass->%s)\n",
@@ -3535,7 +3543,7 @@ print_class_block(Class *c)
 		    " */\n");
 
 	if ( ! overrode_get_type) {
-		out_printf (outh, "GType\t%s_get_type\t(void);\n", funcbase);
+		out_printf (outh, "GType\t%s_get_type\t(void) G_GNUC_CONST;\n", funcbase);
 	}
 
 	for(li = c->nodes; li != NULL; li = li->next) {
@@ -3912,7 +3920,7 @@ print_enum (EnumDef *enode)
 	g_free (str);
 
 	out_printf (outh, "%s_get_type()\n", funcprefix);
-	out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
+	out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix);
 
 	out_printf (out,
 		    "GType\n%s_get_type (void)\n"
@@ -3977,7 +3985,7 @@ print_flags (Flags *fnode)
 	g_free (str);
 
 	out_printf (outh, "%s_get_type()\n", funcprefix);
-	out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
+	out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix);
 
 	out_printf (out,
 		    "GType\n%s_get_type (void)\n"
@@ -4040,7 +4048,7 @@ print_error (Error *enode)
 	g_free (str);
 
 	out_printf (outh, "%s_get_type ()\n", funcprefix);
-	out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
+	out_printf (outh, "GType %s_get_type (void) G_GNUC_CONST;\n\n", funcprefix);
 
 	out_printf (out,
 		    "GType\n%s_get_type (void)\n"
diff --git a/src/parse.y b/src/parse.y
index 55e71ff..e4a8aa5 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -65,52 +65,7 @@ static char *initializer = NULL;
 static int initializer_line = 0;
 static int glade_widget = FALSE;
 
-static GString *funcattrs = NULL;
-static GString *attrargs = NULL;
-
-static void
-clear_funcattrs(void)
-{
-	if(!funcattrs) {
-		funcattrs = g_string_new("");
-	} else {
-		funcattrs = g_string_assign(funcattrs, "");
-	}
-}
-
-static void
-add_to_funcattrs(char *s, ...) G_GNUC_PRINTF (1, 2);
-
-static void
-add_to_funcattrs(char *s, ...)
-{
-  va_list ap;
-  va_start(ap, s);
-  gchar *tmp = g_strdup_vprintf (s, ap);
-  va_end(ap);
-		 
-  if(!funcattrs)
-    funcattrs = g_string_new("");
-
-  funcattrs = g_string_append (funcattrs,tmp);
-
-  g_free(tmp);
-}
-
-static gboolean
-funcattrs_defined (void)
-{
-  return (funcattrs != NULL && funcattrs->len > 0);
-}
-
-/* Return a new string containing a copy of the contents of funcattrs,
-   but with leading and trailing whitespace removed.  */
-static gchar *
-funcattrs_strstripped (void)
-{
-  return g_strstrip (g_strdup (funcattrs->str));
-}
-
+static char *funcattrs = NULL;
 static char *onerror = NULL;
 static char *defreturn = NULL;
 
@@ -242,9 +197,6 @@ push_function (int scope, int method, char *oid, char *id,
 	} else
 		c_cbuf = NULL;
 
-	if(funcattrs == NULL)
-	        funcattrs = g_string_new("");
-
 	node = node_new (METHOD_NODE,
 			 "scope", scope,
 			 "method", method,
@@ -254,7 +206,7 @@ push_function (int scope, int method, char *oid, char *id,
 			 "flags:steal", flags,
 			 "id:steal", id,
 			 "args:steal", funcargs,
-			 "funcattrs", funcattrs->str,
+			 "funcattrs:steal", funcattrs,
 			 "onerror:steal", onerror,
 			 "defreturn:steal", defreturn,
 			 "cbuf:steal", c_cbuf,
@@ -266,8 +218,6 @@ push_function (int scope, int method, char *oid, char *id,
 
 	last_added_method = (Method *)node;
 
-	clear_funcattrs ();
-
 	if(cbuf)
 		g_string_free(cbuf,
 			      /*only free segment if we haven't passed it
@@ -276,6 +226,7 @@ push_function (int scope, int method, char *oid, char *id,
 	gtktypes = NULL;
 	funcargs = NULL;
 
+	funcattrs = NULL;
 	onerror = NULL;
 	defreturn = NULL;
 
@@ -285,9 +236,8 @@ push_function (int scope, int method, char *oid, char *id,
 static void
 free_all_global_state(void)
 {
-        if(funcattrs != NULL)
-                g_string_free(funcattrs, TRUE);
-
+	g_free(funcattrs);
+	funcattrs = NULL;
 	g_free(onerror);
 	onerror = NULL;
 	g_free(defreturn);
@@ -391,9 +341,15 @@ find_var_or_die(const char *id, int line)
 }
 
 static gboolean
-set_return_value(char *type, char *val)
+set_attr_value(char *type, char *val)
 {
-	if(strcmp(type, "onerror")==0) {
+	if(strcmp(type, "attr")==0) {
+		if(!funcattrs) {
+			funcattrs = val;
+			return TRUE;
+		} else
+			return FALSE;
+	} else if(strcmp(type, "onerror")==0) {
 		if(!onerror) {
 			onerror = val;
 			return TRUE;
@@ -732,7 +688,7 @@ ensure_property (void)
 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
 
 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR
-%token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE STRING FUNCATTR
+%token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE STRING
 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT
 %token <line> VIRTUAL SIGNAL OVERRIDE
 %token <line> NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE
@@ -1731,12 +1687,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				free_all_global_state();
 				YYERROR;
 			}
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with signal methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with signal methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(the_scope, $<sigtype>3,NULL,
@@ -1755,12 +1710,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				free_all_global_state();
 				YYERROR;
 			}
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with signal methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with signal methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(the_scope, $<sigtype>4, NULL,
@@ -1779,12 +1733,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				free_all_global_state();
 				YYERROR;
 			}
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with virtual methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
@@ -1803,12 +1756,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				free_all_global_state();
 				YYERROR;
 			}
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with virtual methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
@@ -1822,12 +1774,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				free_all_global_state();
 				YYERROR;
 			}
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with virtual methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
@@ -1835,12 +1786,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				      ccode_line, vararg, NULL);
 									}
 	|	OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode	{
-	                if(funcattrs_defined()) {
-	                        GString *errmsg = g_string_new("");
-	                        g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may not be used with override methods",
-							funcattrs_strstripped()
-						       );
-	                        yyerror(_(errmsg->str));
+	                if (funcattrs != NULL) {
+				char *error = g_strdup_printf
+					(_("function attribute macros ('%s' in this case) may not be used with override methods"),
+					 funcattrs);
+	                        yyerror (error);
 		                YYERROR;
 		        }
 			push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
@@ -1858,35 +1808,13 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 				      $<cbuf>8, $<line>1, ccode_line,
 				      vararg, NULL);
 								}
-             /* It would be nice to include methodmods before
-	        codenocode here, the do error checking to make sure no
-	        function attributes or return values had been added.
-	        But I'm not certain when its safe to NULLify onerror
-	        and defreturn.  So we just settle for the generic
-	        parse error.  */
 	|	TOKEN '(' TOKEN ')' codenocode	{
 			if(strcmp($<id>1, "init")==0) {
-			        if(funcattrs_defined()) {
-			                GString *errmsg = g_string_new("");
-					g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may no be used with the init method",
-								funcattrs_strstripped()
-							       );
-					yyerror(_(errmsg->str));
-					YYERROR;
-				}
 				push_init_arg($<id>3,FALSE);
 				push_function(NO_SCOPE, INIT_METHOD, NULL,
 					      $<id>1, $<cbuf>5, $<line>2,
 					      ccode_line, FALSE, NULL);
 			} else if(strcmp($<id>1, "class_init")==0) {
-			        if(funcattrs_defined()) {
-			                GString *errmsg = g_string_new("");
-					g_string_append_printf(errmsg, "function attribute macros ('%s' in this case) may no be used with the class_init method",
-								funcattrs_strstripped()
-							       );
-					yyerror(_(errmsg->str));
-					YYERROR;
-				}
 				push_init_arg($<id>3,TRUE);
 				push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
 					      $<id>1, $<cbuf>5, $<line>2,
@@ -1903,56 +1831,11 @@ method:		SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenoc
 						}
 	;
 
-methodmods:     funcattrlist { ; }
-              | returnvals_spec  { ; }
-              | funcattrlist returnvals_spec  { ; }
-              | { 
-		         g_free(onerror); onerror = NULL;
-		         g_free(defreturn); defreturn = NULL;
-	        }
-        ; 
-funcattrlist:   funcattrlist funcattr  { ; }
-             |  funcattr             { ; }
-        ;
-
-funcattr:       FUNCATTR '(' attrarglist ')' {
-                         g_assert(attrargs != NULL);
-                         add_to_funcattrs("\t%s (%s)\n", $<id>1,
-                                          attrargs->str);
-                         g_string_free(attrargs, TRUE);
-			 attrargs = NULL;
-                }
-              | FUNCATTR { 
-	                 add_to_funcattrs("\t%s\n", $<id>1);
-                }
-	;
-
-attrarglist:    attrarglist  ',' NUMBER  {
-                         g_assert(attrargs != NULL); 
-                         g_string_append_printf(attrargs, ", %s", $<id>3);
-                }
-              | NUMBER {
-                         if(attrargs == NULL)
-                                 attrargs = g_string_new($<id>1);
-                         else 
-                                 attrargs = g_string_append(attrargs, $<id>1);
-                }
-        ;
-
-			/* This isn't needed anymore.
-			 *
-			 *returnvals:      returnvals_spec
-			 *               | {
-			 *		         g_free(onerror); onerror = NULL;
-			 *		         g_free(defreturn); defreturn = NULL;
-			 *                 }
-			 *        ;
-			 */
-
-returnvals_spec:	TOKEN retcode		{
+methodmods:	TOKEN retcode		{
+			g_free(funcattrs); funcattrs = NULL;
 			g_free(onerror); onerror = NULL;
 			g_free(defreturn); defreturn = NULL;
-			if(!set_return_value($<id>1, $<id>2)) {
+			if(!set_attr_value($<id>1, $<id>2)) {
 				g_free($<id>1);
 				g_free($<id>2);
 				yyerror(_("parse error"));
@@ -1961,24 +1844,61 @@ returnvals_spec:	TOKEN retcode		{
 			g_free($<id>1);
 					}
 	|	TOKEN retcode TOKEN retcode	{
+			g_free(funcattrs); funcattrs = NULL;
+			g_free(onerror); onerror = NULL;
+			g_free(defreturn); defreturn = NULL;
+			if(!set_attr_value($<id>1, $<id>2)) {
+				g_free($<id>1); g_free($<id>2);
+				g_free($<id>3); g_free($<id>4);
+				yyerror(_("parse error"));
+				YYERROR;
+			}
+			if(!set_attr_value($<id>3, $<id>4)) {
+				funcattrs = onerror = defreturn = NULL;
+				g_free($<id>1); g_free($<id>2);
+				g_free($<id>3); g_free($<id>4);
+				yyerror(_("parse error"));
+				YYERROR;
+			}
+			g_free($<id>1);
+			g_free($<id>3);
+						}
+	|	TOKEN retcode TOKEN retcode TOKEN retcode	{
+			g_free(funcattrs); funcattrs = NULL;
 			g_free(onerror); onerror = NULL;
 			g_free(defreturn); defreturn = NULL;
-			if(!set_return_value($<id>1, $<id>2)) {
+			if(!set_attr_value($<id>1, $<id>2)) {
 				g_free($<id>1); g_free($<id>2);
 				g_free($<id>3); g_free($<id>4);
+				g_free($<id>5); g_free($<id>6);
 				yyerror(_("parse error"));
 				YYERROR;
 			}
-			if(!set_return_value($<id>3, $<id>4)) {
-				onerror = defreturn = NULL;
+			if(!set_attr_value($<id>3, $<id>4)) {
+				funcattrs = onerror = defreturn = NULL;
 				g_free($<id>1); g_free($<id>2);
 				g_free($<id>3); g_free($<id>4);
+				g_free($<id>5); g_free($<id>6);
+				yyerror(_("parse error"));
+				YYERROR;
+			}
+			if(!set_attr_value($<id>5, $<id>6)) {
+				funcattrs = onerror = defreturn = NULL;
+				g_free($<id>1); g_free($<id>2);
+				g_free($<id>3); g_free($<id>4);
+				g_free($<id>5); g_free($<id>6);
 				yyerror(_("parse error"));
 				YYERROR;
 			}
 			g_free($<id>1);
 			g_free($<id>3);
+			g_free($<id>5);
 						}
+	|				{
+			g_free(funcattrs); funcattrs = NULL;
+			g_free(onerror); onerror = NULL;
+			g_free(defreturn); defreturn = NULL;
+					}
 	;
 
 retcode:	numtok			{ $<id>$ = $<id>1; }
diff --git a/src/str.gob b/src/str.gob
index 3d51e26..4936879 100644
--- a/src/str.gob
+++ b/src/str.gob
@@ -13,12 +13,12 @@ class :Str from G:Object {
   void
   print (self)
   {
-    g_print (self->_priv->contents->str);
+    g_print ("%s", self->_priv->contents->str);
   }
 
    public
    GObject *
-   new (const char *format (check null), ...) G_GNUC_PRINTF (1, 2)
+   new (const char *format (check null), ...) attr {G_GNUC_PRINTF (1, 2)}
      onerror NULL defreturn NULL
    {
      va_list ap;
@@ -41,7 +41,7 @@ class :Str from G:Object {
    public
    char *
    nonvirt_test (self, const char *format (check null), ...)
-     G_GNUC_PRINTF (2,3)
+     attr {G_GNUC_PRINTF (2,3)}
      defreturn NULL
    {
      return NULL;
@@ -50,7 +50,7 @@ class :Str from G:Object {
    private
    char *
    private_test_method (self, const char *format (check null), ...)   
-     G_GNUC_PRINTF (2, 3)
+     attr {G_GNUC_PRINTF (2, 3)}
      defreturn NULL
    {
      return NULL;
diff --git a/src/test.gob b/src/test.gob
index 435bccd..468fe47 100644
--- a/src/test.gob
+++ b/src/test.gob
@@ -419,7 +419,7 @@ class Test:Object from /*G:Object*/ Gtk:Container
 		return 25;
 	}
 	public gchar *funcattrtest(self, const char *format (check null), ...)
-	        G_GNUC_PRINTF (2, 3)
+	        attr {G_GNUC_PRINTF (2, 3)}
 	{
 	        gchar *result;
 
@@ -430,21 +430,21 @@ class Test:Object from /*G:Object*/ Gtk:Container
 	        return result;
 	}
 	private gchar *funcattrtest2(self, const char *format, ...)
-	        G_GNUC_SCANF(2,3)
+	        attr {G_GNUC_SCANF(2,3)}
 	{
 	        gchar *nonsense = NULL;
 	        format = format;
                 return nonsense;
 	}
         protected gchar *funcattrtest3(self, const char *format)
-	        G_GNUC_FORMAT (2)
+	        attr {G_GNUC_FORMAT (2)}
         {
 	        gchar *nonsense = NULL;
 	        format = format;
                 return nonsense;	        
 	}
 	private char *funcattrtest4(self, const char *format, ...)
-	        G_GNUC_PRINTF(2,3)
+	        attr {G_GNUC_PRINTF(2,3)}
                 onerror NULL
 	{
 	        gchar *nonsense = NULL;
@@ -452,15 +452,15 @@ class Test:Object from /*G:Object*/ Gtk:Container
                 return nonsense;	        
 	}
 	protected char * funcattrtest5(self, const char *format, ...)
-	        G_GNUC_PRINTF(2,3)	        
 	        onerror NULL
+	        attr {G_GNUC_PRINTF(2,3)}
 	{
 	        gchar *nonsense = NULL;
 	        format = format;
                 return nonsense;	        
 	}
 	public char * funcattrtest6(self, const char *format, ...)
-	        G_GNUC_PRINTF(2,3)
+	        attr {G_GNUC_PRINTF(2,3)}
                 onerror NULL 
         {
 	        gchar *nonsense = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]