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

fix according to Cppyy::GetGlobalOperator's implementation #70

Merged
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
5 changes: 3 additions & 2 deletions src/Cppyy.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ namespace Cppyy {
TCppScope_t scope, const std::string& name, const std::string& proto);

CPPYY_IMPORT
TCppIndex_t GetGlobalOperator(
TCppType_t scope, const std::string& lc, const std::string& rc, const std::string& op);
TCppMethod_t GetGlobalOperator(TCppType_t scope, const std::string &lc,
const std::string &rc,
const std::string &op);

// method properties ---------------------------------------------------------
CPPYY_IMPORT
Expand Down
9 changes: 3 additions & 6 deletions src/Utility.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,11 @@ CPyCppyy::PyCallable* BuildOperator(const std::string& lcname, const std::string
const char* op, Cppyy::TCppScope_t scope, bool reverse=false)
{
// Helper to find a function with matching signature in 'funcs'.
std::string opname = "operator";
opname += op;

Cppyy::TCppIndex_t idx = Cppyy::GetGlobalOperator(scope, lcname, rcname, opname);
if (idx == (Cppyy::TCppIndex_t)-1)
Cppyy::TCppMethod_t meth = Cppyy::GetGlobalOperator(scope, lcname, rcname, op);
if (!meth)
return nullptr;

Cppyy::TCppMethod_t meth = Cppyy::GetMethod(scope, idx);
if (!reverse)
return new CPyCppyy::CPPFunction(scope, meth);
return new CPyCppyy::CPPReverseBinary(scope, meth);
Expand Down Expand Up @@ -331,7 +328,7 @@ CPyCppyy::PyCallable* CPyCppyy::Utility::FindBinaryOperator(
if (!scope) {
// TODO: the following should remain sync with what clingwrapper does in its
// type remapper; there must be a better way?
if (lcname == "str" || lcname == "unicode" || lcname == "complex")
if (lcname == "str" || lcname == "unicode" || lcname == "complex" || lcname.find("std::") == 0)
scope = Cppyy::GetScope("std");
else scope = Cppyy::GetScope(TypeManip::extract_namespace(lcname));
}
Expand Down
Loading