-- GENERATED by C->Haskell Compiler, version 0.25.2 Snowboundest, 31 Oct 2014 (Haskell) -- Edit the ORIGNAL .chs file instead! {-# LINE 1 "CFunctions.chs" #-} -- This source file is part of HGamer3D -- (A project to enable 3D game development in Haskell) -- For the latest info, see http://www.hgamer3d.org -- -- (c) 2015 Peter Althainz -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- HGamer3D/Binding/CFunctions.hs -- {-# LANGUAGE ForeignFunctionInterface #-} -- | C-function interface towards the urho3d dll module HGamer3D.Binding.CFunctions where import Foreign import Foreign.C import Data.Word import Data.ByteString import Data.ByteString.Unsafe type CStringCLen i = (CString, i) unsafeUseAsCStringLen' :: (Integral i) => ByteString -> (CStringCLen i -> IO a) -> IO a unsafeUseAsCStringLen' str fn = unsafeUseAsCStringLen str (\(ptr, len) -> fn (ptr, fromIntegral len)) createItem :: (Word64) -> (ByteString) -> IO ((Int), (Ptr ())) createItem a1 a2 = let {a1' = fromIntegral a1} in unsafeUseAsCStringLen' a2 $ \(a2'1, a2'2) -> alloca $ \a3' -> createItem'_ a1' a2'1 a2'2 a3' >>= \res -> let {res' = fromIntegral res} in peek a3'>>= \a3'' -> return (res', a3'') {-# LINE 47 "CFunctions.chs" #-} destroyItem :: (Word64) -> (Ptr ()) -> IO ((Int)) destroyItem a1 a2 = let {a1' = fromIntegral a1} in let {a2' = id a2} in destroyItem'_ a1' a2' >>= \res -> let {res' = fromIntegral res} in return (res') {-# LINE 54 "CFunctions.chs" #-} getMessageSender :: (Word64) -> (Word64) -> IO ((Int), (FunPtr (Ptr () -> Ptr CChar -> CInt -> IO CInt))) getMessageSender a1 a2 = let {a1' = fromIntegral a1} in let {a2' = fromIntegral a2} in alloca $ \a3' -> getMessageSender'_ a1' a2' a3' >>= \res -> let {res' = fromIntegral res} in peek a3'>>= \a3'' -> return (res', a3'') {-# LINE 62 "CFunctions.chs" #-} registerMessageReceiver :: (Word64) -> (Word64) -> (Ptr ()) -> (FunPtr (Ptr () -> Ptr CChar -> CInt -> IO CInt)) -> IO ((Int)) registerMessageReceiver a1 a2 a3 a4 = let {a1' = fromIntegral a1} in let {a2' = fromIntegral a2} in let {a3' = id a3} in let {a4' = id a4} in registerMessageReceiver'_ a1' a2' a3' a4' >>= \res -> let {res' = fromIntegral res} in return (res') {-# LINE 71 "CFunctions.chs" #-} errorMessage :: (Int) -> IO ((String)) errorMessage a1 = let {a1' = fromIntegral a1} in errorMessage'_ a1' >>= \res -> peekCString res >>= \res' -> return (res') {-# LINE 77 "CFunctions.chs" #-} foreign import ccall safe "CFunctions.chs.h hg3durho3d0_create_item" createItem'_ :: (CULLong -> ((Ptr CChar) -> (CInt -> ((Ptr (Ptr ())) -> (IO CInt))))) foreign import ccall safe "CFunctions.chs.h hg3durho3d0_destroy_item" destroyItem'_ :: (CULLong -> ((Ptr ()) -> (IO CInt))) foreign import ccall safe "CFunctions.chs.h hg3durho3d0_get_msg_sender" getMessageSender'_ :: (CULLong -> (CULLong -> ((Ptr (FunPtr ((Ptr ()) -> ((Ptr CChar) -> (CInt -> (IO CInt)))))) -> (IO CInt)))) foreign import ccall safe "CFunctions.chs.h hg3durho3d0_register_msg_receiver" registerMessageReceiver'_ :: (CULLong -> (CULLong -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> ((Ptr CChar) -> (CInt -> (IO CInt))))) -> (IO CInt))))) foreign import ccall safe "CFunctions.chs.h hg3durho3d0_error_message" errorMessage'_ :: (CInt -> (IO (Ptr CChar)))