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
67e746b9
Commit
67e746b9
authored
Aug 17, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SHA256/512 module support.
Add basic support for C API attr members
parent
36192fb0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
10 deletions
+35
-10
include/pyport.h
include/pyport.h
+10
-0
src/Makefile
src/Makefile
+1
-1
src/runtime/capi.cpp
src/runtime/capi.cpp
+7
-8
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+4
-0
src/runtime/types.cpp
src/runtime/types.cpp
+5
-1
src/runtime/types.h
src/runtime/types.h
+2
-0
test/tests/hashlib_test.py
test/tests/hashlib_test.py
+6
-0
No files found.
include/pyport.h
View file @
67e746b9
...
...
@@ -13,6 +13,9 @@
typedef
ssize_t
Py_ssize_t
;
#define Py_FORMAT_PARSETUPLE(func,p1,p2)
#define Py_GCC_ATTRIBUTE(x) __attribute__(x)
#define HAVE_LONG_LONG 1
#define PY_LONG_LONG long long
// Pyston change: the rest of these have just been copied from CPython's pyport.h, in an arbitrary order:
...
...
@@ -126,6 +129,13 @@ typedef ssize_t Py_ssize_t;
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
#endif
#ifndef Py_LL
#define Py_LL(x) x##LL
#endif
#ifndef Py_ULL
#define Py_ULL(x) Py_LL(x##U)
#endif
#endif
/* Py_PYPORT_H */
src/Makefile
View file @
67e746b9
...
...
@@ -268,7 +268,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 md5.c md5module.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS
:=
errnomodule.c shamodule.c
sha256module.c sha512module.c
md5.c md5module.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS
:=
$(
addprefix
../lib_python/2.7_Modules/,
$(STDMODULE_SRCS)
)
# The stdlib objects have slightly longer dependency chains,
...
...
src/runtime/capi.cpp
View file @
67e746b9
...
...
@@ -225,7 +225,6 @@ extern "C" int PyType_Ready(PyTypeObject* cls) {
RELEASE_ASSERT
(
cls
->
tp_weaklistoffset
==
0
,
""
);
RELEASE_ASSERT
(
cls
->
tp_iter
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_iternext
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_members
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_base
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_dict
==
NULL
,
""
);
RELEASE_ASSERT
(
cls
->
tp_descr_get
==
NULL
,
""
);
...
...
@@ -254,13 +253,13 @@ extern "C" int PyType_Ready(PyTypeObject* cls) {
// tp_basicsize, tp_itemsize
// tp_doc
if
(
cls
->
tp_methods
)
{
PyMethodDef
*
method
=
cls
->
tp_methods
;
while
(
method
->
ml_name
)
{
auto
desc
=
new
BoxedMethodDescriptor
(
method
);
cls
->
giveAttr
(
method
->
ml_name
,
desc
);
method
++
;
}
for
(
PyMethodDef
*
method
=
cls
->
tp_methods
;
method
&&
method
->
ml_name
;
++
method
)
{
cls
->
giveAttr
(
method
->
ml_name
,
new
BoxedMethodDescriptor
(
method
));
}
for
(
PyMemberDef
*
member
=
cls
->
tp_members
;
member
&&
member
->
name
;
++
member
)
{
cls
->
giveAttr
(
member
->
name
,
new
BoxedMemberDescriptor
(
member
));
}
if
(
cls
->
tp_getset
)
{
...
...
src/runtime/objmodel.cpp
View file @
67e746b9
...
...
@@ -695,6 +695,10 @@ static Box* _handleClsAttr(Box* obj, Box* attr) {
bool
rtn
=
reinterpret_cast
<
bool
*>
(
obj
)[
member_desc
->
offset
];
return
boxBool
(
rtn
);
}
case
BoxedMemberDescriptor
:
:
INT
:
{
int
rtn
=
reinterpret_cast
<
int
*>
(
obj
)[
member_desc
->
offset
/
sizeof
(
int
)];
return
boxInt
(
rtn
);
}
default:
RELEASE_ASSERT
(
0
,
"%d"
,
member_desc
->
type
);
}
...
...
src/runtime/types.cpp
View file @
67e746b9
...
...
@@ -33,6 +33,8 @@
extern
"C"
void
initerrno
();
extern
"C"
void
init_sha
();
extern
"C"
void
init_sha256
();
extern
"C"
void
init_sha512
();
extern
"C"
void
init_md5
();
namespace
pyston
{
...
...
@@ -734,7 +736,9 @@ void setupRuntime() {
initerrno
();
init_sha
();
// init_md5();
init_sha256
();
init_sha512
();
init_md5
();
setupSysEnd
();
...
...
src/runtime/types.h
View file @
67e746b9
...
...
@@ -324,12 +324,14 @@ public:
enum
MemberType
{
BOOL
=
T_BOOL
,
BYTE
=
T_BYTE
,
INT
=
T_INT
,
OBJECT
=
T_OBJECT
,
}
type
;
int
offset
;
BoxedMemberDescriptor
(
MemberType
type
,
int
offset
)
:
Box
(
member_cls
),
type
(
type
),
offset
(
offset
)
{}
BoxedMemberDescriptor
(
PyMemberDef
*
member
)
:
Box
(
member_cls
),
type
((
MemberType
)
member
->
type
),
offset
(
member
->
offset
)
{}
};
// TODO is there any particular reason to make this a Box, ie a python-level object?
...
...
test/tests/hashlib_test.py
0 → 100644
View file @
67e746b9
import
hashlib
#for m in [hashlib.md5(), hashlib.sha1(), hashlib.sha256(), hashlib.sha512()]:
for
m
in
[
hashlib
.
sha256
(),
hashlib
.
sha512
()]:
m
.
update
(
"pyston"
)
print
m
.
digest_size
,
m
.
hexdigest
()
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