From b21d4af465d575d0072ddf97e178e0e9545f77ba Mon Sep 17 00:00:00 2001 From: panne Date: Thu, 31 Jul 2003 10:48:51 +0000 Subject: [PATCH] [project @ 2003-07-31 10:48:50 by panne] Merge Foreign.C.TypesISO into Foreign.C.Types --- Foreign/C/Types.hs | 29 +++++++++++++- Foreign/C/TypesISO.hs | 101 ------------------------------------------------- Makefile.nhc98 | 2 +- 3 files changed, 29 insertions(+), 103 deletions(-) delete mode 100644 Foreign/C/TypesISO.hs diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs index eb05feb..5d896ea 100644 --- a/Foreign/C/Types.hs +++ b/Foreign/C/Types.hs @@ -58,7 +58,6 @@ import NHC.FFI ) #else -import Foreign.C.TypesISO import Foreign.Storable import Data.Bits ( Bits(..) ) import Data.Int ( Int8, Int16, Int32, Int64 ) @@ -128,4 +127,32 @@ FLOATING_TYPE(CDouble,tyConCDouble,"CDouble",HTYPE_DOUBLE) -- HACK: Currently no long double in the FFI, so we simply re-use double FLOATING_TYPE(CLDouble,tyConCLDouble,"CLDouble",HTYPE_DOUBLE) +INTEGRAL_TYPE(CPtrdiff,tyConCPtrdiff,"CPtrdiff",HTYPE_PTRDIFF_T) +INTEGRAL_TYPE(CSize,tyConCSize,"CSize",HTYPE_SIZE_T) +INTEGRAL_TYPE(CWchar,tyConCWchar,"CWchar",HTYPE_WCHAR_T) +INTEGRAL_TYPE(CSigAtomic,tyConCSigAtomic,"CSigAtomic",HTYPE_SIG_ATOMIC_T) + +{-# RULES +"fromIntegral/a->CPtrdiff" fromIntegral = \x -> CPtrdiff (fromIntegral x) +"fromIntegral/a->CSize" fromIntegral = \x -> CSize (fromIntegral x) +"fromIntegral/a->CWchar" fromIntegral = \x -> CWchar (fromIntegral x) +"fromIntegral/a->CSigAtomic" fromIntegral = \x -> CSigAtomic (fromIntegral x) + +"fromIntegral/CPtrdiff->a" fromIntegral = \(CPtrdiff x) -> fromIntegral x +"fromIntegral/CSize->a" fromIntegral = \(CSize x) -> fromIntegral x +"fromIntegral/CWchar->a" fromIntegral = \(CWchar x) -> fromIntegral x +"fromIntegral/CSigAtomic->a" fromIntegral = \(CSigAtomic x) -> fromIntegral x + #-} + +INTEGRAL_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T) +INTEGRAL_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T) + +-- FIXME: Implement and provide instances for Eq and Storable +data CFile = CFile +data CFpos = CFpos +data CJmpBuf = CJmpBuf + +-- C99 types which are still missing include: +-- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t + #endif diff --git a/Foreign/C/TypesISO.hs b/Foreign/C/TypesISO.hs deleted file mode 100644 index ab2c928..0000000 --- a/Foreign/C/TypesISO.hs +++ /dev/null @@ -1,101 +0,0 @@ -{-# OPTIONS -fno-implicit-prelude #-} ------------------------------------------------------------------------------ --- | --- Module : Foreign.C.TypesISO --- Copyright : (c) The FFI task force 2001 --- License : BSD-style (see the file libraries/base/LICENSE) --- --- Maintainer : ffi@haskell.org --- Stability : provisional --- Portability : portable --- --- A mapping of C types defined by the ISO C standard to corresponding Haskell --- types. Like CTypes, this is a cool hack... --- ------------------------------------------------------------------------------ - --- #hide -module Foreign.C.TypesISO -#ifndef __NHC__ - ( -- Integral types, instances of: Eq, Ord, Num, Read, Show, Enum, - -- Typeable, Storable, Bounded, Real, Integral, Bits - CPtrdiff, CSize, CWchar, CSigAtomic - - -- Numeric types, instances of: Eq, Ord, Num, Read, Show, Enum, - -- Typeable, Storable - , CClock, CTime -#else - ( -- For nhc98, these are exported non-abstractly to work around - -- an interface-file problem. - CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..) - , CClock(..), CTime(..) -#endif - - -- Instances of: Eq and Storable - , CFile, CFpos, CJmpBuf - ) where - -#ifdef __NHC__ -import NHC.FFI - ( CPtrdiff(..) - , CSize(..) - , CWchar(..) - , CSigAtomic(..) - , CClock(..) - , CTime(..) - , CFile - , CFpos - , CJmpBuf - ) -#else - -import Data.Bits ( Bits(..) ) -import Data.Int -import Data.Word -import Data.Typeable -import Foreign.Storable - -#ifdef __GLASGOW_HASKELL__ -import GHC.Base -import GHC.Enum -import GHC.Real -import GHC.Show -import GHC.Read -import GHC.Num -#else -import Control.Monad -import Foreign.Ptr -#endif - -#include "Typeable.h" -#include "CTypes.h" - -INTEGRAL_TYPE(CPtrdiff,tyConCPtrdiff,"CPtrdiff",HTYPE_PTRDIFF_T) -INTEGRAL_TYPE(CSize,tyConCSize,"CSize",HTYPE_SIZE_T) -INTEGRAL_TYPE(CWchar,tyConCWchar,"CWchar",HTYPE_WCHAR_T) -INTEGRAL_TYPE(CSigAtomic,tyConCSigAtomic,"CSigAtomic",HTYPE_SIG_ATOMIC_T) - -{-# RULES -"fromIntegral/a->CPtrdiff" fromIntegral = \x -> CPtrdiff (fromIntegral x) -"fromIntegral/a->CSize" fromIntegral = \x -> CSize (fromIntegral x) -"fromIntegral/a->CWchar" fromIntegral = \x -> CWchar (fromIntegral x) -"fromIntegral/a->CSigAtomic" fromIntegral = \x -> CSigAtomic (fromIntegral x) - -"fromIntegral/CPtrdiff->a" fromIntegral = \(CPtrdiff x) -> fromIntegral x -"fromIntegral/CSize->a" fromIntegral = \(CSize x) -> fromIntegral x -"fromIntegral/CWchar->a" fromIntegral = \(CWchar x) -> fromIntegral x -"fromIntegral/CSigAtomic->a" fromIntegral = \(CSigAtomic x) -> fromIntegral x - #-} - -INTEGRAL_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T) -INTEGRAL_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T) - --- FIXME: Implement and provide instances for Eq and Storable -data CFile = CFile -data CFpos = CFpos -data CJmpBuf = CJmpBuf - --- C99 types which are still missing include: --- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t - -#endif diff --git a/Makefile.nhc98 b/Makefile.nhc98 index 0073159..74ae9c3 100644 --- a/Makefile.nhc98 +++ b/Makefile.nhc98 @@ -18,7 +18,7 @@ SRCS = \ System/Directory.hs System/Mem.hs System/Cmd.hs System/Info.hs \ System/Console/GetOpt.hs System/Random.hs \ Foreign/Ptr.hs Foreign/StablePtr.hs Foreign/Storable.hs \ - Foreign/ForeignPtr.hs Foreign/C/Types.hs Foreign/C/TypesISO.hs \ + Foreign/ForeignPtr.hs Foreign/C/Types.hs \ Foreign/Marshal/Alloc.hs Foreign/Marshal/Array.hs \ Foreign/Marshal/Utils.hs Foreign/Marshal/Error.hs \ Foreign/Marshal/Pool.hs Foreign/Marshal.hs \ -- 1.7.10.4