'Call the callable with the arguments and keyword arguments
provided but inject the active context or environment as first
argument if the callable is a :func:`contextfunction` or
:func:`environmentfunction`.'

@internalcode
def call(__self, __obj, *args, **kwargs):

    if __debug__:
        __traceback_hide__ = True
    if isinstance(__obj, _context_function_types):
        if getattr(__obj, 'contextfunction', 0):
            args = ((__self,) + args)
        elif getattr(__obj, 'environmentfunction', 0):
            args = ((__self.environment,) + args)
    return __obj(*args, **kwargs)
