diff --git a/src/source/Main.scala b/src/source/Main.scala index 49529053..a59b46cf 100644 --- a/src/source/Main.scala +++ b/src/source/Main.scala @@ -84,6 +84,7 @@ object Main { var objcppFunctionPrologueFile: Option[String] = None var objcppDisableExceptionTranslation: Boolean = false var objcFileIdentStyleOptional: Option[IdentConverter] = None + var objcStrictProtocol: Boolean = true var objcppNamespace: String = "djinni_generated" var objcBaseLibIncludePrefix: String = "" var wasmOutFolder: Option[File] = None @@ -202,6 +203,9 @@ object Main { .text("Disable generating Objective-C class init helper method.") opt[Boolean]("objc-closed-enums").valueName("").foreach(x => objcClosedEnums = x) .text("All generated Objective-C enums will be NS_CLOSED_ENUM (default: false). ") + opt[Boolean]("objc-strict-protocols") + .valueName("").foreach(x => objcStrictProtocol = x) + .text("All generated @protocol will implement (default: true). ") note("") opt[File]("objcpp-out").valueName("").foreach(x => objcppOutFolder = Some(x)) .text("The output folder for private Objective-C++ files (Generator disabled if unspecified).") @@ -416,6 +420,7 @@ object Main { objcGenProtocol, objcDisableClassCtor, objcClosedEnums, + objcStrictProtocol, wasmOutFolder, wasmIncludePrefix, wasmIncludeCppPrefix, diff --git a/src/source/ObjcGenerator.scala b/src/source/ObjcGenerator.scala index c5cdee2b..79419b1c 100644 --- a/src/source/ObjcGenerator.scala +++ b/src/source/ObjcGenerator.scala @@ -135,7 +135,12 @@ class ObjcGenerator(spec: Spec) extends BaseObjcGenerator(spec) { w.wl writeDoc(w, doc) - if (useProtocol(i.ext, spec)) w.wl(s"@protocol $self ") else w.wl(s"@interface $self : NSObject") + if (useProtocol(i.ext, spec)) { + val baseProtocol = if (spec.objcStrictProtocol) " " else "" + w.wl(s"@protocol $self$baseProtocol") + } else { + w.wl(s"@interface $self : NSObject") + } for (m <- i.methods) { if (!m.static || (!spec.objcGenProtocol && m.lang.objc)) { diff --git a/src/source/generator.scala b/src/source/generator.scala index 42526dde..5bd55f5a 100644 --- a/src/source/generator.scala +++ b/src/source/generator.scala @@ -88,6 +88,7 @@ package object generatorTools { objcGenProtocol: Boolean, objcDisableClassCtor: Boolean, objcClosedEnums: Boolean, + objcStrictProtocol: Boolean, wasmOutFolder: Option[File], wasmIncludePrefix: String, wasmIncludeCppPrefix: String,