Răsfoiți Sursa

interrogatedb: Indicate whether types/function wrappers are deprecated

rdb 3 ani în urmă
părinte
comite
a28b641bf3

+ 33 - 1
dtool/metalibs/dtoolconfig/pydtool.cxx

@@ -90,6 +90,7 @@ 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 *_inP07ytrrrN(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);
@@ -122,6 +123,7 @@ static PyObject *_inP07ytNHcs(PyObject *self, PyObject *args);
 static PyObject *_inP07ytqHrb(PyObject *self, PyObject *args);
 static PyObject *_inP07ytaOqq(PyObject *self, PyObject *args);
 static PyObject *_inP07ytpTBb(PyObject *self, PyObject *args);
+static PyObject *_inP07ytZUkn(PyObject *self, PyObject *args);
 static PyObject *_inP07ytqWOw(PyObject *self, PyObject *args);
 static PyObject *_inP07ytHu7x(PyObject *self, PyObject *args);
 static PyObject *_inP07ytwGnA(PyObject *self, PyObject *args);
@@ -1327,6 +1329,20 @@ _inP07ytNP_b(PyObject *, PyObject *args) {
   return nullptr;
 }
 
+/*
+ * Python simple wrapper for
+ * bool interrogate_wrapper_is_deprecated(FunctionWrapperIndex wrapper)
+ */
+static PyObject *
+_inP07ytrrrN(PyObject *, PyObject *args) {
+  int param0;
+  if (PyArg_ParseTuple(args, "i", &param0)) {
+    bool return_value = (::interrogate_wrapper_is_deprecated)((FunctionWrapperIndex)param0);
+    return PyBool_FromLong(return_value);
+  }
+  return nullptr;
+}
+
 /*
  * Python simple wrapper for
  * bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper)
@@ -1866,6 +1882,20 @@ _inP07ytpTBb(PyObject *, PyObject *args) {
   return nullptr;
 }
 
+/*
+ * Python simple wrapper for
+ * bool interrogate_type_is_deprecated(TypeIndex type)
+ */
+static PyObject *
+_inP07ytZUkn(PyObject *, PyObject *args) {
+  int param0;
+  if (PyArg_ParseTuple(args, "i", &param0)) {
+    bool return_value = (::interrogate_type_is_deprecated)((TypeIndex)param0);
+    return PyBool_FromLong(return_value);
+  }
+  return nullptr;
+}
+
 /*
  * Python simple wrapper for
  * char const *interrogate_type_name(TypeIndex type)
@@ -2950,6 +2980,7 @@ static PyMethodDef python_simple_funcs[] = {
   { "interrogate_wrapper_is_copy_constructor", &_inP07ytYaah, METH_VARARGS, nullptr },
   { "interrogate_wrapper_is_coerce_constructor", &_inP07yt2otr, METH_VARARGS, nullptr },
   { "interrogate_wrapper_is_extension", &_inP07ytNP_b, METH_VARARGS, nullptr },
+  { "interrogate_wrapper_is_deprecated", &_inP07ytrrrN, METH_VARARGS, nullptr },
   { "interrogate_wrapper_has_comment", &_inP07ytjolz, METH_VARARGS, nullptr },
   { "interrogate_wrapper_comment", &_inP07ytt_JD, METH_VARARGS, nullptr },
   { "interrogate_wrapper_has_return_value", &_inP07ytwEts, METH_VARARGS, nullptr },
@@ -2982,6 +3013,7 @@ static PyMethodDef python_simple_funcs[] = {
   { "interrogate_get_type_by_scoped_name", &_inP07ytqHrb, METH_VARARGS, nullptr },
   { "interrogate_get_type_by_true_name", &_inP07ytaOqq, METH_VARARGS, nullptr },
   { "interrogate_type_is_global", &_inP07ytpTBb, METH_VARARGS, nullptr },
+  { "interrogate_type_is_deprecated", &_inP07ytZUkn, METH_VARARGS, nullptr },
   { "interrogate_type_name", &_inP07ytqWOw, METH_VARARGS, nullptr },
   { "interrogate_type_scoped_name", &_inP07ytHu7x, METH_VARARGS, nullptr },
   { "interrogate_type_true_name", &_inP07ytwGnA, METH_VARARGS, nullptr },
@@ -3050,7 +3082,7 @@ static PyMethodDef python_simple_funcs[] = {
 #if PY_MAJOR_VERSION >= 3
 static struct PyModuleDef python_simple_module = {
   PyModuleDef_HEAD_INIT,
-  "interrogatedb",
+  "panda3d.interrogatedb",
   nullptr,
   -1,
   python_simple_funcs,

+ 4 - 0
dtool/src/interrogate/functionRemap.cxx

@@ -324,6 +324,10 @@ make_wrapper_entry(FunctionIndex function_index) {
     iwrapper._flags |= InterrogateFunctionWrapper::F_extension;
   }
 
+  if (_cppfunc->_attributes.has_attribute("deprecated")) {
+    iwrapper._flags |= InterrogateFunctionWrapper::F_deprecated;
+  }
+
   Parameters::const_iterator pi;
   for (pi = _parameters.begin();
        pi != _parameters.end();

+ 4 - 0
dtool/src/interrogate/interrogateBuilder.cxx

@@ -2381,6 +2381,10 @@ get_type(CPPType *type, bool global) {
     }
   }
 
+  if (type->_attributes.has_attribute("deprecated")) {
+    itype._flags |= InterrogateType::F_deprecated;
+  }
+
   if (forced || !in_ignoretype(true_name)) {
     itype._flags |= InterrogateType::F_fully_defined;
 

+ 8 - 0
dtool/src/interrogatedb/interrogateFunctionWrapper.I

@@ -87,6 +87,14 @@ is_extension() const {
   return (_flags & F_extension) != 0;
 }
 
+/**
+ * @since 1.11.0
+ */
+INLINE bool InterrogateFunctionWrapper::
+is_deprecated() const {
+  return (_flags & F_deprecated) != 0;
+}
+
 /**
  *
  */

