Skip to content

Commit

Permalink
Remove prefixes, fix warnings, escape cmments
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam committed Oct 28, 2024
1 parent 7d9e034 commit ea8160e
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 346 deletions.
5 changes: 3 additions & 2 deletions src/Bindgen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ private bool GenerateComments(CppDeclaration dec, ref string output)
if (!string.IsNullOrEmpty(commentsString))
{
output += $" /// <summary>\n";
output += $" /// {commentsString}\n";
output += $" /// {commentsString.Replace("<", "&lt;").Replace(">", "&gt;")}\n";
output += $" /// </summary>\n";
return true;
}
Expand Down Expand Up @@ -611,7 +611,8 @@ private string ConvertCppTypeToCSharp(

private string MapName(string name, bool toPascalCase = false, bool toCamelCase = false)
{
var o = toCamelCase ? ToCamelCase(name) : toPascalCase ? ToPascalCase(name) : name;
var o = options.TransformName(name) ?? name;
o = toCamelCase ? ToCamelCase(o) : toPascalCase ? ToPascalCase(o) : o;

if (reservedKeywords.Contains(o))
{
Expand Down
1 change: 1 addition & 0 deletions src/Bindgen/GeneratorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct GeneratorOptions
public string[] IncludeFolders = { };
public string[] Defines = { };
public Func<string, string, string, string?> TransformType = (parent, name, type) => null;
public Func<string, string?> TransformName = (name) => null;
public Func<string, string, bool> DetectArray = (parent, name) => false;
public Dictionary<string, string> ExistingTypes = new();

Expand Down
1 change: 1 addition & 0 deletions src/Raylib.NET.Bindgen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"int" => transformEnum(parent, name),
_ => Regex.Replace(type, @"\b(rres|rl|r)", ""),
},
TransformName = (string name) => Regex.Replace(name, @"\b(rres|rl)", ""),
ExistingTypes = new()
{
{ "Vector2", "System.Numerics" },
Expand Down
8 changes: 4 additions & 4 deletions src/Raylib.NET.Test/Raylib.NET.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<NoWarn>$(NoWarn);SYSLIB0050</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0"/>
<PackageReference Include="coverlet.collector" Version="1.2.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="xunit" Version="2.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.*"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Raylib.NET/Enums/GuiControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace RaylibNET;
public enum GuiControl
{
/// <summary>
/// Default -> populates to all controls when set
/// Default -&gt; populates to all controls when set
/// </summary>
DEFAULT = 0,
/// <summary>
Expand Down
620 changes: 310 additions & 310 deletions src/Raylib.NET/Rlgl.cs

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions src/Raylib.NET/Rres.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,91 @@ public static unsafe partial class Rres
/// <summary>
/// Load one resource chunk for provided id
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresLoadResourceChunk", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ResourceChunk rresLoadResourceChunk(string fileName, int rresId);
public static partial ResourceChunk LoadResourceChunk(string fileName, int Id);

/// <summary>
/// Unload resource chunk from memory
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresUnloadResourceChunk", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void rresUnloadResourceChunk(ResourceChunk chunk);
public static partial void UnloadResourceChunk(ResourceChunk chunk);

/// <summary>
/// Load resource for provided id (multiple resource chunks)
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresLoadResourceMulti", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ResourceMulti rresLoadResourceMulti(string fileName, int rresId);
public static partial ResourceMulti LoadResourceMulti(string fileName, int Id);

/// <summary>
/// Unload resource from memory (multiple resource chunks)
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresUnloadResourceMulti", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void rresUnloadResourceMulti(ResourceMulti multi);
public static partial void UnloadResourceMulti(ResourceMulti multi);

/// <summary>
/// Load resource chunk info for provided id
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresLoadResourceChunkInfo", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial ResourceChunkInfo rresLoadResourceChunkInfo(string fileName, int rresId);
public static partial ResourceChunkInfo LoadResourceChunkInfo(string fileName, int Id);

/// <summary>
/// Load all resource chunks info
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresLoadResourceChunkInfoAll", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial ResourceChunkInfo* rresLoadResourceChunkInfoAll(string fileName, ref uint chunkCount);
public static unsafe partial ResourceChunkInfo* LoadResourceChunkInfoAll(string fileName, ref uint chunkCount);

/// <summary>
/// Load central directory resource chunk from file
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresLoadCentralDirectory", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial CentralDir rresLoadCentralDirectory(string fileName);
public static partial CentralDir LoadCentralDirectory(string fileName);

/// <summary>
/// Unload central directory resource chunk
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresUnloadCentralDirectory", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void rresUnloadCentralDirectory(CentralDir dir);
public static partial void UnloadCentralDirectory(CentralDir dir);

/// <summary>
/// Get rresResourceDataType from FourCC code
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresGetDataType", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial uint rresGetDataType(byte* fourCC);
public static unsafe partial uint GetDataType(byte* fourCC);

/// <summary>
/// Get resource id for a provided filename
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresGetResourceId", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int rresGetResourceId(CentralDir dir, string fileName);
public static partial int GetResourceId(CentralDir dir, string fileName);

/// <summary>
/// Compute CRC32 for provided data
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresComputeCRC32", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial uint rresComputeCRC32(byte* data, int len);
public static unsafe partial uint ComputeCRC32(byte* data, int len);

/// <summary>
/// Set password to be used on data decryption
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresSetCipherPassword", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void rresSetCipherPassword(string pass);
public static partial void SetCipherPassword(string pass);

/// <summary>
/// Get password to be used on data decryption
/// </summary>
[LibraryImport(LIBRARY, StringMarshalling = StringMarshalling.Utf8)]
[LibraryImport(LIBRARY, EntryPoint = "rresGetCipherPassword", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial string rresGetCipherPassword();
public static partial string GetCipherPassword();
}
2 changes: 1 addition & 1 deletion src/Raylib.NET/Types/DrawCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial struct DrawCall
/// </summary>
public int VertexAlignment;
/// <summary>
/// Texture id to be used on the draw -> Use to create new draw call if changes
/// Texture id to be used on the draw -&gt; Use to create new draw call if changes
/// </summary>
public uint TextureId;

Expand Down
2 changes: 1 addition & 1 deletion src/Raylib.NET/Types/FileHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial struct FileHeader
/// </summary>
public uint CdOffset;
/// <summary>
/// <reserved>
/// &lt;reserved&gt;
/// </summary>
public uint Reserved;
}
2 changes: 1 addition & 1 deletion src/Raylib.NET/Types/ResourceChunkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public partial struct ResourceChunkInfo
/// </summary>
public uint NextOffset;
/// <summary>
/// <reserved>
/// &lt;reserved&gt;
/// </summary>
public uint Reserved;
/// <summary>
Expand Down

0 comments on commit ea8160e

Please sign in to comment.