Skip to content

Commit 795c223

Browse files
committed
Modify using to indicate which type it is
1 parent 43c65dc commit 795c223

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,6 +3193,8 @@ def _evaluate_stack(self, token=None):
31933193

31943194
# namespace refers to the embedded type
31953195
atype["namespace"] = ns
3196+
atype["using_type"] = "typealias"
3197+
atype["typealias"] = alias
31963198
else:
31973199
# using foo::bar
31983200
# -> in global scope this is bringing in something
@@ -3204,6 +3206,7 @@ def _evaluate_stack(self, token=None):
32043206
stack, self._get_stmt_doxygen(), self._get_location(stack)
32053207
)
32063208
alias = atype["type"]
3209+
atype["using_type"] = "declaration"
32073210
if self.curClass:
32083211
atype["baseclass"] = ns
32093212
else:

test/test_CppHeaderParser.py

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,7 @@ def setUp(self):
27822782
self.cppHeader = CppHeaderParser.CppHeader(
27832783
"""
27842784
using std::thing;
2785+
using MyThing = SomeThing;
27852786
namespace a {
27862787
using std::string;
27872788
using VoidFunction = std::function<void()>;
@@ -2801,10 +2802,77 @@ class A : public B {
28012802
)
28022803

28032804
def test_using(self):
2804-
self.assertEqual(len(self.cppHeader.using), 3)
2805-
self.assertIn("a::string", self.cppHeader.using)
2806-
self.assertIn("a::VoidFunction", self.cppHeader.using)
2807-
self.assertIn("thing", self.cppHeader.using)
2805+
self.assertEqual(len(self.cppHeader.using), 4)
2806+
2807+
self.assertEqual(
2808+
filter_pameters(
2809+
[self.cppHeader.using["a::string"]],
2810+
extra=["using_type", "raw_type", "namespace"],
2811+
),
2812+
[
2813+
{
2814+
"desc": None,
2815+
"name": "",
2816+
"namespace": "std::",
2817+
"raw_type": "std::string",
2818+
"type": "string",
2819+
"using_type": "declaration",
2820+
}
2821+
],
2822+
)
2823+
2824+
self.assertEqual(
2825+
filter_pameters(
2826+
[self.cppHeader.using["a::VoidFunction"]],
2827+
extra=["using_type", "raw_type", "namespace", "typealias"],
2828+
),
2829+
[
2830+
{
2831+
"desc": None,
2832+
"name": "",
2833+
"namespace": "std::",
2834+
"raw_type": "std::function<void ( )>",
2835+
"type": "function<void ( )>",
2836+
"typealias": "VoidFunction",
2837+
"using_type": "typealias",
2838+
}
2839+
],
2840+
)
2841+
2842+
self.assertEqual(
2843+
filter_pameters(
2844+
[self.cppHeader.using["thing"]],
2845+
extra=["using_type", "raw_type", "namespace"],
2846+
),
2847+
[
2848+
{
2849+
"desc": None,
2850+
"name": "",
2851+
"namespace": "std::",
2852+
"raw_type": "std::thing",
2853+
"type": "thing",
2854+
"using_type": "declaration",
2855+
}
2856+
],
2857+
)
2858+
2859+
self.assertEqual(
2860+
filter_pameters(
2861+
[self.cppHeader.using["MyThing"]],
2862+
extra=["using_type", "raw_type", "namespace", "typealias"],
2863+
),
2864+
[
2865+
{
2866+
"desc": None,
2867+
"name": "",
2868+
"namespace": "",
2869+
"raw_type": "SomeThing",
2870+
"type": "SomeThing",
2871+
"typealias": "MyThing",
2872+
"using_type": "typealias",
2873+
}
2874+
],
2875+
)
28082876

28092877
def test_fn(self):
28102878
self.assertEqual(len(self.cppHeader.functions), 1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy