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
0c693471
Commit
0c693471
authored
Sep 25, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add PyObject_AsWriteBuffer, _PyInstance_Lookup, PyInstance_NewRaw, PyInstance_New
parent
4b324243
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
src/capi/abstract.cpp
src/capi/abstract.cpp
+26
-0
src/capi/object.cpp
src/capi/object.cpp
+0
-4
src/capi/types.h
src/capi/types.h
+1
-0
src/runtime/classobj.cpp
src/runtime/classobj.cpp
+37
-0
No files found.
src/capi/abstract.cpp
View file @
0c693471
...
...
@@ -605,6 +605,32 @@ extern "C" int PyObject_AsReadBuffer(PyObject* obj, const void** buffer, Py_ssiz
return
0
;
}
extern
"C"
int
PyObject_AsWriteBuffer
(
PyObject
*
obj
,
void
**
buffer
,
Py_ssize_t
*
buffer_len
)
noexcept
{
PyBufferProcs
*
pb
;
void
*
pp
;
Py_ssize_t
len
;
if
(
obj
==
NULL
||
buffer
==
NULL
||
buffer_len
==
NULL
)
{
null_error
();
return
-
1
;
}
pb
=
obj
->
cls
->
tp_as_buffer
;
if
(
pb
==
NULL
||
pb
->
bf_getwritebuffer
==
NULL
||
pb
->
bf_getsegcount
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"expected a writeable buffer object"
);
return
-
1
;
}
if
((
*
pb
->
bf_getsegcount
)(
obj
,
NULL
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"expected a single-segment buffer object"
);
return
-
1
;
}
len
=
(
*
pb
->
bf_getwritebuffer
)(
obj
,
0
,
&
pp
);
if
(
len
<
0
)
return
-
1
;
*
buffer
=
pp
;
*
buffer_len
=
len
;
return
0
;
}
static
PyObject
*
call_function_tail
(
PyObject
*
callable
,
PyObject
*
args
)
{
PyObject
*
retval
;
...
...
src/capi/object.cpp
View file @
0c693471
...
...
@@ -564,10 +564,6 @@ extern "C" int PyObject_HasAttrString(PyObject* v, const char* name) noexcept {
return
0
;
}
extern
"C"
int
PyObject_AsWriteBuffer
(
PyObject
*
obj
,
void
**
buffer
,
Py_ssize_t
*
buffer_len
)
noexcept
{
Py_FatalError
(
"unimplemented"
);
}
// I'm not sure how we can support this one:
extern
"C"
PyObject
**
_PyObject_GetDictPtr
(
PyObject
*
obj
)
noexcept
{
fatalOrError
(
PyExc_NotImplementedError
,
"unimplemented"
);
...
...
src/capi/types.h
View file @
0c693471
...
...
@@ -68,6 +68,7 @@ public:
BoxedCApiFunction
*
o
=
static_cast
<
BoxedCApiFunction
*>
(
_o
);
Box
::
gcHandler
(
v
,
o
);
v
->
visitPotential
(
o
->
method_def
);
v
->
visit
(
&
o
->
passthrough
);
v
->
visit
(
&
o
->
module
);
}
...
...
src/runtime/classobj.cpp
View file @
0c693471
...
...
@@ -54,6 +54,34 @@ static Box* classLookup(BoxedClassobj* cls, BoxedString* attr, GetattrRewriteArg
return
NULL
;
}
extern
"C"
PyObject
*
_PyInstance_Lookup
(
PyObject
*
pinst
,
PyObject
*
pname
)
noexcept
{
RELEASE_ASSERT
(
PyInstance_Check
(
pinst
),
""
);
BoxedInstance
*
inst
=
(
BoxedInstance
*
)
pinst
;
RELEASE_ASSERT
(
PyString_Check
(
pname
),
""
);
BoxedString
*
name
=
(
BoxedString
*
)
pname
;
try
{
internStringMortalInplace
(
name
);
Box
*
v
=
inst
->
getattr
(
name
,
NULL
);
if
(
v
==
NULL
)
v
=
classLookup
(
inst
->
inst_cls
,
name
);
return
v
;
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
extern
"C"
PyObject
*
PyInstance_NewRaw
(
PyObject
*
klass
,
PyObject
*
dict
)
noexcept
{
RELEASE_ASSERT
(
!
dict
,
"not implemented"
);
if
(
!
PyClass_Check
(
klass
))
{
PyErr_BadInternalCall
();
return
NULL
;
}
return
new
BoxedInstance
((
BoxedClassobj
*
)
klass
);
}
extern
"C"
int
PyClass_IsSubclass
(
PyObject
*
klass
,
PyObject
*
base
)
noexcept
{
Py_ssize_t
i
,
n
;
if
(
klass
==
base
)
...
...
@@ -155,6 +183,15 @@ Box* classobjCall(Box* _cls, Box* _args, Box* _kwargs) {
return
made
;
}
extern
"C"
PyObject
*
PyInstance_New
(
PyObject
*
klass
,
PyObject
*
arg
,
PyObject
*
kw
)
noexcept
{
try
{
return
classobjCall
(
klass
,
arg
,
kw
);
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
return
NULL
;
}
}
static
Box
*
classobjGetattribute
(
Box
*
_cls
,
Box
*
_attr
)
{
RELEASE_ASSERT
(
_cls
->
cls
==
classobj_cls
,
""
);
BoxedClassobj
*
cls
=
static_cast
<
BoxedClassobj
*>
(
_cls
);
...
...
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