8000 MAYH-13831 Refreshed code base · packetloop/haskell-cpython@f0d6802 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0d6802

Browse files
committed
MAYH-13831 Refreshed code base
1 parent 0f0bf15 commit f0d6802

39 files changed

+1615
-1615
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist-newstyle/

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

cpython.cabal renamed to haskell-cpython.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: cpython
1+
name: haskell-cpython
22
version: 3.4.0
33
license: GPL-3
44
license-file: license.txt
@@ -33,7 +33,7 @@ library
3333
hs-source-dirs: lib
3434

3535
build-depends:
36-
base >= 4.0 && < 5.0
36+
base >= 4.7 && < 5
3737
, bytestring >= 0.9
3838
, text
3939

@@ -81,4 +81,4 @@ library
8181
c-sources: cbits/hscpython-shim.c
8282
include-dirs: cbits
8383

84-
pkgconfig-depends: python-3.4
84+
pkgconfig-depends: python-3.6

lib/CPython.chs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
module CPython
19-
( initialize
20-
, isInitialized
21-
, finalize
22-
, newInterpreter
23-
, endInterpreter
24-
, getProgramName
25-
, setProgramName
26-
, getPrefix
27-
, getExecPrefix
28-
, getProgramFullPath
29-
, getPath
30-
, getVersion
31-
, getPlatform
32-
, getCopyright
33-
, getCompiler
34-
, getBuildInfo
35-
, setArgv
36-
, getPythonHome
37-
, setPythonHome
38-
) where
19+
( initialize
20+
, isInitialized
21+
, finalize
22+
, newInterpreter
23+
, endInterpreter
24+
, getProgramName
25+
, setProgramName
26+
, getPrefix
27+
, getExecPrefix
28+
, getProgramFullPath
29+
, getPath
30+
, getVersion
31+
, getPlatform
32+
, getCopyright
33+
, getCompiler
34+
, getBuildInfo
35+
, setArgv
36+
, getPythonHome
37+
, setPythonHome
38+
) where
3939

4040
#include <hscpython-shim.h>
4141

