Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
djinni
Commits
69ebe88c
Commit
69ebe88c
authored
Apr 06, 2017
by
Andrew Twyman
Committed by
GitHub
Apr 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #301 from 4brunu/ObjcSwiftBridgingHEader
Generate bridging header for Swift
parents
0c1aa241
66f6d9b4
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
187 additions
and
24 deletions
+187
-24
example/generated-src/objc/TextSort-Bridging-Header.h
example/generated-src/objc/TextSort-Bridging-Header.h
+7
-0
example/handwritten-src/objc/TXSViewController.m
example/handwritten-src/objc/TXSViewController.m
+22
-2
example/handwritten-src/swift/TXSTextboxListenerDebugableImpl.swift
...ndwritten-src/swift/TXSTextboxListenerDebugableImpl.swift
+21
-0
example/objc/TextSort.xcodeproj/project.pbxproj
example/objc/TextSort.xcodeproj/project.pbxproj
+26
-0
example/objc/TextSort/Base.lproj/Main_iPhone.storyboard
example/objc/TextSort/Base.lproj/Main_iPhone.storyboard
+41
-18
example/run_djinni.sh
example/run_djinni.sh
+3
-2
src/.idea/runConfigurations/djinni_Main__Example_.xml
src/.idea/runConfigurations/djinni_Main__Example_.xml
+2
-2
src/source/Main.scala
src/source/Main.scala
+15
-0
src/source/SwiftBridgingHeaderGenerator.scala
src/source/SwiftBridgingHeaderGenerator.scala
+45
-0
src/source/generator.scala
src/source/generator.scala
+5
-0
No files found.
example/generated-src/objc/TextSort-Bridging-Header.h
0 → 100644
View file @
69ebe88c
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni
#import "TXSItemList.h"
#import "TXSSortOrder.h"
#import "TXSSortItems.h"
#import "TXSTextboxListener.h"
example/handwritten-src/objc/TXSViewController.m
View file @
69ebe88c
#import "TXSItemList.h"
#import "TXSSortItems.h"
#import "TextSort-Swift.h"
#import "TXSTextboxListenerImpl.h"
#import "TXSViewController.h"
#import "TXSTextboxListener.h"
...
...
@@ -12,6 +13,8 @@
@property
(
nonatomic
)
IBOutlet
UIButton
*
button
;
@property
(
nonatomic
)
IBOutlet
UISwitch
*
switchDebugMode
;
@end
@implementation
TXSViewController
{
...
...
@@ -33,11 +36,28 @@
action:
@selector
(
dismissKeyboard
)];
[
self
.
view
addGestureRecognizer
:
tap
];
[
self
createSorter
];
}
-
(
void
)
createSorter
{
if
(
_switchDebugMode
.
isOn
)
{
// Create the Swift TXSTextboxListener
_textboxListener
=
[[
TXSTextboxListenerDebugableImpl
alloc
]
initWithUITextView
:
self
.
textView
];
}
else
{
// Create the Objective-C TXSTextboxListener
_textboxListener
=
[[
TXSTextboxListenerImpl
alloc
]
initWithUITextView
:
self
.
textView
];
}
_sortItemInterface
=
[
TXSSortItems
createWithListener
:
_textboxListener
];
}
-
(
IBAction
)
toggleDebugMode
:(
id
)
sender
{
[
self
createSorter
];
}
-
(
IBAction
)
sort
:(
id
)
sender
{
[
self
sortWithOrder
:
TXSSortOrderAscending
];
...
...
example/handwritten-src/swift/TXSTextboxListenerDebugableImpl.swift
0 → 100644
View file @
69ebe88c
import
UIKit
final
class
TXSTextboxListenerDebugableImpl
:
NSObject
,
TXSTextboxListener
{
private
var
textView
:
UITextView
@available
(
*
,
unavailable
)
override
init
()
{
fatalError
(
"Unsupported"
)
}
@objc
(
initWithUITextView
:)
init
(
textView
:
UITextView
)
{
self
.
textView
=
textView
}
func
update
(
_
items
:
TXSItemList
)
{
let
string
=
items
.
items
.
joined
(
separator
:
"
\n
"
)
print
(
"TXSTextboxListenerDebugableImpl -> update
\n\(
string
)
"
)
textView
.
text
=
string
}
}
example/objc/TextSort.xcodeproj/project.pbxproj
View file @
69ebe88c
...
...
@@ -17,6 +17,7 @@
65D7FDFB19AD0CDF0038F82F
/* TXSAppDelegate.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65D7FDF519AD0CDF0038F82F
/* TXSAppDelegate.m */
;
};
65D7FDFC19AD0CDF0038F82F
/* TXSTextboxListenerImpl.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65D7FDF719AD0CDF0038F82F
/* TXSTextboxListenerImpl.m */
;
};
65D7FDFD19AD0CDF0038F82F
/* TXSViewController.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
65D7FDF919AD0CDF0038F82F
/* TXSViewController.m */
;
};
A546A26E1E72FBAF004A8BBD
/* TXSTextboxListenerDebugableImpl.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
A546A26D1E72FBAF004A8BBD
/* TXSTextboxListenerDebugableImpl.swift */
;
};
B003051919B70561008E1F67
/* libdjinni_objc.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B003051819B70561008E1F67
/* libdjinni_objc.a */
;
};
B097B6BC19B1C07E0047653A
/* libtextsort_objc.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
B097B6BB19B1C07E0047653A
/* libtextsort_objc.a */
;
};
/* End PBXBuildFile section */
...
...
@@ -38,6 +39,7 @@
65D7FDF719AD0CDF0038F82F
/* TXSTextboxListenerImpl.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
TXSTextboxListenerImpl.m
;
sourceTree
=
"<group>"
;
};
65D7FDF819AD0CDF0038F82F
/* TXSViewController.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
TXSViewController.h
;
sourceTree
=
"<group>"
;
};
65D7FDF919AD0CDF0038F82F
/* TXSViewController.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
TXSViewController.m
;
sourceTree
=
"<group>"
;
};
A546A26D1E72FBAF004A8BBD
/* TXSTextboxListenerDebugableImpl.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
name
=
TXSTextboxListenerDebugableImpl.swift
;
path
=
"../handwritten-src/swift/TXSTextboxListenerDebugableImpl.swift"
;
sourceTree
=
"<group>"
;
};
B003051819B70561008E1F67
/* libdjinni_objc.a */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.ar
;
name
=
libdjinni_objc.a
;
path
=
"../../support-lib/build/Debug-iphoneos/libdjinni_objc.a"
;
sourceTree
=
"<group>"
;
};
B097B6BB19B1C07E0047653A
/* libtextsort_objc.a */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.ar
;
name
=
libtextsort_objc.a
;
path
=
"../../build/Debug-iphoneos/libtextsort_objc.a"
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -61,6 +63,7 @@
65834DD419AC599E0061AD3F
=
{
isa
=
PBXGroup
;
children
=
(
A546A26A1E72F967004A8BBD
/* handwritten-swift */
,
65D7FDF219AD0C730038F82F
/* handwritten-objc */
,
65834DE619AC599E0061AD3F
/* TextSort */
,
65834DDF19AC599E0061AD3F
/* Frameworks */
,
...
...
@@ -123,6 +126,14 @@
path
=
"../handwritten-src/objc"
;
sourceTree
=
"<group>"
;
};
A546A26A1E72F967004A8BBD
/* handwritten-swift */
=
{
isa
=
PBXGroup
;
children
=
(
A546A26D1E72FBAF004A8BBD
/* TXSTextboxListenerDebugableImpl.swift */
,
);
name
=
"handwritten-swift"
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -152,6 +163,11 @@
CLASSPREFIX
=
TXS
;
LastUpgradeCheck
=
0820
;
ORGANIZATIONNAME
=
"Dropbox, Inc."
;
TargetAttributes
=
{
65834DDC19AC599E0061AD3F
=
{
LastSwiftMigration
=
0820
;
};
};
};
buildConfigurationList
=
65834DD819AC599E0061AD3F
/* Build configuration list for PBXProject "TextSort" */
;
compatibilityVersion
=
"Xcode 3.2"
;
...
...
@@ -192,6 +208,7 @@
65D7FDFC19AD0CDF0038F82F
/* TXSTextboxListenerImpl.m in Sources */
,
65D7FDFB19AD0CDF0038F82F
/* TXSAppDelegate.m in Sources */
,
65D7FDFD19AD0CDF0038F82F
/* TXSViewController.m in Sources */
,
A546A26E1E72FBAF004A8BBD
/* TXSTextboxListenerDebugableImpl.swift in Sources */
,
65D7FDFA19AD0CDF0038F82F
/* main.mm in Sources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
@@ -308,12 +325,17 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME
=
LaunchImage
;
CLANG_ENABLE_MODULES
=
YES
;
GCC_PRECOMPILE_PREFIX_HEADER
=
YES
;
GCC_PREFIX_HEADER
=
"TextSort/TextSort-Prefix.pch"
;
INFOPLIST_FILE
=
"TextSort/TextSort-Info.plist"
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
LIBRARY_SEARCH_PATHS
=
"$(inherited)"
;
PRODUCT_BUNDLE_IDENTIFIER
=
"Dropbox.${PRODUCT_NAME:rfc1034identifier}"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"../generated-src/objc/TextSort-Bridging-Header.h"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
3.0
;
TARGETED_DEVICE_FAMILY
=
1
;
WRAPPER_EXTENSION
=
app
;
};
...
...
@@ -324,12 +346,16 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME
=
LaunchImage
;
CLANG_ENABLE_MODULES
=
YES
;
GCC_PRECOMPILE_PREFIX_HEADER
=
YES
;
GCC_PREFIX_HEADER
=
"TextSort/TextSort-Prefix.pch"
;
INFOPLIST_FILE
=
"TextSort/TextSort-Info.plist"
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
LIBRARY_SEARCH_PATHS
=
"$(inherited)"
;
PRODUCT_BUNDLE_IDENTIFIER
=
"Dropbox.${PRODUCT_NAME:rfc1034identifier}"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_OBJC_BRIDGING_HEADER
=
"../generated-src/objc/TextSort-Bridging-Header.h"
;
SWIFT_VERSION
=
3.0
;
TARGETED_DEVICE_FAMILY
=
1
;
WRAPPER_EXTENSION
=
app
;
};
...
...
example/objc/TextSort/Base.lproj/Main_iPhone.storyboard
View file @
69ebe88c
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"7531"
systemVersion=
"14D136"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
initialViewController=
"vXZ-lx-hvc"
>
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"12118"
systemVersion=
"16E195"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
colorMatched=
"YES"
initialViewController=
"vXZ-lx-hvc"
>
<device
id=
"retina4_7"
orientation=
"portrait"
>
<adaptation
id=
"fullscreen"
/>
</device>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"
7520
"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"
12086
"
/>
<capability
name=
"Constraints to layout margins"
minToolsVersion=
"6.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<scenes>
<!--View Controller-->
...
...
@@ -15,52 +19,69 @@
<viewControllerLayoutGuide
type=
"bottom"
id=
"2fi-mo-0CV"
/>
</layoutGuides>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"kh9-bI-dsS"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"3
20"
height=
"568
"
/>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"3
75"
height=
"667
"
/>
<autoresizingMask
key=
"autoresizingMask"
flexibleMaxX=
"YES"
flexibleMaxY=
"YES"
/>
<subviews>
<textView
clipsSubviews=
"YES"
multipleTouchEnabled=
"YES"
contentMode=
"scaleToFill"
text=
"Type the lines to sort"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"GOB-Ok-Z2R"
>
<rect
key=
"frame"
x=
"16"
y=
"28"
width=
"
288"
height=
"482
"
/>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"c
alibrated
RGB"
/>
<rect
key=
"frame"
x=
"16"
y=
"28"
width=
"
343"
height=
"531
"
/>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"c
ustom"
customColorSpace=
"s
RGB"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<textInputTraits
key=
"textInputTraits"
autocapitalizationType=
"sentences"
/>
</textView>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
misplaced=
"YES"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"A93-rB-AZ4"
>
<rect
key=
"frame"
x=
"
54"
y=
"518"
width=
"6
0"
height=
"30"
/>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"A93-rB-AZ4"
>
<rect
key=
"frame"
x=
"
105.5"
y=
"567"
width=
"3
0"
height=
"30"
/>
<state
key=
"normal"
title=
"Sort"
>
<color
key=
"titleShadowColor"
white=
"0.5"
alpha=
"1"
colorSpace=
"calibratedWhite
"
/>
<color
key=
"titleShadowColor"
red=
"0.5"
green=
"0.5"
blue=
"0.5"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB
"
/>
</state>
<connections>
<action
selector=
"sort:"
destination=
"vXZ-lx-hvc"
eventType=
"touchUpInside"
id=
"JmD-7I-e8t"
/>
</connections>
</button>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
misplaced=
"YES"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"81n-2H-7fH"
>
<rect
key=
"frame"
x=
"1
04"
y=
"518"
width=
"113
"
height=
"30"
/>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"81n-2H-7fH"
>
<rect
key=
"frame"
x=
"1
43.5"
y=
"567"
width=
"88
"
height=
"30"
/>
<state
key=
"normal"
title=
"Reverse Sort"
>
<color
key=
"titleShadowColor"
white=
"0.5"
alpha=
"1"
colorSpace=
"calibratedWhite
"
/>
<color
key=
"titleShadowColor"
red=
"0.5"
green=
"0.5"
blue=
"0.5"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB
"
/>
</state>
<connections>
<action
selector=
"reverseSort:"
destination=
"vXZ-lx-hvc"
eventType=
"touchUpInside"
id=
"3ph-FD-T7F"
/>
</connections>
</button>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
misplaced=
"YES"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"cv7-dA-P8a"
>
<rect
key=
"frame"
x=
"2
25"
y=
"518"
width=
"60
"
height=
"30"
/>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"roundedRect"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"cv7-dA-P8a"
>
<rect
key=
"frame"
x=
"2
39.5"
y=
"567"
width=
"57
"
height=
"30"
/>
<state
key=
"normal"
title=
"Random"
>
<color
key=
"titleShadowColor"
white=
"0.5"
alpha=
"1"
colorSpace=
"calibratedWhite
"
/>
<color
key=
"titleShadowColor"
red=
"0.5"
green=
"0.5"
blue=
"0.5"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB
"
/>
</state>
<connections>
<action
selector=
"randomSort:"
destination=
"vXZ-lx-hvc"
eventType=
"touchUpInside"
id=
"Qm2-PQ-ghk"
/>
</connections>
</button>
<switch
opaque=
"NO"
contentMode=
"scaleToFill"
horizontalHuggingPriority=
"750"
verticalHuggingPriority=
"750"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"DNu-UL-kyQ"
>
<rect
key=
"frame"
x=
"16"
y=
"612"
width=
"51"
height=
"31"
/>
<connections>
<action
selector=
"toggleDebugMode:"
destination=
"vXZ-lx-hvc"
eventType=
"valueChanged"
id=
"saA-Gv-pMA"
/>
</connections>
</switch>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Debug mode"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"GQQ-Bh-tdD"
>
<rect
key=
"frame"
x=
"73"
y=
"617"
width=
"286"
height=
"21"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"17"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
</subviews>
<color
key=
"backgroundColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"calibratedWhite
"
/>
<color
key=
"backgroundColor"
red=
"1"
green=
"1"
blue=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB
"
/>
<constraints>
<constraint
firstItem=
"cv7-dA-P8a"
firstAttribute=
"leading"
secondItem=
"81n-2H-7fH"
secondAttribute=
"trailing"
constant=
"8"
id=
"6k6-kS-Uv4"
/>
<constraint
firstItem=
"81n-2H-7fH"
firstAttribute=
"baseline"
secondItem=
"cv7-dA-P8a"
secondAttribute=
"baseline"
id=
"EDF-c5-6UY"
/>
<constraint
firstItem=
"GOB-Ok-Z2R"
firstAttribute=
"trailing"
secondItem=
"kh9-bI-dsS"
secondAttribute=
"trailingMargin"
id=
"FcW-gp-TKr"
/>
<constraint
firstItem=
"cv7-dA-P8a"
firstAttribute=
"top"
secondItem=
"GOB-Ok-Z2R"
secondAttribute=
"bottom"
constant=
"8"
id=
"LWK-fr-cJv"
/>
<constraint
firstItem=
"81n-2H-7fH"
firstAttribute=
"leading"
secondItem=
"A93-rB-AZ4"
secondAttribute=
"trailing"
constant=
"8"
id=
"M4F-4D-BXj"
/>
<constraint
firstItem=
"2fi-mo-0CV"
firstAttribute=
"top"
secondItem=
"81n-2H-7fH"
secondAttribute=
"bottom"
constant=
"20"
id=
"Skf-gJ-Pvn"
/>
<constraint
firstItem=
"DNu-UL-kyQ"
firstAttribute=
"leading"
secondItem=
"kh9-bI-dsS"
secondAttribute=
"leadingMargin"
id=
"O7c-MW-i3e"
/>
<constraint
firstItem=
"DNu-UL-kyQ"
firstAttribute=
"centerY"
secondItem=
"GQQ-Bh-tdD"
secondAttribute=
"centerY"
id=
"OmV-xh-MjX"
/>
<constraint
firstItem=
"GQQ-Bh-tdD"
firstAttribute=
"top"
secondItem=
"81n-2H-7fH"
secondAttribute=
"bottom"
constant=
"20"
id=
"P8h-HO-l5l"
/>
<constraint
firstItem=
"2fi-mo-0CV"
firstAttribute=
"top"
secondItem=
"81n-2H-7fH"
secondAttribute=
"bottom"
constant=
"70"
id=
"Skf-gJ-Pvn"
/>
<constraint
firstAttribute=
"centerX"
secondItem=
"81n-2H-7fH"
secondAttribute=
"centerX"
id=
"dPr-yc-eNh"
/>
<constraint
firstItem=
"GQQ-Bh-tdD"
firstAttribute=
"leading"
secondItem=
"DNu-UL-kyQ"
secondAttribute=
"trailing"
constant=
"8"
id=
"jez-lS-j5y"
/>
<constraint
firstAttribute=
"trailingMargin"
secondItem=
"GQQ-Bh-tdD"
secondAttribute=
"trailing"
id=
"pDH-RO-DoJ"
/>
<constraint
firstItem=
"GOB-Ok-Z2R"
firstAttribute=
"top"
secondItem=
"jyV-Pf-zRb"
secondAttribute=
"bottom"
constant=
"8"
id=
"r9O-jI-RXe"
/>
<constraint
firstItem=
"81n-2H-7fH"
firstAttribute=
"baseline"
secondItem=
"A93-rB-AZ4"
secondAttribute=
"baseline"
id=
"sDL-eI-t03"
/>
<constraint
firstItem=
"GOB-Ok-Z2R"
firstAttribute=
"leading"
secondItem=
"kh9-bI-dsS"
secondAttribute=
"leadingMargin"
id=
"ykx-tI-cFm"
/>
...
...
@@ -69,16 +90,18 @@
<navigationItem
key=
"navigationItem"
id=
"LTz-Tk-BIg"
/>
<connections>
<outlet
property=
"button"
destination=
"A93-rB-AZ4"
id=
"WYY-v8-55y"
/>
<outlet
property=
"switchDebugMode"
destination=
"DNu-UL-kyQ"
id=
"zWL-2v-leX"
/>
<outlet
property=
"textView"
destination=
"GOB-Ok-Z2R"
id=
"fKy-K6-TxA"
/>
</connections>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"x5A-6p-PRh"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"26.5"
y=
"34.5"
/>
</scene>
</scenes>
<simulatedMetricsContainer
key=
"defaultSimulatedMetrics"
>
<simulatedStatusBarMetrics
key=
"statusBar"
/>
<simulatedOrientationMetrics
key=
"orientation"
/>
<simulatedScreenMetrics
key=
"destination"
type=
"retina4"
/>
<simulatedScreenMetrics
key=
"destination"
type=
"retina4
_7.fullscreen
"
/>
</simulatedMetricsContainer>
</document>
example/run_djinni.sh
View file @
69ebe88c
...
...
@@ -69,6 +69,7 @@ fi
--objc-out
"
$temp_out
/objc"
\
--objcpp-out
"
$temp_out
/objc"
\
--objc-type-prefix
TXS
\
--objc-swift-bridging-header
"TextSort-Bridging-Header"
\
\
--idl
"
$in
"
...
...
src/.idea/runConfigurations/djinni_Main__Example_.xml
View file @
69ebe88c
...
...
@@ -8,10 +8,10 @@
</extension>
<option
name=
"MAIN_CLASS_NAME"
value=
"djinni.Main"
/>
<option
name=
"VM_PARAMETERS"
value=
""
/>
<option
name=
"PROGRAM_PARAMETERS"
value=
"--java-out djinni-output-temp/java --java-package com.dropbox.textsort --ident-java-field mFooBar --cpp-out djinni-output-temp/cpp --cpp-namespace textsort --ident-cpp-enum-type foo_bar --jni-out djinni-output-temp/jni --ident-jni-class NativeFooBar --ident-jni-file NativeFooBar --objc-out djinni-output-temp/objc --objcpp-out djinni-output-temp/objc --objc-type-prefix TXS --idl example.djinni"
/>
<option
name=
"PROGRAM_PARAMETERS"
value=
"--java-out djinni-output-temp/java --java-package com.dropbox.textsort --ident-java-field mFooBar --cpp-out djinni-output-temp/cpp --cpp-namespace textsort --ident-cpp-enum-type foo_bar --jni-out djinni-output-temp/jni --ident-jni-class NativeFooBar --ident-jni-file NativeFooBar --objc-out djinni-output-temp/objc --objcpp-out djinni-output-temp/objc --objc-type-prefix TXS --
objc-swift-bridging-header TextSort-Bridging-Header --
idl example.djinni"
/>
<option
name=
"WORKING_DIRECTORY"
value=
"file://$PROJECT_DIR$/../example"
/>
<option
name=
"ALTERNATIVE_JRE_PATH_ENABLED"
value=
"false"
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
value=
""
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
/>
<option
name=
"ENABLE_SWING_INSPECTOR"
value=
"false"
/>
<option
name=
"ENV_VARIABLES"
/>
<option
name=
"PASS_PARENT_ENVS"
value=
"true"
/>
...
...
src/source/Main.scala
View file @
69ebe88c
...
...
@@ -68,6 +68,7 @@ object Main {
var
objcTypePrefix
:
String
=
""
var
objcIncludePrefix
:
String
=
""
var
objcExtendedRecordIncludePrefix
:
String
=
""
var
objcSwiftBridgingHeader
:
Option
[
String
]
=
None
var
objcppIncludePrefix
:
String
=
""
var
objcppIncludeCppPrefix
:
String
=
""
var
objcppIncludeObjcPrefixOptional
:
Option
[
String
]
=
None
...
...
@@ -164,6 +165,8 @@ object Main {
.
text
(
"The prefix for Objective-C data types (usually two or three letters)"
)
opt
[
String
](
"objc-include-prefix"
).
valueName
(
"<prefix>"
).
foreach
(
objcIncludePrefix
=
_
)
.
text
(
"The prefix for #import of header files from Objective-C files."
)
opt
[
String
](
"objc-swift-bridging-header"
).
valueName
(
"<name>"
).
foreach
(
x
=>
objcSwiftBridgingHeader
=
Some
(
x
))
.
text
(
"The name of Objective-C Bridging Header used in XCode's Swift projects."
)
note
(
""
)
opt
[
File
](
"objcpp-out"
).
valueName
(
"<out-folder>"
).
foreach
(
x
=>
objcppOutFolder
=
Some
(
x
))
.
text
(
"The output folder for private Objective-C++ files (Generator disabled if unspecified)."
)
...
...
@@ -282,6 +285,14 @@ object Main {
}
else
{
None
}
val
objcSwiftBridgingHeaderWriter
=
if
(
objcSwiftBridgingHeader
.
isDefined
&&
objcOutFolder
.
isDefined
)
{
val
objcSwiftBridgingHeaderFile
=
new
File
(
objcOutFolder
.
get
.
getPath
,
objcSwiftBridgingHeader
.
get
+
".h"
)
if
(
objcSwiftBridgingHeaderFile
.
getParentFile
!=
null
)
createFolder
(
"output file list"
,
objcSwiftBridgingHeaderFile
.
getParentFile
)
Some
(
new
BufferedWriter
(
new
FileWriter
(
objcSwiftBridgingHeaderFile
)))
}
else
{
None
}
val
outSpec
=
Spec
(
javaOutFolder
,
...
...
@@ -330,6 +341,7 @@ object Main {
objcppIncludeObjcPrefix
,
objcppNamespace
,
objcBaseLibIncludePrefix
,
objcSwiftBridgingHeaderWriter
,
outFileListWriter
,
skipGeneration
,
yamlOutFolder
,
...
...
@@ -345,6 +357,9 @@ object Main {
if
(
outFileListWriter
.
isDefined
)
{
outFileListWriter
.
get
.
close
()
}
if
(
objcSwiftBridgingHeaderWriter
.
isDefined
)
{
objcSwiftBridgingHeaderWriter
.
get
.
close
()
}
}
}
}
src/source/SwiftBridgingHeaderGenerator.scala
0 → 100644
View file @
69ebe88c
/**
* Copyright 2016 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
djinni
import
java.io._
import
djinni.ast._
import
djinni.generatorTools._
class
SwiftBridgingHeaderGenerator
(
spec
:
Spec
)
extends
Generator
(
spec
)
{
val
marshal
=
new
ObjcMarshal
(
spec
)
override
def
generateEnum
(
origin
:
String
,
ident
:
Ident
,
doc
:
Doc
,
e
:
Enum
)
{
spec
.
objcSwiftBridgingHeaderWriter
.
get
.
write
(
"#import \""
+
marshal
.
headerName
(
ident
)
+
"\"\n"
)
}
override
def
generateInterface
(
origin
:
String
,
ident
:
Ident
,
doc
:
Doc
,
typeParams
:
Seq
[
TypeParam
],
i
:
Interface
)
{
spec
.
objcSwiftBridgingHeaderWriter
.
get
.
write
(
"#import \""
+
marshal
.
headerName
(
ident
)
+
"\"\n"
)
}
override
def
generateRecord
(
origin
:
String
,
ident
:
Ident
,
doc
:
Doc
,
params
:
Seq
[
TypeParam
],
r
:
Record
)
{
spec
.
objcSwiftBridgingHeaderWriter
.
get
.
write
(
"#import \""
+
marshal
.
headerName
(
ident
)
+
"\"\n"
)
}
}
object
SwiftBridgingHeaderGenerator
{
def
writeAutogenerationWarning
(
writer
:
Writer
)
{
writer
.
write
(
"// AUTOGENERATED FILE - DO NOT MODIFY!\n"
)
writer
.
write
(
"// This file generated by Djinni\n\n"
)
}
}
\ No newline at end of file
src/source/generator.scala
View file @
69ebe88c
...
...
@@ -74,6 +74,7 @@ package object generatorTools {
objcppIncludeObjcPrefix
:
String
,
objcppNamespace
:
String
,
objcBaseLibIncludePrefix
:
String
,
objcSwiftBridgingHeaderWriter
:
Option
[
Writer
],
outFileListWriter
:
Option
[
Writer
],
skipGeneration
:
Boolean
,
yamlOutFolder
:
Option
[
File
],
...
...
@@ -213,6 +214,10 @@ package object generatorTools {
}
new
ObjcppGenerator
(
spec
).
generate
(
idl
)
}
if
(
spec
.
objcSwiftBridgingHeaderWriter
.
isDefined
)
{
SwiftBridgingHeaderGenerator
.
writeAutogenerationWarning
(
spec
.
objcSwiftBridgingHeaderWriter
.
get
)
new
SwiftBridgingHeaderGenerator
(
spec
).
generate
(
idl
)
}
if
(
spec
.
yamlOutFolder
.
isDefined
)
{
if
(!
spec
.
skipGeneration
)
{
createFolder
(
"YAML"
,
spec
.
yamlOutFolder
.
get
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment