Neil Hodgson
2014-06-04 00:19:32 UTC
Swift is a new language from Apple that will be available with Xcode 6. Looks to me like its a decent current language if a little unambitious. While I don't think it is worthwhile using Swift in Scintilla, it should be possible to use Scintilla from Swift.
Swift can use Objective C and C code fairly easily but, as the interop documentation says: "You cannot import C++ code directly into Swift. Instead, create an Objective-C or C wrapper for C++ code.". Unfortunately, Scintilla exposes some C++ features in the main ScintillaView.h header which causes difficulty for the bridging importer. Most problematically, Scintilla on Cocoa has always wrapped everything in namespace "Scintilla" and this errors out.
Lesser issues include problems with bare type names - it seems to want typedefs like old style C. InfoBarCommunicator.h can be made compliant with the 'modern' form of enumeration using NS_ENUM which should be OK to change now.
< namespace Scintilla {
40,41c39,40
< class ScintillaCocoa;
< }
---
< - (void)notification: (Scintilla::SCNotification*)notification;
---
< Scintilla::ScintillaCocoa* mBackend;
---
< @property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend;
---
< - (void) notification: (Scintilla::SCNotification*) notification;
---
< - (void) registerNotifyCallback: (intptr_t) windowid value: (Scintilla::SciNotifyFunc) callback;
---
< enum NotificationType {
---
https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html
Neil
Swift can use Objective C and C code fairly easily but, as the interop documentation says: "You cannot import C++ code directly into Swift. Instead, create an Objective-C or C wrapper for C++ code.". Unfortunately, Scintilla exposes some C++ features in the main ScintillaView.h header which causes difficulty for the bridging importer. Most problematically, Scintilla on Cocoa has always wrapped everything in namespace "Scintilla" and this errors out.
Lesser issues include problems with bare type names - it seems to want typedefs like old style C. InfoBarCommunicator.h can be made compliant with the 'modern' form of enumeration using NS_ENUM which should be OK to change now.
diff ~/merc/scintilla/cocoa/ScintillaView.h ScintillaView.h
26d25< namespace Scintilla {
40,41c39,40
< class ScintillaCocoa;
< }
---
typedef struct SCNotification SCNotification;
typedef struct ScintillaCocoa ScintillaCocoa;
48c47typedef struct ScintillaCocoa ScintillaCocoa;
< - (void)notification: (Scintilla::SCNotification*)notification;
---
- (void)notification: (SCNotification*)notification;
100c99< Scintilla::ScintillaCocoa* mBackend;
---
ScintillaCocoa* mBackend;
117c116< @property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend;
---
@property (nonatomic, readonly) ScintillaCocoa* backend;
131c130< - (void) notification: (Scintilla::SCNotification*) notification;
---
- (void) notification: (SCNotification*) notification;
182c181< - (void) registerNotifyCallback: (intptr_t) windowid value: (Scintilla::SciNotifyFunc) callback;
---
- (void) registerNotifyCallback: (intptr_t) windowid value: (SciNotifyFunc) callback;
diff ~/merc/scintilla/cocoa/InfoBarCommunicator.h InfoBarCommunicator.h
24c24diff ~/merc/scintilla/cocoa/InfoBarCommunicator.h InfoBarCommunicator.h
< enum NotificationType {
---
typedef NS_ENUM(NSInteger, NotificationType) {
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html#//apple_ref/doc/uid/TP40014216-CH2-XID_0https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.