Skip to content

cppyy passing arguments by name to C++ binding #16406

Open
@will-cern

Description

@will-cern

Feature description

Is it possible to support passing arguments by name to a C++ method in cppyy, including passing out of order and not passing all arguments if some are defaulted?

Here is an example:

import ROOT

ROOT.gInterpreter.ProcessLine("""
class MyClass {
public:
    class MyObj {
    public:
        MyObj(const char* in) : s(in) { }
        TString s;
    };
    void MyMethod(const MyObj& x="hello", bool opt=false, bool opt2=true) {
      std::cout << x.s << " " << opt << " " << opt2 << std::endl;
    }

};
""")

ROOT.MyClass().MyMethod(opt2=False,x="hi") # I'd like this to output "hi 0 0"

At the moment this produces:

File cppyy_default_compiler:1, in <module>

NameError: name 'false' is not defined

Thanks!

Alternatives considered

No response

Additional context

No response

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions