Skip to content

Commit

Permalink
Nested records (#38)
Browse files Browse the repository at this point in the history
* Fix snake_cake for json

* Rename logging functions

* Nested records
  • Loading branch information
lithiumtoast authored Jan 6, 2025
1 parent 7e82892 commit 8711216
Show file tree
Hide file tree
Showing 30 changed files with 301 additions and 217 deletions.
8 changes: 4 additions & 4 deletions src/cs/production/c2ffi.Data/CFfiCrossPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public record CFfiCrossPlatform
/// <summary>
/// Gets or sets the macro objects.
/// </summary>
[JsonPropertyName("macroObjects")]
[JsonPropertyName("macro_objects")]
public ImmutableSortedDictionary<string, CMacroObject> MacroObjects { get; set; } =
ImmutableSortedDictionary<string, CMacroObject>.Empty;

Expand Down Expand Up @@ -60,21 +60,21 @@ public record CFfiCrossPlatform
/// <summary>
/// Gets or sets the type aliases.
/// </summary>
[JsonPropertyName("typeAliases")]
[JsonPropertyName("aliases")]
public ImmutableSortedDictionary<string, CTypeAlias> TypeAliases { get; set; } =
ImmutableSortedDictionary<string, CTypeAlias>.Empty;

/// <summary>
/// Gets or sets the opaque types.
/// </summary>
[JsonPropertyName("opaqueTypes")]
[JsonPropertyName("opaques")]
public ImmutableSortedDictionary<string, COpaqueType> OpaqueTypes { get; set; } =
ImmutableSortedDictionary<string, COpaqueType>.Empty;

/// <summary>
/// Gets or sets the function pointers.
/// </summary>
[JsonPropertyName("functionPointers")]
[JsonPropertyName("function_pointers")]
public ImmutableSortedDictionary<string, CFunctionPointer> FunctionPointers { get; set; } =
ImmutableSortedDictionary<string, CFunctionPointer>.Empty;
}
22 changes: 11 additions & 11 deletions src/cs/production/c2ffi.Data/CFfiTargetPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,49 @@ public record CFfiTargetPlatform
/// <summary>
/// Gets or sets the file name of the C header file.
/// </summary>
[JsonPropertyName("fileName")]
[JsonPropertyName("file_name")]
public string FileName { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the target platform requested to be used by Clang.
/// </summary>
[JsonPropertyName("platformRequested")]
[JsonPropertyName("platform_requested")]
public TargetPlatform PlatformRequested { get; set; } = TargetPlatform.Unknown;

/// <summary>
/// Gets or sets the target platform used by Clang.
/// </summary>
[JsonPropertyName("platformActual")]
[JsonPropertyName("platform_actual")]
public TargetPlatform PlatformActual { get; set; } = TargetPlatform.Unknown;

/// <summary>
/// Gets or sets the arguments passed to Clang.
/// </summary>
[JsonPropertyName("clangArguments")]
[JsonPropertyName("clang_arguments")]
public ImmutableArray<string> ClangArguments;

/// <summary>
/// Gets or sets the system include directories used.
/// </summary>
[JsonPropertyName("systemIncludeDirectories")]
[JsonPropertyName("system_include_directories")]
public ImmutableArray<string> SystemIncludeDirectories { get; set; } = ImmutableArray<string>.Empty;

/// <summary>
/// Gets or sets the user include directories used.
/// </summary>
[JsonPropertyName("userIncludeDirectories")]
[JsonPropertyName("user_include_directories")]
public ImmutableArray<string> UserIncludeDirectories { get; set; } = ImmutableArray<string>.Empty;

/// <summary>
/// Gets or sets the pointer size in bytes.
/// </summary>
[JsonPropertyName("pointerSize")]
[JsonPropertyName("pointer_size")]
public int PointerSize { get; set; }

/// <summary>
/// Gets or sets the macro objects.
/// </summary>
[JsonPropertyName("macroObjects")]
[JsonPropertyName("macro_objects")]
public ImmutableSortedDictionary<string, CMacroObject> MacroObjects { get; set; } =
ImmutableSortedDictionary<string, CMacroObject>.Empty;

Expand Down Expand Up @@ -96,21 +96,21 @@ public record CFfiTargetPlatform
/// <summary>
/// Gets or sets the type aliases.
/// </summary>
[JsonPropertyName("typeAliases")]
[JsonPropertyName("aliases")]
public ImmutableSortedDictionary<string, CTypeAlias> TypeAliases { get; set; } =
ImmutableSortedDictionary<string, CTypeAlias>.Empty;

/// <summary>
/// Gets or sets the opaque types.
/// </summary>
[JsonPropertyName("opaqueTypes")]
[JsonPropertyName("opaques")]
public ImmutableSortedDictionary<string, COpaqueType> OpaqueTypes { get; set; } =
ImmutableSortedDictionary<string, COpaqueType>.Empty;

/// <summary>
/// Gets or sets the function pointers.
/// </summary>
[JsonPropertyName("functionPointers")]
[JsonPropertyName("function_pointers")]
public ImmutableSortedDictionary<string, CFunctionPointer> FunctionPointers { get; set; } =
ImmutableSortedDictionary<string, CFunctionPointer>.Empty;
}
6 changes: 6 additions & 0 deletions src/cs/production/c2ffi.Data/Nodes/CRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public class CRecord : CNodeWithLocation
[JsonPropertyName("fields")]
public ImmutableArray<CRecordField> Fields { get; set; } = ImmutableArray<CRecordField>.Empty;

/// <summary>
/// Gets or sets the nested records.
/// </summary>
[JsonPropertyName("nested")]
public ImmutableArray<CRecord> NestedRecords { get; set; } = ImmutableArray<CRecord>.Empty;

/// <inheritdoc />
[ExcludeFromCodeCoverage]
public override string ToString()
Expand Down
Loading

0 comments on commit 8711216

Please sign in to comment.