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
39b32381
Commit
39b32381
authored
Jul 23, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the _ctypes module to compile.
parent
bb31b6ee
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
7 deletions
+113
-7
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+6
-0
from_cpython/Include/compile.h
from_cpython/Include/compile.h
+40
-0
from_cpython/Modules/_ctypes/callbacks.c
from_cpython/Modules/_ctypes/callbacks.c
+10
-1
from_cpython/Modules/_ctypes/cfield.c
from_cpython/Modules/_ctypes/cfield.c
+3
-1
from_cpython/setup.py
from_cpython/setup.py
+54
-5
No files found.
from_cpython/CMakeLists.txt
View file @
39b32381
...
...
@@ -118,6 +118,7 @@ add_custom_command(OUTPUT
${
CMAKE_BINARY_DIR
}
/lib_pyston/pyexpat.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/_elementtree.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/bz2.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/_ctypes.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/grp.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/termios.pyston.so
${
CMAKE_BINARY_DIR
}
/lib_pyston/_curses.pyston.so
...
...
@@ -129,6 +130,11 @@ add_custom_command(OUTPUT
Modules/_multiprocessing/multiprocessing.c
Modules/_multiprocessing/semaphore.c
Modules/_multiprocessing/socket_connection.c
Modules/_ctypes/_ctypes.c
Modules/_ctypes/callbacks.c
Modules/_ctypes/callproc.c
Modules/_ctypes/stgdict.c
Modules/_ctypes/cfield.c
Modules/expat/xmlparse.c
Modules/expat/xmlrole.c
Modules/expat/xmltok.c
...
...
from_cpython/Include/compile.h
0 → 100644
View file @
39b32381
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
#include "code.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* Public interface */
struct
_node
;
/* Declare the existence of this type */
PyAPI_FUNC
(
PyCodeObject
*
)
PyNode_Compile
(
struct
_node
*
,
const
char
*
);
/* Future feature support */
typedef
struct
{
int
ff_features
;
/* flags set by future statements */
int
ff_lineno
;
/* line number of last future statement */
}
PyFutureFeatures
;
#define FUTURE_NESTED_SCOPES "nested_scopes"
#define FUTURE_GENERATORS "generators"
#define FUTURE_DIVISION "division"
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
#define FUTURE_WITH_STATEMENT "with_statement"
#define FUTURE_PRINT_FUNCTION "print_function"
#define FUTURE_UNICODE_LITERALS "unicode_literals"
struct
_mod
;
/* Declare the existence of this type */
PyAPI_FUNC
(
PyCodeObject
*
)
PyAST_Compile
(
struct
_mod
*
,
const
char
*
,
PyCompilerFlags
*
,
PyArena
*
);
PyAPI_FUNC
(
PyFutureFeatures
*
)
PyFuture_FromAST
(
struct
_mod
*
,
const
char
*
);
#ifdef __cplusplus
}
#endif
#endif
/* !Py_COMPILE_H */
from_cpython/Modules/_ctypes/callbacks.c
View file @
39b32381
...
...
@@ -4,7 +4,10 @@
#include "Python.h"
#include "compile.h"
/* required only for 2.3, as it seems */
#include "frameobject.h"
// Pyston change: We don't have this file and commented out the function that needs it, but
// we may want to support that function in the future.
//#include "frameobject.h"
#include <ffi.h>
#ifdef MS_WIN32
...
...
@@ -149,6 +152,9 @@ failed:
/* after code that pyrex generates */
void
_ctypes_add_traceback
(
char
*
funcname
,
char
*
filename
,
int
lineno
)
{
// TODO: Pyston change:
// Supporting this will require frameobject.h
#if 0
PyObject *py_globals = 0;
PyCodeObject *py_code = 0;
PyFrameObject *py_frame = 0;
...
...
@@ -170,6 +176,9 @@ void _ctypes_add_traceback(char *funcname, char *filename, int lineno)
Py_XDECREF(py_globals);
Py_XDECREF(py_code);
Py_XDECREF(py_frame);
#else
assert
(
false
);
#endif
}
#ifdef MS_WIN32
...
...
from_cpython/Modules/_ctypes/cfield.c
View file @
39b32381
...
...
@@ -1291,7 +1291,9 @@ s_get(void *ptr, Py_ssize_t size)
*/
slen
=
strlen
(
PyString_AS_STRING
(
result
));
size
=
min
(
size
,
(
Py_ssize_t
)
slen
);
if
(
result
->
ob_refcnt
==
1
)
{
// Pyston change: no ob_refcnt
if
(
false
/*result->ob_refcnt == 1*/
)
{
/* shorten the result */
_PyString_Resize
(
&
result
,
size
);
return
result
;
...
...
from_cpython/setup.py
View file @
39b32381
...
...
@@ -2,11 +2,22 @@
from
distutils.core
import
setup
,
Extension
import
os
import
sysconfig
def
relpath
(
fn
):
r
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
fn
)
return
r
def
unique
(
f
):
# Use an array otherwise Python 2 gets confused about scoping.
cache
=
[]
def
wrapper
(
*
args
):
if
len
(
cache
)
==
0
:
cache
.
append
(
f
(
*
args
))
return
cache
[
0
]
return
wrapper
@
unique
def
multiprocessing_ext
():
return
Extension
(
"_multiprocessing"
,
sources
=
map
(
relpath
,
[
"Modules/_multiprocessing/multiprocessing.c"
,
...
...
@@ -14,26 +25,58 @@ def multiprocessing_ext():
"Modules/_multiprocessing/semaphore.c"
,
]))
@
unique
def
bz2_ext
():
return
Extension
(
"bz2"
,
sources
=
map
(
relpath
,
[
"Modules/bz2module.c"
,
]),
libraries
=
[
'bz2'
])
@
unique
def
ctypes_ext
():
ext
=
Extension
(
"_ctypes"
,
sources
=
map
(
relpath
,
[
"Modules/_ctypes/_ctypes.c"
,
"Modules/_ctypes/callbacks.c"
,
"Modules/_ctypes/callproc.c"
,
"Modules/_ctypes/stgdict.c"
,
"Modules/_ctypes/cfield.c"
]))
# Hack: Just copy the values of ffi_inc and ffi_lib from CPython's setup.py
# May want something more robust later.
ffi_inc
=
[
'/usr/include/x86_64-linux-gnu'
]
ffi_lib
=
"ffi_pic"
ext
.
include_dirs
.
extend
(
ffi_inc
)
ext
.
libraries
.
append
(
ffi_lib
)
return
ext
@
unique
def
ctypes_test_ext
():
# TODO: I'm not sure how to use the ctypes tests, I just copied it over
# from CPython's setup.py. For now we're only importing ctypes, not passing
# all its tests.
return
Extension
(
'_ctypes_test'
,
sources
=
map
(
relpath
,
[
'Modules/_ctypes/_ctypes_test.c'
]))
@
unique
def
grp_ext
():
return
Extension
(
"grp"
,
sources
=
map
(
relpath
,
[
"Modules/grpmodule.c"
,
]))
@
unique
def
curses_ext
():
return
Extension
(
"_curses"
,
sources
=
map
(
relpath
,
[
"Modules/_cursesmodule.c"
,
]),
libraries
=
[
'curses'
])
@
unique
def
termios_ext
():
return
Extension
(
"termios"
,
sources
=
map
(
relpath
,
[
"Modules/termios.c"
,
]))
@
unique
def
pyexpat_ext
():
define_macros
=
[(
'HAVE_EXPAT_CONFIG_H'
,
'1'
),]
expat_sources
=
map
(
relpath
,
[
'Modules/expat/xmlparse.c'
,
...
...
@@ -60,6 +103,7 @@ def pyexpat_ext():
depends
=
expat_depends
,
)
@
unique
def
elementtree_ext
():
# elementtree depends on expat
pyexpat
=
pyexpat_ext
()
...
...
@@ -71,10 +115,15 @@ def elementtree_ext():
sources
=
[
relpath
(
'Modules/_elementtree.c'
)],
depends
=
pyexpat
.
depends
,
)
ext_modules
=
[
multiprocessing_ext
(),
pyexpat_ext
(),
elementtree_ext
(),
bz2_ext
(),
ctypes_ext
(),
ctypes_test_ext
(),
grp_ext
(),
curses_ext
(),
termios_ext
()]
setup
(
name
=
"Pyston"
,
version
=
"1.0"
,
description
=
"Pyston shared modules"
,
ext_modules
=
[
multiprocessing_ext
(),
pyexpat_ext
(),
elementtree_ext
(),
bz2_ext
(),
grp_ext
(),
curses_ext
(),
termios_ext
()]
)
setup
(
name
=
"Pyston"
,
version
=
"1.0"
,
description
=
"Pyston shared modules"
,
ext_modules
=
ext_modules
)
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