@@ -249,46 +249,53 @@ typedef return_value_policy<copy_const_reference> copy_const_reference_policy;
249
249
typedef return_value_policy<return_by_value> return_by_value_policy;
250
250
251
251
// ---------------------------------------------------------------------------------
252
- // Provides post-construction initialization support of the Python instances .
252
+ // Call policies that initializes the wrapper hierarchy .
253
253
// ---------------------------------------------------------------------------------
254
- template <typename BasePolicies = default_call_policies>
255
- struct initializer_call_policies : BasePolicies
254
+ template <typename HeldType, typename BasePolicies = default_call_policies, int iSelf = - 1 >
255
+ struct initialize_wrapper_policies : BasePolicies
256
256
{
257
257
template <typename ArgumentPackage>
258
258
static PyObject *postcall (const ArgumentPackage &args, PyObject *pResult)
259
259
{
260
- return incref (Py_None); // __init__ should always return None
260
+ PyObject *pSelf = detail::get (boost::mpl::int_<iSelf>(), args);
261
+ detail::initialize_wrapper (
262
+ pSelf,
263
+ get_pointer ((HeldType)extract<HeldType>(pSelf))
264
+ );
265
+
266
+ return BasePolicies::postcall (args, pResult);
261
267
}
262
268
};
263
269
264
- template <typename Constructor, typename Initializer>
265
- struct constructor_initializer
270
+ // ---------------------------------------------------------------------------------
271
+ // Provides post-construction initialization support of the Python instances.
272
+ // ---------------------------------------------------------------------------------
273
+ template <typename BasePolicies = default_call_policies, int iSelf = -1 >
274
+ struct post_constructor_policies : BasePolicies
266
275
{
267
276
public:
268
- constructor_initializer (Constructor constructor, Initializer initializer):
269
- m_constructor (constructor),
277
+ post_constructor_policies (object initializer):
270
278
m_initializer (initializer)
271
279
{
272
280
}
273
281
274
- object operator ()(boost::python::tuple args, dict kwargs)
282
+ template <typename ArgumentPackage>
283
+ PyObject *postcall (const ArgumentPackage &args, PyObject *pResult)
275
284
{
276
- m_constructor (*args, **kwargs);
277
- return m_initializer (*(make_tuple (args[0 ]) + args), **kwargs);
285
+ BasePolicies::postcall (args, pResult);
286
+ m_initializer (
287
+ *(make_tuple (
288
+ object (handle<>(incref (detail::get (boost::mpl::int_<iSelf>(), args))))) +
289
+ boost::python::tuple (handle<>(args.base ))
290
+ )
291
+ );
292
+
293
+ decref (pResult);
294
+ return incref (Py_None); // __init__ should always return None
278
295
}
279
296
280
297
private:
281
- object m_constructor;
282
298
object m_initializer;
283
299
};
284
300
285
- template <typename Constructor, typename Initializer>
286
- object make_constructor_initializer (Constructor constructor, Initializer initializer)
287
- {
288
- return raw_function (
289
- constructor_initializer<Constructor, Initializer>(constructor, initializer),
290
- 1 // self
291
- );
292
- };
293
-
294
301
#endif // _WRAP_MACROS_H
0 commit comments