Home | History | Annotate | Download | only in clinic

Lines Matching defs:Function

338         # The parameter declarations for the impl function.
341 # The arguments to the impl function at the time it's called.
349 # value from the parse function. This is also where
489 Generator function that computes the set of acceptable
543 A simple-minded text wrapper for C function declarations.
551 function won't wrap it.)
555 rather than try and improve/debug this dumb little function.
611 function = None
613 if isinstance(o, Function):
614 if function:
615 fail("You may specify at most one function per block.\nFound a block containing at least two:\n\t" + repr(function) + " and " + repr(o))
616 function = o
617 return self.render_function(clinic, function)
788 # so we skip making a parse function
789 # and call directly into the impl function.
1125 # we use "impl_parameters" for the parsing function
1128 # as variables in the parsing function. but since it's
1271 clinic.Function objects. At the moment it should
1845 this function is only ever used to find the parent of where
2032 class Function:
2034 Mutable duck type for inspect.Function.
2098 return '<clinic.Function ' + self.name + '>'
2110 f = Function(**kwargs)
2114 value = value.copy(function=f)
2126 function, converter, annotation=_empty,
2131 self.function = function
2149 'function': self.function, 'converter': self.converter, 'annotation': self.annotation,
2155 converter.function = kwargs['function']
2215 For the init function, self, name, function, and default
2256 # only dataflow analysis could inline the static function!)
2262 # The C converter *function* to be used, if any.
2267 # the variable when passing it into the _impl function?
2314 def __init__(self, name, py_name, function, default=unspecified, *, c_default=None, py_default=None, annotation=unspecified, **kwargs):
2337 # about the function in the init.
2340 self.function = LandMine("Don't access members of self.function inside converter_init!")
2342 self.function = function
2421 # For "positional-only" function parsing,
2503 A second initialization function, like converter_init,
2505 You are permitted to examine self.function here.
2715 # The r() function (short for "register") both registers the
2828 raise RuntimeError("Unhandled type of function f: " + repr(f.kind))
2849 f = self.function
2854 kind = self.function.kind
2877 # * The name of the first parameter to the impl and the parsing function will always
2882 # * If the function is neither tp_new (METHOD_NEW) nor tp_init (METHOD_INIT):
2883 # * The type of the first parameter to the parsing function is also self.type.
2884 # This means that if you step into the parsing function, your "self" parameter
2887 # * Else if the function is tp_new (METHOD_NEW):
2888 # * The type of the first parameter to the parsing function is "PyTypeObject *",
2889 # so the type signature of the function call is an exact match.
2893 # * Else if the function is tp_init (METHOD_INIT):
2894 # * The type of the first parameter to the parsing function is "PyObject *",
2895 # so the type signature of the function call is an exact match.
2901 return required_type_for_self_for_parser(self.function) or self.type
2908 if self.function.kind == STATIC_METHOD:
2924 kind = self.function.kind
2925 cls = self.function.cls
2935 'type_object': self.function.cls.type_object,
2994 def render(self, function, data):
2996 function is a clinic.Function instance.
3004 def render(self, function, data):
3017 def render(self, function, data):
3028 def render(self, function, data):
3045 def render(self, function, data):
3072 def render(self, function, data):
3086 def render(self, function, data):
3210 self.function = None
3332 fail("Can't set @classmethod, function is not a normal callable")
3337 fail("Can't set @staticmethod, function is not a normal callable")
3417 # function. you can't modify them. you must enter a
3423 # we'll call this number of spaces F (for "function").
3453 fail("Couldn't find existing function " + repr(existing) + "!")
3460 fail("'kind' of function and cloned function don't match! (@classmethod/@staticmethod/@coexist)")
3461 self.function = existing_function.copy(name=function_name, full_name=full_name, module=module, cls=cls, c_basename=c_basename, docstring='')
3463 self.block.signatures.append(self.function)
3464 (cls or module).functions.append(self.function)
3475 fail("Illegal function name: {}".format(full_name))
3523 self.function = Function(name=function_name, full_name=full_name, module=module, cls=cls, c_basename=c_basename,
3525 self.block.signatures.append(self.function)
3528 type, name = correct_name_for_self(self.function)
3532 sc = self.function.self_converter = self_converter(name, name, self.function, **kwargs)
3533 p_self = Parameter(sc.name, inspect.Parameter.POSITIONAL_ONLY, function=self.function, converter=sc)
3534 self.function.parameters[sc.name] = p_self
3536 (cls or module).functions.append(self.function)
3557 # * A line with < P spaces is the first line of the function
3560 # * The first line of the function docstring must be at the same
3561 # indent as the function declaration.
3564 # of the function declaration.)
3626 for p in self.function.parameters.values():
3668 fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".a)")
3697 # the last = was probably inside a function call, like
3706 fail("Function " + self.function.name + " has an invalid parameter declaration:\n\t" + line)
3711 fail("Function " + self.function.name + " has an invalid parameter declaration (comma?):\n\t" + line)
3713 fail("Function " + self.function.name + " has an invalid parameter declaration (default value?):\n\t" + line)
3715 fail("Function " + self.function.name + " has an invalid parameter declaration (*args? **kwargs?):\n\t" + line)
3747 # inline function call
3844 converter = dict[name](c_name or parameter_name, parameter_name, self.function, value, **kwargs)
3849 if len(self.function.parameters) == 1:
3858 self.function.parameters.clear()
3862 p = Parameter(parameter_name, kind, function=self.function, converter=converter, default=value, group=self.group)
3864 if parameter_name in self.function.parameters:
3866 self.function.parameters[parameter_name] = p
3876 fail("Annotations must be either a name, a function call, or a string.")
3887 fail("Function " + self.function.name + " uses '*' more than once.")
3895 fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".b)")
3897 self.function.docstring_only = True
3900 fail("Function " + self.function.name + " has a ] without a matching [.")
3901 if not any(p.group == self.group for p in self.function.parameters.values()):
3902 fail("Function " + self.function.name + " has an empty group.\nAll groups must contain at least one parameter.")
3909 fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".c)")
3912 fail("Function " + self.function.name + " uses '/' more than once.")
3917 fail("Function " + self.function.name + " has an unsupported group configuration. (Unexpected state " + str(self.parameter_state) + ".d)")
3919 fail("Function " + self.function.name + " mixes keyword-only and positional-only parameters, which is unsupported.")
3921 for p in self.function.parameters.values():
3923 fail("Function " + self.function.name + " mixes keyword-only and positional-only parameters, which is unsupported.")
3949 assert self.function.parameters
3950 last_parameter = next(reversed(list(self.function.parameters.values())))
3964 fail("Function " + self.function.name + " has a ] without a matching [.")
3970 new_docstring = self.function.docstring
3978 self.function.docstring = new_docstring
3981 f = self.function
4101 # if inspect.Signature gets this function,
4138 # The Python standard library will not use function annotations
4183 # The first line of a docstring should be a summary of the function.
4197 "Every non-blank function docstring must start with\n" +
4232 if not self.function:
4236 values = self.function.parameters.values()
4243 fail("Function " + self.function.name + " specifies '*' without any parameters afterwards.")
4246 for name, value in self.function.parameters.items():
4251 self.function.docstring = self.format_docstring()