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

Ensure that --with-access-specifier works with *=internal #359

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void VisitEnumConstantDecl(EnumConstantDecl enumConstantDecl)
{
parentName = "";
isAnonymousEnum = true;
accessSpecifier = GetAccessSpecifier(enumDecl);
accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true);
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ private void VisitEnumConstantDecl(EnumConstantDecl enumConstantDecl)

private void VisitEnumDecl(EnumDecl enumDecl)
{
var accessSpecifier = GetAccessSpecifier(enumDecl);
var accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true);
var name = GetRemappedCursorName(enumDecl);
var escapedName = EscapeName(name);
var isAnonymousEnum = false;
Expand Down Expand Up @@ -397,7 +397,7 @@ private void VisitFieldDecl(FieldDecl fieldDecl)
return;
}

var accessSpecifier = GetAccessSpecifier(fieldDecl);
var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false);
var name = GetRemappedCursorName(fieldDecl);
var escapedName = EscapeName(name);

Expand Down Expand Up @@ -505,7 +505,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
return;
}

var accessSpecifier = GetAccessSpecifier(functionDecl);
var accessSpecifier = GetAccessSpecifier(functionDecl, matchStar: false);

var body = functionDecl.Body;
var hasBody = body is not null;
Expand Down Expand Up @@ -828,7 +828,7 @@ private void VisitIndirectFieldDecl(IndirectFieldDecl indirectFieldDecl)

var type = fieldDecl.Type;

var accessSpecifier = GetAccessSpecifier(anonymousRecordDecl);
var accessSpecifier = GetAccessSpecifier(anonymousRecordDecl, matchStar: true);

var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out _);
var name = GetRemappedCursorName(fieldDecl);
Expand Down Expand Up @@ -1381,7 +1381,7 @@ private void VisitRecordDecl(RecordDecl recordDecl)
}

var desc = new StructDesc {
AccessSpecifier = GetAccessSpecifier(recordDecl),
AccessSpecifier = GetAccessSpecifier(recordDecl, matchStar: true),
EscapedName = escapedName,
IsUnsafe = IsUnsafe(recordDecl) || hasGuidMember,
HasVtbl = hasVtbl || hasBaseVtbl,
Expand Down Expand Up @@ -1547,7 +1547,7 @@ private void VisitRecordDecl(RecordDecl recordDecl)
}

var fieldDesc = new FieldDesc {
AccessSpecifier = GetAccessSpecifier(baseCxxRecordDecl),
AccessSpecifier = GetAccessSpecifier(baseCxxRecordDecl, matchStar: true),
NativeTypeName = null,
EscapedName = baseFieldName,
Offset = null,
Expand Down Expand Up @@ -2454,7 +2454,7 @@ void VisitBitfieldDecl(FieldDecl fieldDecl, Type[] types, RecordDecl recordDecl,

canonicalType = type.CanonicalType;

var accessSpecifier = GetAccessSpecifier(fieldDecl);
var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false);
var name = GetRemappedCursorName(fieldDecl);
var escapedName = EscapeName(name);

Expand Down Expand Up @@ -2673,7 +2673,7 @@ void VisitConstantArrayFieldDecl(RecordDecl recordDecl, FieldDecl constantArray)
var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1);
var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment;

var accessSpecifier = GetAccessSpecifier(constantArray);
var accessSpecifier = GetAccessSpecifier(constantArray, matchStar: false);
var canonicalElementType = type.ElementType.CanonicalType;
var isUnsafeElementType =
((canonicalElementType is PointerType) || (canonicalElementType is ReferenceType)) &&
Expand Down Expand Up @@ -2940,7 +2940,7 @@ void ForFunctionProtoType(TypedefDecl typedefDecl, FunctionProtoType functionPro
StartUsingOutputBuilder(name);
{
var desc = new FunctionOrDelegateDesc {
AccessSpecifier = GetAccessSpecifier(typedefDecl),
AccessSpecifier = GetAccessSpecifier(typedefDecl, matchStar: true),
CallingConvention = callingConventionName,
EscapedName = escapedName,
IsVirtual = true, // such that it outputs as a delegate
Expand Down Expand Up @@ -3128,7 +3128,7 @@ private void VisitVarDecl(VarDecl varDecl)
isMacroDefinitionRecord = true;
}

var accessSpecifier = GetAccessSpecifier(varDecl);
var accessSpecifier = GetAccessSpecifier(varDecl, matchStar: false);
var name = GetRemappedName(nativeName, varDecl, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true);
var escapedName = EscapeName(name);

Expand Down
4 changes: 2 additions & 2 deletions sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,9 +1819,9 @@ internal static string EscapeString(string value) => value.Replace("\\", "\\\\")
.Replace("\t", "\\t")
.Replace("\"", "\\\"");

private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl)
private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl, bool matchStar)
{
if (!TryGetRemappedValue(namedDecl, _config.WithAccessSpecifiers, out var accessSpecifier) || (accessSpecifier == AccessSpecifier.None))
if (!TryGetRemappedValue(namedDecl, _config.WithAccessSpecifiers, out var accessSpecifier, matchStar) || (accessSpecifier == AccessSpecifier.None))
{
switch (namedDecl.Access)
{
Expand Down