Skip to content

Commit

Permalink
Merge pull request #8 from bottlenoselabs/type-aliases
Browse files Browse the repository at this point in the history
Type aliases
  • Loading branch information
lithiumtoast authored Mar 31, 2024
2 parents fd14337 + fc1fbae commit 4b4daeb
Show file tree
Hide file tree
Showing 48 changed files with 917 additions and 632 deletions.
27 changes: 27 additions & 0 deletions src/c/tests/opaque_types/opaque_struct/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"inputFilePath": "./main.c",
"userIncludeDirectories": [
"../../../production/ffi_helper/include"
],
"ignoreIncludeFiles": [
"../../../production/ffi_helper/include/ffi_helper.h"
],
"targetPlatforms": {
"windows": {
"i686-pc-windows-msvc": {},
"x86_64-pc-windows-msvc": {},
"aarch64-pc-windows-msvc": {}
},
"macos": {
"i686-apple-darwin": {},
"aarch64-apple-darwin": {},
"x86_64-apple-darwin": {},
"aarch64-apple-ios": {}
},
"linux": {
"i686-unknown-linux-gnu": {},
"x86_64-unknown-linux-gnu": {},
"aarch64-unknown-linux-gnu": {}
}
}
}
6 changes: 6 additions & 0 deletions src/c/tests/opaque_types/opaque_struct/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>
#include "ffi_helper.h"

struct opaque_struct;

FFI_API_DECL struct opaque_struct opaque_struct;
27 changes: 27 additions & 0 deletions src/c/tests/opaque_types/opaque_typedef_struct/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"inputFilePath": "./main.c",
"userIncludeDirectories": [
"../../../production/ffi_helper/include"
],
"ignoreIncludeFiles": [
"../../../production/ffi_helper/include/ffi_helper.h"
],
"targetPlatforms": {
"windows": {
"i686-pc-windows-msvc": {},
"x86_64-pc-windows-msvc": {},
"aarch64-pc-windows-msvc": {}
},
"macos": {
"i686-apple-darwin": {},
"aarch64-apple-darwin": {},
"x86_64-apple-darwin": {},
"aarch64-apple-ios": {}
},
"linux": {
"i686-unknown-linux-gnu": {},
"x86_64-unknown-linux-gnu": {},
"aarch64-unknown-linux-gnu": {}
}
}
}
6 changes: 6 additions & 0 deletions src/c/tests/opaque_types/opaque_typedef_struct/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>
#include "ffi_helper.h"

typedef struct opaque_struct_t opaque_struct_t;

FFI_API_DECL opaque_struct_t opaque_struct;
1 change: 1 addition & 0 deletions src/cs/Analyzers.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
is_global = true

# Microsoft
dotnet_diagnostic.CA1308.severity = none
dotnet_diagnostic.CA1707.severity = error

# StyleCop
Expand Down
6 changes: 6 additions & 0 deletions src/cs/production/c2ffi.Data/CFfiTargetPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public record CFfiTargetPlatform
[JsonPropertyName("platformActual")]
public TargetPlatform PlatformActual { get; set; } = TargetPlatform.Unknown;

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

/// <summary>
/// Gets or sets the macro objects.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/cs/production/c2ffi.Data/CTypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class CTypeInfo : IEquatable<CTypeInfo>
/// Gets or sets the byte size of the C type.
/// </summary>
[JsonPropertyName("sizeOf")]
public int SizeOf { get; set; }
public int? SizeOf { get; set; }

/// <summary>
/// Gets or sets the byte alignment of the C type node.
/// Gets or sets the byte alignment of the C type.
/// </summary>
[JsonPropertyName("alignOf")]
public int? AlignOf { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,9 @@ public partial class JsonSerializerContextCFfiCrossPlatform

private static global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[] COpaqueTypePropInit(global::System.Text.Json.JsonSerializerOptions options)
{
var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[5];
var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[4];

var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int>
{
IsProperty = true,
IsPublic = true,
IsVirtual = false,
DeclaringType = typeof(global::c2ffi.Data.Nodes.COpaqueType),
Converter = null,
Getter = static obj => ((global::c2ffi.Data.Nodes.COpaqueType)obj).SizeOf,
Setter = static (obj, value) => ((global::c2ffi.Data.Nodes.COpaqueType)obj).SizeOf = value!,
IgnoreCondition = null,
HasJsonInclude = false,
IsExtensionData = false,
NumberHandling = null,
PropertyName = "SizeOf",
JsonPropertyName = "size_of"
};

properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<int>(options, info0);

var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::c2ffi.Data.CLocation?>
var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::c2ffi.Data.CLocation?>
{
IsProperty = true,
IsPublic = true,
Expand All @@ -81,9 +62,9 @@ public partial class JsonSerializerContextCFfiCrossPlatform
JsonPropertyName = "location"
};

properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::c2ffi.Data.CLocation?>(options, info1);
properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::c2ffi.Data.CLocation?>(options, info0);

var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
{
IsProperty = true,
IsPublic = true,
Expand All @@ -100,9 +81,9 @@ public partial class JsonSerializerContextCFfiCrossPlatform
JsonPropertyName = "comment"
};

properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info2);
properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info1);

var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<bool>
var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<bool>
{
IsProperty = true,
IsPublic = true,
Expand All @@ -119,9 +100,9 @@ public partial class JsonSerializerContextCFfiCrossPlatform
JsonPropertyName = "is_system"
};

properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<bool>(options, info3);
properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<bool>(options, info2);

var info4 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
{
IsProperty = true,
IsPublic = true,
Expand All @@ -138,7 +119,7 @@ public partial class JsonSerializerContextCFfiCrossPlatform
JsonPropertyName = null
};

properties[4] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info4);
properties[3] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info3);

return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public partial class JsonSerializerContextCFfiCrossPlatform

properties[1] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::c2ffi.Data.CNodeKind>(options, info1);

var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int>
var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int?>
{
IsProperty = true,
IsPublic = true,
Expand All @@ -100,7 +100,7 @@ public partial class JsonSerializerContextCFfiCrossPlatform
JsonPropertyName = "sizeOf"
};

properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<int>(options, info2);
properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<int?>(options, info2);

var info3 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<int?>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ public partial class JsonSerializerContextCFfiCrossPlatform
{
var properties = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfo[5];

var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<string>
var info0 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::c2ffi.Data.CTypeInfo>
{
IsProperty = true,
IsPublic = true,
IsVirtual = false,
DeclaringType = typeof(global::c2ffi.Data.Nodes.CVariable),
Converter = null,
Getter = static obj => ((global::c2ffi.Data.Nodes.CVariable)obj).Type,
Setter = static (obj, value) => ((global::c2ffi.Data.Nodes.CVariable)obj).Type = value!,
Getter = static obj => ((global::c2ffi.Data.Nodes.CVariable)obj).TypeInfo,
Setter = static (obj, value) => ((global::c2ffi.Data.Nodes.CVariable)obj).TypeInfo = value!,
IgnoreCondition = null,
HasJsonInclude = false,
IsExtensionData = false,
NumberHandling = null,
PropertyName = "Type",
PropertyName = "TypeInfo",
JsonPropertyName = "type"
};

properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<string>(options, info0);
properties[0] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::c2ffi.Data.CTypeInfo>(options, info0);

var info1 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::c2ffi.Data.CLocation?>
{
Expand Down
Loading

0 comments on commit 4b4daeb

Please sign in to comment.