Skip to content

Commit 3e9e931

Browse files
committed
api: fix c_datatype hack
1 parent 2b2848b commit 3e9e931

5 files changed

Lines changed: 4 additions & 10 deletions

File tree

devito/ir/iet/visitors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def visit_Break(self, o):
477477
def visit_Return(self, o):
478478
v = 'return'
479479
if o.value is not None:
480-
v += ' %s' % o.value
480+
v += f' {ccode(o.value)}'
481481
return c.Statement(v)
482482

483483
def visit_Definition(self, o):

devito/symbolics/extended_sympy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ def _C_ctype(self):
418418
ctype = dtype_to_ctype(ctype)
419419
except:
420420
pass
421-
422421
return ctype
423422

424423
@property

devito/symbolics/printer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Utilities to turn SymPy objects into C strings.
33
"""
4-
54
import numpy as np
65
import sympy
76

devito/tools/dtypes_lowering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def dtype_to_ctype(dtype):
144144

145145
if isinstance(dtype, CustomDtype):
146146
return dtype
147-
elif issubclass(dtype, ctypes._SimpleCData):
147+
elif issubclass(dtype, (ctypes._Pointer, ctypes.Structure, ctypes._SimpleCData)):
148148
# Bypass np.ctypeslib's normalization rules such as
149149
# `np.ctypeslib.as_ctypes_type(ctypes.c_void_p) -> ctypes.c_ulong`
150150
return dtype

devito/types/basic.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import abc
22
import inspect
33
from collections import namedtuple
4-
from ctypes import POINTER, _Pointer, c_char_p, c_char, Structure
4+
from ctypes import POINTER, _Pointer, c_char_p, c_char
55
from functools import reduce, cached_property
66
from operator import mul
77

@@ -81,7 +81,7 @@ def _C_name(self):
8181
@property
8282
def _C_typedata(self):
8383
"""
84-
The type of the object in the generated code as a `str`.
84+
The type of the object's data in the generated code.
8585
"""
8686
_type = self._C_ctype
8787
if isinstance(_type, CustomDtype):
@@ -94,10 +94,6 @@ def _C_typedata(self):
9494
if _type is c_char_p:
9595
_type = c_char
9696

97-
# ctypes Structures such as dense/array use directly the struct name
98-
if issubclass(_type, Structure):
99-
_type = f'struct {_type.__name__}'
100-
10197
return _type
10298

10399
@abc.abstractproperty

0 commit comments

Comments
 (0)