tools/spec: don't raise strings as exceptions
This commit is contained in:
parent
babd86aa2b
commit
e592afd8e0
@ -401,7 +401,7 @@ class Constant(Type):
|
|||||||
elif 'bitpos' in node.attrib:
|
elif 'bitpos' in node.attrib:
|
||||||
self.value = "1 << %s" % node.attrib['bitpos']
|
self.value = "1 << %s" % node.attrib['bitpos']
|
||||||
else:
|
else:
|
||||||
raise "Unknown constant value type"
|
raise RuntimeError("Unknown constant value type")
|
||||||
|
|
||||||
def declare(self):
|
def declare(self):
|
||||||
return "constexpr auto %(name)s = %(value)s;" % {
|
return "constexpr auto %(name)s = %(value)s;" % {
|
||||||
@ -497,7 +497,7 @@ class Require(object):
|
|||||||
elif node.tag in ['comment']:
|
elif node.tag in ['comment']:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise "Unknown requires node"
|
raise RuntimeError("Unknown requires node")
|
||||||
|
|
||||||
def apply(self, reg: Registry, extnumber=None):
|
def apply(self, reg: Registry, extnumber=None):
|
||||||
required = []
|
required = []
|
||||||
@ -528,7 +528,7 @@ class Require(object):
|
|||||||
elif value.tag == 'command':
|
elif value.tag == 'command':
|
||||||
required.append(name)
|
required.append(name)
|
||||||
else:
|
else:
|
||||||
raise "Unknown type"
|
raise RuntimeError("Unknown type")
|
||||||
|
|
||||||
return required
|
return required
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ class Feature(Type):
|
|||||||
if 'require' == node.tag:
|
if 'require' == node.tag:
|
||||||
self.requires.append(Require(node))
|
self.requires.append(Require(node))
|
||||||
else:
|
else:
|
||||||
raise "Unhandled feature node"
|
raise RuntimeError("Unhandled feature node")
|
||||||
|
|
||||||
def define(self, reg: Registry):
|
def define(self, reg: Registry):
|
||||||
return "#define %s" % self.name
|
return "#define %s" % self.name
|
||||||
@ -579,7 +579,7 @@ class Extension(Type):
|
|||||||
if node.tag == 'require':
|
if node.tag == 'require':
|
||||||
self.requires.append(Require(node))
|
self.requires.append(Require(node))
|
||||||
else:
|
else:
|
||||||
raise "Unknown extension node"
|
raise RuntimeError("Unknown extension node")
|
||||||
|
|
||||||
def apply(self, reg: Registry, platform: Set[str]):
|
def apply(self, reg: Registry, platform: Set[str]):
|
||||||
if self.name in reg.applied:
|
if self.name in reg.applied:
|
||||||
@ -653,7 +653,7 @@ def parse_types(reg: Registry, root):
|
|||||||
if concrete:
|
if concrete:
|
||||||
reg.types[name] = concrete(t)
|
reg.types[name] = concrete(t)
|
||||||
else:
|
else:
|
||||||
raise 'unhandled type'
|
raise RuntimeError('unhandled type')
|
||||||
|
|
||||||
if 'requires' in t.attrib:
|
if 'requires' in t.attrib:
|
||||||
reg.types[name].depends.append(t.attrib['requires'])
|
reg.types[name].depends.append(t.attrib['requires'])
|
||||||
|
Loading…
Reference in New Issue
Block a user