Beispiel #1
0
 protected override TransformationResult TransformTypedef(TransformationContext context, TranslatedTypedef declaration)
 {
     // ImWchar16 is defined as being ushort, but it makes more sense for it to be a C# char.
     if (declaration.Name is "ImWchar16")
     {
         Debug.Assert(declaration.UnderlyingType == CSharpBuiltinType.UShort);
         return(declaration with
         {
             UnderlyingType = CSharpBuiltinType.Char
         });
     }
     // ImWchar32 is defined as being uint, but it makes more sense for it to be a .NET System.Rune.
     // (In theory System.Rune is slightly different since it should only be used with valid unicode characters, but I think this is probably fine.)
     else if (declaration.Name is "ImWchar32")
     {
         Debug.Assert(declaration.UnderlyingType == CSharpBuiltinType.UInt);
         return(declaration with
         {
             UnderlyingType = new ExternallyDefinedTypeReference("System.Text", "Rune")
         });
     }
     else
     {
         return(declaration);
     }
 }
Beispiel #2
0
    protected override TransformationResult TransformTypedef(TransformationContext context, TranslatedTypedef declaration)
    {
        if (declaration.File != PxBatchQueryDescFile)
        {
            return(declaration);
        }

        string?hitType = declaration.Name switch
        {
            "PxRaycastQueryResult" => "PxRaycastHit",
            "PxSweepQueryResult" => "PxSweepHit",
            "PxOverlapQueryResult" => "PxOverlapHit",
            _ => null
        };

        if (hitType is null)
        {
            return(declaration);
        }

        Debug.Assert(declaration.Namespace == "physx");
        Debug.Assert(declaration.UnderlyingType is TranslatedTypeReference);
        Debug.Assert(((TranslatedTypeReference)declaration.UnderlyingType).TryResolve(context.Library) is TranslatedUnsupportedDeclaration or null);

        return(declaration with
        {
            UnderlyingType = new ExternallyDefinedTypeReference("Mochi.PhysX", $"PxBatchQueryResult<{hitType}>")
        });
    }
}