From cfff116de32a2b6036b96a589e4008e3bc89c5ce Mon Sep 17 00:00:00 2001 From: Anand Swaroop Date: Mon, 8 Apr 2024 20:47:15 -0400 Subject: [PATCH] fix: naming and memory bugs --- src/Raylib/Core.hs | 6 +++++- src/Raylib/Core/Models.hs | 9 ++++----- src/Raylib/Types/Core.hs | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Raylib/Core.hs b/src/Raylib/Core.hs index 54654a6..4c1ff7c 100644 --- a/src/Raylib/Core.hs +++ b/src/Raylib/Core.hs @@ -1164,7 +1164,11 @@ isFileDropped :: IO Bool isFileDropped = toBool <$> c'isFileDropped loadDroppedFiles :: IO FilePathList -loadDroppedFiles = c'loadDroppedFiles >>= pop +loadDroppedFiles = do + ptr <- c'loadDroppedFiles + val <- peek ptr + c'unloadDroppedFiles ptr + return val getFileModTime :: String -> IO Integer getFileModTime fileName = fromIntegral <$> withCString fileName c'getFileModTime diff --git a/src/Raylib/Core/Models.hs b/src/Raylib/Core/Models.hs index 699dfd2..1cdf872 100644 --- a/src/Raylib/Core/Models.hs +++ b/src/Raylib/Core/Models.hs @@ -191,7 +191,6 @@ import Raylib.Types Vector2, Vector3, ) -import Prelude hiding (length) $( genNative [ ("c'drawLine3D", "DrawLine3D_", "rl_bindings.h", [t|Ptr Vector3 -> Ptr Vector3 -> Ptr Color -> IO ()|], False), @@ -286,13 +285,13 @@ drawTriangleStrip3D :: [Vector3] -> Int -> Color -> IO () drawTriangleStrip3D points pointCount color = withFreeableArray points (\p -> withFreeable color (c'drawTriangleStrip3D p (fromIntegral pointCount))) drawCube :: Vector3 -> Float -> Float -> Float -> Color -> IO () -drawCube position width height length color = withFreeable position (\p -> withFreeable color (c'drawCube p (realToFrac width) (realToFrac height) (realToFrac length))) +drawCube position width height _length color = withFreeable position (\p -> withFreeable color (c'drawCube p (realToFrac width) (realToFrac height) (realToFrac _length))) drawCubeV :: Vector3 -> Vector3 -> Color -> IO () drawCubeV position size color = withFreeable position (\p -> withFreeable size (withFreeable color . c'drawCubeV p)) drawCubeWires :: Vector3 -> Float -> Float -> Float -> Color -> IO () -drawCubeWires position width height length color = withFreeable position (\p -> withFreeable color (c'drawCubeWires p (realToFrac width) (realToFrac height) (realToFrac length))) +drawCubeWires position width height _length color = withFreeable position (\p -> withFreeable color (c'drawCubeWires p (realToFrac width) (realToFrac height) (realToFrac _length))) drawCubeWiresV :: Vector3 -> Vector3 -> Color -> IO () drawCubeWiresV position size color = withFreeable position (\p -> withFreeable size (withFreeable color . c'drawCubeWiresV p)) @@ -430,10 +429,10 @@ genMeshPoly :: Int -> Float -> WindowResources -> IO Mesh genMeshPoly sides radius wr = c'genMeshPoly (fromIntegral sides) (realToFrac radius) >>= pop >>= (`storeMeshData` wr) genMeshPlane :: Float -> Float -> Int -> Int -> WindowResources -> IO Mesh -genMeshPlane width length resX resZ wr = c'genMeshPlane (realToFrac width) (realToFrac length) (fromIntegral resX) (fromIntegral resZ) >>= pop >>= (`storeMeshData` wr) +genMeshPlane width _length resX resZ wr = c'genMeshPlane (realToFrac width) (realToFrac _length) (fromIntegral resX) (fromIntegral resZ) >>= pop >>= (`storeMeshData` wr) genMeshCube :: Float -> Float -> Float -> WindowResources -> IO Mesh -genMeshCube width height length wr = c'genMeshCube (realToFrac width) (realToFrac height) (realToFrac length) >>= pop >>= (`storeMeshData` wr) +genMeshCube width height _length wr = c'genMeshCube (realToFrac width) (realToFrac height) (realToFrac _length) >>= pop >>= (`storeMeshData` wr) genMeshSphere :: Float -> Int -> Int -> WindowResources -> IO Mesh genMeshSphere radius rings slices wr = c'genMeshSphere (realToFrac radius) (fromIntegral rings) (fromIntegral slices) >>= pop >>= (`storeMeshData` wr) diff --git a/src/Raylib/Types/Core.hs b/src/Raylib/Types/Core.hs index de0cf8f..3a47328 100644 --- a/src/Raylib/Types/Core.hs +++ b/src/Raylib/Types/Core.hs @@ -1052,7 +1052,7 @@ p'vrStereoConfig'scaleIn :: Ptr VrStereoConfig -> Ptr CFloat p'vrStereoConfig'scaleIn = (`plusPtr` 296) data FilePathList = FilePathList - { filePathlist'capacity :: Integer, + { filePathList'capacity :: Integer, filePathList'paths :: [String] } deriving (Eq, Show)