Skip to content

Add C++ support for functions#2537

Draft
EmilyBourne wants to merge 114 commits intodevelfrom
ebourne_cpp_functions
Draft

Add C++ support for functions#2537
EmilyBourne wants to merge 114 commits intodevelfrom
ebourne_cpp_functions

Conversation

@EmilyBourne
Copy link
Copy Markdown
Member

@EmilyBourne EmilyBourne commented Jan 3, 2026

To be reviewed and merged after #2525. This is work towards adding support for C++ as described in #2393.

@pyccel-bot
Copy link
Copy Markdown

pyccel-bot bot commented Jan 3, 2026

Hello again! Thank you for this new pull request 🤩.

Please begin by requesting your checklist using the command /bot checklist

@EmilyBourne
Copy link
Copy Markdown
Member Author

EmilyBourne commented Jan 3, 2026

Here is your checklist. Please tick items off when you have completed them or determined that they are not necessary for this pull request:

  • Write a clear PR description
  • Add tests to check your code works as expected
  • Update documentation if necessary
  • Update Changelog
  • Ensure any relevant issues are linked
  • Ensure new tests are passing

@EmilyBourne
Copy link
Copy Markdown
Member Author

/bot run docs coverage

Copy link
Copy Markdown

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

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

There seems to be lines in this PR which aren't tested. Please take a look at my comments and add tests which cover the new code.

If this is modified code which cannot be easily tested in this PR please open an issue to request that this code be either removed or tested. Once you have done that please leave a message on the relevant conversation beginning with the line /bot accept and referencing the issue.

Similarly if the new code cannot be tested for some reason, please leave a comment beginning with the line /bot accept on the relevant conversation explaining why the code can't be tested.

Comment on lines +217 to +219
return code
else:
# code ends with \n
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +324 to +330
lhs = ObjectAddress(expr.lhs) if isinstance(expr.lhs, Variable) else expr.lhs
rhs = ObjectAddress(expr.rhs) if isinstance(expr.rhs, Variable) else expr.rhs

lhs_code = self._print(lhs)
rhs_code = self._print(rhs)
return f'{lhs_code} {Op} {rhs_code}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +440 to +441
return ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

self.scope.get_temporary_variable, self.scope,
language_has_vectors = False)
else:
body_exprs = expr.body
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +496 to +497
return 'return;\n'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +166 to +168
desc_5 = "Run the single-process tests which can be run in parallel... [language: C++]"
desc_6 = "Run the single-process tests which can be run in parallel... [language: Python]"
descriptions = [desc_1, desc_2, desc_3, desc_4, desc_5, desc_6]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +175 to +177
cmd_5 = ['-ra', '-m (not xdist_incompatible and cpp)', '-n', 'auto']
cmd_6 = ['-ra', '-m (not xdist_incompatible and python)', '-n', 'auto']
commands = [cmd_1, cmd_2, cmd_3, cmd_4, cmd_5, cmd_6]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

assert context in ('module', 'function', 'class', 'variable', 'wrapper')
assert parent_context in ('module', 'function', 'class', 'loop', 'program')
if len(name)>4 and all(name[i] == '_' for i in (0,1,-1,-2)) and parent_context == 'class':
return name
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

if name == '__del__':
name = 'free'
if len(name)>4 and all(name[i] == '_' for i in (0,1,-1,-2)):
name = 'operator' + name[1:-2]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Comment on lines +85 to +86
name = 'private'+name
return self._get_collisionless_name(name, symbols)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

@EmilyBourne EmilyBourne added the blocked Cannot be solved/merged until something else is fixed label Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Cannot be solved/merged until something else is fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant