Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce code duplication with anonymous enums #62

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/CPPDataMember.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,6 @@ static PyObject* dm_get(CPPDataMember* dm, CPPInstance* pyobj, PyObject* /* kls
Py_INCREF(dm->fDescription);
return dm->fDescription;
}

if (Cppyy::IsEnumConstant(dm->fScope)) {
// anonymous enum
long long llval = Cppyy::GetEnumDataValue(dm->fScope);
const std::string& enum_type = Cppyy::ResolveEnum(dm->fScope);

PyObject* bval;
if (enum_type == "bool") {
bval = (bool)llval ? Py_True : Py_False;
Py_INCREF(bval);
} else if (enum_type == "char") {
char val = (char)llval;
bval = CPyCppyy_PyText_FromStringAndSize(&val, 1);
} else if (enum_type == "int" || enum_type == "unsigned int")
bval = PyInt_FromLong((long)llval);
else
bval = PyLong_FromLongLong(llval);

return bval;
}
}

// non-initialized or public data accesses through class (e.g. by help())
Expand Down