==== Utils ====// 
Calls the callback with the given name. The Context of this callback is always _base (this).
@param name The name of the target which shall be called.
@param args The args with which the callback shall be called.
341787
function dispatchCallback(name, args) {
                    if(_initialized) {
                        var callback = _currentPreparedOptions.callbacks[name];
                        var extensionOnName = name;
                        var ext;

                        if(extensionOnName.substr(0, 2) === "on")
                            extensionOnName = extensionOnName.substr(2, 1).toLowerCase() + extensionOnName.substr(3);

                        if(type(callback) == TYPES.f)
                            callback.call(_base, args);

                        FRAMEWORK.each(_extensions, function() {
                            ext = this;
                            if(type(ext.on) == TYPES.f)
                                ext.on(extensionOnName, args);
                        });
                    }
                    else if(!_destroyed)
                        _callbacksInitQeueue.push({ n : name, a : args });
                }
1022977
protected final void args(Object... args) {
        if (args == null) args = NO_ARGS;
        this.args = args;
        retry();
    }
1087195
@Override public Object invokeMethod(final String name, final Object arguments) {
    if (GantState.dryRun) {
      if (GantState.verbosity > GantState.SILENT) {
        final StringBuilder sb = new StringBuilder();
        int padding = 9 - name.length();
        if (padding < 0) { padding = 0; }
        sb.append("         ".substring(0, padding) + '[' + name + "] ");
        final Object[] args = (Object[]) arguments;
        if (args[0] instanceof Map<?,?>) {
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          // Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the
          // cast (Map<?,?>) causes a type check error due to the capture algorithm.
          //
          //  TODO : Fix this rather than use a SuppressWarnings.
          //////////////////////////////////////////////////////////////////////////////////////////////////////////
          @SuppressWarnings({ "unchecked", "rawtypes" } ) final Iterator<Map.Entry<?,?>> i =((Map) args[0]).entrySet().iterator();
          while (i.hasNext()) {
            final Map.Entry<?,?> e = i.next();
            sb.append(e.getKey() + " : '" + e.getValue() + '\'');
            if (i.hasNext()) { sb.append(", "); }
          }
          sb.append('\n');
          getProject().log(sb.toString());
          if (args.length == 2) {((Closure<?>) args[1]).call(); }
        }
        else if (args[0] instanceof Closure) { ((Closure<?>) args[0]).call(); }
        else { throw new RuntimeException("Unexpected type of parameter to method " + name); }
      }
      return null;
    }
    return super.invokeMethod(name, arguments);
  }
990631
public static void notNull(final Object arg, final String name) {
        if(arg == null) {
            throw new IllegalArgumentException(String.format("%s should not be null.", name));
        }
    }
1243540
public MethodCall with(String name1, Object arg1) {
    return with(name1, arg1, null, null, null, null);
  }
865046
def is_argument(self, name):
        
        if name == self.vararg:
            return True
        if name == self.kwarg:
            return True
        return (
            self.find_argname(name, True)[1] is not None
            or self.kwonlyargs
            and _find_arg(name, self.kwonlyargs, True)[1] is not None
        )
1289294
function(name) {
        if (!this._states.hasOwnProperty(name))
          throw new Error('unknown state "'+name+'"')

        var extraArgs = _.toArray(arguments).slice(1)
        this.currentState = name
        this._callCallbacks(this._states[name].enter, extraArgs)
      }
1283651
public void claimName(String name) {
    checkName(name);
    if (names.add(name, 1) != 0) {
      names.remove(name);
      // give a slightly better error message in this case
      if (reserved.contains(name)) {
        throw new IllegalArgumentException("Tried to claim a reserved name: " + name);
      }
      throw new IllegalArgumentException("Name: " + name + " was already claimed!");
    }
  }
971081
private function checkCallbackName(&$name)
    {
        if ( ! is_string($name)) {
            $type = gettype($name);

            throw new Exceptions\InvalidTypeException(
                "The callback name value must be a string, $type given."
            );
        }

        $name = strtolower(trim($name));
    }
1124428
public function callMacro(string $name, array $args)
    {
        if (isset($this->macros[$name])) {
            return call_user_func_array($this->macros[$name], $args);
        }
        throw new RuntimeException('There is no macro with the given name "'.$name.'" to call');
    }
88697
public MethodCall with(String name1, Object arg1, String name2, Object arg2) {
    return with(name1, arg1, name2, arg2, null, null);
  }
