File tree Expand file tree Collapse file tree
include/mrbind/targets/pybind11 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2102,6 +2102,19 @@ namespace MRBind::pb11
21022102 std::size_t last_good_size = 0 ;
21032103 for (char ch : name)
21042104 {
2105+ auto AddSpecialString = [&](std::string_view str)
2106+ {
2107+ if (!prev_char_is_special)
2108+ {
2109+ ret += ' _' ;
2110+ prev_char_is_special = true ;
2111+ }
2112+
2113+ ret += str;
2114+ last_good_size = ret.size ();
2115+ ret += ' _' ;
2116+ };
2117+
21052118 // Somewhat in doubt here. I don't want to treat `_` as a special character, because I want to be able to use this to add
21062119 // custom functions like `__call__` and stuff.
21072120 if (std::isalnum ((unsigned char )ch) || ch == ' _' )
@@ -2112,9 +2125,14 @@ namespace MRBind::pb11
21122125 }
21132126 else if (ch == ' -' )
21142127 {
2115- prev_char_is_special = false ;
2116- ret += " minus" ;
2117- last_good_size = ret.size ();
2128+ AddSpecialString (" minus" );
2129+ }
2130+ else if (ch == ' *' )
2131+ {
2132+ // Need this to disambiguate e.g. `std::vector<T>` vs `std::vector<T *>`.
2133+ // For now we don't support `&`. One reason for that is that it causes `A_ref` and `A_refref` to be defined as aliases for `A`.
2134+ // Supporting `&` would require filtering out those aliases.
2135+ AddSpecialString (" ptr" );
21182136 }
21192137 else
21202138 {
You can’t perform that action at this time.
0 commit comments