https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/95608
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
DeinAlptraum wrote:
@Endilll can I ask you for a review again?
As a next step towards the python-bindings strict typing PR, this one captures
all the enum refactoring changes necessary towards that goal. Don't be scared
by the LoC changed: 90% of that is just indentation changes :)
@@ -611,51 +612,25 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
"""
Common base class for named enumerations held in sync with Index.h values.
-
-Subclasses must define their own _kinds and _name_map
@@ -611,51 +612,25 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
"""
Common base class for named enumerations held in sync with Index.h values.
-
-Subclasses must define their own _kinds and _name_map
@@ -31,17 +31,9 @@ class TestCursorKind(unittest.TestCase):
def test_from_id(self):
"""Check that kinds can be constructed from valid IDs"""
for enum in self.enums:
-self.assertEqual(enum.from_id(2), enum._kinds[2])
+
https://github.com/DeinAlptraum commented:
There is also `TokenKind`: this one does not currently inherit from
`BaseEnumeration` and is defined somewhat differently, having all its variants
and their IDs as a dictionary in `enumerations.py`. This seems quite arbitrary
to me, is there any
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/95608
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -611,51 +612,25 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
"""
Common base class for named enumerations held in sync with Index.h values.
-
-Subclasses must define their own _kinds and _name_map
https://github.com/DeinAlptraum created
https://github.com/llvm/llvm-project/pull/95608
Use Python's builtin enum class instead of writing our own.
This is preparation for passing a strict type check in PR #78114 , fixing 920
out of 1341 strict typing errors
>From
DeinAlptraum wrote:
@Endilll I merged the Python 3.8 CI into this PR and the CI run was successful
(though it only ran on 3.8 for some reason), so can this be merged?
https://github.com/llvm/llvm-project/pull/95381
___
cfe-commits mailing list
https://github.com/DeinAlptraum updated
https://github.com/llvm/llvm-project/pull/95381
>From a3da142b0db6581581ccb135800d77b09476f385 Mon Sep 17 00:00:00 2001
From: Jannick Kremer
Date: Thu, 13 Jun 2024 10:43:52 +0100
Subject: [PATCH 1/2] [libclang/python] Fix bugs in custom enum
DeinAlptraum wrote:
These were all the bugs I'd found, so I think it is
https://github.com/llvm/llvm-project/pull/95381
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,50 @@
+import unittest
+
+from clang.cindex import (
+CursorKind,
+TemplateArgumentKind,
+ExceptionSpecificationKind,
+AvailabilityKind,
+AccessSpecifier,
+TypeKind,
+RefQualifierKind,
+LinkageKind,
+TLSKind,
+StorageClass,
+)
+
https://github.com/DeinAlptraum updated
https://github.com/llvm/llvm-project/pull/95381
>From a3da142b0db6581581ccb135800d77b09476f385 Mon Sep 17 00:00:00 2001
From: Jannick Kremer
Date: Thu, 13 Jun 2024 10:43:52 +0100
Subject: [PATCH 1/2] [libclang/python] Fix bugs in custom enum
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/95381
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1336,7 +1336,7 @@ def __repr__(self):
CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271)
# OpenMP teams distribute simd directive.
-CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272)
+CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272)
https://github.com/DeinAlptraum updated
https://github.com/llvm/llvm-project/pull/95381
>From bfc36e30e84c616adb8ff57754a49a5bb66d1dd9 Mon Sep 17 00:00:00 2001
From: Jannick Kremer
Date: Thu, 13 Jun 2024 10:43:52 +0100
Subject: [PATCH] [libclang/python] Fix bugs in custom enum implementation
@@ -2395,7 +2395,7 @@ def __repr__(self):
TypeKind.OCLRESERVEID = TypeKind(160)
TypeKind.OBJCOBJECT = TypeKind(161)
-TypeKind.OBJCCLASS = TypeKind(162)
+TypeKind.OBJCTYPEPARAM = TypeKind(162)
DeinAlptraum wrote:
This was a duplicate with variant 28
DeinAlptraum wrote:
@Endilll I separated the fixes for the enum bugs from the strict typing PR, and
added tests that cover these cases. I checked that the tests fail before the
fixes and succeed now.
https://github.com/llvm/llvm-project/pull/95381
https://github.com/DeinAlptraum created
https://github.com/llvm/llvm-project/pull/95381
Do not allow initialization of enum from negative IDs (e.g. from_id(-1)
currently produces the last known variant)
Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and
TypeKind.OBJCCLASS
DeinAlptraum wrote:
Thanks a lot for your feedback! Yup I get that the PR is pretty big and might
still need significant changes.
> 1. I have maintainability concerns about `ClangLib` protocol [...]
I completely agree that this is ugly, but I didn't find a better solution that
would
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
DeinAlptraum wrote:
Since https://github.com/llvm/llvm-project/issues/83962 is now closed and the
minimum Python version updated to 3.8, this is now finally ready for review.
I've updated this with the changes to the Python bindings of the past couple
months.
I have no idea idea what the
https://github.com/DeinAlptraum ready_for_review
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -2286,192 +2869,151 @@ class TypeKind(BaseEnumeration):
Describes the kind of type.
"""
-# The unique kind objects, indexed by id.
-_kinds = []
-_name_map = None
-
@property
-def spelling(self):
+def spelling(self) -> str:
@@ -665,867 +1312,858 @@ class CursorKind(BaseEnumeration):
A CursorKind describes the kind of entity that a cursor points to.
"""
-# The required BaseEnumeration declarations.
-_kinds = []
-_name_map = None
-
@staticmethod
-def get_all_kinds():
+
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
DeinAlptraum wrote:
I was just made aware of
[some](https://github.com/llvm/llvm-project/pull/77219)
[changes](https://github.com/llvm/llvm-project/pull/77228) by @linux4life798
that seem reasonable to merge before this, so I've returned this to draft
status for now. Sorry for the
https://github.com/DeinAlptraum converted_to_draft
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
DeinAlptraum wrote:
@AaronBallman could you review this or recommend reviewers? I didn't see any
category in `clang/CodeOwners.rst` that seems to cover the bindings.
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -1722,23 +2300,23 @@ def location(self):
return self._loc
@property
-def linkage(self):
+def linkage(self) -> LinkageKind:
"""Return the linkage of this cursor."""
if not hasattr(self, "_linkage"):
self._linkage =
@@ -67,89 +67,690 @@
import clang.enumerations
import os
-import sys
-
-if sys.version_info[0] == 3:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
-class c_interop_string(c_char_p):
-def __init__(self, p=None):
-if p
@@ -2341,30 +2830,32 @@ class Type(Structure):
_fields_ = [("_kind_id", c_int), ("data", c_void_p * 2)]
+_tu: TranslationUnit
+
@property
-def kind(self):
+def kind(self) -> TypeKind:
"""Return the kind of this type."""
return
@@ -67,89 +67,690 @@
import clang.enumerations
import os
-import sys
-
-if sys.version_info[0] == 3:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
-class c_interop_string(c_char_p):
-def __init__(self, p=None):
-if p
@@ -67,89 +67,690 @@
import clang.enumerations
import os
-import sys
-
-if sys.version_info[0] == 3:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
-class c_interop_string(c_char_p):
-def __init__(self, p=None):
-if p
https://github.com/DeinAlptraum edited
https://github.com/llvm/llvm-project/pull/78114
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -232,13 +840,16 @@ class _CXString(Structure):
_fields_ = [("spelling", c_char_p), ("free", c_int)]
-def __del__(self):
+def __del__(self) -> None:
conf.lib.clang_disposeString(self)
@staticmethod
-def from_result(res, fn=None, args=None):
@@ -3968,7 +4500,7 @@ def function_exists(self, name):
return True
-def register_enumerations():
+def register_enumerations() -> None:
DeinAlptraum wrote:
This implementation dynamically adds the TokenKind variants, which means it
also suffers from
@@ -642,51 +1259,29 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration(object):
-"""
-Common base class for named enumerations held in sync with Index.h values.
+TEnum = TypeVar("TEnum", bound="BaseEnumeration")
-Subclasses must define
@@ -642,51 +1259,29 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration(object):
-"""
-Common base class for named enumerations held in sync with Index.h values.
+TEnum = TypeVar("TEnum", bound="BaseEnumeration")
-Subclasses must define
@@ -67,89 +67,690 @@
import clang.enumerations
import os
-import sys
-
-if sys.version_info[0] == 3:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
-class c_interop_string(c_char_p):
-def __init__(self, p=None):
-if p
@@ -67,89 +67,690 @@
import clang.enumerations
import os
-import sys
-
-if sys.version_info[0] == 3:
-# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
-class c_interop_string(c_char_p):
-def __init__(self, p=None):
-if p
48 matches
Mail list logo