+ 2 - 0
dtool/src/interrogatedb/interrogateFunctionWrapper.h

@@ -37,6 +37,7 @@ public:
   INLINE bool is_copy_constructor() const;
   INLINE bool is_coerce_constructor() const;
   INLINE bool is_extension() const;
+  INLINE bool is_deprecated() const;
 
   INLINE bool has_return_value() const;
   INLINE TypeIndex get_return_type() const;
@@ -68,6 +69,7 @@ private:
     F_copy_constructor = 0x0008,
     F_coerce_constructor = 0x0010,
     F_extension        = 0x0020,
+    F_deprecated       = 0x0040,
   };
 
   enum ParameterFlags {

+ 10 - 0
dtool/src/interrogatedb/interrogateType.I

@@ -20,6 +20,16 @@ is_global() const {
   return (_flags & F_global) != 0;
 }
 
+/**
+ * Returns true if the type is marked as 'deprecated'.
+ *
+ * @since 1.11.0
+ */
+INLINE bool InterrogateType::
+is_deprecated() const {
+  return (_flags & F_deprecated) != 0;
+}
+
 /**
  *
  */

+ 2 - 0
dtool/src/interrogatedb/interrogateType.h

@@ -34,6 +34,7 @@ public:
   void operator = (const InterrogateType &copy);
 
   INLINE bool is_global() const;
+  INLINE bool is_deprecated() const;
 
   INLINE bool has_scoped_name() const;
   INLINE const std::string &get_scoped_name() const;
@@ -141,6 +142,7 @@ private:
     F_array                = 0x400000,
     F_scoped_enum          = 0x800000,
     F_final                =0x1000000,
+    F_deprecated           =0x2000000,
   };
 
 public:

+ 12 - 0
dtool/src/interrogatedb/interrogate_interface.cxx

@@ -455,6 +455,12 @@ interrogate_wrapper_is_extension(FunctionWrapperIndex wrapper) {
   return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_extension();
 }
 
+bool
+interrogate_wrapper_is_deprecated(FunctionWrapperIndex wrapper) {
+  // cerr << "interrogate_wrapper_is_deprecated(" << wrapper << ")\n";
+  return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_deprecated();
+}
+
 bool
 interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper) {
   // cerr << "interrogate_wrapper_has_comment(" << wrapper << ")\n";
@@ -661,6 +667,12 @@ interrogate_type_is_global(TypeIndex type) {
   return InterrogateDatabase::get_ptr()->get_type(type).is_global();
 }
 
+bool
+interrogate_type_is_deprecated(TypeIndex type) {
+  // cerr << "interrogate_type_is_deprecated(" << type << ")\n";
+  return InterrogateDatabase::get_ptr()->get_type(type).is_deprecated();
+}
+
 const char *
 interrogate_type_name(TypeIndex type) {
   // cerr << "interrogate_type_name(" << type << ")\n";

+ 4 - 0
dtool/src/interrogatedb/interrogate_interface.h

@@ -289,6 +289,9 @@ EXPCL_INTERROGATEDB bool interrogate_wrapper_is_coerce_constructor(FunctionWrapp
 // function defined in the C++ code.
 EXPCL_INTERROGATEDB bool interrogate_wrapper_is_extension(FunctionWrapperIndex wrapper);
 
+// This returns true if function is marked as deprecated.
+EXPCL_INTERROGATEDB bool interrogate_wrapper_is_deprecated(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.
@@ -401,6 +404,7 @@ EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_name(const char *type_name
 EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_scoped_name(const char *type_name);
 EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_true_name(const char *type_name);
 EXPCL_INTERROGATEDB bool interrogate_type_is_global(TypeIndex type);
+EXPCL_INTERROGATEDB bool interrogate_type_is_deprecated(TypeIndex type);
 EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type);
 EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type);
 EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type);