@@ -486,6 +486,8 @@ Cppyy::TCppType_t Cppyy::ResolveEnumPointerType(TCppType_t type) {
486486}
487487
488488Cppyy::TCppType_t Cppyy::ResolveType (TCppType_t type) {
489+ if (!type) return type;
490+
489491 Cppyy::TCppType_t canonType = Cpp::GetCanonicalType (type);
490492
491493 if (Cpp::IsEnumType (canonType)) {
@@ -1975,6 +1977,33 @@ bool Cppyy::IsConstVar(TCppScope_t var)
19751977 return Cpp::IsConstVariable (var);
19761978}
19771979
1980+ Cppyy::TCppScope_t Cppyy::ReduceReturnType (TCppScope_t fn, TCppType_t reduce) {
1981+ std::string fn_name = Cpp::GetQualifiedCompleteName (fn);
1982+ std::string signature = Cppyy::GetMethodSignature (fn, true );
1983+ std::string result_type = Cppyy::GetTypeAsString (reduce);
1984+
1985+ std::ostringstream call;
1986+ call << " (" ;
1987+ for (size_t i = 0 , n = Cppyy::GetMethodNumArgs (fn); i < n; i++) {
1988+ call << Cppyy::GetMethodArgName (fn, i);
1989+ if (i != n - 1 )
1990+ call << " , " ;
1991+ }
1992+ call << " )" ;
1993+
1994+ std::ostringstream code;
1995+ static int i = 0 ;
1996+ std::string name = " reduced_function_" + std::to_string (++i);
1997+ code << " namespace __cppyy_internal_wrap_g {\n "
1998+ << result_type << " " << name << signature << " {" << " return (" << result_type << " )::" << fn_name << call.str () << " ; }\n "
1999+ << " }\n " ;
2000+ if (Cppyy::Compile (code.str ().c_str ())) {
2001+ TCppScope_t res = Cpp::GetNamed (name, Cpp::GetScope (" __cppyy_internal_wrap_g" ));
2002+ if (res) return res;
2003+ }
2004+ return fn;
2005+ }
2006+
19782007// bool Cppyy::IsEnumData(TCppScope_t scope, TCppIndex_t idata)
19792008// {
19802009// // TODO: currently, ROOT/meta does not properly distinguish between variables of enum
0 commit comments