 {-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables #-}
 module System.GPU.OpenCL.Program(  
   -- * Types
-  CLProgram,
+  CLProgram, CLBuildStatus(..),
   -- * Functions
   clCreateProgramWithSource, clRetainProgram, clReleaseProgram, 
-  clUnloadCompiler, clBuildProgram
+  clUnloadCompiler, clBuildProgram, clGetProgramReferenceCount, 
+  clGetProgramContext, clGetProgramNumDevices, clGetProgramDevices,
+  clGetProgramSource, clGetProgramBinarySizes, clGetProgramBinaries, 
+  clGetProgramBuildStatus, clGetProgramBuildOptions, clGetProgramBuildLog
   ) where
 
 -- -----------------------------------------------------------------------------
 import Foreign
 import Foreign.C.Types
-import Foreign.C.String( CString, withCString, newCString )
+import Foreign.C.String( CString, withCString, newCString, peekCString )
 import System.GPU.OpenCL.Types( 
-  CLint, CLuint, CLProgram, CLContext, CLDeviceID, CLError(..), 
-  wrapCheckSuccess, wrapPError )
+  CLint, CLuint, CLProgram, CLContext, CLDeviceID, CLError(..), CLProgramInfo_,
+  CLBuildStatus(..), CLBuildStatus_, wrapCheckSuccess, wrapPError, wrapGetInfo, 
+  getCLValue, getEnumCL )
 
 #include <CL/cl.h>
 

foreign import ccall "clGetProgramInfo" raw_clGetProgramInfo :: 
  CLProgram -> CLuint -> CSize -> Ptr () -> Ptr CSize -> IO CLint
foreign import ccall "clGetProgramBuildInfo"  raw_clGetProgramBuildInfo :: 
  CLProgram -> CLuint -> CSize -> Ptr () -> Ptr CSize -> IO CLint

-- -----------------------------------------------------------------------------
clCreateProgramWithSource :: CLContext -> String -> IO (Either CLError CLProgram)
clCreateProgramWithSource ctx source = wrapPError $ \perr -> do
  let strings = lines source

type BuildCallback = CLProgram -> Ptr () -> IO ()
foreign import ccall "clCreateProgramWithSource" raw_clCreateProgramWithSource :: 
  CLContext -> CLuint -> Ptr CString -> Ptr CSize -> Ptr CLint -> IO CLProgram
--foreign import ccall "clCreateProgramWithBinary" raw_clCreateProgramWithBinary :: 
--  CLContext -> CLuint -> Ptr CLDeviceID -> Ptr CSize -> Ptr (Ptr Word8) -> Ptr CLint -> Ptr CLint -> IO CLProgram
foreign import ccall "clRetainProgram" raw_clRetainProgram :: 
  CLProgram -> IO CLint
foreign import ccall "clReleaseProgram" raw_clReleaseProgram :: 
