diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index fa5474a18c..86b409dfa0 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -74,7 +74,10 @@ static PyObject *_inP07yt3zru(PyObject *self, PyObject *args); static PyObject *_inP07ytRrg2(PyObject *self, PyObject *args); static PyObject *_inP07ytEJCx(PyObject *self, PyObject *args); static PyObject *_inP07ytWAZr(PyObject *self, PyObject *args); +static PyObject *_inP07ytHQi6(PyObject *self, PyObject *args); static PyObject *_inP07ytrD_M(PyObject *self, PyObject *args); +static PyObject *_inP07ytYaah(PyObject *self, PyObject *args); +static PyObject *_inP07yt2otr(PyObject *self, PyObject *args); static PyObject *_inP07ytjolz(PyObject *self, PyObject *args); static PyObject *_inP07ytt_JD(PyObject *self, PyObject *args); static PyObject *_inP07ytwEts(PyObject *self, PyObject *args); @@ -1060,6 +1063,24 @@ _inP07ytWAZr(PyObject *, PyObject *args) { return nullptr; } +/* + * Python simple wrapper for + * FunctionIndex interrogate_wrapper_function(FunctionWrapperIndex wrapper) + */ +static PyObject * +_inP07ytHQi6(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + FunctionIndex return_value = (::interrogate_wrapper_function)((FunctionWrapperIndex)param0); +#if PY_MAJOR_VERSION >= 3 + return PyLong_FromLong(return_value); +#else + return PyInt_FromLong(return_value); +#endif + } + return nullptr; +} + /* * Python simple wrapper for * bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper) @@ -1074,6 +1095,34 @@ _inP07ytrD_M(PyObject *, PyObject *args) { return nullptr; } +/* + * Python simple wrapper for + * bool interrogate_wrapper_is_copy_constructor(FunctionWrapperIndex wrapper) + */ +static PyObject * +_inP07ytYaah(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = (::interrogate_wrapper_is_copy_constructor)((FunctionWrapperIndex)param0); + return PyBool_FromLong(return_value); + } + return nullptr; +} + +/* + * Python simple wrapper for + * bool interrogate_wrapper_is_coerce_constructor(FunctionWrapperIndex wrapper) + */ +static PyObject * +_inP07yt2otr(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = (::interrogate_wrapper_is_coerce_constructor)((FunctionWrapperIndex)param0); + return PyBool_FromLong(return_value); + } + return nullptr; +} + /* * Python simple wrapper for * bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper) @@ -2681,7 +2730,10 @@ static PyMethodDef python_simple_funcs[] = { { "interrogate_function_number_of_python_wrappers", &_inP07ytRrg2, METH_VARARGS }, { "interrogate_function_python_wrapper", &_inP07ytEJCx, METH_VARARGS }, { "interrogate_wrapper_name", &_inP07ytWAZr, METH_VARARGS }, + { "interrogate_wrapper_function", &_inP07ytHQi6, METH_VARARGS }, { "interrogate_wrapper_is_callable_by_name", &_inP07ytrD_M, METH_VARARGS }, + { "interrogate_wrapper_is_copy_constructor", &_inP07ytYaah, METH_VARARGS }, + { "interrogate_wrapper_is_coerce_constructor", &_inP07yt2otr, METH_VARARGS }, { "interrogate_wrapper_has_comment", &_inP07ytjolz, METH_VARARGS }, { "interrogate_wrapper_comment", &_inP07ytt_JD, METH_VARARGS }, { "interrogate_wrapper_has_return_value", &_inP07ytwEts, METH_VARARGS }, diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index cb8f9906a8..a66126c56b 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -312,6 +312,14 @@ make_wrapper_entry(FunctionIndex function_index) { iwrapper._flags |= InterrogateFunctionWrapper::F_callable_by_name; } + if (_flags & F_copy_constructor) { + iwrapper._flags |= InterrogateFunctionWrapper::F_copy_constructor; + } + + if (_flags & F_coerce_constructor) { + iwrapper._flags |= InterrogateFunctionWrapper::F_coerce_constructor; + } + Parameters::const_iterator pi; for (pi = _parameters.begin(); pi != _parameters.end(); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.I b/dtool/src/interrogatedb/interrogateFunctionWrapper.I index b0ec398623..67225f0c72 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.I +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.I @@ -63,6 +63,22 @@ is_callable_by_name() const { return (_flags & F_callable_by_name) != 0; } +/** + * @since 1.10.13 + */ +INLINE bool InterrogateFunctionWrapper:: +is_copy_constructor() const { + return (_flags & F_copy_constructor) != 0; +} + +/** + * @since 1.10.13 + */ +INLINE bool InterrogateFunctionWrapper:: +is_coerce_constructor() const { + return (_flags & F_coerce_constructor) != 0; +} + /** * */ diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 29e59ed259..6af5e49d72 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -34,6 +34,8 @@ public: INLINE FunctionIndex get_function() const; INLINE bool is_callable_by_name() const; + INLINE bool is_copy_constructor() const; + INLINE bool is_coerce_constructor() const; INLINE bool has_return_value() const; INLINE TypeIndex get_return_type() const; @@ -61,7 +63,9 @@ private: enum Flags { F_caller_manages = 0x0001, F_has_return = 0x0002, - F_callable_by_name = 0x0004 + F_callable_by_name = 0x0004, + F_copy_constructor = 0x0008, + F_coerce_constructor = 0x0010, }; enum ParameterFlags { diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index d7f4ce58dd..4ec3f28e24 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -359,12 +359,30 @@ interrogate_wrapper_name(FunctionWrapperIndex wrapper) { return result.c_str(); } +FunctionIndex +interrogate_wrapper_function(FunctionWrapperIndex wrapper) { + // cerr << "interrogate_wrapper_function(" << wrapper << ")\n"; + return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_function(); +} + bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper) { // cerr << "interrogate_wrapper_is_callable_by_name(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_callable_by_name(); } +bool +interrogate_wrapper_is_copy_constructor(FunctionWrapperIndex wrapper) { + // cerr << "interrogate_wrapper_is_copy_constructor(" << wrapper << ")\n"; + return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_copy_constructor(); +} + +bool +interrogate_wrapper_is_coerce_constructor(FunctionWrapperIndex wrapper) { + // cerr << "interrogate_wrapper_is_coerce_constructor(" << wrapper << ")\n"; + return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_coerce_constructor(); +} + bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper) { // cerr << "interrogate_wrapper_has_comment(" << wrapper << ")\n"; diff --git a/dtool/src/interrogatedb/interrogate_interface.h b/dtool/src/interrogatedb/interrogate_interface.h index a44f9fef92..4f9d045df5 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -261,10 +261,19 @@ EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_python_wrapper(Fun // not identical. EXPCL_INTERROGATEDB const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper); +// Returns the function that this wrapper belongs to. +EXPCL_INTERROGATEDB FunctionIndex interrogate_wrapper_function(FunctionWrapperIndex wrapper); + // This returns true if -fnames was given to interrogate, making the wrapper // function callable directly by its name. EXPCL_INTERROGATEDB bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper); +// This returns true if this is a copy constructor. +EXPCL_INTERROGATEDB bool interrogate_wrapper_is_copy_constructor(FunctionWrapperIndex wrapper); + +// This returns true if this is a constructor that is not marked "explicit". +EXPCL_INTERROGATEDB bool interrogate_wrapper_is_coerce_constructor(FunctionWrapperIndex wrapper); + // This returns the C++ comment written for the function wrapper, usually from // the .cpp file. There may be a different comment for each overload of a // given function.