[Vala] Some patches for posix.vapi
- From: Clément David <c david86 gmail com>
- To: vala-list gnome org
- Subject: [Vala] Some patches for posix.vapi
- Date: Fri, 08 May 2009 19:19:02 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
When using the posix profile (thx for the feature), I found some missing
functions in the posix.vapi file.
PS: I don't know the commit policy
Attached:
0001-Adding-Math-to-Posix-namespace.patch
0002-Adding-FILE-API-as-FileStream-class.patch
0003-Adding-standards-methods-to-Posix-types-when-posix.patch
Clément David (aka davidcl)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkoEaYYACgkQuqPIXyz9+3Ix/gCgmQntlin8uf83vu0OtNC8PN/c
dTUAoIyy2FZizhUocv12HqDYoOnGLqFU
=3G/c
-----END PGP SIGNATURE-----
From 6c506d18f39510c5ba9ee7c058b69aa11e747bcd Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Cl=C3=A9ment=20David?= <c david86 gmail com>
Date: Fri, 8 May 2009 18:44:46 +0200
Subject: [PATCH 1/3] Adding Math to Posix namespace
---
vapi/posix.vapi | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 174 insertions(+), 0 deletions(-)
diff --git a/vapi/posix.vapi b/vapi/posix.vapi
index d487e65..7440fd8 100644
--- a/vapi/posix.vapi
+++ b/vapi/posix.vapi
@@ -981,5 +981,179 @@ namespace Posix {
public const int SEEK_CUR;
[CCode (cheader_filename = "unistd.h")]
public const int SEEK_END;
+
+ [CCode (lower_case_cprefix = "", cheader_filename = "math.h")]
+ namespace Math {
+ [CCode (cname = "M_E")]
+ public const double E;
+
+ [CCode (cname = "M_PI")]
+ public const double PI;
+
+ [CCode (cname = "M_LN2")]
+ public const double LN2;
+
+ [CCode (cname = "M_LN10")]
+ public const double LN10;
+
+ [CCode (cname = "M_PI_2")]
+ public const double PI_2;
+
+ [CCode (cname = "M_PI_4")]
+ public const double PI_4;
+
+ [CCode (cname = "M_SQRT2")]
+ public const double SQRT2;
+
+ /* generated from <bits/mathcalls.h> of glibc */
+ public static double acos (double x);
+ public static float acosf (float x);
+ public static double asin (double x);
+ public static float asinf (float x);
+ public static double atan (double x);
+ public static float atanf (float x);
+ public static double atan2 (double y, double x);
+ public static float atan2f (float y, float x);
+ public static double cos (double x);
+ public static float cosf (float x);
+ public static double sin (double x);
+ public static float sinf (float x);
+ public static double tan (double x);
+ public static float tanf (float x);
+ public static double cosh (double x);
+ public static float coshf (float x);
+ public static double sinh (double x);
+ public static float sinhf (float x);
+ public static double tanh (double x);
+ public static float tanhf (float x);
+ public static void sincos (double x, out double sinx, out double cosx);
+ public static void sincosf (float x, out float sinx, out float cosx);
+ public static double acosh (double x);
+ public static float acoshf (float x);
+ public static double asinh (double x);
+ public static float asinhf (float x);
+ public static double atanh (double x);
+ public static float atanhf (float x);
+ public static double exp (double x);
+ public static float expf (float x);
+ public static double frexp (double x, out int exponent);
+ public static float frexpf (float x, out int exponent);
+ public static double ldexp (double x, int exponent);
+ public static float ldexpf (float x, int exponent);
+ public static double log (double x);
+ public static float logf (float x);
+ public static double log10 (double x);
+ public static float log10f (float x);
+ public static double modf (double x, out double iptr);
+ public static float modff (float x, out float iptr);
+ public static double exp10 (double x);
+ public static float exp10f (float x);
+ public static double pow10 (double x);
+ public static float pow10f (float x);
+ public static double expm1 (double x);
+ public static float expm1f (float x);
+ public static double log1p (double x);
+ public static float log1pf (float x);
+ public static double logb (double x);
+ public static float logbf (float x);
+ public static double exp2 (double x);
+ public static float exp2f (float x);
+ public static double log2 (double x);
+ public static float log2f (float x);
+ public static double pow (double x, double y);
+ public static float powf (float x, float y);
+ public static double sqrt (double x);
+ public static float sqrtf (float x);
+ public static double hypot (double x, double y);
+ public static float hypotf (float x, float y);
+ public static double cbrt (double x);
+ public static float cbrtf (float x);
+ public static double ceil (double x);
+ public static float ceilf (float x);
+ public static double fabs (double x);
+ public static float fabsf (float x);
+ public static double floor (double x);
+ public static float floorf (float x);
+ public static double fmod (double x, double y);
+ public static float fmodf (float x, float y);
+ public static int isinf (double value);
+ public static int isinff (float value);
+ public static int finite (double value);
+ public static int finitef (float value);
+ public static double drem (double x, double y);
+ public static float dremf (float x, float y);
+ public static double significand (double x);
+ public static float significandf (float x);
+ public static double copysign (double x, double y);
+ public static float copysignf (float x, float y);
+ public static double nan (string tagb);
+ public static float nanf (string tagb);
+ public static int isnan (double value);
+ public static int isnanf (float value);
+ public static double j0 (double x0);
+ public static float j0f (float x0);
+ public static double j1 (double x0);
+ public static float j1f (float x0);
+ public static double jn (int x0, double x1);
+ public static float jnf (int x0, float x1);
+ public static double y0 (double x0);
+ public static float y0f (float x0);
+ public static double y1 (double x0);
+ public static float y1f (float x0);
+ public static double yn (int x0, double x1);
+ public static float ynf (int x0, float x1);
+ public static double erf (double x0);
+ public static float erff (float x0);
+ public static double erfc (double x0);
+ public static float erfcf (float x0);
+ public static double lgamma (double x0);
+ public static float lgammaf (float x0);
+ public static double tgamma (double x0);
+ public static float tgammaf (float x0);
+ public static double gamma (double x0);
+ public static float gammaf (float x0);
+ public static double lgamma_r (double x0, out int signgamp);
+ public static float lgamma_rf (float x0, out int signgamp);
+ public static double rint (double x);
+ public static float rintf (float x);
+ public static double nextafter (double x, double y);
+ public static float nextafterf (float x, float y);
+ public static double nexttoward (double x, double y);
+ public static float nexttowardf (float x, double y);
+ public static double remainder (double x, double y);
+ public static float remainderf (float x, float y);
+ public static double scalbn (double x, int n);
+ public static float scalbnf (float x, int n);
+ public static int ilogb (double x);
+ public static int ilogbf (float x);
+ public static double scalbln (double x, long n);
+ public static float scalblnf (float x, long n);
+ public static double nearbyint (double x);
+ public static float nearbyintf (float x);
+ public static double round (double x);
+ public static float roundf (float x);
+ public static double trunc (double x);
+ public static float truncf (float x);
+ public static double remquo (double x, double y, out int quo);
+ public static float remquof (float x, float y, out int quo);
+ public static long lrint (double x);
+ public static long lrintf (float x);
+ public static int64 llrint (double x);
+ public static int64 llrintf (float x);
+ public static long lround (double x);
+ public static long lroundf (float x);
+ public static int64 llround (double x);
+ public static int64 llroundf (float x);
+ public static double fdim (double x, double y);
+ public static float fdimf (float x, float y);
+ public static double fmax (double x, double y);
+ public static float fmaxf (float x, float y);
+ public static double fmin (double x, double y);
+ public static float fminf (float x, float y);
+ public static double fma (double x, double y, double z);
+ public static float fmaf (float x, float y, float z);
+ public static double scalb (double x, double n);
+ public static float scalbf (float x, float n);
+ }
}
--
1.6.2.4
From f48aefe74134152558495d8f28d8b1dbfa38d279 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Cl=C3=A9ment=20David?= <c david86 gmail com>
Date: Fri, 8 May 2009 18:46:21 +0200
Subject: [PATCH 2/3] Adding FILE* API as FileStream class
---
vapi/posix.vapi | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/vapi/posix.vapi b/vapi/posix.vapi
index 7440fd8..680f845 100644
--- a/vapi/posix.vapi
+++ b/vapi/posix.vapi
@@ -176,6 +176,59 @@ namespace Posix {
[CCode (cheader_filename = "ctype.h")]
public int toupper (int c);
+ [CCode (cprefix = "SEEK_", has_type_id = false)]
+ public enum FileSeek {
+ SET,
+ CUR,
+ END
+ }
+
+ [Compact]
+ [CCode (cname = "FILE", free_function = "fclose", cheader_filename = "stdio.h")]
+ public class FileStream {
+ [CCode (cname = "fopen")]
+ public static FileStream? open (string path, string mode);
+ [CCode (cname = "fdopen")]
+ public static FileStream? fdopen (int fildes, string mode);
+ [CCode (cname = "fprintf"), PrintfFormat]
+ public void printf (string format, ...);
+ [CCode (cname = "fputc", instance_pos = -1)]
+ public void putc (char c);
+ [CCode (cname = "fputs", instance_pos = -1)]
+ public void puts (string s);
+ [CCode (cname = "fgetc")]
+ public int getc ();
+ [CCode (cname = "fgets", instance_pos = -1)]
+ public weak string gets (char[] s);
+ [CCode (cname = "feof")]
+ public bool eof ();
+ [CCode (cname = "fscanf")]
+ public int scanf (string format, ...);
+ [CCode (cname = "fflush")]
+ public int flush ();
+ [CCode (cname = "fseek")]
+ public int seek (long offset, FileSeek whence);
+ [CCode (cname = "ftell")]
+ public long tell ();
+ [CCode (cname = "rewind")]
+ public void rewind ();
+ [CCode (cname = "fileno")]
+ public int fileno ();
+ [CCode (cname = "ferror")]
+ public int error ();
+ [CCode (cname = "clearerr")]
+ public void clearerr ();
+ }
+
+ [CCode (cname = "stdin", cheader_filename = "stdio.h")]
+ public static FileStream stdin;
+
+ [CCode (cname = "stdout", cheader_filename = "stdio.h")]
+ public static FileStream stdout;
+
+ [CCode (cname = "stderr", cheader_filename = "stdio.h")]
+ public static FileStream stderr;
+
[Compact]
[CCode (cname = "struct dirent", cheader_filename = "dirent.h")]
public class DirEnt {
--
1.6.2.4
From 3a144903710e1a43071b2bc7f397e76c11f1a662 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Cl=C3=A9ment=20David?= <c david86 gmail com>
Date: Fri, 8 May 2009 18:52:25 +0200
Subject: [PATCH 3/3] Adding standards methods to Posix types (when posix profile is set)
---
vapi/posix.vapi | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 202 insertions(+), 0 deletions(-)
diff --git a/vapi/posix.vapi b/vapi/posix.vapi
index 680f845..ca7a913 100644
--- a/vapi/posix.vapi
+++ b/vapi/posix.vapi
@@ -24,106 +24,261 @@
[CCode (cname = "bool", cheader_filename = "stdbool.h", default_value = "false")]
[BooleanType]
public struct bool {
+ public string to_string () {
+ if (this) {
+ return "true";
+ } else {
+ return "false";
+ }
+ }
}
[CCode (cname = "char", default_value = "\'\\0\'")]
[IntegerType (rank = 2, min = 0, max = 127)]
public struct char {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hhi");
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isalnum ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isalpha ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool iscntrl ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isdigit ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isgraph ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool islower ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isprint ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool ispunct ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isspace ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isupper ();
+ [CCode (cheader_filename = "ctype.h")]
+ public bool isxdigit ();
+ [CCode (cheader_filename = "ctype.h")]
+ public int digit_value ();
+ [CCode (cheader_filename = "ctype.h")]
+ public int xdigit_value ();
+ [CCode (cheader_filename = "ctype.h")]
+ public char tolower ();
+ [CCode (cheader_filename = "ctype.h")]
+ public char toupper ();
}
[CCode (cname = "unsigned char", default_value = "\'\\0\'")]
[IntegerType (rank = 3, min = 0, max = 255)]
public struct uchar {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hhu");
}
[CCode (cname = "int", default_value = "0")]
[IntegerType (rank = 6)]
public struct int {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%i");
+
+ [CCode (cname = "abs")]
+ public int abs ();
}
[CCode (cname = "unsigned int", default_value = "0U")]
[IntegerType (rank = 7)]
public struct uint {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%u");
}
[CCode (cname = "short", default_value = "0")]
[IntegerType (rank = 4, min = -32768, max = 32767)]
public struct short {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hi");
}
[CCode (cname = "unsigned short", default_value = "0U")]
[IntegerType (rank = 5, min = 0, max = 65535)]
public struct ushort {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hu");
}
[CCode (cname = "long", default_value = "0L")]
[IntegerType (rank = 8)]
public struct long {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%li");
+
+ [CCode (cname = "labs")]
+ public long abs ();
}
[CCode (cname = "unsigned long", default_value = "0UL")]
[IntegerType (rank = 9)]
public struct ulong {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%zu");
}
[CCode (cname = "size_t", cheader_filename = "sys/types.h", default_value = "0UL")]
[IntegerType (rank = 9)]
public struct size_t {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%zu");
}
[CCode (cname = "ssize_t", cheader_filename = "sys/types.h", default_value = "0L")]
[IntegerType (rank = 8)]
public struct ssize_t {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%li");
}
[CCode (cname = "int8_t", cheader_filename = "stdint.h", default_value = "0")]
[IntegerType (rank = 1, min = -128, max = 127)]
public struct int8 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hhi");
}
[CCode (cname = "uint8_t", cheader_filename = "stdint.h", default_value = "0U")]
[IntegerType (rank = 3, min = 0, max = 255)]
public struct uint8 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hhu");
}
[CCode (cname = "int16_t", cheader_filename = "stdint.h", default_value = "0")]
[IntegerType (rank = 4, min = -32768, max = 32767)]
public struct int16 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hi");
}
[CCode (cname = "uint16_t", cheader_filename = "stdint.h", default_value = "0U")]
[IntegerType (rank = 5, min = 0, max = 65535)]
public struct uint16 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%hu");
}
[CCode (cname = "int32_t", cheader_filename = "stdint.h", default_value = "0")]
[IntegerType (rank = 6)]
public struct int32 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%i");
}
[CCode (cname = "uint32_t", cheader_filename = "stdint.h", default_value = "0U")]
[IntegerType (rank = 7)]
public struct uint32 {
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%u");
}
[CCode (cname = "int64_t", cheader_filename = "stdint.h", default_value = "0LL")]
[IntegerType (rank = 10)]
public struct int64 {
+ [CCode (cname = "g_strdup_printf", instance_pos = -1)]
+ public string to_string (string format = "%lli");
}
[CCode (cname = "uint64_t", cheader_filename = "stdint.h", default_value = "0ULL")]
[IntegerType (rank = 11)]
public struct uint64 {
+ [CCode (cname = "g_strdup_printf", instance_pos = -1)]
+ public string to_string (string format = "%llu");
}
[CCode (cname = "float", default_value = "0.0F")]
[FloatingType (rank = 1)]
public struct float {
+ [CCode (cname = "FLT_MANT_DIG")]
+ public static int MANT_DIG;
+ [CCode (cname = "FLT_DIG")]
+ public static int DIG;
+
+ [CCode (cname = "FLT_MIN_EXP")]
+ public static int MIN_EXP;
+ [CCode (cname = "FLT_MAX_EXP")]
+ public static int MAX_EXP;
+
+ [CCode (cname = "FLT_MIN_10_EXP")]
+ public static int MIN_10_EXP;
+ [CCode (cname = "FLT_MAX_10_EXP")]
+ public static int MAX_10_EXP;
+
+ [CCode (cname = "FLT_EPSILON")]
+ public static float EPSILON;
+ [CCode (cname = "FLT_MIN")]
+ public static float MIN;
+ [CCode (cname = "FLT_MAX")]
+ public static float MAX;
+
+ [CCode (cname = "NAN", cheader_filename = "math.h")]
+ public static float NAN;
+ [CCode (cname = "INFINITY", cheader_filename = "math.h")]
+ public static float INFINITY;
+
+ [CCode (cname = "isnan", cheader_filename = "math.h")]
+ public bool is_nan ();
+ [CCode (cname = "isfinite", cheader_filename = "math.h")]
+ public bool is_finite ();
+ [CCode (cname = "isnormal", cheader_filename = "math.h")]
+ public bool is_normal ();
+ [CCode (cname = "isinf", cheader_filename = "math.h")]
+ public int is_infinity ();
+
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%g");
}
[CCode (cname = "double", default_value = "0.0")]
[FloatingType (rank = 2)]
public struct double {
+ [CCode (cname = "DBL_MANT_DIG")]
+ public static int MANT_DIG;
+ [CCode (cname = "DBL_DIG")]
+ public static int DIG;
+
+ [CCode (cname = "DBL_MIN_EXP")]
+ public static int MIN_EXP;
+ [CCode (cname = "DBL_MAX_EXP")]
+ public static int MAX_EXP;
+
+ [CCode (cname = "DBL_MIN_10_EXP")]
+ public static int MIN_10_EXP;
+ [CCode (cname = "DBL_MAX_10_EXP")]
+ public static int MAX_10_EXP;
+
+ [CCode (cname = "DBL_EPSILON")]
+ public static double EPSILON;
+ [CCode (cname = "DBL_MIN")]
+ public static double MIN;
+ [CCode (cname = "DBL_MAX")]
+ public static double MAX;
+
+ [CCode (cname = "((double) NAN)", cheader_filename = "math.h")]
+ public static double NAN;
+ [CCode (cname = "((double) INFINITY)", cheader_filename = "math.h")]
+ public static double INFINITY;
+
+ [CCode (cname = "isnan", cheader_filename = "math.h")]
+ public bool is_nan ();
+ [CCode (cname = "isfinite", cheader_filename = "math.h")]
+ public bool is_finite ();
+ [CCode (cname = "isnormal", cheader_filename = "math.h")]
+ public bool is_normal ();
+ [CCode (cname = "isinf", cheader_filename = "math.h")]
+ public int is_infinity ();
+
+ [CCode (cname = "sprintf", instance_pos = -1)]
+ public string to_string (string format = "%g");
}
[CCode (cheader_filename = "time.h")]
@@ -137,6 +292,53 @@ public struct time_t {
[Immutable]
[CCode (cname = "char", const_cname = "const char", copy_function = "strdup", free_function = "free",
cheader_filename = "stdlib.h,string.h")]
public class string {
+ [CCode (cname = "strstr")]
+ public weak string? str (string needle);
+ [CCode (cname = "sprintf"), PrintfFormat]
+ public weak string printf (...);
+ [CCode (cname = "sscanf", cheader_filename = "stdio.h")]
+ public int scanf (...);
+ [CCode (cname = "strcat")]
+ public string concat (string string2, ...);
+ [CCode (cname = "strlen")]
+ public long len ();
+ [CCode (cname = "strchr")]
+ public weak string chr (char c);
+ [CCode (cname = "strrchr")]
+ public weak string rchr (char c);
+
+ [CCode (cname = "atoi")]
+ public int to_int ();
+ [CCode (cname = "atol")]
+ public long to_long ();
+ [CCode (cname = "strtod")]
+ public double to_double (out weak string endptr = null);
+ [CCode (cname = "strtoul")]
+ public ulong to_ulong (out weak string endptr = null, int _base = 0);
+ [CCode (cname = "strtoll")]
+ public int64 to_int64 (out weak string endptr = null, int _base = 0);
+ public bool to_bool () {
+ if (this == "true") {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ [CCode (cname = "strlen")]
+ public long size ();
+
+ // n is size in bytes, not length in characters
+ [CCode (cname = "strndup")]
+ public string ndup (size_t n);
+
+ public bool contains (string needle) {
+ return this.str (needle) != null;
+ }
+
+ public long length {
+ get { return this.len (); }
+ }
}
#endif
--
1.6.2.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]