diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2011-10-10 17:26:27 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-10-10 17:41:40 +0100 |
commit | e0a7a0722c688aa30b120499d84b3feec1e78479 (patch) | |
tree | d4fcf709cc33f84625bfcf69ad9f2481e3689f36 /tools | |
parent | 43a87ab723d8c21880c18bfd084a5c03e90ad89f (diff) | |
download | telepathy-glib-e0a7a0722c688aa30b120499d84b3feec1e78479.tar.gz |
codegen: add a whitelist of tp_cli_*_run_* methods
We have to generate a bunch of (deprecated) tp_cli_*_run_* methods, for
backwards-compatibility. But there's no reason to add any *more* every
time we define a new channel interface.
So here, we generate a list of methods we need to generate for backwards
compatibility (based on their being listed in the documentation), and
modify the code generator to refuse to generate any _run_ method not
named in that file.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/glib-client-gen.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py index 57d6df313..446d198f4 100644 --- a/tools/glib-client-gen.py +++ b/tools/glib-client-gen.py @@ -56,8 +56,16 @@ class Generator(object): % opts.get('--subclass', 'TpProxy')) if self.proxy_arg == 'void *': self.proxy_arg = 'gpointer ' - self.generate_reentrant = ('--generate-reentrant' in opts or - '--deprecate-reentrant' in opts) + + self.reentrant_symbols = set() + try: + filename = opts['--generate-reentrant'] + with open(filename, 'r') as f: + for line in f.readlines(): + self.reentrant_symbols.add(line.strip()) + except KeyError: + pass + self.deprecate_reentrant = opts.get('--deprecate-reentrant', None) self.deprecation_attribute = opts.get('--deprecation-attribute', 'G_GNUC_DEPRECATED') @@ -846,9 +854,8 @@ class Generator(object): self.b('}') self.b('') - if self.generate_reentrant: - self.do_method_reentrant(method, iface_lc, member, member_lc, - in_args, out_args, collect_callback) + self.do_method_reentrant(method, iface_lc, member, member_lc, + in_args, out_args, collect_callback) # leave a gap for the end of the method self.d('') @@ -867,6 +874,10 @@ class Generator(object): # GError **error, # GMainLoop **loop); + run_method_name = '%s_%s_run_%s' % (self.prefix_lc, iface_lc, member_lc) + if run_method_name not in self.reentrant_symbols: + return + self.b('typedef struct {') self.b(' GMainLoop *loop;') self.b(' GError **error;') @@ -944,12 +955,12 @@ class Generator(object): if self.deprecate_reentrant: self.h('#ifndef %s' % self.deprecate_reentrant) - self.h('gboolean %s_%s_run_%s (%sproxy,' - % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg)) + self.h('gboolean %s (%sproxy,' + % (run_method_name, self.proxy_arg)) self.h(' gint timeout_ms,') self.d('/**') - self.d(' * %s_%s_run_%s:' % (self.prefix_lc, iface_lc, member_lc)) + self.d(' * %s:' % run_method_name) self.d(' * @proxy: %s' % self.proxy_doc) self.d(' * @timeout_ms: Timeout in milliseconds, or -1 for default') @@ -1000,8 +1011,8 @@ class Generator(object): self.d(' */') self.d('') - self.b('gboolean\n%s_%s_run_%s (%sproxy,' - % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg)) + self.b('gboolean\n%s (%sproxy,' + % (run_method_name, self.proxy_arg)) self.b(' gint timeout_ms,') for arg in in_args: @@ -1230,7 +1241,7 @@ if __name__ == '__main__': options, argv = gnu_getopt(sys.argv[1:], '', ['group=', 'subclass=', 'subclass-assert=', 'iface-quark-prefix=', 'tp-proxy-api=', - 'generate-reentrant', 'deprecate-reentrant=', + 'generate-reentrant=', 'deprecate-reentrant=', 'deprecation-attribute=']) opts = {} |