gobject-introspection r664 - in trunk: . giscanner tests/scanner



Author: lucasr
Date: Sat Oct 11 14:42:32 2008
New Revision: 664
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=664&view=rev

Log:
2008-10-11  Lucas Rocha  <lucasr gnome org>

	Bug 552376: scanner generates wrong names for enum members when
	there's no defined gtype.

	* giscanner/utils.py (strip_common_prefix): Always strip common
	prefix exactly up to the last "_", and not beyond.
	* tests/scanner/foo.h (FooEnumNoType): add FOO_ENUM_NEUF. The point
	here is that the first character after the last '_' should should be
	the same as the character in the same position on the type name.
	* tests/scanner/foo-expected.gir: test that


Modified:
   trunk/ChangeLog
   trunk/giscanner/utils.py
   trunk/tests/scanner/foo-expected.gir
   trunk/tests/scanner/foo.h

Modified: trunk/giscanner/utils.py
==============================================================================
--- trunk/giscanner/utils.py	(original)
+++ trunk/giscanner/utils.py	Sat Oct 11 14:42:32 2008
@@ -56,8 +56,11 @@
 
 
 def strip_common_prefix(first, second):
+    max_index = second.rfind('_')
+    second_len = len(second)
     second = second.replace('_', '')
+    max_index -= second_len - len(second) - 1
     for i, c in enumerate(first.upper()):
-        if i >= len(second) or c != second[i]:
+        if i >= len(second) or c != second[i] or i == max_index:
             return second[i:]
     return second[i + 1:]

Modified: trunk/tests/scanner/foo-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-expected.gir	(original)
+++ trunk/tests/scanner/foo-expected.gir	Sat Oct 11 14:42:32 2008
@@ -241,6 +241,7 @@
       <member name="un" value="1" c:identifier="FOO_ENUM_UN"/>
       <member name="deux" value="2" c:identifier="FOO_ENUM_DEUX"/>
       <member name="trois" value="3" c:identifier="FOO_ENUM_TROIS"/>
+      <member name="neuf" value="9" c:identifier="FOO_ENUM_NEUF"/>
     </enumeration>
     <enumeration name="EnumFullname" c:type="FooEnumFullname">
       <member name="one" value="1" c:identifier="FOO_ENUM_FULLNAME_ONE"/>

Modified: trunk/tests/scanner/foo.h
==============================================================================
--- trunk/tests/scanner/foo.h	(original)
+++ trunk/tests/scanner/foo.h	Sat Oct 11 14:42:32 2008
@@ -104,6 +104,7 @@
   FOO_ENUM_UN = 1,
   FOO_ENUM_DEUX = 2,
   FOO_ENUM_TROIS = 3,
+  FOO_ENUM_NEUF = 9
 } FooEnumNoType;
 
 GType foo_flags_type_get_type (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]