-
Notifications
You must be signed in to change notification settings - Fork 487
Generate an XCode like bridging header. #342
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
// AUTOGENERATED FILE - DO NOT MODIFY! | ||
// This file generated by Djinni | ||
|
||
// TextSort_Bridging_Header.h | ||
// TextSort_Bridging_Header | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
//! Project version number for TextSort_Bridging_Header. | ||
FOUNDATION_EXPORT double TextSort_Bridging_HeaderVersionNumber; | ||
|
||
//! Project version string forTextSort_Bridging_Header. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space between "for" and "TextSort_Bridging_Header" here. |
||
FOUNDATION_EXPORT const unsigned char TextSort_Bridging_HeaderVersionString[]; | ||
|
||
#import "TXSItemList.h" | ||
#import "TXSSortOrder.h" | ||
#import "TXSSortItems.h" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,6 +346,7 @@ object Main { | |
objcppNamespace, | ||
objcBaseLibIncludePrefix, | ||
objcSwiftBridgingHeaderWriter, | ||
objcSwiftBridgingHeader, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be Actually, I'd love to see this config used in Unit Test for verification. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable is declared as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, it's just the variable name here while |
||
outFileListWriter, | ||
skipGeneration, | ||
yamlOutFolder, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,23 @@ class SwiftBridgingHeaderGenerator(spec: Spec) extends Generator(spec) { | |
} | ||
|
||
object SwiftBridgingHeaderGenerator { | ||
def writeAutogenerationWarning(writer: Writer) { | ||
|
||
val bridgingVarPrefix = (s: String) => s.split('-').mkString("_") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my comment below, I'd prefer to remove the |
||
|
||
def writeAutogenerationWarning(name: String, writer: Writer) { | ||
val varPrefix = bridgingVarPrefix(name) | ||
writer.write("// AUTOGENERATED FILE - DO NOT MODIFY!\n") | ||
writer.write("// This file generated by Djinni\n\n") | ||
writer.write("// " + varPrefix + ".h\n") | ||
writer.write("// " + varPrefix + "\n\n") | ||
} | ||
|
||
def writeBridgingVars(name: String, writer: Writer) { | ||
val varPrefix = bridgingVarPrefix(name) | ||
writer.write("#import <Foundation/Foundation.h>\n\n") | ||
writer.write("//! Project version number for " + varPrefix +".\n") | ||
writer.write("FOUNDATION_EXPORT double " + varPrefix + "VersionNumber;\n\n") | ||
writer.write("//! Project version string for" + varPrefix +".\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add a space after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like the way this variable is named. In this case: Although it happens to be a prefix in the case of |
||
writer.write("FOUNDATION_EXPORT const unsigned char " + varPrefix + "VersionString[];\n\n") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ package object generatorTools { | |
objcppNamespace: String, | ||
objcBaseLibIncludePrefix: String, | ||
objcSwiftBridgingHeaderWriter: Option[Writer], | ||
objcSwiftBridgingHeaderName: Option[String], | ||
outFileListWriter: Option[Writer], | ||
skipGeneration: Boolean, | ||
yamlOutFolder: Option[File], | ||
|
@@ -216,7 +217,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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent with the declaration |
||
SwiftBridgingHeaderGenerator.writeBridgingVars(spec.objcSwiftBridgingHeaderName.get, spec.objcSwiftBridgingHeaderWriter.get) | ||
new SwiftBridgingHeaderGenerator(spec).generate(idl) | ||
} | ||
if (spec.yamlOutFolder.isDefined) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have a
_
separatingTextSort_Bridging_Header
andVersionNumber
so that it'sTextSort_Bridging_Header_VersionNumber
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I choosed the Xcode Convention. By calling a framework
MyLib
, the two variables are namedMyLibVersionNumber
andMyLibVersionString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the explanation.
In that case, would it make sense to name it
TextSortBridgingHeaderVersionNumber
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess yes 🤔