[cfe-commits] Request for approval: Pythonstuff including Cursor.enum_value

Manuel Klimek klimek at google.com
Wed May 2 10:47:16 PDT 2012


Regarding patch 0005:

+    def enum_value(self):
+        """Return the value of an enum constant."""
+        if not hasattr(self, '_enum_value'):
+            assert self.kind == CursorKind.ENUM_CONSTANT_DECL
+            typ = self.type

Is there a reason to call it "typ" instead of "type"?

+            if typ.kind == TypeKind.ENUM:
+                typ = typ.get_declaration().enum_type

I think this special-casing warrants a comment.

+def test_enum_values():
+    tu = get_tu('enum TEST { SPAM=1, EGG, HAM = EGG * 20};')
+    enum = get_cursor(tu, 'TEST')
+    assert enum is not None
+
+    assert enum.kind == CursorKind.ENUM_DECL
+
+    chld = list(enum.get_children())

I'd be grateful for using "children" here, it's much easier to read,
especially for non-native speakers :)

Cheers,
/Manuel


On Wed, May 2, 2012 at 10:49 AM, Anders Waldenborg <anders at 0x63.nu> wrote:
> 5 patches attached, 4 first is mostly trivial stuff.
>
>
> * [python] Add testcase for annotation cursor kind
>
>  Old testcase I had laying around.
>
> * [python] Fix warning in testcase
>
>  Trivial fix for a warning in the c-code in testcase
>
> * [python] Run tests for c++ with std=c++11
>
>  Makes c++ python testcases compile with -std=c++11,
>  which is needed by...
>
> * [python] Add testcase for enum with specified underlaying type
>
>  Adds a more interesting enum_type testcase which
>  has a different type.
>
> * [python] Add Cursor.enum_value wrapping clang_getEnumConstantDeclValue
>
>  This is the main patch. It adds a new "enum_value" property to the
>  Cursor type, allowing to get the value of enum constants
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list