diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-09-03 11:22:35 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-09-04 00:06:24 +0800 |
commit | c112e9830f8af59275d6f590bbcb365c9968c1fc (patch) | |
tree | 7edf821a5fb472655a85888b14e5d0f25002a14e /giscanner/scannermain.py | |
parent | 5143afb1e79f4a67f57499ca60f6df3a4682eb21 (diff) | |
download | gobject-introspection-c112e9830f8af59275d6f590bbcb365c9968c1fc.tar.gz |
giscanner: Add Optional Options for Codegen
This adds options to scannermain so that we can decorate functions with
macros as needed, so that we can use compiler annotations for symbol export
for example.
Options are also added to include headers before or after the main include
block at the top so that we can include headers as necessary in the
generated sources and/or headers, so that we could for example grab
definitions from those headers as needed, such as to grab definitions of
macros used for symbol export.
The testcodegen.py script has been updated as well to make use of this
functionality, if needed.
https://bugzilla.gnome.org/show_bug.cgi?id=732669
Diffstat (limited to 'giscanner/scannermain.py')
-rwxr-xr-x | giscanner/scannermain.py | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py index c3706f20..bca4a887 100755 --- a/giscanner/scannermain.py +++ b/giscanner/scannermain.py @@ -217,6 +217,21 @@ match the namespace prefix.""") parser.add_option("", "--typelib-xml", action="store_true", dest="typelib_xml", help=optparse.SUPPRESS_HELP) + parser.add_option("", "--function-decoration", + action="append", dest="function_decoration", default=[], + help="Macro to decorate functions in generated code") + parser.add_option("", "--include-first-in-header", + action="append", dest="include_first_header", default=[], + help="Header to include first in generated header") + parser.add_option("", "--include-last-in-header", + action="append", dest="include_last_header", default=[], + help="Header to include after the other headers in generated header") + parser.add_option("", "--include-first-in-src", + action="append", dest="include_first_src", default=[], + help="Header to include first in generated sources") + parser.add_option("", "--include-last-in-src", + action="append", dest="include_last_src", default=[], + help="Header to include after the other headers in generated sources") return parser @@ -233,11 +248,22 @@ def passthrough_gir(path, f): f.write(writer.get_xml()) -def test_codegen(optstring): +def test_codegen(optstring, + function_decoration, + include_first_header, + include_last_header, + include_first_src, + include_last_src): (namespace, out_h_filename, out_c_filename) = optstring.split(',') if namespace == 'Everything': from .testcodegen import EverythingCodeGenerator - gen = EverythingCodeGenerator(out_h_filename, out_c_filename) + gen = EverythingCodeGenerator(out_h_filename, + out_c_filename, + function_decoration, + include_first_header, + include_last_header, + include_first_src, + include_last_src) gen.write() else: _error("Invaild namespace %r" % (namespace, )) @@ -450,7 +476,12 @@ def scanner_main(args): if options.passthrough_gir: passthrough_gir(options.passthrough_gir, sys.stdout) if options.test_codegen: - return test_codegen(options.test_codegen) + return test_codegen(options.test_codegen, + options.function_decoration, + options.include_first_header, + options.include_last_header, + options.include_first_src, + options.include_last_src) if hasattr(options, 'filelist') and not options.filelist: if len(args) <= 1: |