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

Improve operator resolution #129

Merged

Conversation

Vipul-Cariappa
Copy link
Collaborator

@Vipul-Cariappa Vipul-Cariappa commented Feb 22, 2025

GetMethodTemplate now also checks for operators methods using GetClassOperators
GetGlobalOperator can now handle templated types

Fixes 2 tests. Along with compiler-research/CppInterOp#509, fixes 3 tests.

Copy link
Collaborator

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Vipul-Cariappa
Copy link
Collaborator Author

@vgvassilev, something is failing with cling. Call to gbl.Cpp.Declare(code) fails. But if I force it to compile an empty string before compiling the actual code, it passes.
Any ideas, on what might be causing this? I suspect we need to do something in InterOp.

@vgvassilev
Copy link
Collaborator

@vgvassilev, something is failing with cling. Call to gbl.Cpp.Declare(code) fails. But if I force it to compile an empty string before compiling the actual code, it passes. Any ideas, on what might be causing this? I suspect we need to do something in InterOp.

Maybe Declare just parses and does not do jit and some previous call needed to be finalized or something like that?

void Cppyy::GetClassOperators(Cppyy::TCppScope_t klass,
const std::string& opname,
std::vector<TCppScope_t>& operators) {
if (opname == "operator+")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we can fold into an API: const char * GetOperatorKindAsString(Cpp::OperatorKind K);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this use case, shouldn't it be Cpp::OperatorKind Cpp::GetOperatorKindFromString(std::string op)?
Also, I believe this should be part of InterOp.
Should I add both? Any thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Let's keep it as is.

Vipul-Cariappa and others added 2 commits March 12, 2025 11:19
`GetMethodTemplate` now also checks for operators methods using `GetClassOperators`

`GetGlobalOperator` can now handle templated types
Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com>
Copy link
Collaborator

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

void Cppyy::GetClassOperators(Cppyy::TCppScope_t klass,
const std::string& opname,
std::vector<TCppScope_t>& operators) {
if (opname == "operator+")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Let's keep it as is.

@Vipul-Cariappa Vipul-Cariappa force-pushed the dev/templated-operators branch from 005777f to 14b05fa Compare March 12, 2025 06:44
@Vipul-Cariappa Vipul-Cariappa merged commit 752117e into compiler-research:master Mar 12, 2025
42 checks passed
@Vipul-Cariappa Vipul-Cariappa deleted the dev/templated-operators branch March 12, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants