[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [pykde5/srhaque-new-sip-generator] sip_generation: Support UNEXPOSED_DECL for the container case.
From:       Shaheed Haque <srhaque () theiet ! org>
Date:       2016-03-31 23:52:03
Message-ID: E1almNf-0003el-Le () scm ! kde ! org
[Download RAW message or body]

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 = self._read_source(member.extent)
                 if member.kind in [CursorKind.UNEXPOSED_ATTR, \
CursorKind.VISIBILITY_ATTR] and skippable_visibility_attr(member, text):  pass
-                elif member.kind == CursorKind.UNEXPOSED_DECL and \
                skippable_unexposed_decl(member, text):
-                    pass
+                elif member.kind == CursorKind.UNEXPOSED_DECL:
+                    if skippable_unexposed_decl(member, text):
+                        pass
+                    else:
+                        decl = self._unexposed_decl_get(container, member)
                 else:
                     Generator._report_ignoring(container, member)
             if decl:
@@ -585,6 +588,33 @@ class Generator(object):
             decl += " /" + ",".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, bailing out \
when we see the ";" +            or a "{" marking the end.
+        """
+        possible_extent = SourceRange.from_locations(decl.extent.start, \
parent.extent.end) +        text = ""
+        found_end = False
+        was_punctuated = True
+        for token in self.tu.get_tokens(extent=possible_extent):
+            if token.spelling in [";", "{"]:
+                found_end = True
+                break
+            elif token.kind == TokenKind.PUNCTUATION:
+                was_punctuated = True
+                text += token.spelling
+            else:
+                if not was_punctuated:
+                    text += " "
+                text += token.spelling
+                was_punctuated = 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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic