Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ExtensionClass-2.13.2
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
ExtensionClass-2.13.2
Commits
bca9323e
Commit
bca9323e
authored
Oct 20, 2016
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite part of Base_getattro
parent
dc34f2c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
20 deletions
+65
-20
src/ExtensionClass/_ExtensionClass.c
src/ExtensionClass/_ExtensionClass.c
+65
-20
No files found.
src/ExtensionClass/_ExtensionClass.c
View file @
bca9323e
...
...
@@ -122,28 +122,19 @@ Base_getattro(PyObject *obj, PyObject *name)
}
}
/* Inline _PyObject_GetDictPtr */
dictoffset
=
tp
->
tp_dictoffset
;
if
(
dictoffset
!=
0
)
{
PyObject
*
dict
;
if
(
dictoffset
<
0
)
{
int
tsize
;
size_t
size
;
tsize
=
((
PyVarObject
*
)
obj
)
->
ob_size
;
if
(
tsize
<
0
)
tsize
=
-
tsize
;
size
=
_PyObject_VAR_SIZE
(
tp
,
tsize
);
dictoffset
+=
(
long
)
size
;
assert
(
dictoffset
>
0
);
assert
(
dictoffset
%
SIZEOF_VOID_P
==
0
);
}
dictptr
=
(
PyObject
**
)
((
char
*
)
obj
+
dictoffset
);
dict
=
*
dictptr
;
// Pyston change:
// The code below basically did these things:
// get the dict of the obj
// get the item in the dict by name
// if the item type is ExtensionClassType
// then do something
PyObject
*
dict
=
PyObject_GetDict
(
obj
);
// New API added in Pyston
if
(
dict
)
{
res
=
PyDict_GetItem
(
dict
,
name
);
if
(
dict
!=
NULL
)
{
Py_INCREF
(
dict
);
res
=
PyDict_GetItem
(
dict
,
name
);
// get the dict item through the name
if
(
res
!=
NULL
)
{
Py_INCREF
(
res
);
Py_XDECREF
(
descr
);
...
...
@@ -153,6 +144,9 @@ Base_getattro(PyObject *obj, PyObject *name)
If the tp_descr_get of res is of_get,
then call it. */
// if the item type is ExtensionClassType
// and the tp_descr_get is not NULL
// do something
if
(
PyObject_TypeCheck
(
res
->
ob_type
,
&
ExtensionClassType
)
&&
res
->
ob_type
->
tp_descr_get
!=
NULL
)
{
...
...
@@ -168,6 +162,57 @@ Base_getattro(PyObject *obj, PyObject *name)
Py_DECREF
(
dict
);
}
}
/* Inline _PyObject_GetDictPtr */
/* dictoffset = tp->tp_dictoffset; */
/* if (dictoffset != 0) { */
/* PyObject *dict; */
/* if (dictoffset < 0) { */
/* int tsize; */
/* size_t size; */
/* */
/* tsize = ((PyVarObject *)obj)->ob_size; */
/* if (tsize < 0) */
/* tsize = -tsize; */
/* size = _PyObject_VAR_SIZE(tp, tsize); */
/* */
/* dictoffset += (long)size; */
/* assert(dictoffset > 0); */
/* assert(dictoffset % SIZEOF_VOID_P == 0); */
/* } */
/* dictptr = (PyObject **) ((char *)obj + dictoffset); */
/* dict = *dictptr; */
/* // get the dict object */
/* if (dict != NULL) { */
/* Py_INCREF(dict); */
/* res = PyDict_GetItem(dict, name); */
/* // get the dict item through the name */
/* if (res != NULL) { */
/* Py_INCREF(res); */
/* Py_XDECREF(descr); */
/* Py_DECREF(dict); */
/* */
/* #<{(| CHANGED! */
/* If the tp_descr_get of res is of_get, */
/* then call it. |)}># */
/* */
/* // if the item type is ExtensionClassType */
/* // and the tp_descr_get is not NULL */
/* // do something */
/* if (PyObject_TypeCheck(res->ob_type, */
/* &ExtensionClassType) */
/* && res->ob_type->tp_descr_get != NULL) { */
/* PyObject *tres; */
/* tres = res->ob_type->tp_descr_get( */
/* res, obj, */
/* OBJECT(obj->ob_type)); */
/* Py_DECREF(res); */
/* res = tres; */
/* } */
/* goto done; */
/* } */
/* Py_DECREF(dict); */
/* } */
/* } */
if
(
f
!=
NULL
)
{
res
=
f
(
descr
,
obj
,
(
PyObject
*
)
obj
->
ob_type
);
...
...
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