From 5ebe79f05e78365513170fcaaf0b1fed9d04b86c Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Sun, 26 Jan 2014 13:12:41 +0100 Subject: [PATCH] New C++11 keyword and workaround for failing key lookup --- src/c_client.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/c_client.py b/src/c_client.py index 161cbf5..7f78fab 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -19,6 +19,7 @@ _extension_special_cases = ['XPrint', 'XCMisc', 'BigRequests'] _cplusplus_annoyances = {'class' : '_class', 'new' : '_new', + 'explicit': '_explicit', 'delete': '_delete'} _c_keywords = {'default' : '_default'} @@ -102,6 +103,17 @@ def _cpp(str): else: return str +def _cpp_reverse(str): + ''' + Reverse lookup counterpart for _cpp(str) + ''' + c_kws = _cplusplus_annoyances + c_kws.update(_c_keywords.items()) + for k, v in c_kws.items(): + if v == str: + return k + return str + def _ext(str): ''' Does C-name conversion on an extension name. @@ -1619,7 +1631,7 @@ def _c_accessors_list(self, field): _c('{') if switch_obj is not None: - _c(' return %s;', fields[field.c_field_name][0]) + _c(' return %s;', fields[_cpp_reverse(field.c_field_name)][0]) elif field.prev_varsized_field is None: _c(' return (%s *) (R + 1);', field.c_field_type) else: @@ -1722,7 +1734,7 @@ def _c_accessors_list(self, field): _c(' %s i;', field.c_iterator_type) if switch_obj is not None: - _c(' i.data = %s;', fields[field.c_field_name][0]) + _c(' i.data = %s;', fields[_cpp_reverse(field.c_field_name)][0]) _c(' i.rem = %s;', _c_accessor_get_expr(field.type.expr, fields)) elif field.prev_varsized_field == None: _c(' i.data = (%s *) (R + 1);', field.c_field_type) -- 1.8.5.3