-
Notifications
You must be signed in to change notification settings - Fork 146
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
Showing
27 changed files
with
713 additions
and
1 deletion.
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,16 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
// This file is used by Code Analysis to maintain SuppressMessage | ||
// attributes that are applied to this project. | ||
// Project-level suppressions either have no target or are given | ||
// a specific target and scoped to a namespace, type, member, etc. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[assembly: SuppressMessage( | ||
"Design", | ||
"CA1002: Do not expose generic lists", | ||
Scope = "namespaceAndDescendants", | ||
Target = "~N:ClangSharp.XML", | ||
Justification = nameof(System.Xml.Serialization) | ||
)] | ||
|
18 changes: 18 additions & 0 deletions
18
sources/ClangSharp.PInvokeGenerator/XML/BindingsElement.cs
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,18 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
[XmlRoot("bindings")] | ||
public sealed class BindingsElement | ||
{ | ||
[XmlElement("comment")] | ||
public string? HeaderText { get; init; } | ||
|
||
[XmlElement("namespace")] | ||
public List<NamespaceElement> Namespaces { get; } = []; | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/ClangSharp.PInvokeGenerator/XML/CSharpCodeElement.cs
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,15 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Xml; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public sealed class CSharpCodeElement | ||
{ | ||
[XmlText] | ||
[XmlAnyElement] | ||
public List<XmlNode> Segments { get; } = []; | ||
} |
8 changes: 8 additions & 0 deletions
8
sources/ClangSharp.PInvokeGenerator/XML/ConstantDescElement.cs
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,8 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class ConstantDescElement : FieldDescElement { } |
8 changes: 8 additions & 0 deletions
8
sources/ClangSharp.PInvokeGenerator/XML/DelegateDescElement.cs
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,8 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class DelegateDescElement : FunctionOrDelegateDescElement { } |
10 changes: 10 additions & 0 deletions
10
sources/ClangSharp.PInvokeGenerator/XML/EnumConstantDeclElement.cs
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,10 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Diagnostics; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
[DebuggerDisplay($"{{{nameof(Name)},nq}}")] | ||
public class EnumConstantDeclElement : FieldDescElement { } |
19 changes: 19 additions & 0 deletions
19
sources/ClangSharp.PInvokeGenerator/XML/EnumDescElement.cs
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,19 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class EnumDescElement : NamedAccessDescElement | ||
{ | ||
[XmlElement("attribute")] | ||
public List<string> Attributes { get; } = []; | ||
|
||
[XmlElement("type")] | ||
public required string TypeName { get; init; } | ||
|
||
[XmlElement("enumerator")] | ||
public List<EnumConstantDeclElement> Enumerators { get; } = []; | ||
} |
54 changes: 54 additions & 0 deletions
54
sources/ClangSharp.PInvokeGenerator/XML/FieldDescElement.cs
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,54 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
[DebuggerDisplay($"{{{nameof(AccessSpecifier)},nq}} {{{nameof(Type)}}} {{{nameof(Name)},nq}}")] | ||
public class FieldDescElement : NamedAccessDescElement | ||
{ | ||
[XmlAttribute("inherited")] | ||
public string? InheritedFrom { get; init; } | ||
|
||
[XmlAttribute("offset")] | ||
public string? OffsetValue { get; init; } | ||
|
||
[XmlIgnore] | ||
public int? Offset | ||
{ | ||
get | ||
{ | ||
return int.TryParse( | ||
OffsetValue, | ||
CultureInfo.InvariantCulture, | ||
out var offset | ||
) ? offset : null; | ||
} | ||
|
||
init | ||
{ | ||
OffsetValue = value.HasValue | ||
? value.Value.ToString(CultureInfo.InvariantCulture) | ||
: null; | ||
} | ||
} | ||
|
||
[XmlElement("attribute")] | ||
public List<string> Attributes { get; } = []; | ||
|
||
[XmlElement("type")] | ||
public required FieldTypeElement Type { get; init; } | ||
|
||
[XmlElement("value")] | ||
public ValueDescValueElement? Initializer { get; init; } | ||
|
||
[XmlElement("get")] | ||
public PropertyAccessorElement? Getter { get; init; } | ||
|
||
[XmlElement("set")] | ||
public PropertyAccessorElement? Setter { get; init; } | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/ClangSharp.PInvokeGenerator/XML/FieldTypeElement.cs
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,15 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class FieldTypeElement : TypeWithNativeTypeNameElement | ||
{ | ||
[XmlAttribute("count")] | ||
public string? Count { get; init; } | ||
|
||
[XmlAttribute("fixed")] | ||
public string? FixedName { get; init; } | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/ClangSharp.PInvokeGenerator/XML/FunctionBodyElement.cs
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,12 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class FunctionBodyElement | ||
{ | ||
[XmlElement("code")] | ||
public CSharpCodeElement? Code { get; init; } | ||
} |
19 changes: 19 additions & 0 deletions
19
sources/ClangSharp.PInvokeGenerator/XML/FunctionDescElement.cs
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,19 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class FunctionDescElement : FunctionOrDelegateDescElement | ||
{ | ||
[XmlElement("init")] | ||
public List<TypeInitializationExpressionElement> TypeInitializationExpressions { get; } = []; | ||
|
||
[XmlElement("body")] | ||
public FunctionBodyElement? BlockBody { get; init; } | ||
|
||
[XmlElement("code")] | ||
public CSharpCodeElement? ExpressionBody { get; init; } | ||
} |
76 changes: 76 additions & 0 deletions
76
sources/ClangSharp.PInvokeGenerator/XML/FunctionOrDelegateDescElement.cs
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,76 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public abstract class FunctionOrDelegateDescElement : NamedAccessDescElement | ||
{ | ||
[XmlAttribute("lib")] | ||
public string? LibraryPath { get; init; } | ||
|
||
[XmlAttribute("convention")] | ||
public string? CallingConvention { get; init; } | ||
|
||
[XmlAttribute("entrypoint")] | ||
public string? EntryPoint { get; init; } | ||
|
||
[XmlAttribute("setlasterror")] | ||
public bool SetLastError { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool SetLastErrorSpecified => SetLastError; | ||
|
||
[XmlAttribute("static")] | ||
public bool IsStatic { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool IsStaticSpecified => IsStatic; | ||
|
||
[XmlAttribute("unsafe")] | ||
public bool IsUnsafe { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool IsUnsafeSpecified => IsUnsafe; | ||
|
||
[XmlAttribute("vtblindex")] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public string? VtblIndexValue { get; init; } | ||
|
||
[XmlIgnore] | ||
public long? VtblIndex | ||
{ | ||
get | ||
{ | ||
return !string.IsNullOrEmpty(VtblIndexValue) | ||
&& long.TryParse( | ||
VtblIndexValue, | ||
CultureInfo.InvariantCulture, | ||
out var vtblindex | ||
) ? vtblindex : null; | ||
} | ||
|
||
init | ||
{ | ||
VtblIndexValue = value.HasValue | ||
? value.Value.ToString(CultureInfo.InvariantCulture) | ||
: null; | ||
} | ||
} | ||
|
||
[XmlElement("attribute")] | ||
public List<string> Attributes { get; } = []; | ||
|
||
[XmlElement("type")] | ||
public required TypeWithNativeTypeNameElement ReturnType { get; init; } | ||
|
||
[XmlElement("param")] | ||
public List<ParameterDescElement> Parameters { get; } = []; | ||
} |
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,12 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class IidDescElement : NamedDescElement | ||
{ | ||
[XmlAttribute("value")] | ||
public required string Value { get; init; } | ||
} |
29 changes: 29 additions & 0 deletions
29
sources/ClangSharp.PInvokeGenerator/XML/IndexerDeclElement.cs
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,29 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.ComponentModel; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class IndexerDeclElement | ||
{ | ||
[XmlAttribute("access")] | ||
public required string AccessSpecifier { get; init; } | ||
|
||
[XmlAttribute("unsafe")] | ||
public bool IsUnsafe { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool IsUnsafeSpecified => IsUnsafe; | ||
|
||
[XmlElement("type")] | ||
public required string Type { get; init; } | ||
|
||
[XmlElement("param")] | ||
public required ParameterDescElement IndexerParameter { get; init; } | ||
|
||
[XmlElement("get")] | ||
public required PropertyAccessorElement Getter { get; init; } | ||
} |
15 changes: 15 additions & 0 deletions
15
sources/ClangSharp.PInvokeGenerator/XML/InterfaceElement.cs
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,15 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class InterfaceElement | ||
{ | ||
[XmlElement("constant", typeof(ConstantDescElement))] | ||
[XmlElement("field", typeof(FieldDescElement))] | ||
[XmlElement("function", typeof(FunctionDescElement))] | ||
public List<NamedAccessDescElement> Decls { get; } = []; | ||
} |
32 changes: 32 additions & 0 deletions
32
sources/ClangSharp.PInvokeGenerator/XML/MethodClassElement.cs
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,32 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
[XmlType] | ||
public class MethodClassElement : NamedAccessDescElement | ||
{ | ||
[XmlAttribute("static")] | ||
public bool IsStatic { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool IsStaticSpecified => IsStatic; | ||
|
||
[XmlAttribute("unsafe")] | ||
public bool IsUnsafe { get; init; } | ||
|
||
[XmlIgnore] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public bool IsUnsafeSpecified => IsUnsafe; | ||
|
||
[XmlElement("constant", typeof(ConstantDescElement))] | ||
[XmlElement("field", typeof(FieldDescElement))] | ||
[XmlElement("function", typeof(FunctionDescElement))] | ||
[XmlElement("delegate", typeof(DelegateDescElement))] | ||
[XmlElement("iid", typeof(IidDescElement))] | ||
public List<NamedDescElement> Decls { get; } = []; | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/ClangSharp.PInvokeGenerator/XML/NamedAccessDescElement.cs
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,12 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
public abstract class NamedAccessDescElement : NamedDescElement | ||
{ | ||
[XmlAttribute("access")] | ||
public required string AccessSpecifier { get; init; } | ||
} |
12 changes: 12 additions & 0 deletions
12
sources/ClangSharp.PInvokeGenerator/XML/NamedDescElement.cs
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,12 @@ | ||
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. | ||
|
||
|
||
using System.Xml.Serialization; | ||
|
||
namespace ClangSharp.XML; | ||
|
||
public abstract class NamedDescElement | ||
{ | ||
[XmlAttribute("name")] | ||
public required string Name { get; init; } | ||
} |
Oops, something went wrong.