Skip to content

Commit

Permalink
Removed all project warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcant0n committed Jul 8, 2024
1 parent 9095569 commit cbeaaee
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions OpenXRGen/Evergine.Bindings.OpenXR/Generated/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace Evergine.Bindings.OpenXR
public static unsafe partial class OpenXRNative
{
[UnmanagedFunctionPointer(CallConv)]
private delegate XrResult xrGetInstanceProcAddrDelegate(XrInstance instance, byte* name, PFN_xrVoidFunction function);
private delegate XrResult xrGetInstanceProcAddrDelegate(XrInstance instance, byte* name, IntPtr function);
private static xrGetInstanceProcAddrDelegate xrGetInstanceProcAddr_ptr;
public static XrResult xrGetInstanceProcAddr(XrInstance instance, byte* name, PFN_xrVoidFunction function)
public static XrResult xrGetInstanceProcAddr(XrInstance instance, byte* name, IntPtr function)
=> xrGetInstanceProcAddr_ptr(instance, name, function);

[UnmanagedFunctionPointer(CallConv)]
Expand Down
2 changes: 1 addition & 1 deletion OpenXRGen/Evergine.Bindings.OpenXR/Generated/Delegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Evergine.Bindings.OpenXR
public unsafe delegate XrResult PFN_xrGetInstanceProcAddr(
XrInstance instance,
byte* name,
PFN_xrVoidFunction* function);
IntPtr function);

public unsafe delegate XrResult PFN_xrCreateApiLayerInstance(
XrInstanceCreateInfo* info,
Expand Down
14 changes: 7 additions & 7 deletions OpenXRGen/Evergine.Bindings.OpenXR/Generated/Structs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public unsafe partial struct XrNegotiateApiLayerRequest
public UIntPtr structSize;
public uint layerInterfaceVersion;
public ulong layerApiVersion;
public PFN_xrGetInstanceProcAddr getInstanceProcAddr;
public PFN_xrCreateApiLayerInstance createApiLayerInstance;
public IntPtr getInstanceProcAddr;
public IntPtr createApiLayerInstance;
}

[StructLayout(LayoutKind.Sequential)]
Expand All @@ -126,7 +126,7 @@ public unsafe partial struct XrNegotiateRuntimeRequest
public UIntPtr structSize;
public uint runtimeInterfaceVersion;
public ulong runtimeApiVersion;
public PFN_xrGetInstanceProcAddr getInstanceProcAddr;
public IntPtr getInstanceProcAddr;
}

[StructLayout(LayoutKind.Sequential)]
Expand All @@ -136,8 +136,8 @@ public unsafe partial struct XrApiLayerNextInfo
public uint structVersion;
public UIntPtr structSize;
public fixed byte layerName[(int)OpenXRNative.XR_MAX_API_LAYER_NAME_SIZE];
public PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr;
public PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance;
public IntPtr nextGetInstanceProcAddr;
public IntPtr nextCreateApiLayerInstance;
public XrApiLayerNextInfo* next;
}

Expand Down Expand Up @@ -4976,7 +4976,7 @@ public unsafe partial struct XrDebugUtilsMessengerCreateInfoEXT
public void* next;
public ulong messageSeverities;
public ulong messageTypes;
public PFN_xrDebugUtilsMessengerCallbackEXT userCallback;
public IntPtr userCallback;
public void* userData;
}

Expand Down Expand Up @@ -5232,7 +5232,7 @@ public unsafe partial struct XrGraphicsBindingEGLMNDX
{
public XrStructureType type;
public void* next;
public PFN_xrEglGetProcAddressMNDX getProcAddress;
public IntPtr getProcAddress;
public IntPtr display;
public IntPtr config;
public IntPtr context;
Expand Down
3 changes: 1 addition & 2 deletions OpenXRGen/Evergine.Bindings.OpenXR/NativeLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public unsafe void LoadFunction<T>(string name, out T field)
IntPtr funcPtr = LoadFunction(name);
if (funcPtr == IntPtr.Zero)
{
PFN_xrVoidFunction delegateFromPointer = (PFN_xrVoidFunction)Marshal.GetDelegateForFunctionPointer(funcPtr, typeof(PFN_xrVoidFunction));
OpenXRNative.xrGetInstanceProcAddr(instance, (byte*)Marshal.StringToHGlobalAnsi(name), delegateFromPointer);
OpenXRNative.xrGetInstanceProcAddr(instance, (byte*)Marshal.StringToHGlobalAnsi(name), new IntPtr(&funcPtr));
}

if (funcPtr != IntPtr.Zero)
Expand Down
14 changes: 7 additions & 7 deletions OpenXRGen/OpenXRGen/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public static string ConvertToCSharpType(string type, int pointerlevel, OpenXRSp
{
string memberType = type;

if (type.StartsWith("PFN"))
{
string fp = memberType.Replace("*", "");
if (spec.FuncPointers.Exists(f => f.Name == fp))
return fp;
}
//if (type.StartsWith("PFN"))
//{
// string fp = memberType.Replace("*", "");
// if (spec.FuncPointers.Exists(f => f.Name == fp))
// return fp;
//}


if(IsIntPtr(memberType))
if (memberType.StartsWith("PFN") || IsIntPtr(memberType))
return "IntPtr";

string result = ConvertBasicTypes(memberType);
Expand Down
2 changes: 1 addition & 1 deletion OpenXRGen/OpenXRGen/OpenXRGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
5 changes: 1 addition & 4 deletions OpenXRGen/OpenXRGen/OpenXRVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public static OpenXRVersion FromSpec(OpenXRSpecification spec, string versionNam
}

var commandDefinition = spec.Commands.Find(c => c.Prototype.Name == name);
if (commandDefinition != null)
version.Commands.Add(commandDefinition);
else
;
version.Commands.Add(commandDefinition);
}

if (feature.Name == versionName)
Expand Down
13 changes: 10 additions & 3 deletions OpenXRGen/OpenXRGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;

namespace OpenXRGen
{
Expand Down Expand Up @@ -67,10 +68,16 @@ static void Main(string[] args)
openXRSpec.BaseTypes.TryGetValue(typeDef.Type, out type);
}

convertedType = Helpers.ConvertBasicTypes(type);
if (convertedType == string.Empty)
if (type.StartsWith("PFN") || Helpers.IsIntPtr(type))
convertedType = "IntPtr";
else
{
convertedType = type;
convertedType = Helpers.ConvertBasicTypes(type);

if (convertedType == string.Empty)
{
convertedType = type;
}
}

file.Write($"\t\t{Helpers.GetPrettyEnumName(convertedType)} {Helpers.ValidatedName(func.Parameters[p].Name)}");
Expand Down

0 comments on commit cbeaaee

Please sign in to comment.