-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Python][RDF] Enable Support for C++ Free Functions in RDF Define and Filter #19437
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a78169c
[Python][cppyy] Get overload from template proxy using input and temp…
siliataider 5f01519
[Python][cppyy] Add patch file
siliataider ae03573
[Python][RDF] Convert cpp free functions to std::function to pass in …
siliataider 1b16f28
[Python] Extend the RDF define tests with cpp free functions
siliataider e1c1f4c
[Python][RDF] Ruff lint and format
siliataider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
bindings/pyroot/cppyy/patches/cppyy-Get-overload-from-template-proxy-using-tmpl-args.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| From a78169cedc78a7a3787473652e394da3ead5dbdf Mon Sep 17 00:00:00 2001 | ||
| From: Silia Taider <siliataider@gmail.com> | ||
| Date: Mon, 14 Jul 2025 11:26:30 +0200 | ||
| Subject: [PATCH] [Python][cppyy] Get overload from template proxy using input | ||
| and template arguments | ||
|
|
||
| --- | ||
| .../cppyy/CPyCppyy/src/TemplateProxy.cxx | 25 ++++++++++++++++++- | ||
| 1 file changed, 24 insertions(+), 1 deletion(-) | ||
|
|
||
| diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx | ||
| index 20ea4929ad..235a804c37 100644 | ||
| --- a/bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx | ||
| +++ b/bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx | ||
| @@ -729,6 +729,21 @@ static int tpp_setuseffi(CPPOverload*, PyObject*, void*) | ||
| return 0; // dummy (__useffi__ unused) | ||
| } | ||
|
|
||
| +//----------------------------------------------------------------------------- | ||
| +static PyObject* tpp_gettemplateargs(TemplateProxy* self, void*) { | ||
| + if (!self->fTemplateArgs) { | ||
| + Py_RETURN_NONE; | ||
| + } | ||
| + | ||
| + Py_INCREF(self->fTemplateArgs); | ||
| + return self->fTemplateArgs; | ||
| +} | ||
| + | ||
| +//----------------------------------------------------------------------------- | ||
| +static int tpp_settemplateargs(TemplateProxy*, PyObject*, void*) { | ||
| + PyErr_SetString(PyExc_AttributeError, "__template_args__ is read-only"); | ||
| + return -1; | ||
| +} | ||
|
|
||
| //---------------------------------------------------------------------------- | ||
| static PyMappingMethods tpp_as_mapping = { | ||
| @@ -739,7 +754,9 @@ static PyGetSetDef tpp_getset[] = { | ||
| {(char*)"__doc__", (getter)tpp_doc, (setter)tpp_doc_set, nullptr, nullptr}, | ||
| {(char*)"__useffi__", (getter)tpp_getuseffi, (setter)tpp_setuseffi, | ||
| (char*)"unused", nullptr}, | ||
| - {(char*)nullptr, nullptr, nullptr, nullptr, nullptr} | ||
| + {(char*)"__template_args__", (getter)tpp_gettemplateargs, (setter)tpp_settemplateargs, | ||
| + (char*)"the template arguments for this method", nullptr}, | ||
| + {(char*)nullptr, nullptr, nullptr, nullptr, nullptr}, | ||
| }; | ||
|
|
||
|
|
||
| @@ -770,6 +787,7 @@ static PyObject* tpp_overload(TemplateProxy* pytmpl, PyObject* args) | ||
| { | ||
| // Select and call a specific C++ overload, based on its signature. | ||
| const char* sigarg = nullptr; | ||
| + const char* tmplarg = nullptr; | ||
| PyObject* sigarg_tuple = nullptr; | ||
| int want_const = -1; | ||
|
|
||
| @@ -795,6 +813,11 @@ static PyObject* tpp_overload(TemplateProxy* pytmpl, PyObject* args) | ||
| scope = ((CPPClass*)pytmpl->fTI->fPyClass)->fCppType; | ||
| cppmeth = Cppyy::GetMethodTemplate( | ||
| scope, pytmpl->fTI->fCppName, proto.substr(1, proto.size()-2)); | ||
| + } else if (PyArg_ParseTuple(args, const_cast<char*>("ss:__overload__"), &sigarg, &tmplarg)) { | ||
| + scope = ((CPPClass*)pytmpl->fTI->fPyClass)->fCppType; | ||
| + std::string full_name = std::string(pytmpl->fTI->fCppName) + "<" + tmplarg + ">"; | ||
| + | ||
| + cppmeth = Cppyy::GetMethodTemplate(scope, full_name, sigarg); | ||
| } else if (PyArg_ParseTuple(args, const_cast<char*>("O|i:__overload__"), &sigarg_tuple, &want_const)) { | ||
| PyErr_Clear(); | ||
| want_const = PyTuple_GET_SIZE(args) == 1 ? -1 : want_const; | ||
| -- | ||
| 2.49.0 | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.