| 97 | } |
| 98 | |
| 99 | std::string getTypeName(const char *text, const std::type_info *const *types) { |
| 100 | std::string signature; |
| 101 | size_t type_depth = 0, char_index = 0, type_index = 0; |
| 102 | while (true) { |
| 103 | char c = text[char_index++]; |
| 104 | if (c == '\0') |
| 105 | break; |
| 106 | |
| 107 | if (c == '{') { |
| 108 | ++type_depth; |
| 109 | } else if (c == '}') { |
| 110 | --type_depth; |
| 111 | } else if (c == '%') { |
| 112 | const std::type_info *t = types[type_index++]; |
| 113 | if (!t) |
| 114 | pybind11::pybind11_fail("Internal error while parsing type signature (1)"); |
| 115 | if (auto tinfo = pybind11::detail::get_type_info(*t)) { |
| 116 | pybind11::handle th((PyObject *) tinfo->type); |
| 117 | signature += |
| 118 | th.attr("__module__").cast<std::string>() + "." + |
| 119 | th.attr("__qualname__").cast<std::string>(); // Python 3.3+, but we backport it to earlier versions |
| 120 | } else { |
| 121 | std::string tname(t->name()); |
| 122 | pybind11::detail::clean_type_id(tname); |
| 123 | signature += tname; |
| 124 | } |
| 125 | } else { |
| 126 | signature += c; |
| 127 | } |
| 128 | } |
| 129 | return signature; |
| 130 | } |
nothing calls this directly
no outgoing calls
no test coverage detected