Anansi
Anansi

Reputation: 526

What is the correct monotouch binding for this?

It seems most of the examples regarding binding an Objective-C library to c# show methods and properties, but what do you do with instance variables that are declared?

Here's an example of the .h file I'm trying to create a binding for:

@interface NdefRecord : NSObject
{
@public
        uint8_t                 Flags;

         NDEF_TNF_Type                 Tnf;

        uint8_t                 TypeLength;

        uint8_t                *Type;

        uint8_t                 IdLength;

        uint8_t                *Id;


        uint32_t                PayloadLength;

        uint8_t                *PayloadData;
}

/**
 Initialize this record.

 - Optional: Since member fields are public, you can also set them directly.
 */
- (id) init:(NDEF_TNF_Type)tnf type:(NSData*)type Id:(NSData*)IdBytes payload:(NSData*)payload;

/**
 Parse an NDEF Record from raw bytes.
 */
- (BOOL) parse:(UInt8*)data;

/**
 Returns this entire NDEF Record as a byte array.
 */
- (uint32_t) toByteArray:(UInt8*)buffer;
...
@end

In my binding project, things like the parse: method are easy enough to bind, but things like TypeLength and *Type were missed by Objective Sharpie, and nothing I seem to hand create works properly.

In an iOS XCode project, those variables are accessed with syntax like so: record->TypeLength instead of [record TypeLength] which leads me to believe a simple binding like:

[Export ("TypeLength")]
Byte TypeLength { get; set; }

isn't going to work.

I'm completely stuck on a solution here, so any guidance is much appreciated!

Upvotes: 0

Views: 250

Answers (1)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

The binding tool does not support accessing internal fields of a class, which is what you are trying to do here.

The only thing you can bind with an [Export] are actual properties and methods.

You need to alter that library to expose properties to those internals.

Upvotes: 1

Related Questions