packages feed

bindings-common 1.1 → 1.2

raw patch · 5 files changed

+59/−34 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Bindings.C.Signal: c'SIGABRT :: (Num a) => a
+ Bindings.C.Signal: c'SIGFPE :: (Num a) => a
+ Bindings.C.Signal: c'SIGILL :: (Num a) => a
+ Bindings.C.Signal: c'SIGINT :: (Num a) => a
+ Bindings.C.Signal: c'SIGSEGV :: (Num a) => a
+ Bindings.C.Signal: c'SIGTERM :: (Num a) => a
+ Bindings.C.Signal: c'SIG_DFL :: FunPtr a
+ Bindings.C.Signal: c'SIG_ERR :: FunPtr a
+ Bindings.C.Signal: c'SIG_IGN :: FunPtr a
+ Bindings.C.Signal: c'raise :: CInt -> IO CInt
+ Bindings.C.Signal: c'signal :: CInt -> FunPtr (CInt -> IO ()) -> IO (FunPtr (CInt -> IO ()))
+ Bindings.C.Signal: p'raise :: FunPtr (CInt -> IO CInt)
+ Bindings.C.Signal: p'signal :: FunPtr (CInt -> FunPtr (CInt -> IO ()) -> IO (FunPtr (CInt -> IO ())))

Files

− .hg_archival.txt
@@ -1,2 +0,0 @@-repo: db8906263ec6e2f02cd51ed9b583ad96027042e9-node: a2dc49f39c0e3678a73d9b26594a245f377257af
− .hgtags
@@ -1,21 +0,0 @@-732c539846db8a8b9825b7445b7c706a6f2619af 0.1-10358cd50ecf3fa8577ffdf8717c766a415d7416 0.01-889288856ad5811301fce6a4d1b78cf95bd4f3b1 0.1-f8ea48ffae0bc7510078b7dc2197563350fa029b common-0.1, sqlite3-0.0.1, libusb-0.0.1-374097230e7e2f8b4e43078e05c3bb8474b0fa32 common-0.1.1, sqlite-0.0.2-72e4c7dd156a72ccdc336f87c9dffc18d4fae675 common 0.1.2, libusb 0.0.2-223d51ab2838181a873d2ed6bbd07c4248ff37b1 common-0.1.3,-223d51ab2838181a873d2ed6bbd07c4248ff37b1 libusb-0.0.3-223d51ab2838181a873d2ed6bbd07c4248ff37b1 common-0.1.3,-0000000000000000000000000000000000000000 common-0.1.3,-1f7a8763147e5a85b4c72032b7be711d1481a37b common-0.1.3-d01e3d14f790402bd7e690e2ee01b68bc3528022 libusb-0.0.4-23e70370956c7c13fa16dbe9f2687a0b2677cf65 libffi-0.0.1-cb32aba3821c64fae6bb6c8eafe75080fcd36d76 libffi-0.0.2-686776ade367d2c82c76b93175d1a8a1cd82646a common-0.1.4-5e3a2847f6bae1b520db8f1ec0d5facea23d2bb5 common-0.2-e4b2035d9ac09075748f164694a67bc066c7f5ea libusb-0.0.5-720960ad84b9248da6470fa90908a539c1c439bd posix-0.0.1-c000d3f4d858be75a9714d4cc930458c529876e4 0.2.1-0e7d69c9fbfe822197a36ff77d28e15ccb1c8e7e 1.0-56cd9fc29fc9268cda35557f39c13624d84a862f 1.1
bindings-common.cabal view
@@ -2,7 +2,7 @@ name: bindings-common homepage: http://bitbucket.org/mauricio/bindings-common synopsis:-  Support package for low-level FFI.+  Preprocessor combinator library for low level FFI. description:    Packages named @bindings-*@ contain low level bindings to well   known libraries, as a resource to be used by developers of@@ -16,15 +16,12 @@   read the code for "Bindings.C" to understand how they work, or   just fill question\/sugestion reports in the bug tracking web   site.-  (/Caveat/: fields of a struct declared as arrays are-  not properly supported in this release. Pointer fieds, of course,-  are okay.)-version: 1.1+version: 1.2 license: BSD3 license-file: LICENSE maintainer: Maurício C. Antunes <mauricio.antunes@gmail.com> author: Maurício C. Antunes-stability: Very close to API stability.+stability: Stable, tested, maintained. build-type: Simple bug-reports: http://bitbucket.org/mauricio/bindings-common/issues category: FFI@@ -40,6 +37,7 @@     Bindings.C     Bindings.C.Errno     Bindings.C.Math+    Bindings.C.Signal     Bindings.C.Stddef     Bindings.C.Stdio     Bindings.C.String
+ src/Bindings/C/Signal.hsc view
@@ -0,0 +1,23 @@+#include <signal.h>+#include <bindings.macros.h>++-- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html>++module Bindings.C.Signal where+import Foreign+import Foreign.C++#function_pointer SIG_DFL+#function_pointer SIG_ERR+#function_pointer SIG_IGN++#num SIGABRT+#num SIGFPE+#num SIGILL+#num SIGINT+#num SIGSEGV+#num SIGTERM++#ccall raise , CInt -> IO CInt+#ccall signal , CInt -> FunPtr (CInt -> \+  IO ()) -> IO (FunPtr (CInt -> IO ()))
src/bindings.macros.h view
@@ -17,14 +17,19 @@  #define bc_fieldname(type,field) \     { \-     char buffer[strlen(type)+1]; \+     char *p, *q, buffer[strlen(type)+strlen(field)+1]; \      strcpy(buffer,type); \-     char *p = buffer; \-     char *q = strtok(p," "); \-     while (q = strtok(NULL," ")) p = q; \-     printf("%s'%s",p,field); \+     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); \     } \ +#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)) \@@ -61,6 +66,11 @@     bc_varid(# name);printf(" = wordPtrToPtr %zu\n",(size_t)(name)); \     bc_varid(# name);printf(" :: Ptr a\n"); \ +#define hsc_function_pointer(name) \+    bc_varid(# name);printf(" = (castPtrToFunPtr . wordPtrToPtr) "); \+    printf("%zu\n",(size_t)(name)); \+    bc_varid(# name);printf(" :: FunPtr a\n"); \+ #define hsc_ccall(name,type) \     printf("foreign import ccall \"%s\" ",# name); \     bc_varid(# name);printf("\n"); \@@ -79,6 +89,11 @@     bc_ptrid(# name);printf("\n"); \     printf("  :: Ptr (");bc_typemarkup(# type);printf(")\n"); \ +#define hsc_globalarray(name,type) \+    printf("foreign import ccall \"array_%s\" ",# name); \+    bc_varid(# name);printf("\n"); \+    printf("  :: Ptr (");bc_typemarkup(# type);printf(")\n"); \+ #define hsc_integral_t(name) \     printf("type ");bc_conid(# name);printf(" = "); \     printf("%s%zu\n",(name)(-1)<0?"Int":"Word",8*sizeof(name)); \@@ -110,6 +125,8 @@      bc_conid(# name);printf("{"); \      char typename[] = # name; \      size_t typesize = sizeof(name); \+     struct {int d; char n[1000], t[1000];} fam; \+     fam.n[0] = '\0' ; \  #define bc_prefield(name,type,typeofarray) \      if (f.n > 0) printf(","); \@@ -134,10 +151,20 @@  #define hsc_flexible_array_member(name,type) \      bc_prefield(name,[type],0); \+     strcpy(fam.n,# name); strcpy(fam.t,# type); \+     fam.d = f.o[f.n]; \      bc_posfield; \  #define hsc_stoptype(dummy) \      printf("\n } deriving (Eq,Show)\n"); \+     if (*fam.n) \+        { \+         bc_famaccess(typename,fam.n); \+         printf(" p = plusPtr p %d\n",fam.d); \+         bc_famaccess(typename,fam.n); \+         printf(" :: Ptr (");bc_conid(typename);printf(") -> "); \+         printf("Ptr (");bc_typemarkup(fam.t);printf(")\n"); \+        } \      printf("instance Storable "); \      bc_conid(typename);printf(" where\n"); \      printf("  sizeOf _ = %zu\n  alignment = sizeOf\n",typesize); \