Add more compatibility mode hacks

When using the `--header --body` compatibility mode, we need to emit
things we generally define in the header, such as the aliases for
standard marshallers, and aliases for deprecated tokens.

This fixes dbus-binding-tool, which is using `--header --body` and
deprecated tokens.

See: https://bugs.freedesktop.org/show_bug.cgi?id=101799
This commit is contained in:
Emmanuele Bassi 2017-07-16 11:15:07 +01:00
parent fbf3511309
commit d19f53a767

View File

@ -931,11 +931,13 @@ if __name__ == '__main__':
# it's not really a supported use case. We keep this behaviour by # it's not really a supported use case. We keep this behaviour by
# forcing the --prototypes and --body arguments instead. We make this # forcing the --prototypes and --body arguments instead. We make this
# warning non-fatal even with --g-fatal-warnings, as it's a deprecation # warning non-fatal even with --g-fatal-warnings, as it's a deprecation
compatibility_mode = False
if args.header and args.body: if args.header and args.body:
print_warning('Using --header and --body at the same time time is deprecated; ' + print_warning('Using --header and --body at the same time time is deprecated; ' +
'use --body --prototypes instead', False) 'use --body --prototypes instead', False)
args.prototypes = True args.prototypes = True
args.header = False args.header = False
compatibility_mode = True
if args.header: if args.header:
generate_header_preamble(args.output, generate_header_preamble(args.output,
@ -1015,12 +1017,31 @@ if __name__ == '__main__':
elif args.body: elif args.body:
if args.verbose: if args.verbose:
print_info('Generating definition for {}'.format(line.strip())) print_info('Generating definition for {}'.format(line.strip()))
generate_marshallers_body(args.output, retval, params, if compatibility_mode:
prefix=args.prefix, generate_std_alias = False
internal=args.internal, if args.stdinc:
include_prototype=args.prototypes, std_marshaller = generate_marshaller_name(STD_PREFIX, retval, params)
include_va=args.valist_marshallers, if std_marshaller in GOBJECT_MARSHALLERS:
source_location=location) if args.verbose:
print_info('Skipping default marshaller {}'.format(line.strip()))
generate_std_alias = True
marshaller = generate_marshaller_name(args.prefix, retval, params)
if compatibility_mode and generate_std_alias:
generate_marshaller_alias(args.output, marshaller, std_marshaller,
source_location=location,
include_va=args.valist_marshallers)
else:
generate_marshallers_body(args.output, retval, params,
prefix=args.prefix,
internal=args.internal,
include_prototype=args.prototypes,
include_va=args.valist_marshallers,
source_location=location)
if compatibility_mode and marshaller != raw_marshaller:
if args.verbose:
print_info('Generating alias for deprecated tokens')
generate_marshaller_alias(args.output, raw_marshaller, marshaller,
include_va=args.valist_marshallers)
seen_marshallers.add(raw_marshaller) seen_marshallers.add(raw_marshaller)