S
Silk.NET12mo ago
Perksey

ClangSharp Objective-C

revised agenda for my flight in that case
No description
5 Replies
Perksey
PerkseyOP12mo ago
Hey @Tanner Gooding, currently looking at this. I've got to the point where I believe the native part + ClangSharp.Interop/ClangSharp is done, and am now looking at getting some basic visitation working. Right now I've got a common VisitObjCContainerDecl function that just does a BeginStruct/EndStruct and nothing else at the moment. However, this itself was enough to expose the issue of: F O R W A R D D E C L A R A T I O N S MTLAccelerationStructure.h, for example, contains:
@protocol MTLBuffer;
@protocol MTLAccelerationStructure;

// ...

@protocol MTLAccelerationStructure <MTLResource>

@property (nonatomic, readonly) NSUInteger size;

@property (readonly) MTLResourceID gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0));

@end
@protocol MTLBuffer;
@protocol MTLAccelerationStructure;

// ...

@protocol MTLAccelerationStructure <MTLResource>

@property (nonatomic, readonly) NSUInteger size;

@property (readonly) MTLResourceID gpuResourceID API_AVAILABLE(macos(13.0), ios(16.0));

@end
Which as far as I can tell is just a regular forward declaration. This results in a MTLAccelerationStructure.cs of:
// Copyright © Dylan Perks and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from MTLAccelerationStructure.h in XCode 15.1
// Original source is Copyright © Apple.

namespace TerraFX.Interop.MacOSX;

/// <include file='MTLAccelerationStructure.xml' path='doc/member[@name="MTLAccelerationStructure"]/*' />
[NativeTypeName("MTLAccelerationStructure")]
public unsafe partial struct MTLAccelerationStructure
{
}

/// <include file='MTLAccelerationStructure.xml' path='doc/member[@name="MTLAccelerationStructure"]/*' />
[NativeTypeName("MTLAccelerationStructure")]
public unsafe partial struct MTLAccelerationStructure
{
}
// Copyright © Dylan Perks and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

// Ported from MTLAccelerationStructure.h in XCode 15.1
// Original source is Copyright © Apple.

namespace TerraFX.Interop.MacOSX;

/// <include file='MTLAccelerationStructure.xml' path='doc/member[@name="MTLAccelerationStructure"]/*' />
[NativeTypeName("MTLAccelerationStructure")]
public unsafe partial struct MTLAccelerationStructure
{
}

/// <include file='MTLAccelerationStructure.xml' path='doc/member[@name="MTLAccelerationStructure"]/*' />
[NativeTypeName("MTLAccelerationStructure")]
public unsafe partial struct MTLAccelerationStructure
{
}
How does ClangSharp handle this for e.g. C++ classes that may be forward declared? I'm not sure how best to handle this, IsCanonicalDecl is false for both and the only way I can think of is detecting when CursorChildren only contains 1 element of a ref to itself, but this may prevent valid forward declarations from being output (do we care?). Please advise 😅
Perksey
PerkseyOP12mo ago
that's exactly what I wanted, thanks! smacked that at the start of the function. discovered another problematic case: enums that are nuint sized. what's your stance here?
No description
Perksey
PerkseyOP12mo ago
just prefer 64-bit and call it a day?
tannergooding
tannergooding12mo ago
there isn't really a good option there, but matching 64-bit is the closest especially considering apples stance on 32-bit
Want results from more Discord servers?
Add your server