GNOME Bugzilla – Bug 551056
make codegen not import when corresponding argument types are not registered
Last modified: 2008-09-08 20:26:40 UTC
In bug 550754 PyGTK needs to import 'gio-types.defs' and use those types for generating various wrappers. However, that file is not always present as PyGObject can be build without GIO. And anyway, we might later come into situation when PyGObject doesn't define certain types (because GLib is too old), but e.g. PyGTK optionally needs them for wrappers. Patch follows.
Created attachment 118127 [details] [review] conditional importing in .override files This patch adds featurer to import in .override files conditionally. If importing line looks like import python_type as c_name for arg_type then importing is done only if arg_type is registered (as usually done in *-types.defs). For existing imports this makes no changes at all.
Comment on attachment 118127 [details] [review] conditional importing in .override files >Index: codegen/codegen.py >+ # All conditionals must go first. >+ if command in ('ifdef'): You probably meant == 'ifdef Rest looks good
Created attachment 118260 [details] [review] correct patch Sorry, that was a wrong patch. It doesn't do what it should... This is the correct one.
Sending ChangeLog Sending codegen/codegen.py Sending codegen/override.py Transmitting file data ... Committed revision 967. 2008-09-08 Paul Pogonyshev <pogonyshev@gmx.net> Bug 551056 – make codegen not import when corresponding argument types are not registered * codegen/override.py (import_pat): Add support for optional 'for' clause. (Overrides.__parse_override): Handle it. * codegen/codegen.py (SourceWriter.write_imports) (SourceWriter.write_object_imports): Adapt for changes in get_imports() return value. (is_registered_object): New function.