Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 14 additions & 8 deletions src/CPPDataMember.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,22 @@ PyTypeObject CPPDataMember_Type = {
//- public members -----------------------------------------------------------
void CPyCppyy::CPPDataMember::Set(Cppyy::TCppScope_t scope, Cppyy::TCppScope_t data)
{
if (Cppyy::IsLambdaClass(Cppyy::GetDatamemberType(data))) {
fScope = Cppyy::WrapLambdaFromVariable(data);
} else {
fScope = data;
}

fEnclosingScope = scope;
fScope = data;
fOffset = Cppyy::GetDatamemberOffset(data, scope); // XXX: Check back here // TODO: make lazy
fFlags = Cppyy::IsStaticDatamember(data) ? kIsStaticData : 0;
fOffset = Cppyy::GetDatamemberOffset(fScope, fScope == data ? scope : Cppyy::GetScope("__cppyy_internal_wrap_g")); // XXX: Check back here // TODO: make lazy
fFlags = Cppyy::IsStaticDatamember(fScope) ? kIsStaticData : 0;

const std::string name = Cppyy::GetFinalName(data);
const std::string name = Cppyy::GetFinalName(fScope);
Cppyy::TCppType_t type;

if (Cppyy::IsEnumConstant(data)) {
type = Cppyy::GetEnumConstantType(data);

if (Cppyy::IsEnumConstant(fScope)) {
type = Cppyy::GetEnumConstantType(fScope);
fFullType = Cppyy::GetTypeAsString(type);
if (fFullType.find("(anonymous)") == std::string::npos &&
fFullType.find("(unnamed)") == std::string::npos) {
Expand All @@ -344,14 +350,14 @@ void CPyCppyy::CPPDataMember::Set(Cppyy::TCppScope_t scope, Cppyy::TCppScope_t d
type = Cppyy::ResolveType(type);
fFlags |= kIsConstData;
} else {
type = Cppyy::GetDatamemberType(data);
type = Cppyy::GetDatamemberType(fScope);
fFullType = Cppyy::GetTypeAsString(type);

// Get the integer type if it's an enum
if (Cppyy::IsEnumType(type))
type = Cppyy::ResolveType(type);

if (Cppyy::IsConstVar(data))
if (Cppyy::IsConstVar(fScope))
fFlags |= kIsConstData;
}

Expand Down
7 changes: 4 additions & 3 deletions src/CPPMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,11 @@ CPyCppyy::CPPMethod::CPPMethod(
fMethod(method), fScope(scope), fExecutor(nullptr), fArgIndices(nullptr),
fArgsRequired(-1)
{
Cppyy::TCppType_t result = Cppyy::ResolveType(Cppyy::GetMethodReturnType(fMethod));
if (TypeReductionMap.contains(result)) {
Cppyy::TCppType_t result = Cppyy::ResolveType(Cppyy::GetMethodReturnType(fMethod));
if (TypeReductionMap.contains(result))
fMethod = Cppyy::ReduceReturnType(fMethod, TypeReductionMap[result]);
}
if (result && Cppyy::IsLambdaClass(result))
fMethod = Cppyy::AdaptFunctionForLambdaReturn(fMethod);
}

//----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions src/Cppyy.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ namespace Cppyy {
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata);
CPPYY_IMPORT
TCppScope_t ReduceReturnType(TCppScope_t fn, TCppType_t reduce);
bool IsLambdaClass(TCppType_t type);
CPPYY_IMPORT
TCppScope_t WrapLambdaFromVariable(TCppScope_t var);
CPPYY_IMPORT
TCppScope_t AdaptFunctionForLambdaReturn(TCppScope_t fn);
CPPYY_IMPORT
TCppType_t GetDatamemberType(TCppScope_t var);
CPPYY_IMPORT
Expand Down
Loading