packages feed

bindings-common 1.2 → 1.3

raw patch · 10 files changed

+65/−57 lines, 10 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Bindings.C.Time: tm'tm_hour :: C'tm -> CInt
- Bindings.C.Time: tm'tm_isdst :: C'tm -> CInt
- Bindings.C.Time: tm'tm_mday :: C'tm -> CInt
- Bindings.C.Time: tm'tm_min :: C'tm -> CInt
- Bindings.C.Time: tm'tm_mon :: C'tm -> CInt
- Bindings.C.Time: tm'tm_sec :: C'tm -> CInt
- Bindings.C.Time: tm'tm_wday :: C'tm -> CInt
- Bindings.C.Time: tm'tm_yday :: C'tm -> CInt
- Bindings.C.Time: tm'tm_year :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_hour :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_isdst :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_mday :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_min :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_mon :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_sec :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_wday :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_yday :: C'tm -> CInt
+ Bindings.C.Time: c'tm'tm_year :: C'tm -> CInt

Files

bindings-common.cabal view
@@ -8,7 +8,7 @@   known libraries, as a resource to be used by developers of   higher level modules. This @bindings-common@ package provides   @hsc2hs@ macros that allows writing code for such low level-  bindings that is easy to read an maintain, while keeping names+  bindings that is easy to read and maintain, while keeping names   and functionality as close as possible to the base library.   These macros can be used as a simple alternative to, say,   @c2hs@, or to @hsc2hs@ original macros. At this moment, there's@@ -16,7 +16,7 @@   read the code for "Bindings.C" to understand how they work, or   just fill question\/sugestion reports in the bug tracking web   site.-version: 1.2+version: 1.3 license: BSD3 license-file: LICENSE maintainer: Maurício C. Antunes <mauricio.antunes@gmail.com>
src/Bindings/C.hs view
@@ -6,6 +6,7 @@   module Bindings.C.String,   module Bindings.C.Time,  ) where+import Prelude () import Bindings.C.Errno import Bindings.C.Math import Bindings.C.Stddef
src/Bindings/C/Errno.hsc view
@@ -4,6 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html>  module Bindings.C.Errno where+#strict_import  #num EDOM #num EILSEQ
src/Bindings/C/Math.hsc view
@@ -4,8 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html>  module Bindings.C.Math where-import Foreign-import Foreign.C+#strict_import  #num FP_INFINITE #num FP_NAN
src/Bindings/C/Signal.hsc view
@@ -4,8 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html>  module Bindings.C.Signal where-import Foreign-import Foreign.C+#strict_import  #function_pointer SIG_DFL #function_pointer SIG_ERR
src/Bindings/C/Stddef.hsc view
@@ -4,6 +4,6 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>  module Bindings.C.Stddef where-import Foreign+#strict_import  #pointer NULL
src/Bindings/C/Stdio.hsc view
@@ -4,8 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html>  module Bindings.C.Stdio where-import Foreign-import Foreign.C+#strict_import  #num BUFSIZ #num L_tmpnam
src/Bindings/C/String.hsc view
@@ -4,8 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/string.h.html>  module Bindings.C.String where-import Foreign-import Foreign.C+#strict_import  #ccall memchr , Ptr () -> CInt -> CSize -> IO (Ptr ()) #ccall memcmp , Ptr () -> Ptr () -> CSize -> IO CInt
src/Bindings/C/Time.hsc view
@@ -4,8 +4,7 @@ -- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html>  module Bindings.C.Time where-import Foreign-import Foreign.C+#strict_import  #starttype struct tm #field tm_sec , CInt
src/bindings.macros.h view
@@ -1,47 +1,40 @@--#define bc_varid(name) printf("c'%s",(name)) \+#define hsc_strict_import(dummy) printf( \+    "import Prelude (IO,Num,return,(.),($),Eq,Show,take)\n" \+    "import Foreign.Ptr (Ptr,FunPtr,plusPtr)\n" \+    "import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)\n" \+    "import Foreign.Storable\n" \+    "import Foreign.C.Types\n" \+    "import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)\n" \+    "import Foreign.Marshal.Array (peekArray,pokeArray)\n" \+    "import Data.Int\n" \+    "import Data.Word\n" \+    ); \ -#define bc_conid(name) \+#define bc_word(name) \     { \-     char buffer[strlen(name)+1]; \-     strcpy(buffer,name); \-     char *p, *q; \-     p = strtok(buffer," "); \-     while (q = strtok(NULL," ")) p = q; \-     printf("C'%s",p); \+     char *p, *q, buffer_w[strlen(name)+1]; \+     strcpy(buffer_w,name); \+     for (p=strtok(buffer_w," \t");q=strtok(NULL," \t");p=q); \+     printf("%s",p); \     } \ -#define bc_ptrid(name) printf("p'%s",(name)) \--#define bc_wrapper(name) printf("mk'%s",(name)) \--#define bc_fieldname(type,field) \+#define bc_glue(type,field) \     { \-     char *p, *q, buffer[strlen(type)+strlen(field)+1]; \-     strcpy(buffer,type); \-     for (p=strtok(buffer," ");q=strtok(NULL," ");p=q); \-     printf("%s'",p); \-     strcpy(buffer,field); \-     for (p=buffer;*p;p++) if (*p == '.') *p = '\''; \-     printf("%s",buffer); \+     bc_word(type); \+     printf("'"); \+     char *p, buffer_g[strlen(field)+1]; \+     strcpy(buffer_g,field); \+     for (p=buffer_g;*p;p++) \+        *p = *p=='.' ? '\'' : ispunct(*p) ? '_' : *p; \+     bc_word(buffer_g); \     } \ -#define bc_famaccess(type,field) \-    printf("p'"); \-    bc_fieldname(type,field) \--#define bc_decimal(name) (name) > 0 \-    ? printf("%ju",(uintmax_t)(name)) \-    : printf("%jd",(intmax_t)(name)) \--#define bc_float(name) printf("%Le",(long double)(name)) \- #define bc_typemarkup(name) \     { \-     char buffer[strlen(name)+1]; \-     strcpy(buffer,name); \+     char buffer_t[strlen(name)+1]; \+     strcpy(buffer_t,name); \      char *p1,*p2,*p3; \-     p1 = buffer; \+     p1 = buffer_t; \      while (*p1) \         { \          for (p2=p1;*p2 && *p2!='<';p2++); \@@ -54,6 +47,24 @@         } \     } \ +#define bc_varid(name) {printf("c'");bc_word(name);}; \++#define bc_conid(name) {printf("C'");bc_word(name);}; \++#define bc_ptrid(name) {printf("p'");bc_word(name);}; \++#define bc_wrapper(name) {printf("mk'");bc_word(name);}; \++#define bc_fieldname(type,field) {printf("c'");bc_glue(type,field);}; \++#define bc_famaccess(type,field) {printf("p'");bc_glue(type,field);}; \++#define bc_decimal(name) (name) > 0 \+    ? printf("%ju",(uintmax_t)(name)) \+    : printf("%jd",(intmax_t)(name)) \++#define bc_float(name) printf("%Le",(long double)(name)) \+ #define hsc_num(name) \     bc_varid(# name);printf(" = ");bc_decimal(name);printf("\n"); \     bc_varid(# name);printf(" :: (Num a) => a\n"); \@@ -96,7 +107,12 @@  #define hsc_integral_t(name) \     printf("type ");bc_conid(# name);printf(" = "); \-    printf("%s%zu\n",(name)(-1)<0?"Int":"Word",8*sizeof(name)); \+    { \+     int sign = (name)(-1)<0; \+     size_t size = sizeof(name); \+     if (sign && size==sizeof(int)) printf("CInt\n"); \+     else printf("%s%zu\n",sign?"Int":"Word",8*size); \+    } \  #define hsc_opaque_t(name) \     printf("data ");bc_conid(# name); \@@ -104,17 +120,12 @@     bc_conid(# name);printf("\n"); \  #define hsc_callback(name,type) \-    printf("type ");bc_conid(# name); \-    printf(" = FunPtr ("); \+    printf("type ");bc_conid(# name);printf(" = FunPtr ("); \     bc_typemarkup(# type);printf(")\n"); \     printf("foreign import ccall \"wrapper\" "); \-    bc_wrapper(# name); \-    printf("\n"); \-    printf("  :: ("); \-    bc_typemarkup(# type); \-    printf(") -> IO "); \-    bc_conid(# name); \-    printf("\n"); \+    bc_wrapper(# name);printf("\n"); \+    printf("  :: (");bc_typemarkup(# type); \+    printf(") -> IO ");bc_conid(# name);printf("\n"); \  #define hsc_starttype(name) \     { \