Bug 1259960 - s/DummyFunction/DependsFunction/. r=chmanchester
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 26 Mar 2016 09:53:38 +0900
changeset 290982 7ebd549a0af91d9bc1a3cfbe8e55631becf6f3b8
parent 290981 23b31c46e2117f80b78e6033fb5f1dee3a222965
child 290983 273794fe2b2cbaa28a52d17ceae069aa26bcb9d1
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Bug 1259960 - s/DummyFunction/DependsFunction/. r=chmanchester While DummyFunction is descriptive of what the instances are (and they can't even be called), the various uses of isintance(obj, DummyFunction) are kind of confusing, especially when they are in moz.configure land (and this bug is about to add another one).
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -127,18 +127,18 @@ def old_configure_assignments(help):
 def extra_old_configure_args(help):
     return []
 def add_old_configure_assignment(var, value_func):
-    from mozbuild.configure import DummyFunction
-    assert isinstance(value_func, DummyFunction)
+    from mozbuild.configure import DependsFunction
+    assert isinstance(value_func, DependsFunction)
     @depends(old_configure_assignments, value_func)
     def add_assignment(assignments, value):
         if value is None:
         if value is True:
             assignments.append('%s=1' % var)
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -32,17 +32,17 @@ from mozbuild.util import (
 import mozpack.path as mozpath
 class ConfigureError(Exception):
-class DummyFunction(object):
+class DependsFunction(object):
     '''Sandbox-visible representation of @depends functions.'''
     def __call__(self, *arg, **kwargs):
         raise RuntimeError('The `%s` function may not be called'
                            % self.__name__)
 class SandboxedGlobal(dict):
     '''Identifiable dict type for use as function global'''
@@ -99,17 +99,17 @@ class ConfigureSandbox(dict):
     def __init__(self, config, environ=os.environ, argv=sys.argv,
                  stdout=sys.stdout, stderr=sys.stderr, logger=None):
         dict.__setitem__(self, '__builtins__', self.BUILTINS)
         self._paths = []
         self._templates = set()
         # Store the real function and its dependencies, behind each
-        # DummyFunction generated from @depends.
+        # DependsFunction generated from @depends.
         self._depends = {}
         self._seen = set()
         self._options = OrderedDict()
         # Store the raw values returned by @depends functions
         self._results = {}
         # Store values for each Option, as per returned by Option.get_value
         self._option_values = {}
@@ -226,26 +226,26 @@ class ConfigureSandbox(dict):
         return super(ConfigureSandbox, self).__getitem__(key)
     def __setitem__(self, key, value):
         if (key in self.BUILTINS or key == '__builtins__' or
                 hasattr(self, '%s_impl' % key)):
             raise KeyError('Cannot reassign builtins')
-        if (not isinstance(value, DummyFunction) and
+        if (not isinstance(value, DependsFunction) and
                 value not in self._templates and
                 not issubclass(value, Exception)):
             raise KeyError('Cannot assign `%s` because it is neither a '
                            '@depends nor a @template' % key)
         return super(ConfigureSandbox, self).__setitem__(key, value)
     def _resolve(self, arg, need_help_dependency=True):
-        if isinstance(arg, DummyFunction):
+        if isinstance(arg, DependsFunction):
             assert arg in self._depends
             func, deps = self._depends[arg]
             assert not inspect.isgeneratorfunction(func)
             assert func in self._results
             if need_help_dependency and self._help_option not in deps:
                 raise ConfigureError("Missing @depends for `%s`: '--help'" %
             result = self._results[func]
@@ -323,39 +323,39 @@ class ConfigureSandbox(dict):
                     raise ConfigureError("'%s' is not a known option. "
                                          "Maybe it's declared too late?"
                                          % arg)
                 arg = self._options[name]
                 assert arg in self._option_values or self._help
                 resolved_arg = self._option_values.get(arg)
-            elif isinstance(arg, DummyFunction):
+            elif isinstance(arg, DependsFunction):
                 assert arg in self._depends
                 arg, _ = self._depends[arg]
                 resolved_arg = self._results.get(arg)
                 raise TypeError(
                     "Cannot use object of type '%s' as argument to @depends"
                     % type(arg))
         dependencies = tuple(dependencies)
         def decorator(func):
             if inspect.isgeneratorfunction(func):
                 raise ConfigureError(
                     'Cannot decorate generator functions with @depends')
             func, glob = self._prepare_function(func)
-            dummy = wraps(func)(DummyFunction())
+            dummy = wraps(func)(DependsFunction())
             self._depends[dummy] = func, dependencies
             with_help = self._help_option in dependencies
             if with_help:
                 for arg in args:
-                    if isinstance(arg, DummyFunction):
+                    if isinstance(arg, DependsFunction):
                         _, deps = self._depends[arg]
                         if self._help_option not in deps:
                             raise ConfigureError(
                                 "`%s` depends on '--help' and `%s`. "
                                 "`%s` must depend on '--help'"
                                 % (func.__name__, arg.__name__, arg.__name__))
             if not self._help or with_help:
@@ -483,25 +483,25 @@ class ConfigureSandbox(dict):
         used as per the descripted mapping above.
         The `reason` argument indicates what caused the option to be implied.
         It is necessary when it cannot be inferred from the `value`.
         # Don't do anything when --help was on the command line
         if self._help:
-        if not reason and isinstance(value, DummyFunction):
+        if not reason and isinstance(value, DependsFunction):
             deps = self._depends[value][1]
             possible_reasons = [d for d in deps if d != self._help_option]
             if len(possible_reasons) == 1:
                 if isinstance(possible_reasons[0], Option):
                     reason = (self._raw_options.get(possible_reasons[0]) or
-        if not reason or not isinstance(value, DummyFunction):
+        if not reason or not isinstance(value, DependsFunction):
             raise ConfigureError(
                 "Cannot infer what implies '%s'. Please add a `reason` to "
                 "the `imply_option` call."
                 % option)
         value = self._resolve(value, need_help_dependency=False)
         if value is not None:
             if isinstance(value, OptionValue):