|
64 | 64 | object_method_old_new_handler( |
65 | 65 | Member* member, CAtom* atom, PyObject* oldvalue, PyObject* newvalue ) |
66 | 66 | { |
67 | | - cppy::ptr callable( PyObject_GetAttr( pyobject_cast( atom ), member->post_setattr_context ) ); |
68 | | - if( !callable ) |
69 | | - return -1; |
70 | | - cppy::ptr args( PyTuple_New( 2 ) ); |
71 | | - if( !args ) |
72 | | - return -1; |
73 | | - PyTuple_SET_ITEM( args.get(), 0, cppy::incref( oldvalue ) ); |
74 | | - PyTuple_SET_ITEM( args.get(), 1, cppy::incref( newvalue ) ); |
75 | | - if( !callable.call( args ) ) |
| 67 | + PyObject* args[] = { pyobject_cast( atom ), oldvalue, newvalue }; |
| 68 | + cppy::ptr ok( PyObject_VectorcallMethod( member->post_setattr_context, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) ); |
| 69 | + if( !ok ) |
76 | 70 | return -1; |
77 | 71 | return 0; |
78 | 72 | } |
|
82 | 76 | object_method_name_old_new_handler( |
83 | 77 | Member* member, CAtom* atom, PyObject* oldvalue, PyObject* newvalue ) |
84 | 78 | { |
85 | | - cppy::ptr callable( PyObject_GetAttr( pyobject_cast( atom ), member->post_setattr_context ) ); |
86 | | - if( !callable ) |
87 | | - return -1; |
88 | | - cppy::ptr args( PyTuple_New( 3 ) ); |
89 | | - if( !args ) |
90 | | - return -1; |
91 | | - PyTuple_SET_ITEM( args.get(), 0, cppy::incref( member->name ) ); |
92 | | - PyTuple_SET_ITEM( args.get(), 1, cppy::incref( oldvalue ) ); |
93 | | - PyTuple_SET_ITEM( args.get(), 2, cppy::incref( newvalue ) ); |
94 | | - if( !callable.call( args ) ) |
| 79 | + PyObject* args[] = { pyobject_cast( atom ), member->name, oldvalue, newvalue }; |
| 80 | + cppy::ptr ok( PyObject_VectorcallMethod( member->post_setattr_context, args, 4 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) ); |
| 81 | + if( !ok ) |
95 | 82 | return -1; |
96 | 83 | return 0; |
97 | 84 | } |
|
101 | 88 | member_method_object_old_new_handler( |
102 | 89 | Member* member, CAtom* atom, PyObject* oldvalue, PyObject* newvalue ) |
103 | 90 | { |
104 | | - cppy::ptr callable( PyObject_GetAttr( pyobject_cast( member ), member->post_setattr_context ) ); |
105 | | - if( !callable ) |
106 | | - return -1; |
107 | | - cppy::ptr args( PyTuple_New( 3 ) ); |
108 | | - if( !args ) |
109 | | - return -1; |
110 | | - PyTuple_SET_ITEM( args.get(), 0, cppy::incref( pyobject_cast( atom ) ) ); |
111 | | - PyTuple_SET_ITEM( args.get(), 1, cppy::incref( oldvalue ) ); |
112 | | - PyTuple_SET_ITEM( args.get(), 2, cppy::incref( newvalue ) ); |
113 | | - if( !callable.call( args ) ) |
| 91 | + PyObject* args[] = { pyobject_cast( member ), pyobject_cast( atom ), oldvalue, newvalue }; |
| 92 | + cppy::ptr ok( PyObject_VectorcallMethod( member->post_setattr_context, args, 4 | PY_VECTORCALL_ARGUMENTS_OFFSET, 0 ) ); |
| 93 | + if( !ok ) |
114 | 94 | return -1; |
115 | 95 | return 0; |
116 | 96 | } |
|
0 commit comments