Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Generate an XCode like bridging header. #342

Merged
merged 4 commits into from Mar 2, 2018
Merged

Generate an XCode like bridging header. #342

merged 4 commits into from Mar 2, 2018

Conversation

yageek
Copy link
Contributor

@yageek yageek commented Dec 7, 2017

Generates also the version number and name variable inside the bridging header.

Generates also the version number and name variable.
@artwyman
Copy link
Contributor

I think Xianwen should be the primary reviewer here since he has more experience with Swift. Two bits of housekeeping though:

  1. Can you please re-generate the code for the example and test-suite so they're in-sync, and reviewers can see the effects of your change?
  2. Before this can merge you need to sign the CLA here: https://opensource.dropbox.com/cla/

@yageek
Copy link
Contributor Author

yageek commented Dec 12, 2017

I think I have already signed it two times. Should we sign it for every PR?

@artwyman
Copy link
Contributor

Oops, sorry. I think it was my mistake searching for your userid. It's manual and error-prone since our bot broke.
I can confirm now that you've signed the CLA, so you're all set.

//! Project version number for TextSort_Bridging_Header.
FOUNDATION_EXPORT double TextSort_Bridging_HeaderVersionNumber;

//! Project version string forTextSort_Bridging_Header.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space between "for" and "TextSort_Bridging_Header" here.

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")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add a space after for.

@@ -346,6 +346,7 @@ object Main {
objcppNamespace,
objcBaseLibIncludePrefix,
objcSwiftBridgingHeaderWriter,
objcSwiftBridgingHeader,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be objcSwiftBridgingHeaderName as you're using spec.objcSwiftBridgingHeaderName.get below.

Actually, I'd love to see this config used in Unit Test for verification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable is declared as objcSwiftBridgingHeader inside main.scala.
Do you want me to change the name of the property in generator.scala from objcSwiftBridgingHeaderName to objcSwiftBridgingHeader instead?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, it's just the variable name here while objcSwiftBridgingHeaderName is the parameter, sorry I got confused.
Yes, I'd prefer to have the same name since this is the case for all the other parameters.

@@ -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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with the declaration objcSwiftBridgingHeader above.

#import <Foundation/Foundation.h>

//! Project version number for TextSort_Bridging_Header.
FOUNDATION_EXPORT double TextSort_Bridging_HeaderVersionNumber;
Copy link

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 _ separating TextSort_Bridging_Header and VersionNumber so that it's TextSort_Bridging_Header_VersionNumber.

Copy link
Contributor Author

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 named MyLibVersionNumber and MyLibVersionString

Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess yes 🤔

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")
Copy link

Choose a reason for hiding this comment

The 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: "..." + varPrefix +"...", it's not used as a prefix.

Although it happens to be a prefix in the case of VersionNumber, I'd still prefer to remove the prefix in the var name, to make it something like bridgingHeaderVarName.

@@ -38,8 +38,23 @@ class SwiftBridgingHeaderGenerator(spec: Spec) extends Generator(spec) {
}

object SwiftBridgingHeaderGenerator {
def writeAutogenerationWarning(writer: Writer) {

val bridgingVarPrefix = (s: String) => s.split('-').mkString("_")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment below, I'd prefer to remove the Prefix here, to make it something like bridgingHeaderName, since it doesn't have to be used as a prefix. (Although it's not a great name either, as - is replaced by _ and this method name I suggest wouldn't make it obvious.)

@xianwen xianwen assigned yageek and unassigned xianwen Jan 4, 2018
@xianwen
Copy link

xianwen commented Mar 2, 2018

Thanks for your updates, I'll merge it after testing.

@xianwen xianwen merged commit 9463fa9 into dropbox:master Mar 2, 2018
danielkaldheim pushed a commit to danielkaldheim/djinni that referenced this pull request Mar 27, 2018
* Generate an XCode like bridging header.

Generates also the version number and name variable.

* Add new generated headers.

* Changes naming accorging to comments.

* Update generated variable names.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants