forked from AustinBrunkhorst/CPP-Reflection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c028e6e
commit 8c6d42f
Showing
114 changed files
with
8,716 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#include "Precompiled.h" | ||
|
||
#include "Cursor.h" | ||
|
||
#include "MetaUtils.h" | ||
|
||
Cursor::Cursor(const CXCursor &handle) | ||
: m_handle( handle ) { } | ||
|
||
CXCursorKind Cursor::GetKind(void) const | ||
{ | ||
return m_handle.kind; | ||
} | ||
|
||
Cursor Cursor::GetLexicalParent(void) const | ||
{ | ||
return clang_getCursorLexicalParent( m_handle ); | ||
} | ||
|
||
std::string Cursor::GetSpelling(void) const | ||
{ | ||
std::string spelling; | ||
|
||
utils::ToString( clang_getCursorSpelling( m_handle ), spelling ); | ||
|
||
return spelling; | ||
} | ||
|
||
std::string Cursor::GetDisplayName(void) const | ||
{ | ||
std::string displayName; | ||
|
||
utils::ToString( clang_getCursorDisplayName( m_handle ), displayName ); | ||
|
||
return displayName; | ||
} | ||
|
||
std::string Cursor::GetMangledName(void) const | ||
{ | ||
std::string mangled; | ||
|
||
utils::ToString( clang_Cursor_getMangling( m_handle ), mangled ); | ||
|
||
return mangled; | ||
} | ||
|
||
bool Cursor::IsDefinition(void) const | ||
{ | ||
return clang_isCursorDefinition( m_handle ) ? true : false; | ||
} | ||
|
||
bool Cursor::IsConst(void) const | ||
{ | ||
return clang_CXXMethod_isConst( m_handle ) ? true : false; | ||
} | ||
|
||
bool Cursor::IsStatic(void) const | ||
{ | ||
return clang_CXXMethod_isStatic( m_handle ) ? true : false; | ||
} | ||
|
||
CX_CXXAccessSpecifier Cursor::GetAccessModifier(void) const | ||
{ | ||
return clang_getCXXAccessSpecifier( m_handle ); | ||
} | ||
|
||
CX_StorageClass Cursor::GetStorageClass(void) const | ||
{ | ||
return clang_Cursor_getStorageClass( m_handle ); | ||
} | ||
|
||
CursorType Cursor::GetType(void) const | ||
{ | ||
return clang_getCursorType( m_handle ); | ||
} | ||
|
||
CursorType Cursor::GetReturnType(void) const | ||
{ | ||
return clang_getCursorResultType( m_handle ); | ||
} | ||
|
||
CursorType Cursor::GetTypedefType(void) const | ||
{ | ||
return clang_getTypedefDeclUnderlyingType( m_handle ); | ||
} | ||
|
||
Cursor::List Cursor::GetChildren(void) const | ||
{ | ||
List children; | ||
|
||
auto visitor = [](CXCursor cursor, CXCursor parent, CXClientData data) | ||
{ | ||
auto container = static_cast<List *>( data ); | ||
|
||
container->emplace_back( cursor ); | ||
|
||
if (cursor.kind == CXCursor_LastPreprocessing) | ||
return CXChildVisit_Break; | ||
|
||
return CXChildVisit_Continue; | ||
}; | ||
|
||
clang_visitChildren( m_handle, visitor, &children ); | ||
|
||
return children; | ||
} | ||
|
||
void Cursor::VisitChildren(Visitor visitor, void *data) | ||
{ | ||
clang_visitChildren( m_handle, visitor, data ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include "CursorType.h" | ||
|
||
class Cursor | ||
{ | ||
public: | ||
typedef std::vector<Cursor> List; | ||
typedef CXCursorVisitor Visitor; | ||
|
||
Cursor(const CXCursor &handle); | ||
|
||
CXCursorKind GetKind(void) const; | ||
|
||
Cursor GetLexicalParent(void) const; | ||
|
||
std::string GetSpelling(void) const; | ||
std::string GetDisplayName(void) const; | ||
std::string GetMangledName(void) const; | ||
|
||
bool IsDefinition(void) const; | ||
bool IsConst(void) const; | ||
bool IsStatic(void) const; | ||
|
||
CX_CXXAccessSpecifier GetAccessModifier(void) const; | ||
CX_StorageClass GetStorageClass(void) const; | ||
|
||
CursorType GetType(void) const; | ||
CursorType GetReturnType(void) const; | ||
CursorType GetTypedefType(void) const; | ||
|
||
List GetChildren(void) const; | ||
void VisitChildren(Visitor visitor, void *data = nullptr); | ||
|
||
private: | ||
CXCursor m_handle; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "Precompiled.h" | ||
|
||
#include "CursorType.h" | ||
|
||
CursorType::CursorType(const CXType &handle) | ||
: m_handle( handle ) | ||
{ | ||
|
||
} | ||
|
||
std::string CursorType::GetDisplayName(void) const | ||
{ | ||
std::string displayName; | ||
|
||
utils::ToString( clang_getTypeSpelling( m_handle ), displayName ); | ||
|
||
return displayName; | ||
} | ||
|
||
int CursorType::GetArgumentCount(void) const | ||
{ | ||
return clang_getNumArgTypes( m_handle ); | ||
} | ||
|
||
CursorType CursorType::GetArgument(unsigned index) const | ||
{ | ||
return clang_getArgType( m_handle, index ); | ||
} | ||
|
||
CursorType CursorType::GetCanonicalType(void) const | ||
{ | ||
return clang_getCanonicalType( m_handle ); | ||
} | ||
|
||
Cursor CursorType::GetDeclaration(void) const | ||
{ | ||
return clang_getTypeDeclaration( m_handle ); | ||
} | ||
|
||
CXTypeKind CursorType::GetKind(void) const | ||
{ | ||
return m_handle.kind; | ||
} | ||
|
||
bool CursorType::IsConst(void) const | ||
{ | ||
return clang_isConstQualifiedType( m_handle ) ? true : false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* ---------------------------------------------------------------------------- | ||
** Team Bear King | ||
** © 201x DigiPen Institute of Technology, All Rights Reserved. | ||
** | ||
** CursorType.h | ||
** | ||
** Author: | ||
** - Austin Brunkhorst - [email protected] | ||
** --------------------------------------------------------------------------*/ | ||
|
||
#pragma once | ||
|
||
class Cursor; | ||
|
||
class CursorType | ||
{ | ||
public: | ||
CursorType(const CXType &handle); | ||
|
||
std::string GetDisplayName(void) const; | ||
|
||
int GetArgumentCount(void) const; | ||
CursorType GetArgument(unsigned index) const; | ||
|
||
CursorType GetCanonicalType(void) const; | ||
|
||
Cursor GetDeclaration(void) const; | ||
|
||
CXTypeKind GetKind(void) const; | ||
|
||
bool IsConst(void) const; | ||
|
||
private: | ||
CXType m_handle; | ||
}; |
Oops, something went wrong.