Skip to content

[QUESTION] Returning a Python built-in type #4249

Answered by jiwaszki
leocencetti asked this question in Q&A
Discussion options

You must be logged in to vote

First things first, without helper function it is impossible to translate enum values (which are in fact integers) to some types. This is a good point from you that you need some helper either in form of separate method or type/type().

How to approach this? Why don't use wrapper classes for this? "Fake it till you make it" -- this is the general idea. First create a class that will simulate single enum entry, let's call it ValueTypeWrapper. It will hold two values, actual integer value from enum and py::object (it will be useful later). Create FakeEnum struct that will be inserted in place of ValueType, still look at the name when binding -- it matches original one. Now define essential h…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@leocencetti
Comment options

@jiwaszki
Comment options

Answer selected by leocencetti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants