Skip to content

Commit f82be28

Browse files
fix according to Cppyy::GetGlobalOperator's implementation
1 parent 373d3fb commit f82be28

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Cppyy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ namespace Cppyy {
286286
TCppScope_t scope, const std::string& name, const std::string& proto);
287287

288288
CPPYY_IMPORT
289-
TCppIndex_t GetGlobalOperator(
290-
TCppType_t scope, const std::string& lc, const std::string& rc, const std::string& op);
289+
TCppMethod_t GetGlobalOperator(TCppType_t scope, const std::string &lc,
290+
const std::string &rc,
291+
const std::string &op);
291292

292293
// method properties ---------------------------------------------------------
293294
CPPYY_IMPORT

src/Utility.cxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,11 @@ CPyCppyy::PyCallable* BuildOperator(const std::string& lcname, const std::string
265265
const char* op, Cppyy::TCppScope_t scope, bool reverse=false)
266266
{
267267
// Helper to find a function with matching signature in 'funcs'.
268-
std::string opname = "operator";
269-
opname += op;
270268

271-
Cppyy::TCppIndex_t idx = Cppyy::GetGlobalOperator(scope, lcname, rcname, opname);
272-
if (idx == (Cppyy::TCppIndex_t)-1)
269+
Cppyy::TCppMethod_t meth = Cppyy::GetGlobalOperator(scope, lcname, rcname, op);
270+
if (!meth)
273271
return nullptr;
274272

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

0 commit comments

Comments
 (0)