File tree Expand file tree Collapse file tree 6 files changed +128
-93
lines changed Expand file tree Collapse file tree 6 files changed +128
-93
lines changed Original file line number Diff line number Diff line change 37
37
NameSpecifier ,
38
38
NamespaceAlias ,
39
39
NamespaceDecl ,
40
- Operator ,
41
40
PQNameSegment ,
42
41
Parameter ,
43
42
PQName ,
@@ -1825,33 +1824,19 @@ def _parse_function(
1825
1824
if (is_class_block or multiple_name_segments ) and not is_typedef :
1826
1825
props .update (dict .fromkeys (mods .meths .keys (), True ))
1827
1826
1828
- method : Method
1829
-
1830
- if op :
1831
- method = Operator (
1832
- return_type ,
1833
- pqname ,
1834
- params ,
1835
- vararg ,
1836
- doxygen = doxygen ,
1837
- operator = op ,
1838
- template = template ,
1839
- access = self ._current_access ,
1840
- ** props , # type: ignore
1841
- )
1842
- else :
1843
- method = Method (
1844
- return_type ,
1845
- pqname ,
1846
- params ,
1847
- vararg ,
1848
- doxygen = doxygen ,
1849
- constructor = constructor ,
1850
- destructor = destructor ,
1851
- template = template ,
1852
- access = self ._current_access ,
1853
- ** props , # type: ignore
1854
- )
1827
+ method = Method (
1828
+ return_type ,
1829
+ pqname ,
1830
+ params ,
1831
+ vararg ,
1832
+ doxygen = doxygen ,
1833
+ constructor = constructor ,
1834
+ destructor = destructor ,
1835
+ template = template ,
1836
+ operator = op ,
1837
+ access = self ._current_access ,
1838
+ ** props , # type: ignore
1839
+ )
1855
1840
1856
1841
self ._parse_method_end (method )
1857
1842
@@ -1883,6 +1868,7 @@ def _parse_function(
1883
1868
vararg ,
1884
1869
doxygen = doxygen ,
1885
1870
template = template ,
1871
+ operator = op ,
1886
1872
** props ,
1887
1873
)
1888
1874
self ._parse_fn_end (fn )
Original file line number Diff line number Diff line change @@ -550,6 +550,15 @@ class Function:
550
550
#: calling convention
551
551
msvc_convention : typing .Optional [str ] = None
552
552
553
+ #: The operator type (+, +=, etc).
554
+ #:
555
+ #: If this object is a Function, then this is a free operator function. If
556
+ #: this object is a Method, then it is an operator method.
557
+ #:
558
+ #: In the case of a conversion operator (such as 'operator bool'), this
559
+ #: is the string "conversion" and the full Type is found in return_type
560
+ operator : typing .Optional [str ] = None
561
+
553
562
554
563
@dataclass
555
564
class Method (Function ):
@@ -585,19 +594,6 @@ class Method(Function):
585
594
override : bool = False
586
595
587
596
588
- @dataclass
589
- class Operator (Method ):
590
- """
591
- Represents an operator method
592
- """
593
-
594
- #: The operator type (+, +=, etc).
595
- #:
596
- #: In the case of a conversion operator (such as 'operator bool'), this
597
- #: is the string "conversion" and the full Type is found in return_type
598
- operator : str = ""
599
-
600
-
601
597
@dataclass
602
598
class FriendDecl :
603
599
"""
Original file line number Diff line number Diff line change 14
14
Method ,
15
15
MoveReference ,
16
16
NameSpecifier ,
17
- Operator ,
18
17
PQName ,
19
18
Parameter ,
20
19
Pointer ,
@@ -369,7 +368,7 @@ class M {
369
368
access = "public" ,
370
369
constructor = True ,
371
370
),
372
- Operator (
371
+ Method (
373
372
return_type = Type (
374
373
typename = PQName (
375
374
segments = [FundamentalSpecifier (name = "int" )]
@@ -399,7 +398,7 @@ class M {
399
398
const = True ,
400
399
operator = "()" ,
401
400
),
402
- Operator (
401
+ Method (
403
402
return_type = Reference (
404
403
ref_to = Type (
405
404
typename = PQName (
Original file line number Diff line number Diff line change 14
14
Method ,
15
15
MoveReference ,
16
16
NameSpecifier ,
17
- Operator ,
18
17
PQName ,
19
18
Parameter ,
20
19
Pointer ,
Original file line number Diff line number Diff line change 7
7
Function ,
8
8
FunctionType ,
9
9
FundamentalSpecifier ,
10
+ Method ,
10
11
MoveReference ,
11
12
NameSpecifier ,
12
- Operator ,
13
13
PQName ,
14
14
Parameter ,
15
15
Pointer ,
@@ -888,7 +888,7 @@ def test_method_w_reference() -> None:
888
888
)
889
889
),
890
890
methods = [
891
- Operator (
891
+ Method (
892
892
return_type = Reference (
893
893
ref_to = Type (
894
894
typename = PQName (
You can’t perform that action at this time.
0 commit comments