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
13459951
Commit
13459951
authored
Jan 27, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic "select" module support
parent
8a0d635a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
2 deletions
+114
-2
Makefile
Makefile
+1
-1
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+1
-1
from_cpython/Include/pyconfig.h
from_cpython/Include/pyconfig.h
+5
-0
src/runtime/capi.cpp
src/runtime/capi.cpp
+68
-0
src/runtime/dict.cpp
src/runtime/dict.cpp
+10
-0
src/runtime/list.cpp
src/runtime/list.cpp
+20
-0
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
test/tests/select_test.py
test/tests/select_test.py
+7
-0
No files found.
Makefile
View file @
13459951
...
...
@@ -290,7 +290,7 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS
:=
stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c
selectmodule.c
$(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS
:=
structseq.c capsule.c stringobject.c
$(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS
:=
pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.c
$(EXTRA_STDPYTHON_SRCS)
FROM_CPYTHON_SRCS
:=
$(
addprefix
from_cpython/Modules/,
$(STDMODULE_SRCS)
)
$(
addprefix
from_cpython/Objects/,
$(STDOBJECT_SRCS)
)
$(
addprefix
from_cpython/Python/,
$(STDPYTHON_SRCS)
)
...
...
from_cpython/CMakeLists.txt
View file @
13459951
...
...
@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
add_custom_target
(
copy_stdlib ALL DEPENDS
${
STDLIB_TARGETS
}
)
# compile specified files in from_cpython/Modules
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c
)
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c
selectmodule.c
)
# compile specified files in from_cpython/Objects
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c
)
...
...
from_cpython/Include/pyconfig.h
View file @
13459951
...
...
@@ -17,6 +17,8 @@
#ifndef Py_PYCONFIG_H
#define Py_PYCONFIG_H
#define _GNU_SOURCE 1
#define HAVE_STDARG_PROTOTYPES
#define HAVE_LONG_LONG 1
#define PY_LONG_LONG long long
...
...
@@ -41,6 +43,9 @@
#define HAVE_UINTPTR_T 1
#define HAVE_INT32_T 1
#define HAVE_INT64_T 1
#define HAVE_EPOLL 1
#define HAVE_POLL 1
#define HAVE_SELECT 1
#define PY_FORMAT_LONG_LONG "ll"
#define PY_FORMAT_SIZE_T "z"
...
...
src/runtime/capi.cpp
View file @
13459951
...
...
@@ -1309,6 +1309,74 @@ extern "C" PyObject* _PyImport_FindExtension(char* name, char* filename) noexcep
Py_FatalError
(
"unimplemented"
);
}
static
PyObject
*
listmethodchain
(
PyMethodChain
*
chain
)
noexcept
{
PyMethodChain
*
c
;
PyMethodDef
*
ml
;
int
i
,
n
;
PyObject
*
v
;
n
=
0
;
for
(
c
=
chain
;
c
!=
NULL
;
c
=
c
->
link
)
{
for
(
ml
=
c
->
methods
;
ml
->
ml_name
!=
NULL
;
ml
++
)
n
++
;
}
v
=
PyList_New
(
n
);
if
(
v
==
NULL
)
return
NULL
;
i
=
0
;
for
(
c
=
chain
;
c
!=
NULL
;
c
=
c
->
link
)
{
for
(
ml
=
c
->
methods
;
ml
->
ml_name
!=
NULL
;
ml
++
)
{
PyList_SetItem
(
v
,
i
,
PyString_FromString
(
ml
->
ml_name
));
i
++
;
}
}
if
(
PyErr_Occurred
())
{
Py_DECREF
(
v
);
return
NULL
;
}
PyList_Sort
(
v
);
return
v
;
}
extern
"C"
PyObject
*
Py_FindMethodInChain
(
PyMethodChain
*
chain
,
PyObject
*
self
,
const
char
*
name
)
noexcept
{
if
(
name
[
0
]
==
'_'
&&
name
[
1
]
==
'_'
)
{
if
(
strcmp
(
name
,
"__methods__"
)
==
0
)
{
if
(
PyErr_WarnPy3k
(
"__methods__ not supported in 3.x"
,
1
)
<
0
)
return
NULL
;
return
listmethodchain
(
chain
);
}
if
(
strcmp
(
name
,
"__doc__"
)
==
0
)
{
const
char
*
doc
=
self
->
cls
->
tp_doc
;
if
(
doc
!=
NULL
)
return
PyString_FromString
(
doc
);
}
}
while
(
chain
!=
NULL
)
{
PyMethodDef
*
ml
=
chain
->
methods
;
for
(;
ml
->
ml_name
!=
NULL
;
ml
++
)
{
if
(
name
[
0
]
==
ml
->
ml_name
[
0
]
&&
strcmp
(
name
+
1
,
ml
->
ml_name
+
1
)
==
0
)
/* XXX */
return
PyCFunction_New
(
ml
,
self
);
}
chain
=
chain
->
link
;
}
PyErr_SetString
(
PyExc_AttributeError
,
name
);
return
NULL
;
}
/* Find a method in a single method list */
extern
"C"
PyObject
*
Py_FindMethod
(
PyMethodDef
*
methods
,
PyObject
*
self
,
const
char
*
name
)
noexcept
{
PyMethodChain
chain
;
chain
.
methods
=
methods
;
chain
.
link
=
NULL
;
return
Py_FindMethodInChain
(
&
chain
,
self
,
name
);
}
extern
"C"
PyObject
*
PyCFunction_NewEx
(
PyMethodDef
*
ml
,
PyObject
*
self
,
PyObject
*
module
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
}
BoxedModule
*
importTestExtension
(
const
std
::
string
&
name
)
{
std
::
string
pathname_name
=
"test/test_extension/"
+
name
+
".pyston.so"
;
const
char
*
pathname
=
pathname_name
.
c_str
();
...
...
src/runtime/dict.cpp
View file @
13459951
...
...
@@ -284,6 +284,16 @@ Box* dictDelitem(BoxedDict* self, Box* k) {
return
None
;
}
extern
"C"
int
PyDict_DelItem
(
PyObject
*
op
,
PyObject
*
key
)
noexcept
{
try
{
dictDelitem
((
BoxedDict
*
)
op
,
key
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
-
1
;
}
return
0
;
}
Box
*
dictPop
(
BoxedDict
*
self
,
Box
*
k
,
Box
*
d
)
{
if
(
!
isSubclass
(
self
->
cls
,
dict_cls
))
raiseExcHelper
(
TypeError
,
"descriptor 'pop' requires a 'dict' object but received a '%s'"
,
...
...
src/runtime/list.cpp
View file @
13459951
...
...
@@ -39,6 +39,10 @@ extern "C" int PyList_Append(PyObject* op, PyObject* newitem) noexcept {
return
0
;
}
extern
"C"
int
PyList_SetItem
(
PyObject
*
op
,
Py_ssize_t
i
,
PyObject
*
newitem
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
}
extern
"C"
Box
*
listRepr
(
BoxedList
*
self
)
{
LOCK_REGION
(
self
->
lock
.
asRead
());
...
...
@@ -428,6 +432,22 @@ Box* listSort1(BoxedList* self) {
return
None
;
}
extern
"C"
int
PyList_Sort
(
PyObject
*
v
)
noexcept
{
if
(
v
==
NULL
||
!
PyList_Check
(
v
))
{
PyErr_BadInternalCall
();
return
-
1
;
}
try
{
listSort1
((
BoxedList
*
)
v
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
-
1
;
}
return
0
;
}
Box
*
listContains
(
BoxedList
*
self
,
Box
*
elt
)
{
LOCK_REGION
(
self
->
lock
.
asRead
());
...
...
src/runtime/types.cpp
View file @
13459951
...
...
@@ -54,6 +54,7 @@ extern "C" void init_collections();
extern
"C"
void
inititertools
();
extern
"C"
void
initresource
();
extern
"C"
void
initsignal
();
extern
"C"
void
initselect
();
namespace
pyston
{
...
...
@@ -1188,6 +1189,7 @@ void setupRuntime() {
inititertools
();
initresource
();
initsignal
();
initselect
();
setupSysEnd
();
...
...
test/tests/select_test.py
0 → 100644
View file @
13459951
import
select
for
k
in
sorted
(
dir
(
select
)):
if
not
k
.
startswith
(
"EPOLL"
)
and
not
k
.
startswith
(
"POLL"
):
continue
print
k
,
getattr
(
select
,
k
)
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