Skip to content

Commit

Permalink
parse: properly parses "new" enum groups
Browse files Browse the repository at this point in the history
closes: #241
  • Loading branch information
Dav1dde committed Apr 5, 2020
1 parent eea92d2 commit f161fb6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions glad/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def enums(self):
for element in self.root.iter('enums'):
namespace = element.attrib['namespace']
type_ = element.get('type')
group = element.get('group')
parent_group = element.get('group')
vendor = element.get('vendor')
comment = element.get('comment', '')

Expand All @@ -118,8 +118,11 @@ def enums(self):
assert enum.tag == 'enum'

name = enum.attrib['name']
self._enums[name] = Enum(name, enum.attrib['value'], namespace,
type_, group, vendor, comment)
self._enums[name] = Enum(
name, enum.attrib['value'], namespace,
type_=type_, group=enum.get('group'), parent_group=parent_group,
vendor=vendor, comment=comment
)

return self._enums

Expand Down Expand Up @@ -191,15 +194,20 @@ def __init__(self, element):

class Enum(object):
def __init__(self, name, value, namespace, type_=None,
group=None, vendor=None, comment=''):
group=None, parent_group=None, vendor=None, comment=''):
self.name = name
self.value = value
self.namespace = namespace
self.type = type_
self.group = group
self.parent_group = parent_group
self.vendor = vendor
self.comment = comment

@property
def groups(self):
return [] if self.group is None else self.group.split(',')

def __hash__(self):
return hash(self.name)

Expand Down

0 comments on commit f161fb6

Please sign in to comment.