Browse Source

interrogatedb: Add `interrogate_wrapper_is_extension()` function

rdb 3 years ago
parent
commit
bb8b08a690

+ 16 - 0
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", &param0)) {
+    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 },

+ 4 - 0
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();

+ 8 - 0
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;
+}
+
 /**
  *
  */

+ 2 - 0
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 {

+ 6 - 0
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";

+ 4 - 0
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.