diff --git a/src/source/Main.scala b/src/source/Main.scala index 33fa6189..b7356bbb 100644 --- a/src/source/Main.scala +++ b/src/source/Main.scala @@ -116,6 +116,7 @@ object Main { var swiftIdentStyle = IdentStyle.swiftDefault var swiftxxOutFolder: Option[File] = None var swiftxxNamespace: String = "djinni_generated" + var swiftxxIncludePrefix: String = "" var swiftxxBaseLibModule: String = "DjinniSupportCxx" var swiftxxClassIdentStyleOptional: Option[IdentConverter] = None var swiftxxFileIdentStyleOptional: Option[IdentConverter] = None @@ -306,6 +307,8 @@ object Main { .text("Swift module name (default: \"Module\").") opt[File]("swiftxx-out").valueName("").foreach(x => swiftxxOutFolder = Some(x)) .text("The output folder for private Swift/C++ interop files (Generator disabled if unspecified).") + opt[String]("swiftxx-include-prefix").valueName("").foreach(swiftxxIncludePrefix = _) + .text("The prefix for #includes of Swift C++ header files.") opt[String]("swiftxx-include-cpp-prefix").valueName("").foreach(swiftxxIncludeCppPrefix = _) .text("The prefix for #includes of the main header files from Swift C++ files.") opt[String]("swiftxx-base-lib-include-prefix").valueName("...").foreach(x => swiftxxBaseLibIncludePrefix = x) @@ -522,6 +525,7 @@ object Main { swiftModule, swiftxxOutFolder, swiftxxNamespace, + swiftxxIncludePrefix, swiftxxBaseLibModule, swiftxxClassIdentStyle, swiftxxFileIdentStyle, diff --git a/src/source/SwiftGenerator.scala b/src/source/SwiftGenerator.scala index 9bb9212a..5c25c22b 100644 --- a/src/source/SwiftGenerator.scala +++ b/src/source/SwiftGenerator.scala @@ -125,7 +125,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) { class SwiftRefs(name: String) { var swiftImports = mutable.TreeSet[String]() - var privateImports = mutable.TreeSet[String]("DjinniSupport", "Foundation",spec.swiftxxBaseLibModule, spec.swiftModule, spec.swiftModule + "Cxx") + var privateImports = mutable.TreeSet[String]("DjinniSupport", "Foundation", spec.swiftxxBaseLibModule, spec.swiftModule, spec.swiftModule + "Cxx") swiftImports.add("Foundation") def find(ty: TypeRef) { find(ty.resolved) } def find(tm: MExpr) { @@ -326,7 +326,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) { if (!staticMethods.isEmpty) { w.w(s"public class ${marshal.typename(ident, i)}_statics").braced { for (m <- staticMethods) { - w.w(s"static func ${swiftMethodName(m.ident)}(") + w.w(s"public static func ${swiftMethodName(m.ident)}(") if (m.params.nonEmpty) { w.w("_ ") } w.w(m.params.map(p => s"${idSwift.local(p.ident)}: ${marshal.fqParamType(p.ty)}").mkString(", ")) w.w(s") throws -> ${marshal.fqReturnType(m.ret)}").braced { diff --git a/src/source/SwiftMarshal.scala b/src/source/SwiftMarshal.scala index 5fb91330..c4fcc76d 100644 --- a/src/source/SwiftMarshal.scala +++ b/src/source/SwiftMarshal.scala @@ -102,7 +102,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) { private def helperClass(tm: MExpr): String = helperName(tm) + helperTemplates(tm) def helperName(tm: MExpr): String = tm.base match { case d: MDef => helperClass(d.name) - case e: MExtern => e.swift.translatorModule + "." + e.swift.translator + case e: MExtern => e.swift.translator case o => o match { case p: MPrimitive => p.idlName match { case "i8" => "I8Marshaller" @@ -128,7 +128,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) { case d: MDef => throw new AssertionError("unreachable") case e: MExtern => throw new AssertionError("unreachable") case p: MParam => throw new AssertionError("not applicable") - case MVoid => "VoidMarshaller" + case MVoid => "Void_Marshaller" } } private def helperTemplates(tm: MExpr): String = { diff --git a/src/source/SwiftxxMarshal.scala b/src/source/SwiftxxMarshal.scala index 66c3f3e0..f2d32672 100644 --- a/src/source/SwiftxxMarshal.scala +++ b/src/source/SwiftxxMarshal.scala @@ -47,10 +47,10 @@ class SwiftxxMarshal(spec: Spec) extends Marshal(spec) { case _ => List() } - def include(ident: String) = q(spec.swiftxxFileIdentStyle(ident) + "." + spec.cppHeaderExt) + def include(ident: String) = q(spec.swiftxxIncludePrefix + spec.swiftxxFileIdentStyle(ident) + "." + spec.cppHeaderExt) def resolveExtSwiftxxHdr(path: String) = { - path.replaceAll("\\$", ""); + path.replaceAll("\\$", spec.swiftxxBaseLibIncludePrefix); } def helperClass(name: String) = spec.swiftxxClassIdentStyle(name) diff --git a/src/source/generator.scala b/src/source/generator.scala index d64c4641..54844a27 100644 --- a/src/source/generator.scala +++ b/src/source/generator.scala @@ -118,6 +118,7 @@ package object generatorTools { swiftModule: String, swiftxxOutFolder: Option[File], swiftxxNamespace: String, + swiftxxIncludePrefix: String, swiftxxBaseLibModule: String, swiftxxClassIdentStyle: IdentConverter, swiftxxFileIdentStyle: IdentConverter, diff --git a/support-lib/swift/DJMarshal.swift b/support-lib/swift/DJMarshal.swift index 905f097d..9dcf1f14 100644 --- a/support-lib/swift/DJMarshal.swift +++ b/support-lib/swift/DJMarshal.swift @@ -113,7 +113,7 @@ public enum DateMarshaller: Marshaller { } } -public enum VoidMarshaller: Marshaller { +public enum Void_Marshaller: Marshaller { public typealias SwiftType = Void static public func fromCpp(_ v: djinni.swift.AnyValue) -> SwiftType { return () diff --git a/test-suite/generated-src/swift/TestHelpers+Private.swift b/test-suite/generated-src/swift/TestHelpers+Private.swift index 855aa9b4..da7c0a3c 100644 --- a/test-suite/generated-src/swift/TestHelpers+Private.swift +++ b/test-suite/generated-src/swift/TestHelpers+Private.swift @@ -207,10 +207,10 @@ public class TestHelpers_statics { } static func voidAsyncMethod(_ f: DJFuture) throws -> DJFuture { var params = djinni.swift.ParameterList() - params.addValue(FutureMarshaller.toCpp(f)) + params.addValue(FutureMarshaller.toCpp(f)) var ret = djinni_generated.TestHelpers_voidAsyncMethod(¶ms) try handleCppErrors(&ret) - return FutureMarshaller.fromCpp(ret) + return FutureMarshaller.fromCpp(ret) } static func addOneIfPresent(_ f: DJFuture>) throws -> DJFuture> { var params = djinni.swift.ParameterList()