Skip to content

Commit 8c6d42f

Browse files
Initial commit
1 parent c028e6e commit 8c6d42f

File tree

114 files changed

+8716
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+8716
-0
lines changed

Source/Parser/Cursor.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#include "Precompiled.h"
2+
3+
#include "Cursor.h"
4+
5+
#include "MetaUtils.h"
6+
7+
Cursor::Cursor(const CXCursor &handle)
8+
: m_handle( handle ) { }
9+
10+
CXCursorKind Cursor::GetKind(void) const
11+
{
12+
return m_handle.kind;
13+
}
14+
15+
Cursor Cursor::GetLexicalParent(void) const
16+
{
17+
return clang_getCursorLexicalParent( m_handle );
18+
}
19+
20+
std::string Cursor::GetSpelling(void) const
21+
{
22+
std::string spelling;
23+
24+
utils::ToString( clang_getCursorSpelling( m_handle ), spelling );
25+
26+
return spelling;
27+
}
28+
29+
std::string Cursor::GetDisplayName(void) const
30+
{
31+
std::string displayName;
32+
33+
utils::ToString( clang_getCursorDisplayName( m_handle ), displayName );
34+
35+
return displayName;
36+
}
37+
38+
std::string Cursor::GetMangledName(void) const
39+
{
40+
std::string mangled;
41+
42+
utils::ToString( clang_Cursor_getMangling( m_handle ), mangled );
43+
44+
return mangled;
45+
}
46+
47+
bool Cursor::IsDefinition(void) const
48+
{
49+
return clang_isCursorDefinition( m_handle ) ? true : false;
50+
}
51+
52+
bool Cursor::IsConst(void) const
53+
{
54+
return clang_CXXMethod_isConst( m_handle ) ? true : false;
55+
}
56+
57+
bool Cursor::IsStatic(void) const
58+
{
59+
return clang_CXXMethod_isStatic( m_handle ) ? true : false;
60+
}
61+
62+
CX_CXXAccessSpecifier Cursor::GetAccessModifier(void) const
63+
{
64+
return clang_getCXXAccessSpecifier( m_handle );
65+
}
66+
67+
CX_StorageClass Cursor::GetStorageClass(void) const
68+
{
69+
return clang_Cursor_getStorageClass( m_handle );
70+
}
71+
72+
CursorType Cursor::GetType(void) const
73+
{
74+
return clang_getCursorType( m_handle );
75+
}
76+
77+
CursorType Cursor::GetReturnType(void) const
78+
{
79+
return clang_getCursorResultType( m_handle );
80+
}
81+
82+
CursorType Cursor::GetTypedefType(void) const
83+
{
84+
return clang_getTypedefDeclUnderlyingType( m_handle );
85+
}
86+
87+
Cursor::List Cursor::GetChildren(void) const
88+
{
89+
List children;
90+
91+
auto visitor = [](CXCursor cursor, CXCursor parent, CXClientData data)
92+
{
93+
auto container = static_cast<List *>( data );
94+
95+
container->emplace_back( cursor );
96+
97+
if (cursor.kind == CXCursor_LastPreprocessing)
98+
return CXChildVisit_Break;
99+
100+
return CXChildVisit_Continue;
101+
};
102+
103+
clang_visitChildren( m_handle, visitor, &children );
104+
105+
return children;
106+
}
107+
108+
void Cursor::VisitChildren(Visitor visitor, void *data)
109+
{
110+
clang_visitChildren( m_handle, visitor, data );
111+
}

Source/Parser/Cursor.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma once
2+
3+
#include "CursorType.h"
4+
5+
class Cursor
6+
{
7+
public:
8+
typedef std::vector<Cursor> List;
9+
typedef CXCursorVisitor Visitor;
10+
11+
Cursor(const CXCursor &handle);
12+
13+
CXCursorKind GetKind(void) const;
14+
15+
Cursor GetLexicalParent(void) const;
16+
17+
std::string GetSpelling(void) const;
18+
std::string GetDisplayName(void) const;
19+
std::string GetMangledName(void) const;
20+
21+
bool IsDefinition(void) const;
22+
bool IsConst(void) const;
23+
bool IsStatic(void) const;
24+
25+
CX_CXXAccessSpecifier GetAccessModifier(void) const;
26+
CX_StorageClass GetStorageClass(void) const;
27+
28+
CursorType GetType(void) const;
29+
CursorType GetReturnType(void) const;
30+
CursorType GetTypedefType(void) const;
31+
32+
List GetChildren(void) const;
33+
void VisitChildren(Visitor visitor, void *data = nullptr);
34+
35+
private:
36+
CXCursor m_handle;
37+
};

Source/Parser/CursorType.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "Precompiled.h"
2+
3+
#include "CursorType.h"
4+
5+
CursorType::CursorType(const CXType &handle)
6+
: m_handle( handle )
7+
{
8+
9+
}
10+
11+
std::string CursorType::GetDisplayName(void) const
12+
{
13+
std::string displayName;
14+
15+
utils::ToString( clang_getTypeSpelling( m_handle ), displayName );
16+
17+
return displayName;
18+
}
19+
20+
int CursorType::GetArgumentCount(void) const
21+
{
22+
return clang_getNumArgTypes( m_handle );
23+
}
24+
25+
CursorType CursorType::GetArgument(unsigned index) const
26+
{
27+
return clang_getArgType( m_handle, index );
28+
}
29+
30+
CursorType CursorType::GetCanonicalType(void) const
31+
{
32+
return clang_getCanonicalType( m_handle );
33+
}
34+
35+
Cursor CursorType::GetDeclaration(void) const
36+
{
37+
return clang_getTypeDeclaration( m_handle );
38+
}
39+
40+
CXTypeKind CursorType::GetKind(void) const
41+
{
42+
return m_handle.kind;
43+
}
44+
45+
bool CursorType::IsConst(void) const
46+
{
47+
return clang_isConstQualifiedType( m_handle ) ? true : false;
48+
}

Source/Parser/CursorType.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* ----------------------------------------------------------------------------
2+
** Team Bear King
3+
** © 201x DigiPen Institute of Technology, All Rights Reserved.
4+
**
5+
** CursorType.h
6+
**
7+
** Author:
8+
** - Austin Brunkhorst - a.brunkhorst@digipen.edu
9+
** --------------------------------------------------------------------------*/
10+
11+
#pragma once
12+
13+
class Cursor;
14+
15+
class CursorType
16+
{
17+
public:
18+
CursorType(const CXType &handle);
19+
20+
std::string GetDisplayName(void) const;
21+
22+
int GetArgumentCount(void) const;
23+
CursorType GetArgument(unsigned index) const;
24+
25+
CursorType GetCanonicalType(void) const;
26+
27+
Cursor GetDeclaration(void) const;
28+
29+
CXTypeKind GetKind(void) const;
30+
31+
bool IsConst(void) const;
32+
33+
private:
34+
CXType m_handle;
35+
};

0 commit comments

Comments
 (0)