Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to programmatically retrieve C++ class name / Python class name mapping ? #424

Open
Gregwar opened this issue Nov 1, 2023 · 1 comment

Comments

@Gregwar
Copy link

Gregwar commented Nov 1, 2023

Hello,

Suppose I do the following:

class_<somevendor::SomeClass>("SomePyClass");

Is there a way at runtime in Python to retrieve the mapping between SomePyClass and somevendor::SomeClass ?

For context I am writing some code to parse Doxygen XML files and producing the .pyi file to get more auto-completion and docstrings

@Gregwar
Copy link
Author

Gregwar commented Nov 1, 2023

Currently I am wrapping my calls to class_ with some methods like:

template <class T, class DT>
class_<T> class__(const char* name, init_base<DT> const& init)
{
  class_<T> c = class_<T>(name, init);
  register_type(typeid(T).name(), boost::python::extract<std::string>(c.attr("__name__")));
  return c;
}

(Where register_type stores the two strings in a map which is itself exposed)
This works but is not really satisfying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant