Commit 34e8984b authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

don't add NULL to end of variable argument list for printf-style functions

2006-10-31  Jürg Billeter  <j@bitron.ch>

	* vala/valacodegenerator.vala: don't add NULL to end of variable
	  argument list for printf-style functions to reduce the number of
	  warnings during C compilation
	* vala/valamethod.vala: support PrintfFormat attribute
	* vala/vala.h: include valareport.h
	* vapi/glib-2.0.vala: use PrintfFormat attribute

svn path=/trunk/; revision=160
parent 34d33d9d
2006-10-31 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: don't add NULL to end of variable
argument list for printf-style functions to reduce the number of
warnings during C compilation
* vala/valamethod.vala: support PrintfFormat attribute
* vala/vala.h: include valareport.h
* vapi/glib-2.0.vala: use PrintfFormat attribute
2006-10-27 Jürg Billeter <j@bitron.ch>
* vapi/atk.vala, vapi/gdk-2.0.vala, vapi/gtk+-2.0.vala, vapi/pango.vala:
......
......@@ -52,6 +52,7 @@
#include <vala/valaproperty.h>
#include <vala/valapropertyaccessor.h>
#include <vala/valarealliteral.h>
#include <vala/valareport.h>
#include <vala/valareturnstatement.h>
#include <vala/valasignal.h>
#include <vala/valasourcefile.h>
......
......@@ -2833,8 +2833,11 @@ public class Vala.CodeGenerator : CodeVisitor {
if (m != null && m.instance && m.instance_last) {
ccall.add_argument (instance);
} else if (ellipsis) {
// ensure variable argument list ends with NULL
ccall.add_argument (new CCodeConstant ("NULL"));
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
if (m == null || !m.printf_format) {
ccall.add_argument (new CCodeConstant ("NULL"));
}
}
if (m != null && m.instance && m.returns_modified_pointer) {
......
......@@ -134,6 +134,11 @@ public class Vala.Method : Member, Invokable {
}
}
}
/**
* Specifies whether this method expects printf-style format arguments.
*/
public bool printf_format { get; set; }
private bool _instance = true;
private List<FormalParameter> parameters;
......@@ -274,6 +279,8 @@ public class Vala.Method : Member, Invokable {
return_type.floating_reference = true;
} else if (a.name == "NoArrayLength") {
no_array_length = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
}
}
}
......
......@@ -173,6 +173,7 @@ public struct string {
[CCode (cname = "g_str_has_suffix")]
public bool has_suffix (string! suffix);
[CCode (cname = "g_strdup_printf")]
[PrintfFormat ()]
public ref string printf (...);
[CCode (cname = "g_strconcat")]
public ref string concat (string string2, ...);
......@@ -764,6 +765,7 @@ namespace GLib {
[CCode (cname = "fdopen")]
public static ref File fdopen (int fildes, string mode);
[CCode (cname = "fprintf")]
[PrintfFormat ()]
public void printf (string format, ...);
[InstanceLast ()]
[CCode (cname = "fputc")]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment