diff --git a/example/generated-src/objc/TextSort-Bridging-Header.h b/example/generated-src/objc/TextSort-Bridging-Header.h index bad025562..840e576f0 100644 --- a/example/generated-src/objc/TextSort-Bridging-Header.h +++ b/example/generated-src/objc/TextSort-Bridging-Header.h @@ -1,6 +1,17 @@ // AUTOGENERATED FILE - DO NOT MODIFY! // This file generated by Djinni +// TextSort_Bridging_Header.h +// TextSort_Bridging_Header + +#import + +//! Project version number for TextSortBridgingHeader. +FOUNDATION_EXPORT double TextSortBridgingHeaderVersionNumber; + +//! Project version string for TextSortBridgingHeader. +FOUNDATION_EXPORT const unsigned char TextSortBridgingHeaderVersionString[]; + #import "TXSItemList.h" #import "TXSSortOrder.h" #import "TXSSortItems.h" diff --git a/src/source/Main.scala b/src/source/Main.scala index 84d97f017..ecbcee006 100644 --- a/src/source/Main.scala +++ b/src/source/Main.scala @@ -69,7 +69,7 @@ object Main { var objcTypePrefix: String = "" var objcIncludePrefix: String = "" var objcExtendedRecordIncludePrefix: String = "" - var objcSwiftBridgingHeader: Option[String] = None + var objcSwiftBridgingHeaderName: Option[String] = None var objcppIncludePrefix: String = "" var objcppIncludeCppPrefix: String = "" var objcppIncludeObjcPrefixOptional: Option[String] = None @@ -168,7 +168,7 @@ object Main { .text("The prefix for Objective-C data types (usually two or three letters)") opt[String]("objc-include-prefix").valueName("").foreach(objcIncludePrefix = _) .text("The prefix for #import of header files from Objective-C files.") - opt[String]("objc-swift-bridging-header").valueName("").foreach(x => objcSwiftBridgingHeader = Some(x)) + opt[String]("objc-swift-bridging-header").valueName("").foreach(x => objcSwiftBridgingHeaderName = Some(x)) .text("The name of Objective-C Bridging Header used in XCode's Swift projects.") note("") opt[File]("objcpp-out").valueName("").foreach(x => objcppOutFolder = Some(x)) @@ -288,8 +288,8 @@ object Main { } else { None } - val objcSwiftBridgingHeaderWriter = if (objcSwiftBridgingHeader.isDefined && objcOutFolder.isDefined) { - val objcSwiftBridgingHeaderFile = new File(objcOutFolder.get.getPath, objcSwiftBridgingHeader.get + ".h") + val objcSwiftBridgingHeaderWriter = if (objcSwiftBridgingHeaderName.isDefined && objcOutFolder.isDefined) { + val objcSwiftBridgingHeaderFile = new File(objcOutFolder.get.getPath, objcSwiftBridgingHeaderName.get + ".h") if (objcSwiftBridgingHeaderFile.getParentFile != null) createFolder("output file list", objcSwiftBridgingHeaderFile.getParentFile) Some(new BufferedWriter(new FileWriter(objcSwiftBridgingHeaderFile))) @@ -346,6 +346,7 @@ object Main { objcppNamespace, objcBaseLibIncludePrefix, objcSwiftBridgingHeaderWriter, + objcSwiftBridgingHeaderName, outFileListWriter, skipGeneration, yamlOutFolder, diff --git a/src/source/SwiftBridgingHeaderGenerator.scala b/src/source/SwiftBridgingHeaderGenerator.scala index 441ea987b..f5d9d0761 100644 --- a/src/source/SwiftBridgingHeaderGenerator.scala +++ b/src/source/SwiftBridgingHeaderGenerator.scala @@ -38,8 +38,24 @@ class SwiftBridgingHeaderGenerator(spec: Spec) extends Generator(spec) { } object SwiftBridgingHeaderGenerator { - def writeAutogenerationWarning(writer: Writer) { + + val bridgingHeaderName = (s: String) => s.split('-').mkString("_") + val bridgingHeaderVariables = (s: String) => s.split('-').mkString("") + + def writeAutogenerationWarning(name: String, writer: Writer) { + val bridgingHeaderVarName = bridgingHeaderName(name) writer.write("// AUTOGENERATED FILE - DO NOT MODIFY!\n") writer.write("// This file generated by Djinni\n\n") + writer.write("// " + bridgingHeaderVarName + ".h\n") + writer.write("// " + bridgingHeaderVarName + "\n\n") + } + + def writeBridgingVars(name: String, writer: Writer) { + val bridgingHeaderVarName = bridgingHeaderVariables(name) + writer.write("#import \n\n") + writer.write("//! Project version number for " + bridgingHeaderVarName +".\n") + writer.write("FOUNDATION_EXPORT double " + bridgingHeaderVarName + "VersionNumber;\n\n") + writer.write("//! Project version string for " + bridgingHeaderVarName +".\n") + writer.write("FOUNDATION_EXPORT const unsigned char " + bridgingHeaderVarName + "VersionString[];\n\n") } } \ No newline at end of file diff --git a/src/source/generator.scala b/src/source/generator.scala index 17780f39c..b6024a7f5 100644 --- a/src/source/generator.scala +++ b/src/source/generator.scala @@ -77,6 +77,7 @@ package object generatorTools { objcppNamespace: String, objcBaseLibIncludePrefix: String, objcSwiftBridgingHeaderWriter: Option[Writer], + objcSwiftBridgingHeaderName: Option[String], outFileListWriter: Option[Writer], skipGeneration: Boolean, yamlOutFolder: Option[File], @@ -217,7 +218,8 @@ package object generatorTools { new ObjcppGenerator(spec).generate(idl) } if (spec.objcSwiftBridgingHeaderWriter.isDefined) { - SwiftBridgingHeaderGenerator.writeAutogenerationWarning(spec.objcSwiftBridgingHeaderWriter.get) + SwiftBridgingHeaderGenerator.writeAutogenerationWarning(spec.objcSwiftBridgingHeaderName.get, spec.objcSwiftBridgingHeaderWriter.get) + SwiftBridgingHeaderGenerator.writeBridgingVars(spec.objcSwiftBridgingHeaderName.get, spec.objcSwiftBridgingHeaderWriter.get) new SwiftBridgingHeaderGenerator(spec).generate(idl) } if (spec.yamlOutFolder.isDefined) {