MCPcopy Index your code
hub / github.com/python/cpython / process_methoddef

Method process_methoddef

Tools/clinic/libclinic/parse_args.py:895–923  ·  view source on GitHub ↗
(self, clang: CLanguage)

Source from the content-addressed store, hash-verified

893 self.parser_body(*fields, declarations=self.declarations)
894
895 def process_methoddef(self, clang: CLanguage) -> None:
896 methoddef_cast_end = ""
897 if self.flags in ('METH_NOARGS', 'METH_O', 'METH_VARARGS'):
898 methoddef_cast = "(PyCFunction)"
899 elif self.func.kind is GETTER:
900 methoddef_cast = "" # This should end up unused
901 elif self.limited_capi:
902 methoddef_cast = "(PyCFunction)(void(*)(void))"
903 else:
904 methoddef_cast = "_PyCFunction_CAST("
905 methoddef_cast_end = ")"
906
907 if self.func.methoddef_flags:
908 self.flags += '|' + self.func.methoddef_flags
909
910 self.methoddef_define = self.methoddef_define.replace('{methoddef_flags}', self.flags)
911 self.methoddef_define = self.methoddef_define.replace('{methoddef_cast}', methoddef_cast)
912 self.methoddef_define = self.methoddef_define.replace('{methoddef_cast_end}', methoddef_cast_end)
913
914 self.methoddef_ifndef = ''
915 conditional = clang.cpp.condition()
916 if not conditional:
917 self.cpp_if = self.cpp_endif = ''
918 else:
919 self.cpp_if = "#if " + conditional
920 self.cpp_endif = "#endif /* " + conditional + " */"
921
922 if self.methoddef_define and self.codegen.add_ifndef_symbol(self.func.full_name):
923 self.methoddef_ifndef = METHODDEF_PROTOTYPE_IFNDEF
924
925 def finalize(self, clang: CLanguage) -> None:
926 # add ';' to the end of self.parser_prototype and self.impl_prototype

Callers 1

parse_argsMethod · 0.95

Calls 3

add_ifndef_symbolMethod · 0.80
replaceMethod · 0.45
conditionMethod · 0.45

Tested by

no test coverage detected