Set option name in constructor. Closes #164.

pull/174/head
Jussi Pakkanen 10 years ago
parent 790fe206e6
commit 214a6b5c0a
  1. 18
      optinterpreter.py

@ -37,16 +37,17 @@ class OptionException(coredata.MesonException):
optname_regex = re.compile('[^a-zA-Z0-9_-]') optname_regex = re.compile('[^a-zA-Z0-9_-]')
class UserOption: class UserOption:
def __init__(self, kwargs): def __init__(self, name, kwargs):
super().__init__() super().__init__()
self.description = kwargs.get('description', '') self.description = kwargs.get('description', '')
self.name = name
def parse_string(self, valuestring): def parse_string(self, valuestring):
return valuestring return valuestring
class UserStringOption(UserOption): class UserStringOption(UserOption):
def __init__(self, kwargs): def __init__(self, name, kwargs):
super().__init__(kwargs) super().__init__(name, kwargs)
self.set_value(kwargs.get('value', '')) self.set_value(kwargs.get('value', ''))
def set_value(self, newvalue): def set_value(self, newvalue):
@ -55,8 +56,8 @@ class UserStringOption(UserOption):
self.value = newvalue self.value = newvalue
class UserBooleanOption(UserOption): class UserBooleanOption(UserOption):
def __init__(self, kwargs): def __init__(self, name, kwargs):
super().__init__(kwargs) super().__init__(name, kwargs)
self.set_value(kwargs.get('value', 'true')) self.set_value(kwargs.get('value', 'true'))
def set_value(self, newvalue): def set_value(self, newvalue):
@ -72,8 +73,8 @@ class UserBooleanOption(UserOption):
raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name)) raise OptionException('Value "%s" for boolean option "%s" is not a boolean.' % (valuestring, self.name))
class UserComboOption(UserOption): class UserComboOption(UserOption):
def __init__(self, kwargs): def __init__(self, name, kwargs):
super().__init__(kwargs) super().__init__(name, kwargs)
if 'choices' not in kwargs: if 'choices' not in kwargs:
raise OptionException('Combo option missing "choices" keyword.') raise OptionException('Combo option missing "choices" keyword.')
self.choices = kwargs['choices'] self.choices = kwargs['choices']
@ -173,8 +174,7 @@ class OptionInterpreter:
raise OptionException('Option name %s is reserved.' % opt_name) raise OptionException('Option name %s is reserved.' % opt_name)
if self.subproject != '': if self.subproject != '':
opt_name = self.subproject + ':' + opt_name opt_name = self.subproject + ':' + opt_name
opt = option_types[opt_type](kwargs) opt = option_types[opt_type](opt_name, kwargs)
opt.name = opt_name
if opt.description == '': if opt.description == '':
opt.description = opt_name opt.description = opt_name
if opt_name in self.cmd_line_options: if opt_name in self.cmd_line_options:

Loading…
Cancel
Save