[RFC] Bind pointers to structs in parameters
- Dominant language
- C#
- Stars
- 2.9k
- Forks
- 576
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 123
Description
Currently bgen doesn't support binding pointers to structs in api definitions.
Example:
```objc
(void) doSomething: (struct SomeStruct* ) value withNumber: (NSInteger) someNumber;
```
This can mean:
* `value` is a pointer to a single value of `struct SomeStruct`.
* `value` is an array of `struct SomeStruct` elements, the number of elements specified by some other means:
* Another parameter (`someNumber` for instance)
* Terminated by some sentinel value
* A field/property on the type.
* Convention / documentation.
* Anything else?
In any case, may be NULL if `__nullable`.
Bind as any of:
No length (single struct):
```cs
[Export ("doSomething:withNumber:")]
unsafe void DoSomething ([PointerAsStruct] SomeStruct* value, nint someNumber);
unsafe void DoSomething ([PointerAsStruct] ref SomeStruct value, nint someNumber);
unsafe void DoSomething ([PointerAsStruct] out SomeStruct value, nint someNumber);
```
Length specified as a parameter:
```cs
unsafe void DoSomething ([PointerAsArray (LengthFromParameter = nameof (someNumber))] SomeStruct[] value, nint someNumber);
```
Length specified as a member:
```cs
unsafe void DoSomething ([PointerAsArray (LengthFromMember = nameof (PropertyOrField))] SomeStruct[] value, nint someNumber);
```
Length specified with convention:
```cs
unsafe void DoSomething ([PointerAsArray (Length = 3] SomeStruct[] value, nint someNumber);
```
Unsupported:
* Length is specified in ways not explicitly supported (examples?)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.