Skip to content

Commit 64434f8

Browse files
committed
Merge pull request #66 from FilipeMaia/enum_fix
Ensure that the types of the enums values are correct
2 parents 9adae09 + cf38ac3 commit 64434f8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

arrayfire/library.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@
1919
def _Enum_Type(v):
2020
return v
2121
except:
22+
class _MetaEnum(type):
23+
def __init__(cls, name, bases, attrs):
24+
for attrname, attrvalue in attrs.iteritems():
25+
if name != '_Enum' and isinstance(attrvalue, _Enum_Type):
26+
attrvalue.__class__ = cls
27+
attrs[attrname] = attrvalue
28+
2229
class _Enum(object):
23-
pass
30+
__metaclass__ = _MetaEnum
2431

2532
class _Enum_Type(object):
2633
def __init__(self, v):
@@ -31,7 +38,7 @@ class ERR(_Enum):
3138
Error values. For internal use only.
3239
"""
3340

34-
NONE = _Enum_Type(0)
41+
NONE = _Enum_Type(0)
3542

3643
#100-199 Errors in environment
3744
NO_MEM = _Enum_Type(101)

0 commit comments

Comments
 (0)