diff options
author | Dan Winship <danw@gnome.org> | 2011-05-19 16:21:13 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-08-12 11:10:43 -0400 |
commit | 5fd2fa5bf5a07a66d2150740d534a398598e8dd1 (patch) | |
tree | d40cb5a96e53cd518c8a00e14855bf6196fcf03b /giscanner/dumper.py | |
parent | 4dabe20ed5753bccd2abf8ad02e95ce6ab53036c (diff) | |
download | gobject-introspection-5fd2fa5bf5a07a66d2150740d534a398598e8dd1.tar.gz |
Switch to storing string form of error quarks
Instead of storing the name of the function to call to get the
error quark, store the string form of the error quark, which
we derive from the introspection binary during scanning.
Update EnumBlob and GIEnumInfo to include the new information.
This will allow determining a back-mapping from error quark
to error domain without having to dlsym() and call all the
known error quark functions.
Based on earlier patches from Owen Taylor and Maxim Ermilov.
https://bugzilla.gnome.org/show_bug.cgi?id=602516
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r-- | giscanner/dumper.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/giscanner/dumper.py b/giscanner/dumper.py index 615b3fc5..61cba257 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -76,9 +76,10 @@ class LinkerError(Exception): class DumpCompiler(object): - def __init__(self, options, get_type_functions): + def __init__(self, options, get_type_functions, error_quark_functions): self._options = options self._get_type_functions = get_type_functions + self._error_quark_functions = error_quark_functions self._compiler_cmd = os.environ.get('CC', 'gcc') self._linker_cmd = os.environ.get('CC', self._compiler_cmd) @@ -114,9 +115,9 @@ class DumpCompiler(object): f = open(c_path, 'w') f.write(_PROGRAM_TEMPLATE % tpl_args) - # We need to reference our get_type functions to make sure they are - # pulled in at the linking stage if the library is a static library - # rather than a shared library. + # We need to reference our get_type and error_quark functions + # to make sure they are pulled in at the linking stage if the + # library is a static library rather than a shared library. if len(self._get_type_functions) > 0: for func in self._get_type_functions: f.write("extern GType " + func + "(void);\n") @@ -129,6 +130,18 @@ class DumpCompiler(object): f.write(",\n") f.write(" " + func) f.write("\n};\n") + if len(self._error_quark_functions) > 0: + for func in self._error_quark_functions: + f.write("extern GQuark " + func + "(void);\n") + f.write("GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n") + first = True + for func in self._error_quark_functions: + if first: + first = False + else: + f.write(",\n") + f.write(" " + func) + f.write("\n};\n") f.close() o_path = self._generate_tempfile(tmpdir, '.o') @@ -271,6 +284,7 @@ class DumpCompiler(object): else: args.append('-l' + library) -def compile_introspection_binary(options, get_type_functions): - dc = DumpCompiler(options, get_type_functions) +def compile_introspection_binary(options, get_type_functions, + error_quark_functions): + dc = DumpCompiler(options, get_type_functions, error_quark_functions) return dc.run() |