Bug 33107 - BTOUCH has error with float** and float* parameters
Summary: BTOUCH has error with float** and float* parameters
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-08-14 09:56 UTC by Bryon Baker
Modified: 2015-09-01 06:35 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Projects that reproduce problem. (3.35 MB, application/zip)
2015-08-14 23:52 UTC, Bryon Baker
Details

Description Bryon Baker 2015-08-14 09:56:15 UTC
Cannot bind interfaces that use pointers to floats. (Have not checked other types.)

The following types in APIDefinition.cs generate an error:

// @required -(_Bool)audioProcessingCallback:(float **)buffers inputChannels:(unsigned int)inputChannels outputChannels:(unsigned int)outputChannels numberOfSamples:(unsigned int)numberOfSamples samplerate:(unsigned int)samplerate hostTime:(UInt64)hostTime;
[Abstract]
[Export ("audioProcessingCallback:inputChannels:outputChannels:numberOfSamples:samplerate:hostTime:")]
unsafe bool AudioProcessingCallback (float** buffers, uint inputChannels, uint outputChannels, uint numberOfSamples, uint samplerate, ulong hostTime);

buffers is supposed to be a pointer to an array of floats.

This example also fails but could be worked around using "ref float freqs"
// -(void)getFrequencies:(float *)freqs;
[Export ("getFrequencies:")]
void GetFrequencies( float[] freqs );
Comment 1 Marek Safar 2015-08-14 14:49:11 UTC
What's the actual error?
Comment 2 Bryon Baker 2015-08-14 23:52:41 UTC
Created attachment 12524 [details]
Projects that reproduce problem.

This project reproduces the problem. It contains the Objective-C XCode project and the Xamarin Binding project. Just build the Binding project to see the errors.
I have added notes to the ApiDefinition.cs file that shows one workaround.
Each binding item produces a slightly different error so best to comment them out one by one and see the result.
Comment 3 Bryon Baker 2015-08-14 23:59:46 UTC
If you build the entire ApiDefintiion you get:
BTOUCH: error BI1012: btouch: No Export or Bind attribute defined on SuperPoweredWrapper.BandPassFilter.ArrayOfFloatArrays

void ArrayOfFloats (float[] freqs, int numBands) generates the following error:
obj/Debug/ios/SuperPoweredWrapper/BandPassFilter.g.cs(76,43): error CS1503: Argument `#1' cannot convert `float[]' expression to type `Foundation.NSObject[]'
	Task "Csc" execution -- FAILED

unsafe void ArrayOfFloats (float* freqs, int numBands); generates the following error:
BTOUCH: error BI1002: btouch: Unknown kind Single* freqs in method 'SuperPoweredWrapper.BandPassFilter.ArrayOfFloats'

THIS ONE WORKS: void ArrayOfFloats (ref float freqs, int numBands);

unsafe void ArrayOfFloatArrays (float** freqs, int numBands, int numBuffers); generates the following error:
BTOUCH: error BI1002: btouch: Unknown kind Single** freqs in method 'SuperPoweredWrapper.BandPassFilter.ArrayOfFloatArrays'

unsafe void PointerToVoid (void* freqs, int numBands); generates the following error:
BTOUCH: error BI1002: btouch: Unknown kind System.Void* freqs in method 'SuperPoweredWrapper.BandPassFilter.PointerToVoid'
Comment 4 Bryon Baker 2015-08-15 03:53:26 UTC
I forgot to add that the XCode project is built with Makefile. That will generate the ApiDefinitions.cs file which I then hand edited.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-09-01 06:35:14 UTC
Binding support is limited to the most frequently used types (we usually add support for more types when someone requests it though).

In most cases this can be worked around using IntPtr and manually marshalling data as required.

Note You need to log in before you can comment on or make changes to this bug.