Git commit ac23cee85341b1e6aa383586815366def994ff2a by Shaheed Haque. Committed on 31/03/2016 at 23:51. Pushed by shaheed into branch 'srhaque-new-sip-generator'. Support UNEXPOSED_DECL for the container case. M +32 -2 sip_generation/generator.py http://commits.kde.org/pykde5/ac23cee85341b1e6aa383586815366def994ff2a diff --git a/sip_generation/generator.py b/sip_generation/generator.py index 662f54f..e2ce5f4 100755 --- a/sip_generation/generator.py +++ b/sip_generation/generator.py @@ -261,8 +261,11 @@ class Generator(object): text =3D self._read_source(member.extent) if member.kind in [CursorKind.UNEXPOSED_ATTR, CursorKind.V= ISIBILITY_ATTR] and skippable_visibility_attr(member, text): pass - elif member.kind =3D=3D CursorKind.UNEXPOSED_DECL and skip= pable_unexposed_decl(member, text): - pass + elif member.kind =3D=3D CursorKind.UNEXPOSED_DECL: + if skippable_unexposed_decl(member, text): + pass + else: + decl =3D self._unexposed_decl_get(container, membe= r) else: Generator._report_ignoring(container, member) if decl: @@ -585,6 +588,33 @@ class Generator(object): decl +=3D " /" + ",".join(typedef.sip_annotations) + "/" return decl + ";\n" = + def _unexposed_decl_get(self, parent, decl): + """ + The parser does not seem to provide access to the complete text of= an unexposed decl. + + 1. Run the lexer from "here" to the end of the outer scope, ba= iling out when we see the ";" + or a "{" marking the end. + """ + possible_extent =3D SourceRange.from_locations(decl.extent.start, = parent.extent.end) + text =3D "" + found_end =3D False + was_punctuated =3D True + for token in self.tu.get_tokens(extent=3Dpossible_extent): + if token.spelling in [";", "{"]: + found_end =3D True + break + elif token.kind =3D=3D TokenKind.PUNCTUATION: + was_punctuated =3D True + text +=3D token.spelling + else: + if not was_punctuated: + text +=3D " " + text +=3D token.spelling + was_punctuated =3D False + if not found_end and text: + RuntimeError(_("No end found for {}::{}, '{}'").format(parent.= spelling, decl.spelling, text)) + return text + def _var_get(self, container, variable, level): """ Walk of a variable.