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

Add structref as a mutable struct that is pass-by-ref #5978

Merged
merged 19 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ exclude =
numba/core/types/abstract.py
numba/core/types/functions.py
numba/core/types/misc.py
numba/core/types/containers.py
numba/core/types/npytypes.py
numba/core/types/common.py
numba/core/types/iterators.py
Expand Down
1 change: 1 addition & 0 deletions docs/source/developer/repomap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ These define aspects of the public Numba interface.
regular functions on the CPU
- :ghfile:`numba/core/extending.py` - Public decorators for extending Numba
(``overload``, ``intrinsic``, etc)
- :ghfile:`numba/experimental/structref.py` - Public API for defining a mutable struct
- :ghfile:`numba/core/ccallback.py` - ``@cfunc`` decorator for compiling
functions to a fixed C signature. Used to make callbacks.
- :ghfile:`numba/np/ufunc/decorators.py` - ufunc/gufunc compilation
Expand Down
22 changes: 22 additions & 0 deletions numba/core/datamodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,3 +1342,25 @@ def _actual_model(self):
def traverse(self, builder):
return [(self.actual_fe_type,
lambda value: builder.extract_value(value, [0]))]


@register_default(types.StructRefPayload)
class StructPayloadModel(StructModel):
"""Model for the payload of a mutable struct
"""
def __init__(self, dmm, fe_typ):
members = tuple(fe_typ.field_dict.items())
super().__init__(dmm, fe_typ, members)


class StructRefModel(StructModel):
"""Model for a mutable struct.
A reference to the payload
"""
def __init__(self, dmm, fe_typ):
dtype = fe_typ.get_data_type()
members = [
("meminfo", types.MemInfoPointer(dtype)),
]
super().__init__(dmm, fe_typ, members)