Hi Walter, Try this: /Developer/MonoTouch/usr/bin/btouch libTestLib.cs Stuff.cs
(e.g. no -s:) Jeff On Mon, Sep 26, 2011 at 7:28 AM, retlaW <[email protected]>wrote: > Hi. > > I am attempt to use btouch to bind to an obj-c library that needs to pass > data back and forth via structs. > > Ultimately I want to bind to the Wahoo Fitness ANT+ API they have but have > built a test library just to ensure I get the mapping concepts working > before I attempt to bind to the real library. > > Now I can bind everything I need with the exception of the struct. I have > a > separate file with the struct definition and have tried to include the > struct in the mappingFile itself. The struct is named Stuff and the error > I > get is : error CS0246: The type or namespace name `Stuff' could not be > found. Are you missing a using directive or an assembly reference? > > now the interesting part is if I leave the struct in the mapping file and > include the separate struct file I get this error : Stuff.cs(7,23): error > CS0101: The namespace `TestOne' already contains a definition for `Stuff' > So it appears to see the struct yet it wont let me bind anything with it. > > Do I need to annotate the struct in some way for it to be used in btouch? > > If I comment out the parts that use the struct the everything else works as > expected. > > The command line I am using when the struct tis defined in the mapping file > is > /Developer/MonoTouch/usr/bin/btouch libTestLib.cs > > and when I have the struct in a separate file i use: > /Developer/MonoTouch/usr/bin/btouch libTestLib.cs -s:Stuff.cs > > > > Any help would be greatly appreciated. > > Thanks, > > > Walt > > > > > Below are the files in question : > > I have created a Obj-C Lib with the following header : > #import <Foundation/Foundation.h> > > --begin heder > typedef unsigned char UCHAR; > > typedef struct > { > UCHAR messageSize; > UCHAR messageId; > UCHAR data1; > UCHAR data2; > } Stuff; > > @protocol StructDelegate > - (void)processStruct:(Stuff)antMessage; > @end > > @protocol SimpleDelegate > - (NSString*)process:(NSString*)msg; > @end > > @interface TestLib : NSObject > { > id <StructDelegate> del; > id<SimpleDelegate> sDel; > } > - (NSString *) RepeatAfterMe:(NSString*) repeatMe; > - (NSString*) SayHello; > - (int) HardCodedValue; > - (NSString*) Send:(Stuff) s; > + (NSString*) classMethod; > - (void) save:(id <StructDelegate>) d; > - (void) saveSimple:(id <SimpleDelegate>) d; > - (NSString*) callSimple:(NSString*) s; > @end > > -- end header > > > and I have a mapping file for bTouch as : > > -- begin mapping file (libTestLib.cs) > > > using System; > using MonoTouch.Foundation; > using System.Runtime.InteropServices; > using MonoTouch.ObjCRuntime; > > > namespace TestOne > { > [BaseType (typeof(NSObject))] > [Model] > interface StructDelegate > { > [Export ("processStruct:")] > string processStruct (Stuff s); > } > > > [BaseType (typeof(NSObject))] > [Model] > interface SimpleDelegate > { > [Export ("process:")] > string process (string s); > } > > > [BaseType (typeof (NSObject))] > interface TestLib { > [Export ("RepeatAfterMe:")] > string RepeatAfterMe (string repeatMe); > > [Export ("SayHello")] > string SayHello { get; } > > [Export ("HardCodedValue")] > int HardCodedValue { get; } > > [Static, Export ("classMethod")] > string ClassMethod { get; } > > [Export("saveSimple:")] > void SaveSimple(SimpleDelegate del); > > [Export("callSimple:")] > string CallSimple (string s); > > [Export ("save:")] > void Save(StructDelegate d); > > [Export ("Send:")] > string Send (Stuff s); > } > > /* > [StructLayout(LayoutKind.Sequential)] > [Serializable] > public struct Stuff > { > public byte messageSize; > public byte messageId; > public byte data1; > public byte data2; > } > */ > > } > > -- end mapping file > > and I have a file for the struct that I pass in defined as : > > -- begin struct file (Stuff.cs) > using System; > > namespace TestOne > { > //[StructLayout(LayoutKind.Sequential)] > [Serializable ] > public struct Stuff > { > public byte messageSize; > public byte messageId; > public byte data1; > public byte data2; > } > } > -end struct file > > -- > View this message in context: > http://monotouch.2284126.n4.nabble.com/btouch-and-structs-tp3843442p3843442.html > Sent from the MonoTouch mailing list archive at Nabble.com. > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
