use polymorphism
[tiramisu.git] / tiramisu / autolib.py
index ffdbb0a..503bcdd 100644 (file)
@@ -29,6 +29,7 @@ def carry_out_calculation(option, config, callback, callback_params,
                           index=None, max_len=None):
     """a function that carries out a calculation for an option's value
 
+    :param name: the option name (`opt.impl_getname()`)
     :param name: the option
     :param config: the context config in order to have
                    the whole options available
@@ -142,12 +143,13 @@ def carry_out_calculation(option, config, callback, callback_params,
     one_is_multi = False
     # multi's option should have same value for all option
     len_multi = None
-
-    for key, callbacks in callback_params.items():
-        for callbk in callbacks:
-            if isinstance(callbk, tuple):
+    for callbacks in callback_params:
+        key = callbacks.name
+        for callbk in callbacks.params:
+            if callbk.option is not None:
                 # callbk is something link (opt, True|False)
-                opt, force_permissive = callbk
+                opt = callbk.get_option(config)
+                force_permissive = callbk.force_permissive
                 path = config.cfgimpl_get_description().impl_get_path_by_opt(
                     opt)
                 # get value
@@ -158,7 +160,7 @@ def carry_out_calculation(option, config, callback, callback_params,
                         continue
                     raise ConfigError(_('unable to carry out a calculation, '
                                         'option {0} has properties: {1} for: '
-                                        '{2}').format(opt._name,
+                                        '{2}').format(option.impl_getname(),
                                                       err.proptype,
                                                       option._name))
 
@@ -178,7 +180,7 @@ def carry_out_calculation(option, config, callback, callback_params,
                 tcparams.setdefault(key, []).append((value, is_multi))
             else:
                 # callbk is a value and not a multi
-                tcparams.setdefault(key, []).append((callbk, False))
+                tcparams.setdefault(key, []).append((callbk.value, False))
 
     # if one value is a multi, launch several time calculate
     # if index is set, return a value