pyccel.codegen.printing.cppcode module#

Functions for printing C++ code.

class pyccel.codegen.printing.cppcode.CppCodePrinter(filename, *, verbose)[source]View on GitHub#

Bases: CodePrinter

A printer for printing code in C++.

A printer to convert Pyccel’s AST to strings of C++ code. As for all printers the navigation of this file is done via _print_X functions.

Parameters:
  • filename (str) – The name of the file being pyccelised.

  • verbose (int) – The level of verbosity.

exit_scope()[source]View on GitHub#

Exit the current scope and return to the enclosing scope.

Exit the current scope and return to the enclosing scope.

function_signature(expr, print_arg_names=True)[source]View on GitHub#

Get the C++ representation of the function signature.

Extract from the function definition expr all the information (name, input, output) needed to create the function signature and return a string describing the function.

This is not a declaration as the signature does not end with a semi-colon.

Parameters:
  • expr (FunctionDef) – The function definition for which a signature is needed.

  • print_arg_names (bool, default : True) – Indicates whether argument names should be printed.

Returns:

Signature of the function.

Return type:

str

get_declare_type(var)[source]View on GitHub#

Get the type of a variable for its declaration.

Get the type of a variable for its declaration.

Parameters:

var (Variable) – The variable to be declared.

Returns:

The code describing the type of the variable.

Return type:

str

language = 'C++'#
printmethod = '_cppcode'#
set_scope(scope)[source]View on GitHub#

Set the current scope.

Set the current scope and create a new set of all variables that have been declared in this scope. This allows variables to be declared at their first usage.

Parameters:

scope (Scope) – The current scope.