Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for parsing expressions attached to EnumConstantDecl #45

Merged
merged 3 commits into from May 11, 2019

Conversation

Projects
None yet
2 participants
@tannergooding
Copy link
Member

commented May 11, 2019

This just updates the binding generator to traverse expressions attached to enum constant declarations. This means that the generated code will more closely match the source files.

CXAvailability_Deprecated = 1,
CXAvailability_NotAvailable = 2,
CXAvailability_NotAccessible = 3,
CXAvailability_Available,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

The header file doesn't explicitly set the values for most enums and we don't need to either.

@@ -13,7 +13,7 @@ public enum CXCallingConv
CXCallingConv_X86RegCall = 8,
CXCallingConv_IntelOclBicc = 9,
CXCallingConv_Win64 = 10,
CXCallingConv_X86_64Win64 = 10,
CXCallingConv_X86_64Win64 = CXCallingConv_Win64,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

An example of traversing a declaration reference expression

CXCodeComplete_IncludeBriefComments = 4,
CXCodeComplete_SkipPreamble = 8,
CXCodeComplete_IncludeCompletionsWithFixIts = 16,
CXCodeComplete_IncludeMacros = 0x01,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

An example of traversing an integer literal expression

CXCompletionContext_NaturalLanguage = 2097152,
CXCompletionContext_IncludedFile = 4194304,
CXCompletionContext_Unknown = 8388607,
CXCompletionContext_AnyType = 1 << 0,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

An example of traversing a binary operator expression

This comment has been minimized.

Copy link
@mjsabby

mjsabby May 11, 2019

Member

Very nice!

CXCompletionContext_MacroName = 1 << 20,
CXCompletionContext_NaturalLanguage = 1 << 21,
CXCompletionContext_IncludedFile = 1 << 22,
CXCompletionContext_Unknown = ((1 << 23) - 1),

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

even works with parentheses

CXGlobalOpt_None = 0x0,
CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing | CXGlobalOpt_ThreadBackgroundPriorityForEditing,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

and combining multiple declaration references

@@ -3,8 +3,8 @@ namespace ClangSharp
public enum CXLanguageKind
{
CXLanguage_Invalid = 0,

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

An example of the native header explicitly setting the value for one entry, but not the subsequent declarations

@@ -89,12 +89,17 @@ public static int Run(InvocationContext context)
arr = arr.Concat(defines.Select(x => "-D" + x)).ToArray();
arr = arr.Concat(additionalArgs).ToArray();

var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None;

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

Also updated this to start passing in some flags. Namely, not processing function bodies currently and including implicit attribute information (which ensures we aren't missing anything if the user specifies additional command line options).

@@ -258,7 +268,7 @@ public CXChildVisitResult VisitTranslationUnit(CXCursor cursor, CXCursor parent,
{
Debug.Assert(parent.Kind == CXCursorKind.CXCursor_TranslationUnit);

if (cursor.Location.IsInSystemHeader || !cursor.Location.IsFromMainFile)
if (!cursor.Location.IsFromMainFile)

This comment has been minimized.

Copy link
@tannergooding

tannergooding May 11, 2019

Author Member

Changed this to just check if we aren't in the main file; which ultimately allows users to generate bindings for system headers as well.

@mjsabby

This comment has been minimized.

Copy link
Member

commented May 11, 2019

This is an exciting change! Thank you so much.

@tannergooding tannergooding merged commit 0d6204a into microsoft:master May 11, 2019

1 check passed

license/cla All CLA requirements met.
Details

@tannergooding tannergooding deleted the tannergooding:enumconstantexpr branch May 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.