[gobject-introspection] giscanner: Make comments starting with tab characters work
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Make comments starting with tab characters work
- Date: Fri, 22 Jul 2011 21:17:48 +0000 (UTC)
commit eda7d98cb70de1445239955a99b44e128802dcc9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Jul 22 16:46:10 2011 -0400
giscanner: Make comments starting with tab characters work
https://bugzilla.gnome.org/show_bug.cgi?id=655149
giscanner/annotationparser.py | 8 +++++---
tests/scanner/Annotation-1.0-expected.gir | 9 +++++++++
tests/scanner/annotation.c | 22 +++++++++++++++++++++-
3 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 2a22ece..ac6430d 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -413,7 +413,8 @@ class DocOption(object):
class AnnotationParser(object):
- COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n ')
+ COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n[\t ]')
+ COMMENT_HEADER_START_RE = re.compile(r'\n[\t ]')
WHITESPACE_RE = re.compile(r'^\s*$')
ASCII_TEXT_RE = re.compile(r'\s*[A-Za-z]+')
OPTION_RE = re.compile(r'\([A-Za-z]+[^(]*\)')
@@ -451,9 +452,10 @@ class AnnotationParser(object):
return
comment = comment[2:]
- pos = comment.find('\n ')
- if pos == -1:
+ match = self.COMMENT_HEADER_START_RE.search(comment)
+ if match is None:
return
+ pos = match.start()
block_header = comment[:pos]
block_header = block_header.strip()
cpos = block_header.find(': ')
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index f650c25..8ae17f5 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -537,6 +537,15 @@ annotation_object_watch_full().</doc>
<doc xml:whitespace="preserve">This is a property which is a string</doc>
<type name="utf8"/>
</property>
+ <property name="tab-property"
+ version="1.2"
+ writable="1"
+ construct="1"
+ transfer-ownership="none">
+ <doc xml:whitespace="preserve">This is a property annotation intentionally indented with a mix
+of tabs and strings to test the tab handling capabilities of the scanner.</doc>
+ <type name="utf8"/>
+ </property>
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index f7046e8..29036b3 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -7,7 +7,8 @@ G_DEFINE_TYPE (AnnotationObject, annotation_object, G_TYPE_OBJECT);
enum {
PROP_0,
PROP_STRING_PROPERTY,
- PROP_FUNCTION_PROPERTY
+ PROP_FUNCTION_PROPERTY,
+ PROP_TAB_PROPERTY
};
enum {
@@ -32,6 +33,8 @@ annotation_object_set_property (GObject *object,
break;
case PROP_FUNCTION_PROPERTY:
break;
+ case PROP_TAB_PROPERTY:
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -50,6 +53,8 @@ annotation_object_get_property (GObject *object,
break;
case PROP_FUNCTION_PROPERTY:
break;
+ case PROP_TAB_PROPERTY:
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -168,6 +173,21 @@ annotation_object_class_init (AnnotationObjectClass *klass)
"This property is a function pointer",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ /**
+ * AnnotationObject:tab-property:
+ *
+ * This is a property annotation intentionally indented with a mix
+ * of tabs and strings to test the tab handling capabilities of the scanner.
+ *
+ * Since: 1.2
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_TAB_PROPERTY,
+ g_param_spec_string ("tab-property",
+ "Tab property",
+ "This property is a thing",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]