From bb8b08a69077f704e2f8afdbaa16734c3b2e6eff Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 20 Oct 2022 10:09:45 +0200 Subject: [PATCH] interrogatedb: Add `interrogate_wrapper_is_extension()` function --- dtool/metalibs/dtoolconfig/pydtool.cxx | 16 ++++++++++++++++ dtool/src/interrogate/functionRemap.cxx | 4 ++++ .../interrogatedb/interrogateFunctionWrapper.I | 8 ++++++++ .../interrogatedb/interrogateFunctionWrapper.h | 2 ++ .../src/interrogatedb/interrogate_interface.cxx | 6 ++++++ dtool/src/interrogatedb/interrogate_interface.h | 4 ++++ 6 files changed, 40 insertions(+) diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index a3112f2a58..cdfdb3e14f 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -89,6 +89,7 @@ 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 *_inP07ytNP_b(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); @@ -1312,6 +1313,20 @@ _inP07yt2otr(PyObject *, PyObject *args) { return nullptr; } +/* + * Python simple wrapper for + * bool interrogate_wrapper_is_extension(FunctionWrapperIndex wrapper) + */ +static PyObject * +_inP07ytNP_b(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = (::interrogate_wrapper_is_extension)((FunctionWrapperIndex)param0); + return PyBool_FromLong(return_value); + } + return nullptr; +} + /* * Python simple wrapper for * bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper) @@ -2934,6 +2949,7 @@ static PyMethodDef python_simple_funcs[] = { { "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_is_extension", &_inP07ytNP_b, 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 a66126c56b..2e984c652b 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -320,6 +320,10 @@ make_wrapper_entry(FunctionIndex function_index) { iwrapper._flags |= InterrogateFunctionWrapper::F_coerce_constructor; } + if (_extension) { + iwrapper._flags |= InterrogateFunctionWrapper::F_extension; + } + 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 67225f0c72..111eba10c1 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.I +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.I @@ -79,6 +79,14 @@ is_coerce_constructor() const { return (_flags & F_coerce_constructor) != 0; } +/** + * @since 1.10.13 + */ +INLINE bool InterrogateFunctionWrapper:: +is_extension() const { + return (_flags & F_extension) != 0; +} + /** * */ diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 6af5e49d72..6c41a46cab 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -36,6 +36,7 @@ public: INLINE bool is_callable_by_name() const; INLINE bool is_copy_constructor() const; INLINE bool is_coerce_constructor() const; + INLINE bool is_extension() const; INLINE bool has_return_value() const; INLINE TypeIndex get_return_type() const; @@ -66,6 +67,7 @@ private: F_callable_by_name = 0x0004, F_copy_constructor = 0x0008, F_coerce_constructor = 0x0010, + F_extension = 0x0020, }; enum ParameterFlags { diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index b4515f72c9..e4dbef1a76 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -449,6 +449,12 @@ interrogate_wrapper_is_coerce_constructor(FunctionWrapperIndex wrapper) { return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_coerce_constructor(); } +bool +interrogate_wrapper_is_extension(FunctionWrapperIndex wrapper) { + // cerr << "interrogate_wrapper_is_extension(" << wrapper << ")\n"; + return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_extension(); +} + 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 be5562ec40..5c776e70eb 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -285,6 +285,10 @@ EXPCL_INTERROGATEDB bool interrogate_wrapper_is_copy_constructor(FunctionWrapper // 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 true if this is an extension function, rather than a real +// function defined in the C++ code. +EXPCL_INTERROGATEDB bool interrogate_wrapper_is_extension(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.