Skip to content

Commit

Permalink
fix (ApiDefinition.cs): fix the attributes used to decorate native cl…
Browse files Browse the repository at this point in the history
…asses and delegates

   - anything with '@interface <class name> : NSObject' just needs the [BaseType]    if we use [Model] on these an exception will be thrown
     in runtime because we will get an empty model with no code besides the exception being thrown

       // @interface DFUFirmware : NSObject
       [BaseType(typeof(NSObject), Name = "_TtC9NordicDFU11DFUFirmware")]
       [DisableDefaultCtor]
       interface DFUFirmware { ... }

   - anything '@protocol <class name>' is decorated like so:

       // @protocol DFUPeripheralSelectorDelegate
	      [BaseType(typeof(NSObject), Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
	      [Protocol(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
	      [Model(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
       interface DFUPeripheralSelectorDelegate { ... }
  • Loading branch information
ksidirop-laerdal committed May 15, 2024
1 parent 544daeb commit 00f60d5
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions Laerdal.Dfu.Bindings.iOS/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
//
// - anything with '@interface <class name> : NSObject' just needs the [BaseType] if we use [Model] on these an exception will be thrown
// in runtime because we will get an empty model with no code besides the exception being thrown
//
// // @interface DFUFirmware : NSObject
// [BaseType(typeof(NSObject), Name = "_TtC9NordicDFU11DFUFirmware")]
// [DisableDefaultCtor]
// interface DFUFirmware { ... }
//
// - anything '@protocol <class name>' is decorated like so:
//
// // @protocol DFUPeripheralSelectorDelegate
// [BaseType(typeof(NSObject), Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
// [Protocol(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
// [Model(Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_")]
// interface DFUPeripheralSelectorDelegate { ... }
//

using System;
using CoreBluetooth;
using CoreFoundation;
Expand All @@ -7,7 +25,7 @@
namespace Laerdal.Dfu.Bindings.iOS
{
// @interface DFUFirmware : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary11DFUFirmware")] // [Model (Name = "_TtC13iOSDFULibrary11DFUFirmware")]
// [Model (Name = "_TtC13iOSDFULibrary11DFUFirmware")] // [Protocol (Name = "_TtC13iOSDFULibrary11DFUFirmware")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary11DFUFirmware")]
[DisableDefaultCtor]
interface DFUFirmware
Expand Down Expand Up @@ -68,7 +86,7 @@ interface DFUFirmware
}

// @interface DFUFirmwareSize : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] // [Model (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")]
// [Model (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")] // [Protocol (Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary15DFUFirmwareSize")]
[DisableDefaultCtor]
interface DFUFirmwareSize
Expand Down Expand Up @@ -117,7 +135,7 @@ interface DFUProgressDelegate
}

// @interface DFUServiceController : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary20DFUServiceController")] // [Model (Name = "_TtC13iOSDFULibrary20DFUServiceController")]
// [Model (Name = "_TtC13iOSDFULibrary20DFUServiceController")] // [Protocol (Name = "_TtC13iOSDFULibrary20DFUServiceController")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary20DFUServiceController")]
[DisableDefaultCtor]
interface DFUServiceController
Expand Down Expand Up @@ -165,7 +183,7 @@ interface DFUServiceDelegate
}

// @interface DFUServiceInitiator : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] // [Model (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")]
// [Model (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")] [Protocol (Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary19DFUServiceInitiator")]
[DisableDefaultCtor]
interface DFUServiceInitiator
Expand Down Expand Up @@ -265,7 +283,7 @@ interface DFUServiceInitiator
}

// @interface DFUUuid : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary7DFUUuid")] // [Model (Name = "_TtC13iOSDFULibrary7DFUUuid")]
// [Model (Name = "_TtC13iOSDFULibrary7DFUUuid")] // [Protocol (Name = "_TtC13iOSDFULibrary7DFUUuid")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary7DFUUuid")]
[DisableDefaultCtor]
interface DFUUuid
Expand All @@ -285,8 +303,8 @@ interface DFUUuid
}

// @interface DFUUuidHelper : NSObject
// [Model (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] // [Protocol (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary13DFUUuidHelper")]
[Protocol (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")] // [Model (Name = "_TtC13iOSDFULibrary13DFUUuidHelper")]
[DisableDefaultCtor]
interface DFUUuidHelper
{
Expand Down Expand Up @@ -340,16 +358,16 @@ interface DFUUuidHelper
}

// @interface IntelHex2BinConverter : NSObject
[Protocol (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] // [Model (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")]
// [Model (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")] // [Protocol (Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")]
[BaseType (typeof(NSObject), Name = "_TtC13iOSDFULibrary21IntelHex2BinConverter")]
[DisableDefaultCtor]
interface IntelHex2BinConverter
{
}

// @interface LegacyDFUServiceInitiator : DFUServiceInitiator
// [Model (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] // [Protocol (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")]
[BaseType (typeof(DFUServiceInitiator), Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")]
[Protocol (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")] // [Model (Name = "_TtC13iOSDFULibrary25LegacyDFUServiceInitiator")]
[DisableDefaultCtor]
interface LegacyDFUServiceInitiator
{
Expand Down Expand Up @@ -382,8 +400,8 @@ interface LoggerDelegate
}

// @interface SecureDFUServiceInitiator : DFUServiceInitiator
// [Model (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] // [Protocol (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")]
[BaseType (typeof(DFUServiceInitiator), Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")]
[Protocol (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")] // [Model (Name = "_TtC13iOSDFULibrary25SecureDFUServiceInitiator")]
[DisableDefaultCtor]
interface SecureDFUServiceInitiator
{
Expand Down

0 comments on commit 00f60d5

Please sign in to comment.