[PyROOT] Get names and types of all overloads' signature#9138
[PyROOT] Get names and types of all overloads' signature#9138siliataider merged 2 commits intoroot-project:masterfrom
Conversation
|
Starting build on |
|
Build failed on mac11.0/cxx17. Warnings:
And 212 more Failing tests: |
|
Build failed on mac1014/python3. Warnings:
And 101 more |
|
Starting build on |
|
Build failed on mac11.0/cxx17. Failing tests: |
8e3e5e8 to
db26d41
Compare
|
Starting build on |
|
A clear use case for this functionality has not surfaced since the opening of the PR. This can be closed now, to be reopened in case it becomes necessary. |
|
Reopening and bringing this up to date, a clear use case has surfaced in fact: #19437 |
db26d41 to
d6f02d8
Compare
Test Results 21 files 21 suites 3d 5h 1m 30s ⏱️ For more details on these failures, see this check. Results for commit 9f6b3d1. ♻️ This comment has been updated with latest results. |
cbe56ee to
26818b5
Compare
|
We should be able to merge this now, @vepadulano ? |
Yes, but given it's my own PR I can't approve it. Let's ask @guitargeek for an approval. This is in the context of RDF Pythonizations. It may be that this code is not going to be necessary once we have a CppInterop-based CPyCppyy, but currently we need it. |
guitargeek
left a comment
There was a problem hiding this comment.
Thank you very much @siliataider!
Could you please just revert the unrelated code formatting changes in CPPOverload.cxx? CPyCppyy has its own code style incompatible with the one of ROOT, and it would be better to not do unnecessary formatting changes in a codebase that is already hard to keep in sync.
dd6615e to
d0716bb
Compare
Expose two new attributes of a CPPOverload object on the Python side,
namely `func_overloads_names` and `func_overloads_types`. The first
returns a dictionary with all the input parameter names for all the
overloads, the second returns a dictionary with the types of the return
and input parameters for all the overloads. An example:
```python
import ROOT
from pprint import pprint
ROOT.gInterpreter.Declare("""
int foo(int a, float b);
int foo(int a);
float foo(float b);
double foo(int a, float b, double c);
""")
pprint(ROOT.foo.func_overloads_names)
pprint(ROOT.foo.func_overloads_types)
```
Output:
```
{'double ::foo(int a, float b, double c)': ('a', 'b', 'c'),
'float ::foo(float b)': ('b',),
'int ::foo(int a)': ('a',),
'int ::foo(int a, float b)': ('a', 'b')}
{'double ::foo(int a, float b, double c)': {'input_types': ('int',
'float',
'double'),
'return_type': 'double'},
'float ::foo(float b)': {'input_types': ('float',), 'return_type': 'float'},
'int ::foo(int a)': {'input_types': ('int',), 'return_type': 'int'},
'int ::foo(int a, float b)': {'input_types': ('int', 'float'),
'return_type': 'int'}}
```
d0716bb to
b3d0f9b
Compare
b3d0f9b to
9f6b3d1
Compare
guitargeek
left a comment
There was a problem hiding this comment.
LGTM! Thank you very much Vincenzo and Silia.
Make sure that you quickly integrate some pythonizations that use these new functions, so that we have some coverage and make sure this functionality is not broken in the future, e.g. by the upcoming cppyy upgrade.
This PR introduces a machinery to get the names and types (separately) of the signature of each overload of a particular
CPPOverloadobject. This allows for example for something like.EDIT
Here is the latest status of this feature after some discussion: