packages feed

bindings-common 1.3.2 → 1.3.3

raw patch · 3 files changed

+20/−29 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Bindings.Utils: cast666 :: (Storable a, Storable b) => a -> b

Files

bindings-common.cabal view
@@ -16,7 +16,7 @@   code shows how most macros are supposed to be used. More   examples and reference documentation can be found at project   homepage.-version: 1.3.2+version: 1.3.3 license: BSD3 license-file: LICENSE maintainer: Maurício C. Antunes <mauricio.antunes@gmail.com>@@ -44,6 +44,5 @@     Bindings.C.Stdio     Bindings.C.String     Bindings.C.Time-    Bindings.Utils   cc-options:     "-D_ISOC99_SOURCE"
− src/Bindings/Utils.hs
@@ -1,27 +0,0 @@-module Bindings.Utils (-  cast666,- ) where-import Foreign---- | This is safe regarding use of memory. Enough space is--- allocated to store both values, and the difference between--- sizes, if any, is filled with zeros. The result is what you--- would expect if you have a C pointer to the first value and--- cast it to a pointer to the result. Of course, this can have--- undesired effects if 'peek' implementation for--- the result type does more than just reading memory.------ This function can be safely used with any datatype generated by--- this package macro library.--cast666 :: (Storable a, Storable b) => a -> b-cast666 = unsafePerformIO . genericCast-  where-    genericCast :: (Storable a, Storable b) => a -> IO b-    genericCast v = return undefined >>= \r ->-      let size = max (sizeOf v) (sizeOf r) in-        allocaBytes size $ \p ->-          pokeArray p (replicate size (0::Word8)) >>-            poke (castPtr p) v >>-              if False then return r else peek (castPtr p)-
src/bindings.macros.h view
@@ -119,6 +119,7 @@      printf("\n"); \     } \ +/* hsc_fractional_t is deprecated */ #define hsc_fractional_t(name) \     printf("type ");bc_conid(# name);printf(" = "); \     switch (sizeof(name)) \@@ -134,6 +135,12 @@     printf(" = "); \     bc_conid(# name);printf("\n"); \ +#define hsc_synonym_t(name,type) \+    printf("type ");bc_conid(# name); \+    printf(" = "); \+    bc_typemarkup(# type); \+    printf("\n"); \+ #define hsc_callback(name,type) \     printf("type ");bc_conid(# name);printf(" = FunPtr ("); \     bc_typemarkup(# type);printf(")\n"); \@@ -226,6 +233,9 @@      printf("    return ()\n"); \     } \ +#define BC_GLOBALARRAY(name,type) \+    type* array_##name () {return name;} \+ #define BC_INLINE_(name,ret) \     ret inline_##name () {return name;} \ @@ -235,8 +245,17 @@ #define BC_INLINE1(name,t1,ret) \     ret inline_##name (t1 v1) {return name(v1);} \ +#define BC_INLINE1VOID(name,t1) \+    void inline_##name (t1 v1) {name(v1);} \+ #define BC_INLINE2(name,t1,t2,ret) \     ret inline_##name (t1 v1,t2 v2) {return name(v1,v2);} \++#define BC_INLINE2VOID(name,t1,t2) \+    void inline_##name (t1 v1,t2 v2) {name(v1,v2);} \++#define BC_INLINE3(name,t1,t2,t3,ret) \+    ret inline_##name (t1 v1,t2 v2,t3 v3) {return name(v1,v2,v3);} \  #define BC_INLINE4(name,t1,t2,t3,t4,ret) \     ret inline_##name (t1 v1,t2 v2,t3 v3,t4 v4) {return name(v1,v2,v3,v4);} \