@@ -54,13 +54,13 @@ import CPython.Internal
5454
-- first). There is no return value; it is a fatal error if the initialization
5555
-- fails.
5656
{# fun Py_Initialize as initialize
57-
{} -> `()' id #}
57+
{} -> `()' id #}
5858

5959
-- | Return 'True' when the Python interpreter has been initialized, 'False'
6060
-- if not. After 'finalize' is called, this returns 'False' until
6161
-- 'initialize' is called again.
6262
{# fun Py_IsInitialized as isInitialized
63-
{} -> `Bool' #}
63+
{} -> `Bool' #}
6464

6565
-- | Undo all initializations made by 'initialize' and subsequent use of
6666
-- Python/C API computations, and destroy all sub-interpreters (see
@@ -89,7 +89,7 @@ import CPython.Internal
8989
-- initialization routine is called more than once; this can happen if an
9090
-- application calls 'initialize' and 'finalize' more than once.
9191
{# fun Py_Finalize as finalize
92-
{} -> `()' id #}
92+
{} -> `()' id #}
9393

9494
newtype ThreadState = ThreadState (Ptr ThreadState)
9595

@@ -147,10 +147,10 @@ newtype ThreadState = ThreadState (Ptr ThreadState)
147147
-- work). Simple things may work, but confusing behavior will always be near.
148148
newInterpreter :: IO (Maybe ThreadState)
149149
newInterpreter = do
150-
ptr <- {# call Py_NewInterpreter as ^ #}
151-
return $ if ptr == nullPtr
152-
then Nothing
153-
else Just $ ThreadState $ castPtr ptr
150+
ptr <- {# call Py_NewInterpreter as ^ #}
151+
return $ if ptr == nullPtr
152+
then Nothing
153+
else Just $ ThreadState $ castPtr ptr
154154

155155
-- | Destroy the (sub-)interpreter represented by the given thread state.
156156
-- The given thread state must be the current thread state. See the
@@ -162,14 +162,14 @@ newInterpreter = do
162162
-- explicitly destroyed at that point.
163163
endInterpreter :: ThreadState -> IO ()
164164
endInterpreter (ThreadState ptr) =
165-
{# call Py_EndInterpreter as ^ #} $ castPtr ptr
165+
{# call Py_EndInterpreter as ^ #} $ castPtr ptr
166166

167167
-- | Return the program name set with 'setProgramName', or the default.
168168
getProgramName :: IO Text
169169
getProgramName = pyGetProgramName >>= peekTextW
170170

171171
foreign import ccall safe "hscpython-shim.h Py_GetProgramName"
172-
pyGetProgramName :: IO CWString
172+
pyGetProgramName :: IO CWString
173173

174174
-- | This computation should be called before 'initialize' is called for the
175175
-- first time, if it is called at all. It tells the interpreter the value of
@@ -182,7 +182,7 @@ setProgramName :: Text -> IO ()
182182
setProgramName name = withTextW name cSetProgramName
183183

184184
foreign import ccall safe "hscpython-shim.h hscpython_SetProgramName"
185-
cSetProgramName :: CWString -> IO ()
185+
cSetProgramName :: CWString -> IO ()
186186

187187
-- | Return the prefix for installed platform-independent files. This is
188188
-- derived through a number of complicated rules from the program name set
@@ -196,7 +196,7 @@ getPrefix :: IO Text
196196
getPrefix = pyGetPrefix >>= peekTextW
197197

198198
foreign import ccall safe "hscpython-shim.h Py_GetPrefix"
199-
pyGetPrefix :: IO CWString
199+
pyGetPrefix :: IO CWString
200200

201201
-- | Return the /exec-prefix/ for installed platform-/dependent/ files. This
202202
-- is derived through a number of complicated rules from the program name
@@ -232,7 +232,7 @@ getExecPrefix :: IO Text
232232
getExecPrefix = pyGetExecPrefix >>= peekTextW
233233

234234
foreign import ccall safe "hscpython-shim.h Py_GetExecPrefix"
235-
pyGetExecPrefix :: IO CWString
235+
pyGetExecPrefix :: IO CWString
236236

237237
-- | Return the full program name of the Python executable; this is computed
238238
-- as a side-effect of deriving the default module search path from the
@@ -242,7 +242,7 @@ getProgramFullPath :: IO Text
242242
getProgramFullPath = pyGetProgramFullPath >>= peekTextW
243243

244244
foreign import ccall safe "hscpython-shim.h Py_GetProgramFullPath"
245-
pyGetProgramFullPath :: IO CWString
245+
pyGetProgramFullPath :: IO CWString
246246

247247
-- | Return the default module search path; this is computed from the
248248
-- program name (set by 'setProgramName' above) and some environment
@@ -255,7 +255,7 @@ getPath :: IO Text
255255
getPath = pyGetPath >>= peekTextW
256256

257257
foreign import ccall safe "hscpython-shim.h Py_GetPath"
258-
pyGetPath :: IO CWString
258+
pyGetPath :: IO CWString
259259

260260
-- | Return the version of this Python interpreter. This is a string that
261261
-- looks something like
@@ -269,7 +269,7 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
269269
-- separated by a period. The value is available to Python code as
270270
-- @sys.version@.
271271
{# fun Py_GetVersion as getVersion
272-
{} -> `Text' peekText* #}
272+
{} -> `Text' peekText* #}
273273

274274
-- | Return the platform identifier for the current platform. On Unix, this
275275
-- is formed from the &#x201c;official&#x201d; name of the operating system,
@@ -278,7 +278,7 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
278278
-- On Mac OS X, it is @\"darwin\"@. On Windows, it is @\"win\"@. The value
279279
-- is available to Python code as @sys.platform@.
280280
{# fun Py_GetPlatform as getPlatform
281-
{} -> `Text' peekText* #}
281+
{} -> `Text' peekText* #}
282282

283283
-- | Return the official copyright string for the current Python version,
284284
-- for example
@@ -289,7 +289,7 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
289289
--
290290
-- The value is available to Python code as @sys.copyright@.
291291
{# fun Py_GetCopyright as getCopyright
292-
{} -> `Text' peekText* #}
292+
{} -> `Text' peekText* #}
293293

294294
-- | Return an indication of the compiler used to build the current Python
295295
-- version, in square brackets, for example:
@@ -301,7 +301,7 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
301301
-- The value is available to Python code as part of the variable
302302
-- @sys.version@.
303303
{# fun Py_GetCompiler as getCompiler
304-
{} -> `Text' peekText* #}
304+
{} -> `Text' peekText* #}
305305

306306
-- | Return information about the sequence number and build date and time of
307307
-- the current Python interpreter instance, for example
@@ -313,7 +313,7 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
313313
-- The value is available to Python code as part of the variable
314314
-- @sys.version@.
315315
{# fun Py_GetBuildInfo as getBuildInfo
316-
{} -> `Text' peekText* #}
316+
{} -> `Text' peekText* #}
317317

318318
-- | Set @sys.argv@. The first parameter is similar to the result of
319319
-- 'getProgName', with the difference that it should refer to the script
@@ -327,12 +327,12 @@ foreign import ccall safe "hscpython-shim.h Py_GetPath"
327327
-- or just the interactive interpreter), the empty string is used instead.
328328
setArgv :: Text -> [Text] -> IO ()
329329
setArgv argv0 argv =
330-
mapWith withTextW (argv0 : argv) $ \textPtrs ->
331-
let argc = fromIntegral $ length textPtrs in
332-
withArray textPtrs $ pySetArgv argc
330+
mapWith withTextW (argv0 : argv) $ \textPtrs ->
331+
let argc = fromIntegral $ length textPtrs in
332+
withArray textPtrs $ pySetArgv argc
333333

334334
foreign import ccall safe "hscpython-shim.h PySys_SetArgv"
335-
pySetArgv :: CInt -> Ptr CWString -> IO ()
335+
pySetArgv :: CInt -> Ptr CWString -> IO ()
336336

337337
-- | Return the default &#x201c;home&#x201d;, that is, the value set by a
338338
-- previous call to 'setPythonHome', or the value of the @PYTHONHOME@
@@ -341,7 +341,7 @@ getPythonHome :: IO (Maybe Text)
341341
getPythonHome = pyGetPythonHome >>= peekMaybeTextW
342342

343343
foreign import ccall safe "hscpython-shim.h Py_GetPythonHome"
344-
pyGetPythonHome :: IO CWString
344+
pyGetPythonHome :: IO CWString
345345

346346
-- | Set the default &#x201c;home&#x201d; directory, that is, the location
347347
-- of the standard Python libraries. The libraries are searched in
@@ -351,4 +351,4 @@ setPythonHome :: Maybe Text -> IO ()
351351
setPythonHome name = withMaybeTextW name cSetPythonHome
352352

353353
foreign import ccall safe "hscpython-shim.h hscpython_SetPythonHome"
354-
cSetPythonHome :: CWString -> IO ()
354+
cSetPythonHome :: CWString -> IO ()

lib/CPython/Constants.chs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,38 @@
1616
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
module CPython.Constants
19-
( none
20-
, true
21-
, false
22-
, isNone
23-
, isTrue
24-
, isFalse
25-
) where
19+
( none
20+
, true
21+
, false
22+
, isNone
23+
, isTrue
24+
, isFalse
25+
) where
2626

2727
#include <hscpython-shim.h>
2828

2929
import CPython.Internal
3030

3131
-- | The Python @None@ object, denoting lack of value.
3232
{# fun unsafe hscpython_Py_None as none
33-
{} -> `SomeObject' peekObject* #}
33+
{} -> `SomeObject' peekObject* #}
3434

3535
-- | The Python @True@ object.
3636
{# fun unsafe hscpython_Py_True as true
37-
{} -> `SomeObject' peekObject* #}
37+
{} -> `SomeObject' peekObject* #}
3838

3939
-- | The Python @False@ object.
4040
{# fun unsafe hscpython_Py_False as false
41-
{} -> `SomeObject' peekObject* #}
41+
{} -> `SomeObject' peekObject* #}
4242

4343
{# fun pure unsafe hscpython_Py_None as rawNone
44-
{} -> `Ptr ()' id #}
44+
{} -> `Ptr ()' id #}
4545

4646
{# fun pure unsafe hscpython_Py_True as rawTrue
47-
{} -> `Ptr ()' id #}
47+
{} -> `Ptr ()' id #}
4848

4949
{# fun pure unsafe hscpython_Py_False as rawFalse
50-
{} -> `Ptr ()' id #}
50+
{} -> `Ptr ()' id #}
5151

5252
isNone :: SomeObject -> IO Bool
5353
isNone obj = withObject obj $ \ptr -> return $ ptr == rawNone

0 commit comments

Comments
 (0)
0