pyccel.codegen.wrapper.c_to_python_wrapper module#
Module describing the code-wrapping class : CToPythonWrapper which creates an interface exposing C code to Python.
- class pyccel.codegen.wrapper.c_to_python_wrapper.CToPythonWrapper(file_location, verbose)[source]#
Bases:
Wrapper
Class for creating a wrapper exposing C code to Python.
A class which provides all necessary functions for wrapping different AST objects such that the resulting AST is Python-compatible.
- Parameters:
file_location (str) – The folder where the translated code is located and where the generated .so file will be located.
verbose (int) – The level of verbosity.
- connect_pointer_targets(orig_var, python_res, funcdef, is_bind_c)[source]#
Get the code to connect pointers to their targets.
Get the code to connect pointers to their targets. The connection is done via reference counting to ensure that the target is not cleaned by the garbage collector before the pointer.
- Parameters:
orig_var (Variable) – The result of the function being wrapped.
python_res (Variable) – The Python accessible result of the function being wrapped.
funcdef (FunctionDef) – The function being wrapped.
is_bind_c (bool) – True if the code is translated from a C-compatible language. False if the translated code is in C.
- Returns:
Any nodes which must be printed to increase reference counts.
- Return type:
list
- get_new_PyObject(name, dtype=None, is_temp=False)[source]#
Create new PyccelPyObject Variable with the desired name.
Create a new Variable with the datatype PyccelPyObject and the desired name. A PyccelPyObject datatype means that this variable can be accessed and manipulated from Python.
- Parameters:
name (str) – The desired name.
dtype (DataType, optional) – The datatype of the object which will be represented by this PyObject. This is not necessary unless a variable sis required which will describe a class.
is_temp (bool, default=False) – Indicates if the Variable is temporary. A temporary variable may be ignored by the printer.
- Returns:
The new variable.
- Return type: