Skip to content

Commit 462b91f

Browse files
committed
Added min/max argument count checking
[SVN r12225]
1 parent b65f4ff commit 462b91f

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

include/boost/python/make_function.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,30 @@
1212
# include <boost/python/object/function.hpp>
1313
# include <boost/python/object/make_holder.hpp>
1414
# include <boost/python/detail/caller.hpp>
15+
# include <boost/python/detail/arg_tuple_size.hpp>
1516

1617
namespace boost { namespace python {
1718

1819
template <class F>
19-
PyObject* make_function(F f)
20+
objects::function* make_function(F f)
2021
{
21-
return new object::function(
22-
object::py_function(
23-
bind<PyObject*>(detail::caller(), f, _1, _2)));
22+
return new objects::function(
23+
objects::py_function(
24+
bind<PyObject*>(detail::caller(), f, _1, _2))
25+
, detail::arg_tuple_size<F>::value);
2426
}
2527

2628
template <class T, class ArgList, class Generator>
27-
PyObject* make_constructor(T* = 0, ArgList* = 0, Generator* = 0)
29+
objects::function* make_constructor(T* = 0, ArgList* = 0, Generator* = 0)
2830
{
2931
enum { nargs = mpl::size<ArgList>::value };
30-
return new object::function(
31-
object::py_function(
32+
return new objects::function(
33+
objects::py_function(
3234
bind<PyObject*>(detail::caller(),
33-
object::make_holder<nargs>
35+
objects::make_holder<nargs>
3436
::template apply<T,Generator,ArgList>::execute
35-
, _1, _2)));
37+
, _1, _2))
38+
, nargs + 1);
3639
}
3740

3841
}} // namespace boost::python

0 commit comments

Comments
 (0)