880967
function callHandler(callback, context, args) {
  switch (args.length) {
    case 0: return callback.call(context);
    case 1: return callback.call(context, args[0]);
    case 2: return callback.call(context, args[0], args[1]);
    case 3: return callback.call(context, args[0], args[1], args[2]);
    default: return callback.apply(context, args);
  }
}
909445
public function trigger($name, ...$args)
    {
        //we should deal with strings
        //then callables respectively
        //to allow overriding
        if (is_string($name)) {
            //is it a protocol?
            if (strpos($name, '://') !== false) {
                return $this->triggerProtocol($name, ...$args);
            }

            //they can call a class
            if (strpos($name, '@') !== false) {
                return $this->triggerController($name, ...$args);
            }

            //unless it's a static call
            if (strpos($name, '::') !== false && is_callable($name)) {
                call_user_func_array($name, $args);
                return $this;
            }

            return $this->triggerEvent($name, ...$args);
        }

        if (is_callable($name)) {
            if ($name instanceof Closure) {
                $name = $this->bindCallback($name);
            }

            call_user_func_array($name, $args);
        }

        //we can only deal with callable and strings
        //we don't want to throw an error
        //because it could just be a pseudo
        //placeholder
        return $this;
    }
144484
public final <T> void addArgument(Class<T> cls, String name)
    {
        if (map.containsKey(name))
        {
            throw new IllegalArgumentException(name+" is already added as option");
        }
        if (hasArrayArgument)
        {
            throw new IllegalArgumentException("no argument allowed after array argument");
        }
        types.add(cls);
        names.add(name);
        if (cls.isArray())
        {
            hasArrayArgument = true;
        }
    }
479990
public final void setArgs(String... args) throws CmdArgsException
    {
        try
        {
            options = new HashMap<>();
            Option opt = null;
            int index = 0;
            for (String arg : args)
            {
                if (opt != null)
                {
                    options.put(opt.name, ConvertUtility.convert(opt.cls, arg));
                    opt = null;
                }
                else
                {
                    if (map.containsKey(arg))
                    {
                        opt = map.get(arg);
                        if (opt.exclusiveGroup != null)
                        {
                            if (effectiveGroup != null && !effectiveGroup.equals(opt.exclusiveGroup))
                            {
                                throw new CmdArgsException(opt.exclusiveGroup+" mix with "+effectiveGroup, this);
                            }
                            effectiveGroup = opt.exclusiveGroup;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                index++;
            }
            // defaults
            for (Option o : map.values())
            {
                if (!o.mandatory && !options.containsKey(o.name))
                {
                    options.put(o.name, o.defValue);
                }
            }
            int len = args.length-index;
            if (hasArrayArgument)
            {
                if (len < types.size())
                {
                    throw new CmdArgsException("too few arguments", this);
                }
            }
            else
            {
                if (len != types.size())
                {
                    throw new CmdArgsException("wrong number of arguments", this);
                }
            }
            arguments = new HashMap<>();
            int arraySize = len - types.size() + 1;
            int arrayIndex = Integer.MAX_VALUE;
            Object array = null;
            Class<?> componenType = null;
            if (hasArrayArgument)
            {
                arrayIndex = types.size()-1;
                Class<?> arrayType = types.get(arrayIndex);
                componenType = arrayType.getComponentType();
                array = Array.newInstance(componenType, arraySize);
                arguments.put(names.get(arrayIndex), array);
            }
            for (int ii=0;ii<len;ii++)
            {
                if (ii < arrayIndex)
                {
                    Object value = ConvertUtility.convert(types.get(ii), args[ii+index]);
                    arguments.put(names.get(ii), value);
                }
                else
                {
                    Object value = ConvertUtility.convert(componenType, args[ii+index]);
                    Array.set(array, ii - arrayIndex, value);
                }
            }
            for (Option o : map.values())
            {
                if (o.mandatory && !options.containsKey(o.name))
                {
                    throw new CmdArgsException("mandatory option "+o.name+": "+o.description+" missing", this);
                }
            }
            if (effectiveGroup != null)
            {
                for (Option o : groups.get(effectiveGroup))
                {
                    if (o.mandatory && !options.containsKey(o.name))
                    {
                        throw new CmdArgsException(effectiveGroup+" option "+o.name+": "+o.description+" missing", this);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw new CmdArgsException(ex, this);
        }
    }
607166
public void setArgs(String[] args) {
        if (args == null) {
            args = new String[]{};
        }
        this.args = args;
        this.argsList = Collections.unmodifiableList(new ArrayList<String>(Arrays.asList(args)));
    }
861906
public final boolean hasAnnotation(final String name) {
        if (name == null) {
            throw new IllegalArgumentException("The argument 'name' cannot be NULL!");
        }
        for (int i = 0; i < annotations.size(); i++) {
            final SgAnnotation annotation = annotations.get(i);
            if (annotation.getName().equals(name)) {
                return true;
            }
        }
        return false;
    }