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 | |
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.
-rw-r--r-- | examples/extensions/Makefile.am | 1 | ||||
-rw-r--r-- | telepathy-glib/codegen.am | 19 | ||||
-rw-r--r-- | tools/glib-client-gen.py | 33 |
3 files changed, 32 insertions, 21 deletions
diff --git a/examples/extensions/Makefile.am b/examples/extensions/Makefile.am index 636a82575..b1e1f4c5e 100644 --- a/examples/extensions/Makefile.am +++ b/examples/extensions/Makefile.am @@ -127,7 +127,6 @@ _gen/cli-connection-body.h _gen/cli-connection.h: _gen/connection.xml \ --subclass-assert=TP_IS_CONNECTION \ --iface-quark-prefix=EXAMPLE_IFACE_QUARK \ --tp-proxy-api=0.7.6 \ - --generate-reentrant \ $< Example_Cli _gen/cli-connection _gen/svc-connection.c _gen/svc-connection.h: _gen/connection.xml \ diff --git a/telepathy-glib/codegen.am b/telepathy-glib/codegen.am index d82af79d1..5440fae46 100644 --- a/telepathy-glib/codegen.am +++ b/telepathy-glib/codegen.am @@ -29,7 +29,8 @@ codegen_sources = \ $(nodist_geninclude_HEADERS) \ _gen/stable-spec.xml \ _gen/spec-stamp \ - _gen/stable-stamp + _gen/stable-stamp \ + _gen/reentrant-methods.list nodist_geninclude_HEADERS = \ _gen/error-str.h \ @@ -124,6 +125,11 @@ _gen/stable-stamp: $(wildcard $(abs_srcdir)/*.xml) _gen/spec-stamp _gen/stable-spec.xml: stable-interfaces.xml _gen/stable-stamp $(tools_dir)/xincludator.py $(AM_V_GEN)$(PYTHON) $(tools_dir)/xincludator.py $< > $@ +# Grab a list of re-entrant tp_cli_*_run_* methods we are committed to +# generating for backwards compatibility. +_gen/reentrant-methods.list: $(top_srcdir)/docs/reference/telepathy-glib-sections.txt + $(AM_V_GEN)$(GREP) 'tp_cli_.*_run_.*' $< > $@ + # Things generated from the whole spec at once _gen/gtypes.h _gen/gtypes-body.h: _gen/stable-spec.xml \ @@ -193,6 +199,7 @@ _gen/tp-svc-%.c _gen/tp-svc-%.h: _gen/tp-spec-%.xml \ $< Tp_Svc_ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \ + _gen/reentrant-methods.list \ $(tools_dir)/glib-client-gen.py \ codegen.am $(AM_V_GEN)set -e; \ @@ -200,7 +207,6 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \ subclass_assert= ; \ case $* in \ generic) \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ account-manager) \ subclass=--subclass=TpAccountManager; \ @@ -213,7 +219,6 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \ channel) \ subclass=--subclass=TpChannel; \ subclass_assert=--subclass-assert=TP_IS_CHANNEL; \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ channel-dispatcher) \ subclass=--subclass=TpChannelDispatcher; \ @@ -234,27 +239,22 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \ connection-manager) \ subclass=--subclass=TpConnectionManager; \ subclass_assert=--subclass-assert=TP_IS_CONNECTION_MANAGER \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ connection) \ subclass=--subclass=TpConnection; \ subclass_assert=--subclass-assert=TP_IS_CONNECTION; \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ media-session-handler) \ subclass=--subclass=TpMediaSessionHandler; \ subclass_assert=--subclass-assert=TP_IS_MEDIA_SESSION_HANDLER; \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ media-stream-handler) \ subclass=--subclass=TpMediaStreamHandler; \ subclass_assert=--subclass-assert=TP_IS_MEDIA_STREAM_HANDLER; \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ dbus-daemon) \ subclass=--subclass=TpDBusDaemon; \ subclass_assert=--subclass-assert=TP_IS_DBUS_DAEMON; \ - maybe_reentrant=--deprecate-reentrant=TP_DISABLE_DEPRECATED; \ ;; \ esac; \ $(PYTHON) $(tools_dir)/glib-client-gen.py \ @@ -263,7 +263,8 @@ _gen/tp-cli-%-body.h _gen/tp-cli-%.h: _gen/tp-spec-%.xml \ --iface-quark-prefix=TP_IFACE_QUARK \ --tp-proxy-api=0.7.6 \ --deprecation-attribute=_TP_GNUC_DEPRECATED \ - $$maybe_reentrant \ + --deprecate-reentrant=TP_DISABLE_DEPRECATED \ + --generate-reentrant=_gen/reentrant-methods.list \ $< Tp_Cli _gen/tp-cli-$* # vim:set ft=automake: 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 = {} |