Skip to content

Commit fd888ba

Browse files
committed
Add conditional compilation for different operating systems.
1 parent b74fdc1 commit fd888ba

File tree

5 files changed

+75
-19
lines changed

5 files changed

+75
-19
lines changed

Foreign/Matlab/Internal.hsc

+18-3
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,27 @@ type MAnyArray = MXArray MAny
177177
178178
-- |Tag for a NULL array
179179
data MNull
180-
instance MType MNull MNull where mxClassOf _ = MXClassNull
180+
instance MType MNull MNull where
181+
hs2mx = id
182+
mx2hs = id
183+
mxClassOf _ = MXClassNull
181184
182185
mNullArray :: MXArray MNull
183186
mNullArray = MXArray nullPtr
184187
185188
-- |A wrapper for a member of a cell array, which itself simply any other array
186189
newtype MCell = MCell { mCell :: MAnyArray }
187-
instance MType MCell MCell where mxClassOf _ = MXClassCell
190+
instance MType MCell MCell where
191+
hs2mx = id
192+
mx2hs = id
193+
mxClassOf _ = MXClassCell
188194
189195
-- |A single struct in an array, represented by an (ordered) list of key-value pairs
190196
newtype MStruct = MStruct { mStruct :: [(String,MAnyArray)] }
191-
instance MType MStruct MStruct where mxClassOf _ = MXClassStruct
197+
instance MType MStruct MStruct where
198+
hs2mx = id
199+
mx2hs = id
200+
mxClassOf _ = MXClassStruct
192201
193202
type MXFun = CInt -> Ptr MXArrayPtr -> CInt -> Ptr MXArrayPtr -> IO ()
194203
-- |A Matlab function
@@ -208,6 +217,12 @@ instance MType MXFun MFun where
208217
map MXArray =.< peekArray no outp
209218
mxClassOf _ = MXClassFun
210219
220+
#ifdef mingw32_HOST_OS
221+
type MWSize = Word32
222+
type MWIndex = Word32
223+
type MWSignedIndex = Int32
224+
#else
211225
type MWSize = #type mwSize
212226
type MWIndex = #type mwIndex
213227
type MWSignedIndex = #type mwSignedIndex
228+
#endif

Foreign/Matlab/MAT.hsc

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Foreign.C.String
2121
import Foreign.C.Error
2222
import Foreign.Matlab.Util
2323
import Foreign.Matlab.Internal
24-
import Foreign.Matlab.Types
2524

2625
#include <mat.h>
2726

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) [2008..2015] Dylan Simon, Ben Sherman. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
* Redistributions of source code must retain the above copyright
6+
notice, this list of conditions and the following disclaimer.
7+
* Redistributions in binary form must reproduce the above copyright
8+
notice, this list of conditions and the following disclaimer in the
9+
documentation and/or other materials provided with the distribution.
10+
* Neither the names of the contributors nor of their affiliations may
11+
be used to endorse or promote products derived from this software
12+
without specific prior written permission.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+

README.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@ This is an updated version of Dylan Simon's
33
available on Hackage. I made changes primarily to allow the package to work
44
with newer versions of GHC and MATLAB.
55

6-
You will probably need to some arguments that point Cabal to your MATLAB
7-
installation. For example,
6+
## Installation
7+
8+
You will probably need to add some arguments that point Cabal to your MATLAB
9+
installation. For example, on a Linux system with MATLAB R2014a,
10+
it may look like this:
811
```
912
cabal install --extra-lib-dirs="/usr/local/MATLAB/R2014a/bin/glnxa64/" --extra-include-dirs="/usr/local/MATLAB/R2014a/extern/include/"
1013
```
1114

12-
I have successfully used package with GHC 7.8.3, cabal-install 1.20.0.3, and
13-
MATLAB R2014a on Ubuntu 14.10. To use the package on Windows, please check out
14-
the
15-
[Windows branch](https://github.com/bmsherman/haskell-matlab/tree/windows32bit),
16-
which has a hack which fixes errors which occur otherwise
17-
(see [this issue](https://github.com/bmsherman/haskell-matlab/issues/1)).
15+
On a Windows system with the MATLAB Compiler Runtime, it might look like this:
16+
```
17+
cabal install --extra-lib-dirs="C:\Program Files\MATLAB\MATLAB Compiler Runtime\v83\extern\include" --extra-lib-dirs="C:\Program Files\MATLAB\MATLAB Compiler Runtime\v83\bin\win64"
18+
```
19+
20+
## Test platforms
21+
22+
This package has been confirmed to work on the following systems:
23+
24+
GHC version | cabal-install version | Operating System | MATLAB
25+
7.8.3 1.20.0.3 Ubuntu 14.10 MATLAB R2014a
26+
7.8.3 1.18.0.5 Windows 7 MCR R2014a
27+

matlab.cabal

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
Name: matlab
2-
Version: 0.1.1.2
2+
Version: 0.1.1.3
33
Cabal-Version: >= 1.10
44
Author: Dylan Simon, Ben Sherman
55
Maintainer: Ben Sherman <[email protected]>
66
License: BSD3
7+
License-file: LICENSE
78
Synopsis: Matlab bindings and interface
8-
Description: This package aims to provide a comprehensive interface to the
9-
MathWorks MATLAB(R) libraries and native data structures, including
10-
complete matrix access, MAT-format files, linking and execution of
11-
runtime libraries and engine. Requires MATLAB for full functionality
12-
or an installed Matlab Component Runtime (MCR). This has been tested
13-
with MATLAB R2014a and might work with others.
9+
Description:
10+
This package aims to provide a comprehensive interface to the
11+
MathWorks MATLAB(R) libraries and native data structures, including
12+
complete matrix access, MAT-format files, linking and execution of
13+
runtime libraries and engine. Requires MATLAB for full functionality
14+
or an installed Matlab Component Runtime (MCR). This has been tested
15+
with MATLAB R2014a and might work with others.
16+
.
17+
[/Installation/]
18+
You will probably need add some arguments that point Cabal to your MATLAB
19+
installation. For example, on a Linux system, it may look like this:
20+
.
21+
> cabal install --extra-lib-dirs="/usr/local/MATLAB/R2014a/bin/glnxa64/" --extra-include-dirs="/usr/local/MATLAB/R2014a/extern/include/"
1422
Category: Foreign,Math
1523
build-type: Custom
1624
tested-with: GHC == 7.8.3

0 commit comments

Comments
 (0)