Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

Repeated code: CreateConverter #201

Description

@Vipul-Cariappa

There are two overloads to CreateConverter.
First:

CPyCppyy::Converter* CPyCppyy::CreateConverter(const std::string& fullType, cdims_t dims)

Second:
CPyCppyy::Converter* CPyCppyy::CreateConverter(Cppyy::TCppType_t type, cdims_t dims)

One takes a string and the other a type (clang::QualType). But the type version again converts the type to a string and processes it in the same way as the string version.
Look:

CPyCppyy/src/Converters.cxx

Lines 3538 to 3558 in 482ccb7

CPyCppyy::Converter* CPyCppyy::CreateConverter(Cppyy::TCppType_t type, cdims_t dims)
{
// The matching of the fulltype to a converter factory goes through up to five levels:
// 1) full, exact match
// 2) match of decorated, unqualified type
// 3) accept const ref as by value
// 4) accept ref as pointer
// 5) generalized cases (covers basically all C++ classes)
//
// If all fails, void is used, which will generate a run-time warning when used.
// an exactly matching converter is best
std::string fullType = Cppyy::GetTypeAsString(type);
ConvFactories_t::iterator h = gConvFactories.find(fullType);
if (h != gConvFactories.end()) {
return (h->second)(dims);
}
// resolve typedefs etc.
Cppyy::TCppType_t resolvedType = Cppyy::ResolveType(type);
const std::string& resolvedTypeStr = Cppyy::GetTypeAsString(resolvedType);

Proposal: We should remove the string overload. The string parsing can stay for now. String parsing - to be removed eventually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions