Commit 54352d1e authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Minor preparations for forbidden params in RAPI handlers

This patch prepares the way for defining forbidden parameters in RAPI
handler classes as is done with renames and the like. No implementation
of the logic is present here, just the expansion of expected
Signed-off-by: default avatarHrvoje Ribicic <>
Reviewed-by: default avatarKlaus Aehlig <>
parent 14047f60
......@@ -60,6 +60,7 @@ class OpcodeAttributes(object):
......@@ -71,13 +72,15 @@ class OpcodeAttributes(object):
self.opcode = "%s_OPCODE" % method_name
self.rename = "%s_RENAME" % method_name
self.aliases = "%s_ALIASES" % method_name
self.forbidden = "%s_FORBIDDEN" % method_name
self.get_input = "Get%sOpInput" % method_name.capitalize()
def GetModifiers(self):
"""Returns the names of all the attributes that replace or modify a method.
return [self.opcode, self.rename, self.aliases, self.get_input]
return [self.opcode, self.rename, self.aliases, self.forbidden,
def GetAll(self):
return [self.method] + self.GetModifiers()
......@@ -469,7 +472,7 @@ class _MetaOpcodeResource(type):
obj = type.__call__(mcs, *args, **kwargs)
for m_attrs in OPCODE_ATTRS:
method, op_attr, rename_attr, aliases_attr, fn_attr = m_attrs.GetAll()
method, op_attr, rename_attr, aliases_attr, _, fn_attr = m_attrs.GetAll()
if hasattr(obj, method):
# If the method handler is already defined, "*_RENAME" or
# "Get*OpInput" shouldn't be (they're only used by the automatically
......@@ -107,7 +107,8 @@ class TestOpcodeResource(unittest.TestCase):
def _GetMethodAttributes(method):
attrs = ["%s_OPCODE" % method, "%s_RENAME" % method,
"%s_ALIASES" % method, "Get%sOpInput" % method.capitalize()]
"%s_ALIASES" % method, "%s_FORBIDDEN" % method,
"Get%sOpInput" % method.capitalize()]
assert attrs == dict((opattrs.method, opattrs.GetModifiers())
for opattrs in baserlib.OPCODE_ATTRS)[method]
return attrs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment