[vala] Support [ScanfFormat] attribute
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Support [ScanfFormat] attribute
- Date: Sat, 1 Aug 2009 16:18:22 +0000 (UTC)
commit 7d5a61e38664ceabfe6a903af38d057bdf831a4b
Author: Jürg Billeter <j bitron ch>
Date: Sat Aug 1 18:17:29 2009 +0200
Support [ScanfFormat] attribute
Fixes bug 589930.
codegen/valaccodebasemodule.vala | 2 +-
codegen/valaccodemethodcallmodule.vala | 2 +-
vala/valacodewriter.vala | 4 ++++
vala/valamethod.vala | 7 +++++++
vapi/glib-2.0.vapi | 4 ++--
5 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 2f7dc94..ca28952 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3228,7 +3228,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
if (ellipsis) {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
- if (!m.printf_format && m.sentinel != "") {
+ if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
creation_call.add_argument (new CCodeConstant (m.sentinel));
}
}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 94862ef..f9ff372 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -556,7 +556,7 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (ellipsis) {
/* ensure variable argument list ends with NULL
* except when using printf-style arguments */
- if (!m.printf_format && m.sentinel != "") {
+ if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
in_arg_map.set (get_param_pos (-1, true), new CCodeConstant (m.sentinel));
}
} else if (itype is DelegateType) {
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index b83b44b..55dd513 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -826,6 +826,10 @@ public class Vala.CodeWriter : CodeVisitor {
write_indent ();
write_string ("[PrintfFormat]");
}
+ if (m.scanf_format) {
+ write_indent ();
+ write_string ("[ScanfFormat]");
+ }
var ccode_params = new StringBuilder ();
var separator = "";
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index d1f5172..88d4e21 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -195,6 +195,11 @@ public class Vala.Method : Member {
public bool printf_format { get; set; }
/**
+ * Specifies whether this method expects scanf-style format arguments.
+ */
+ public bool scanf_format { get; set; }
+
+ /**
* Specifies whether a construct function with a GType parameter is
* available. This is only applicable to creation methods.
*/
@@ -401,6 +406,8 @@ public class Vala.Method : Member {
return_type.floating_reference = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
+ } else if (a.name == "ScanfFormat") {
+ scanf_format = true;
}
}
}
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 464763e..6052c8d 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -818,7 +818,7 @@ public class string {
public bool has_suffix (string suffix);
[CCode (cname = "g_strdup_printf"), PrintfFormat]
public string printf (...);
- [CCode (cname = "sscanf", cheader_filename = "stdio.h")]
+ [CCode (cname = "sscanf", cheader_filename = "stdio.h"), ScanfFormat]
public int scanf (...);
[CCode (cname = "g_strconcat")]
public string concat (string string2, ...);
@@ -2402,7 +2402,7 @@ namespace GLib {
public weak string gets (char[] s);
[CCode (cname = "feof")]
public bool eof ();
- [CCode (cname = "fscanf")]
+ [CCode (cname = "fscanf"), ScanfFormat]
public int scanf (string format, ...);
[CCode (cname = "fflush")]
public int flush ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]