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

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

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 33107 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

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;
[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.