diff -r 642247a536d5 Modules/clinic/spwdmodule.c.h --- a/Modules/clinic/spwdmodule.c.h Sat Mar 14 20:17:38 2015 -0700 +++ b/Modules/clinic/spwdmodule.c.h Sun Mar 15 09:18:13 2015 +0200 @@ -36,10 +36,6 @@ exit: #endif /* defined(HAVE_GETSPNAM) */ -#ifndef SPWD_GETSPNAM_METHODDEF - #define SPWD_GETSPNAM_METHODDEF -#endif /* !defined(SPWD_GETSPNAM_METHODDEF) */ - #if defined(HAVE_GETSPENT) PyDoc_STRVAR(spwd_getspall__doc__, @@ -64,7 +60,11 @@ spwd_getspall(PyModuleDef *module, PyObj #endif /* defined(HAVE_GETSPENT) */ +#ifndef SPWD_GETSPNAM_METHODDEF + #define SPWD_GETSPNAM_METHODDEF +#endif /* !defined(SPWD_GETSPNAM_METHODDEF) */ + #ifndef SPWD_GETSPALL_METHODDEF #define SPWD_GETSPALL_METHODDEF #endif /* !defined(SPWD_GETSPALL_METHODDEF) */ -/*[clinic end generated code: output=41fec4a15b0cd2a0 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=ab16125c5e5f2b1b input=a9049054013a1b77]*/ diff -r 642247a536d5 Modules/clinic/zlibmodule.c.h --- a/Modules/clinic/zlibmodule.c.h Sat Mar 14 20:17:38 2015 -0700 +++ b/Modules/clinic/zlibmodule.c.h Sun Mar 15 09:18:13 2015 +0200 @@ -314,10 +314,6 @@ zlib_Compress_copy(compobject *self, PyO #endif /* defined(HAVE_ZLIB_COPY) */ -#ifndef ZLIB_COMPRESS_COPY_METHODDEF - #define ZLIB_COMPRESS_COPY_METHODDEF -#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ - #if defined(HAVE_ZLIB_COPY) PyDoc_STRVAR(zlib_Decompress_copy__doc__, @@ -340,10 +336,6 @@ zlib_Decompress_copy(compobject *self, P #endif /* defined(HAVE_ZLIB_COPY) */ -#ifndef ZLIB_DECOMPRESS_COPY_METHODDEF - #define ZLIB_DECOMPRESS_COPY_METHODDEF -#endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */ - PyDoc_STRVAR(zlib_Decompress_flush__doc__, "flush($self, length=zlib.DEF_BUF_SIZE, /)\n" "--\n" @@ -450,4 +442,8 @@ exit: return return_value; } -/*[clinic end generated code: output=bc9473721ca7c962 input=a9049054013a1b77]*/ + +#ifndef ZLIB_COMPRESS_COPY_METHODDEF + #define ZLIB_COMPRESS_COPY_METHODDEF +#endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ +/*[clinic end generated code: output=901c18189767dc08 input=a9049054013a1b77]*/ diff -r 642247a536d5 Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Mar 14 20:17:38 2015 -0700 +++ b/Modules/posixmodule.c Sun Mar 15 09:18:13 2015 +0200 @@ -17212,10 +17212,6 @@ dump buffer #define OS_SYSTEM_METHODDEF #endif /* !defined(OS_SYSTEM_METHODDEF) */ -#ifndef OS_SYSTEM_METHODDEF - #define OS_SYSTEM_METHODDEF -#endif /* !defined(OS_SYSTEM_METHODDEF) */ - #ifndef OS_UNAME_METHODDEF #define OS_UNAME_METHODDEF #endif /* !defined(OS_UNAME_METHODDEF) */ @@ -17388,10 +17384,6 @@ dump buffer #define OS_WAITPID_METHODDEF #endif /* !defined(OS_WAITPID_METHODDEF) */ -#ifndef OS_WAITPID_METHODDEF - #define OS_WAITPID_METHODDEF -#endif /* !defined(OS_WAITPID_METHODDEF) */ - #ifndef OS_WAIT_METHODDEF #define OS_WAIT_METHODDEF #endif /* !defined(OS_WAIT_METHODDEF) */ @@ -17492,10 +17484,6 @@ dump buffer #define OS_PUTENV_METHODDEF #endif /* !defined(OS_PUTENV_METHODDEF) */ -#ifndef OS_PUTENV_METHODDEF - #define OS_PUTENV_METHODDEF -#endif /* !defined(OS_PUTENV_METHODDEF) */ - #ifndef OS_UNSETENV_METHODDEF #define OS_UNSETENV_METHODDEF #endif /* !defined(OS_UNSETENV_METHODDEF) */ @@ -17603,7 +17591,7 @@ dump buffer #ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF #define OS_SET_HANDLE_INHERITABLE_METHODDEF #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ -/*[clinic end generated code: output=52a6140b0b052ce6 input=524ce2e021e4eba6]*/ +/*[clinic end generated code: output=b788c2d6010113e8 input=524ce2e021e4eba6]*/ static PyMethodDef posix_methods[] = { diff -r 642247a536d5 Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Sat Mar 14 20:17:38 2015 -0700 +++ b/Tools/clinic/clinic.py Sun Mar 15 09:18:13 2015 +0200 @@ -820,7 +820,8 @@ class CLanguage(Language): cpp_if = "#if " + conditional cpp_endif = "#endif /* " + conditional + " */" - if methoddef_define: + if methoddef_define and f.name not in clinic.ifndef_symbols: + clinic.ifndef_symbols.add(f.name) methoddef_ifndef = normalize_snippet(""" #ifndef {methoddef_name} #define {methoddef_name} @@ -1408,10 +1409,10 @@ class Destination: self.name = name self.type = type self.clinic = clinic - valid_types = ('buffer', 'file', 'suppress', 'two-pass') + valid_types = ('buffer', 'file', 'suppress', 'two-pass', 'append') if type not in valid_types: fail("Invalid destination type " + repr(type) + " for " + name + " , must be " + ', '.join(valid_types)) - extra_arguments = 1 if type == "file" else 0 + extra_arguments = 1 if type in ('file', 'append') else 0 if len(args) < extra_arguments: fail("Not enough arguments for destination " + name + " new " + type) if len(args) > extra_arguments: @@ -1427,8 +1428,10 @@ class Destination: d['basename'] = basename d['basename_root'], d['basename_extension'] = os.path.splitext(filename) self.filename = args[0].format_map(d) - if type == 'two-pass': + elif type == 'two-pass': self.id = None + elif type == 'append': + self.target, = args self.text, self.append, self._dump = _text_accumulator() @@ -1508,6 +1511,7 @@ everything file docstring_prototype suppress parser_prototype suppress impl_definition block +methoddef_ifndef append-file preset buffer everything buffer @@ -1515,6 +1519,7 @@ docstring_prototype suppress impl_prototype suppress parser_prototype suppress impl_definition block +methoddef_ifndef append-buffer preset partial-buffer everything buffer @@ -1523,6 +1528,7 @@ impl_prototype suppress methoddef_define block parser_prototype block impl_definition block +methoddef_ifndef append-buffer preset two-pass everything buffer @@ -1531,6 +1537,7 @@ impl_prototype suppress methoddef_define two-pass parser_prototype two-pass impl_definition block +methoddef_ifndef append-buffer """ @@ -1555,9 +1562,11 @@ impl_definition block self.add_destination("block", "buffer") self.add_destination("suppress", "suppress") self.add_destination("buffer", "buffer") + self.add_destination('append-buffer', 'append', 'buffer') self.add_destination("two-pass", "two-pass") if filename: self.add_destination("file", "file", "{dirname}/clinic/{basename}.h") + self.add_destination('append-file', 'append', 'file') d = self.destinations.get self.field_destinations = collections.OrderedDict(( @@ -1569,11 +1578,12 @@ impl_definition block ('parser_prototype', d('suppress')), ('parser_definition', d('block')), ('cpp_endif', d('suppress')), - ('methoddef_ifndef', d('buffer')), + ('methoddef_ifndef', d('append-buffer')), ('impl_definition', d('block')), )) self.field_destinations_stack = [] + self.ifndef_symbols = set() self.presets = {} preset = None @@ -1632,6 +1642,11 @@ impl_definition block second_pass_replacements = {} for name, destination in self.destinations.items(): + if destination.type == 'append': + target = self.destinations[destination.target] + target.append(destination._dump()) + + for name, destination in self.destinations.items(): if destination.type == 'suppress': continue output = destination._dump() @@ -3144,6 +3159,9 @@ class DSLParser: def directive_dump(self, name): self.block.output.append(self.clinic.get_destination(name).dump()) + for destination in self.clinic.destinations.values(): + if destination.type == 'append' and destination.target == name: + self.block.output.append(destination._dump()) def directive_print(self, *args): self.block.output.append(' '.join(args))