Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
0ef87733
Commit
0ef87733
authored
Jun 16, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for the _curses, bz2, and grp modules (mercurial needs them)
parent
649e33f4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
209 additions
and
5 deletions
+209
-5
.travis.yml
.travis.yml
+1
-0
CMakeLists.txt
CMakeLists.txt
+1
-1
docs/INSTALLING.md
docs/INSTALLING.md
+3
-3
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+4
-0
from_cpython/Include/py_curses.h
from_cpython/Include/py_curses.h
+176
-0
from_cpython/Modules/_cursesmodule.c
from_cpython/Modules/_cursesmodule.c
+1
-1
src/runtime/file.cpp
src/runtime/file.cpp
+15
-0
src/runtime/types.cpp
src/runtime/types.cpp
+8
-0
No files found.
.travis.yml
View file @
0ef87733
...
...
@@ -24,6 +24,7 @@ addons:
-
cmake
-
g++-4.8
-
gdb
-
libbz2-dev
-
libgmp3-dev
-
liblzma-dev
-
libncurses5-dev
...
...
CMakeLists.txt
View file @
0ef87733
...
...
@@ -213,7 +213,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/linkdeps_dummy.c COMMAND ${CMAKE_C
add_executable
(
pyston $<TARGET_OBJECTS:PYSTON_MAIN_OBJECT> $<TARGET_OBJECTS:PYSTON_OBJECTS> $<TARGET_OBJECTS:FROM_CPYTHON> linkdeps_dummy.c
)
# Wrap the stdlib in --whole-archive to force all the symbols to be included and eventually exported
target_link_libraries
(
pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m z readline sqlite3 gmp ssl crypto unwind pypa liblz4 double-conversion
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
${
OPTIONAL_LIBRARIES
}
)
target_link_libraries
(
pyston -Wl,--whole-archive stdlib -Wl,--no-whole-archive pthread m z readline sqlite3 gmp ssl crypto unwind pypa liblz4 double-conversion
bz2 curses
${
LLVM_LIBS
}
${
LIBLZMA_LIBRARIES
}
${
OPTIONAL_LIBRARIES
}
)
# copy src/codegen/parse_ast.py to the build directory
add_custom_command
(
TARGET pyston POST_BUILD COMMAND
${
CMAKE_COMMAND
}
-E copy_if_different
${
CMAKE_SOURCE_DIR
}
/src/codegen/parse_ast.py
${
CMAKE_BINARY_DIR
}
/src/codegen/parse_ast.py
)
...
...
docs/INSTALLING.md
View file @
0ef87733
...
...
@@ -14,18 +14,18 @@ sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo add-apt-repository --yes ppa:kubuntu-ppa/backports
sudo apt-get -qq update
sudo apt-get install -yq git cmake ninja-build ccache libncurses5-dev liblzma-dev libreadline-dev libgmp3-dev autoconf libtool python-dev texlive-extra-utils clang-3.4 libstdc++-4.8-dev libssl-dev libsqlite3-dev pkg-config
sudo apt-get install -yq git cmake ninja-build ccache libncurses5-dev liblzma-dev libreadline-dev libgmp3-dev autoconf libtool python-dev texlive-extra-utils clang-3.4 libstdc++-4.8-dev libssl-dev libsqlite3-dev pkg-config
libbz2-dev
```
**Ubuntu 14.04/14.10/15.04**
```
sudo apt-get install -yq git cmake ninja-build ccache libncurses5-dev liblzma-dev libreadline-dev libgmp3-dev autoconf libtool python-dev texlive-extra-utils clang libssl-dev libsqlite3-dev pkg-config
sudo apt-get install -yq git cmake ninja-build ccache libncurses5-dev liblzma-dev libreadline-dev libgmp3-dev autoconf libtool python-dev texlive-extra-utils clang libssl-dev libsqlite3-dev pkg-config
libbz2-dev
```
**Fedora 21**
```
sudo yum install cmake clang gcc gcc-c++ ccache ninja-build xz-devel automake libtool gmp-devel readline-devel openssl-devel sqlite-devel python-devel zlib-devel
sudo yum install cmake clang gcc gcc-c++ ccache ninja-build xz-devel automake libtool gmp-devel readline-devel openssl-devel sqlite-devel python-devel zlib-devel
bzip2-devel ncurses-devel
```
### Building and testing
...
...
from_cpython/CMakeLists.txt
View file @
0ef87733
...
...
@@ -20,6 +20,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
_codecsmodule.c
_collectionsmodule.c
_csv.c
_cursesmodule.c
_functoolsmodule.c
_iomodule.c
_math.c
...
...
@@ -32,6 +33,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
binascii.c
bufferedio.c
bytesio.c
bz2module.c
cache.c
connection.c
cStringIO.c
...
...
@@ -41,6 +43,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
fcntlmodule.c
fileio.c
getpath.c
grpmodule.c
iobase.c
itertoolsmodule.c
mathmodule.c
...
...
@@ -63,6 +66,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
statement.c
stringio.c
stropmodule.c
termios.c
textio.c
threadmodule.c
timemodule.c
...
...
from_cpython/Include/py_curses.h
0 → 100644
View file @
0ef87733
#ifndef Py_CURSES_H
#define Py_CURSES_H
#ifdef __APPLE__
/*
** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
** against multiple definition of wchar_t.
*/
#ifdef _BSD_WCHAR_T_DEFINED_
#define _WCHAR_T
#endif
/* the following define is necessary for OS X 10.6; without it, the
Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
can't get at the WINDOW flags field. */
#define NCURSES_OPAQUE 0
#endif
/* __APPLE__ */
#ifdef __FreeBSD__
/*
** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
** against multiple definition of wchar_t and wint_t.
*/
#ifdef _XOPEN_SOURCE_EXTENDED
#ifndef __FreeBSD_version
#include <osreldate.h>
#endif
#if __FreeBSD_version >= 500000
#ifndef __wchar_t
#define __wchar_t
#endif
#ifndef __wint_t
#define __wint_t
#endif
#else
#ifndef _WCHAR_T
#define _WCHAR_T
#endif
#ifndef _WINT_T
#define _WINT_T
#endif
#endif
#endif
#endif
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#ifdef HAVE_TERM_H
/* for tigetstr, which is not declared in SysV curses */
#include <term.h>
#endif
#endif
#ifdef HAVE_NCURSES_H
/* configure was checking <curses.h>, but we will
use <ncurses.h>, which has all these features. */
#ifndef WINDOW_HAS_FLAGS
#define WINDOW_HAS_FLAGS 1
#endif
#ifndef MVWDELCH_IS_EXPRESSION
#define MVWDELCH_IS_EXPRESSION 1
#endif
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
#define PyCurses_API_pointers 4
/* Type declarations */
typedef
struct
{
PyObject_HEAD
WINDOW
*
win
;
}
PyCursesWindowObject
;
#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)
#define PyCurses_CAPSULE_NAME "_curses._C_API"
#ifdef CURSES_MODULE
/* This section is used when compiling _cursesmodule.c */
#else
/* This section is used in modules that use the _cursesmodule API */
static
void
**
PyCurses_API
;
#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0])
#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
#define import_curses() \
PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
#endif
/* general error messages */
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
X - function name
TYPE - parameter Type
ERGSTR - format string for construction of the return value
PARSESTR - format string for argument parsing
*/
#define NoArgNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
return PyCursesCheckERR(X(), # X); }
#define NoArgOrFlagNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \
{ \
int flag = 0; \
PyCursesInitialised \
switch(PyTuple_Size(args)) { \
case 0: \
return PyCursesCheckERR(X(), # X); \
case 1: \
if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \
if (flag) return PyCursesCheckERR(X(), # X); \
else return PyCursesCheckERR(no ## X (), # X); \
default: \
PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \
return NULL; } }
#define NoArgReturnIntFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
return PyInt_FromLong((long) X()); }
#define NoArgReturnStringFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
return PyString_FromString(X()); }
#define NoArgTrueFalseFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (X () == FALSE) { \
Py_INCREF(Py_False); \
return Py_False; \
} \
Py_INCREF(Py_True); \
return Py_True; }
#define NoArgNoReturnVoidFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
X(); \
Py_INCREF(Py_None); \
return Py_None; }
#ifdef __cplusplus
}
#endif
#endif
/* !defined(Py_CURSES_H) */
from_cpython/Modules/_cursesmodule.c
View file @
0ef87733
...
...
@@ -1064,7 +1064,7 @@ PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args)
case
2
:
if
(
!
PyArg_ParseTuple
(
args
,
"ii;y,x"
,
&
y
,
&
x
))
return
NULL
;
rtn
=
mvwinch
(
self
->
win
,
y
,
x
);
rtn
=
(
int
)
mvwinch
(
self
->
win
,
y
,
x
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"inch requires 0 or 2 arguments"
);
...
...
src/runtime/file.cpp
View file @
0ef87733
...
...
@@ -1127,6 +1127,21 @@ Box* fileIterHasNext(Box* s) {
return
boxBool
(
!
fileEof
(
self
));
}
extern
"C"
void
PyFile_IncUseCount
(
PyFileObject
*
_f
)
noexcept
{
BoxedFile
*
f
=
reinterpret_cast
<
BoxedFile
*>
(
_f
);
assert
(
f
->
cls
==
file_cls
);
f
->
unlocked_count
++
;
}
extern
"C"
void
PyFile_DecUseCount
(
PyFileObject
*
_f
)
noexcept
{
BoxedFile
*
f
=
reinterpret_cast
<
BoxedFile
*>
(
_f
);
assert
(
f
->
cls
==
file_cls
);
f
->
unlocked_count
--
;
assert
(
f
->
unlocked_count
>=
0
);
}
extern
"C"
void
PyFile_SetFP
(
PyObject
*
_f
,
FILE
*
fp
)
noexcept
{
assert
(
_f
->
cls
==
file_cls
);
BoxedFile
*
f
=
static_cast
<
BoxedFile
*>
(
_f
);
...
...
src/runtime/types.cpp
View file @
0ef87733
...
...
@@ -84,6 +84,10 @@ extern "C" void init_ssl();
extern
"C"
void
init_sqlite3
();
extern
"C"
void
PyMarshal_Init
();
extern
"C"
void
initstrop
();
extern
"C"
void
initgrp
();
extern
"C"
void
initbz2
();
extern
"C"
void
init_curses
();
extern
"C"
void
inittermios
();
namespace
pyston
{
...
...
@@ -3382,6 +3386,10 @@ void setupRuntime() {
init_sqlite3
();
PyMarshal_Init
();
initstrop
();
initgrp
();
initbz2
();
init_curses
();
inittermios
();
// some additional setup to ensure weakrefs participate in our GC
BoxedClass
*
weakref_ref_cls
=
&
_PyWeakref_RefType
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment