Import C functions as subscript methods (follow-up)

It seems that the “Import as subscript” feature described in SE-0044 Import as member still does not work (compare Import C functions as subscript methods). Tested with Xcode 10.2 beta (10P82s).

Example:

// CFile.h:

typedef struct Point3D {
    float x;
    float y;
    float z;
} Point3D;

float Point3DGetPointAtIndex(Point3D point, int idx)
__attribute__((swift_name("getter:Point3D.subscript(self:_:)")));

// main.swift:

let p = Point3D()
let x = p[0];
// Error: Value of type 'Point3D' has no subscripts

Interestingly, calling the C function directly does not work either:

let y = Point3DGetPointAtIndex(p, 0)
// 'Point3DGetPointAtIndex' has been replaced by property 'Point3D.subscript'

Is this feature still on the wishlist? I can write a bug report, but wanted to make sure that I am not overlooking something obvious.

Regards, Martin

:-( It looks like the switch to represent subscript as a special identifier broke this; it's now importing as a property named "subscript". Please do file a bug!

https://bugs.swift.org/browse/SR-9862

1 Like
Terms of Service

Privacy Policy

Cookie Policy