Re: [Vala] Assisted printf format
- From: "Juan Luis Paz" <juanluispaz gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] Assisted printf format
- Date: Wed, 13 Aug 2008 10:43:50 +1930
Hello,
I finished the first element about the assisted printf format, I attached the changes (I don't have a svn account)
Now is possible do it:
void main () {
string a = "foo";
double b = 123.45;
long c = 678;
uint d = 9;
stdout.printf ("Hello World: %-10?%? %?%?\n", a, b, c, d);
}
Vala
translate the '?' for the real format, indicate in the CCode attribute,
in the field printf_format, if printf_format is not defined in the type
is not possible use the assited printf format,if you try, valac
generates a compiler error
Also, I changed the default to_string format to the char type,
before:
public string to_string (string format = "%hhi");
now:
public string to_string (string format = "%c");
I don't know if this change is correctly, but why the default char format is numerical ?
Missing format string:
I don't know the format string for unichar
If this is a good feature make this changes in the source repository
2008/8/11 Juan Luis Paz
<juanluispaz gmail com>
Hello,
Actually, when I want use a prinf I need remember the data type format string; but vala can do it automatically
I propose create another data type in the format string: ?, like i, g u, li, etc. Example: %?, %-10?
When use '?' vala can translate this for the real format string, indicate in CCode attribute
Example:
void main () {
string a = "foo";
double b = 123.45;
long c = 678;
uint d = 9;
stdout.printf ("Hello World: %-10?%g %?%?\n", a, b, c, d);
}
Vala translate the printf string to "Hello World: %-10s%g %li%u\n"
The '?' indicate to vala that must use assisted prinf format
The assisted prinf format can:
- use a format string indicate in CCode attribute (ideal for int, uint, string, etc.)
- get a field value indicate in CCode attribute (ideal for StringBuilder, for get str field value)
- call a to string method o another indicate in CCode attribute (ideal for general propose and for bool)
I'm working for do it.
I want to know what their opinions about that
--
Juan Luis Paz
--
Juan Luis Paz
Attachment:
diff
Description: Binary data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]