Skip to content

Commit 6e986dd

Browse files
committed
fixes for snap client integration
1 parent eedf683 commit 6e986dd

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

src/source/Main.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ object Main {
116116
var swiftIdentStyle = IdentStyle.swiftDefault
117117
var swiftxxOutFolder: Option[File] = None
118118
var swiftxxNamespace: String = "djinni_generated"
119+
var swiftxxIncludePrefix: String = ""
119120
var swiftxxBaseLibModule: String = "DjinniSupportCxx"
120121
var swiftxxClassIdentStyleOptional: Option[IdentConverter] = None
121122
var swiftxxFileIdentStyleOptional: Option[IdentConverter] = None
@@ -306,6 +307,8 @@ object Main {
306307
.text("Swift module name (default: \"Module\").")
307308
opt[File]("swiftxx-out").valueName("<out-folder>").foreach(x => swiftxxOutFolder = Some(x))
308309
.text("The output folder for private Swift/C++ interop files (Generator disabled if unspecified).")
310+
opt[String]("swiftxx-include-prefix").valueName("<prefix>").foreach(swiftxxIncludePrefix = _)
311+
.text("The prefix for #includes of Swift C++ header files.")
309312
opt[String]("swiftxx-include-cpp-prefix").valueName("<prefix>").foreach(swiftxxIncludeCppPrefix = _)
310313
.text("The prefix for #includes of the main header files from Swift C++ files.")
311314
opt[String]("swiftxx-base-lib-include-prefix").valueName("...").foreach(x => swiftxxBaseLibIncludePrefix = x)
@@ -522,6 +525,7 @@ object Main {
522525
swiftModule,
523526
swiftxxOutFolder,
524527
swiftxxNamespace,
528+
swiftxxIncludePrefix,
525529
swiftxxBaseLibModule,
526530
swiftxxClassIdentStyle,
527531
swiftxxFileIdentStyle,

src/source/SwiftGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
125125

126126
class SwiftRefs(name: String) {
127127
var swiftImports = mutable.TreeSet[String]()
128-
var privateImports = mutable.TreeSet[String]("DjinniSupport", "Foundation",spec.swiftxxBaseLibModule, spec.swiftModule, spec.swiftModule + "Cxx")
128+
var privateImports = mutable.TreeSet[String]("DjinniSupport", "Foundation", spec.swiftxxBaseLibModule, spec.swiftModule, spec.swiftModule + "Cxx")
129129
swiftImports.add("Foundation")
130130
def find(ty: TypeRef) { find(ty.resolved) }
131131
def find(tm: MExpr) {
@@ -326,7 +326,7 @@ class SwiftGenerator(spec: Spec) extends Generator(spec) {
326326
if (!staticMethods.isEmpty) {
327327
w.w(s"public class ${marshal.typename(ident, i)}_statics").braced {
328328
for (m <- staticMethods) {
329-
w.w(s"static func ${swiftMethodName(m.ident)}(")
329+
w.w(s"public static func ${swiftMethodName(m.ident)}(")
330330
if (m.params.nonEmpty) { w.w("_ ") }
331331
w.w(m.params.map(p => s"${idSwift.local(p.ident)}: ${marshal.fqParamType(p.ty)}").mkString(", "))
332332
w.w(s") throws -> ${marshal.fqReturnType(m.ret)}").braced {

src/source/SwiftMarshal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
102102
private def helperClass(tm: MExpr): String = helperName(tm) + helperTemplates(tm)
103103
def helperName(tm: MExpr): String = tm.base match {
104104
case d: MDef => helperClass(d.name)
105-
case e: MExtern => e.swift.translatorModule + "." + e.swift.translator
105+
case e: MExtern => e.swift.translator
106106
case o => o match {
107107
case p: MPrimitive => p.idlName match {
108108
case "i8" => "I8Marshaller"
@@ -128,7 +128,7 @@ class SwiftMarshal(spec: Spec) extends Marshal(spec) {
128128
case d: MDef => throw new AssertionError("unreachable")
129129
case e: MExtern => throw new AssertionError("unreachable")
130130
case p: MParam => throw new AssertionError("not applicable")
131-
case MVoid => "VoidMarshaller"
131+
case MVoid => "Void_Marshaller"
132132
}
133133
}
134134
private def helperTemplates(tm: MExpr): String = {

src/source/SwiftxxMarshal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class SwiftxxMarshal(spec: Spec) extends Marshal(spec) {
4747
case _ => List()
4848
}
4949

50-
def include(ident: String) = q(spec.swiftxxFileIdentStyle(ident) + "." + spec.cppHeaderExt)
50+
def include(ident: String) = q(spec.swiftxxIncludePrefix + spec.swiftxxFileIdentStyle(ident) + "." + spec.cppHeaderExt)
5151

5252
def resolveExtSwiftxxHdr(path: String) = {
53-
path.replaceAll("\\$", "");
53+
path.replaceAll("\\$", spec.swiftxxBaseLibIncludePrefix);
5454
}
5555

5656
def helperClass(name: String) = spec.swiftxxClassIdentStyle(name)

src/source/generator.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ package object generatorTools {
118118
swiftModule: String,
119119
swiftxxOutFolder: Option[File],
120120
swiftxxNamespace: String,
121+
swiftxxIncludePrefix: String,
121122
swiftxxBaseLibModule: String,
122123
swiftxxClassIdentStyle: IdentConverter,
123124
swiftxxFileIdentStyle: IdentConverter,

support-lib/swift/DJMarshal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public enum DateMarshaller: Marshaller {
113113
}
114114
}
115115

116-
public enum VoidMarshaller: Marshaller {
116+
public enum Void_Marshaller: Marshaller {
117117
public typealias SwiftType = Void
118118
static public func fromCpp(_ v: djinni.swift.AnyValue) -> SwiftType {
119119
return ()

test-suite/generated-src/swift/TestHelpers+Private.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ public class TestHelpers_statics {
207207
}
208208
static func voidAsyncMethod(_ f: DJFuture<Void>) throws -> DJFuture<Void> {
209209
var params = djinni.swift.ParameterList()
210-
params.addValue(FutureMarshaller<VoidMarshaller>.toCpp(f))
210+
params.addValue(FutureMarshaller<Void_Marshaller>.toCpp(f))
211211
var ret = djinni_generated.TestHelpers_voidAsyncMethod(&params)
212212
try handleCppErrors(&ret)
213-
return FutureMarshaller<VoidMarshaller>.fromCpp(ret)
213+
return FutureMarshaller<Void_Marshaller>.fromCpp(ret)
214214
}
215215
static func addOneIfPresent(_ f: DJFuture<Optional<Int32>>) throws -> DJFuture<Optional<Int32>> {
216216
var params = djinni.swift.ParameterList()

0 commit comments

Comments
 (0)