Skip to content

Commit 0eee679

Browse files
committed
Complete typename utility with GetReferencedType and GetPointerType
1 parent 924e399 commit 0eee679

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/Cppyy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ namespace Cppyy {
7676
CPPYY_IMPORT
7777
TCppType_t GetRealType(TCppType_t type);
7878
CPPYY_IMPORT
79+
TCppType_t GetReferencedType(TCppType_t type, bool rvalue);
80+
CPPYY_IMPORT
81+
TCppType_t GetPointerType(TCppType_t type);
82+
CPPYY_IMPORT
7983
std::string ResolveEnum(TCppScope_t enum_type);
8084
CPPYY_IMPORT
8185
TCppScope_t GetScope(const std::string& name, TCppScope_t parent_scope = 0);

src/Utility.cxx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -751,31 +751,26 @@ static bool AddTypeName(std::vector<Cpp::TemplateArgInfo>& types, PyObject* tn,
751751
}
752752

753753
if (CPPScope_Check(tn)) {
754-
auto cpp_type = Cppyy::GetTypeFromScope(((CPPClass*)tn)->fCppType);
755-
types.push_back(cpp_type);
756-
if (arg) {
754+
auto cpp_type = Cppyy::GetTypeFromScope(((CPPClass*)tn)->fCppType);
755+
if (arg) {
757756
// try to specialize the type match for the given object
758757
CPPInstance* pyobj = (CPPInstance*)arg;
759758
if (CPPInstance_Check(pyobj)) {
760759
if (pyobj->fFlags & CPPInstance::kIsRValue)
761-
// tmpl_name.append("&&");
762-
// FIXME: add r-value reference to the last added type
763-
types;
760+
cpp_type =
761+
Cppyy::GetReferencedType(cpp_type, /*rvalue=*/true);
764762
else {
765763
if (pcnt) *pcnt += 1;
766764
if ((pyobj->fFlags & CPPInstance::kIsReference) || pref == kPointer)
767-
// tmpl_name.push_back('*');
768-
// FIXME: wrap the last added type in a pointer
769-
types;
765+
cpp_type = Cppyy::GetPointerType(cpp_type);
770766
else if (pref != kValue)
771-
// tmpl_name.push_back('&');
772-
// FIXME: add l-value reference to the last added type
773-
types;
767+
cpp_type =
768+
Cppyy::GetReferencedType(cpp_type, /*rvalue=*/false);
774769
}
775770
}
776-
}
777-
778-
return true;
771+
}
772+
types.push_back(cpp_type);
773+
return true;
779774
}
780775

781776
if (tn == (PyObject*)&CPPOverload_Type) {
@@ -810,8 +805,8 @@ static bool AddTypeName(std::vector<Cpp::TemplateArgInfo>& types, PyObject* tn,
810805
tpn << ')';
811806
// tmpl_name.append(tpn.str());
812807
// FIXME: find a way to add it to types
813-
throw std::runtime_error("This path is not yet implemented (AddTypeName) \n");
814-
types;
808+
throw std::runtime_error(
809+
"This path is not yet implemented (AddTypeName) \n");
815810

816811
return true;
817812

0 commit comments

Comments
 (0)