|
|
@ -7,7 +7,9 @@ by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keyb |
|
|
|
 |
|
|
|
[](https://travis-ci.org/hrbrmstr/swiftr) |
|
|
|
Status](https://travis-ci.org/hrbrmstr/swiftr.svg?branch=master)](https://travis-ci.org/hrbrmstr/swiftr) |
|
|
|
[](https://codecov.io/gh/hrbrmstr/swiftr) |
|
|
|
 |
|
|
|
 |
|
|
@ -26,6 +28,7 @@ The following functions are implemented: |
|
|
|
|
|
|
|
- `add_registration_glue`: This examines a package swift file and |
|
|
|
builds the necessary registration glue code |
|
|
|
- `swift_function`: Define an R Function with a Swift Implementation |
|
|
|
|
|
|
|
## Installation |
|
|
|
|
|
|
@ -33,6 +36,8 @@ The following functions are implemented: |
|
|
|
remotes::install_git("https://git.rud.is/hrbrmstr/swiftr.git") |
|
|
|
# or |
|
|
|
remotes::install_gitlab("hrbrmstr/swiftr") |
|
|
|
# or |
|
|
|
remotes::install_github("hrbrmstr/swiftr") |
|
|
|
``` |
|
|
|
|
|
|
|
NOTE: To use the ‘remotes’ install options you will need to have the |
|
|
@ -48,13 +53,92 @@ packageVersion("swiftr") |
|
|
|
## [1] '0.1.0' |
|
|
|
``` |
|
|
|
|
|
|
|
``` r |
|
|
|
swift_function( |
|
|
|
code = ' |
|
|
|
|
|
|
|
func ignored() { |
|
|
|
print(""" |
|
|
|
this will be ignored by swift_function() but you could use private |
|
|
|
functions as helpers for the main public Swift function which will be |
|
|
|
made available to R. |
|
|
|
""") |
|
|
|
} |
|
|
|
|
|
|
|
@_cdecl ("read_plist") |
|
|
|
public func read_plist(path: SEXP) -> SEXP { |
|
|
|
|
|
|
|
var out: SEXP = R_NilValue |
|
|
|
|
|
|
|
do { |
|
|
|
// read in the raw plist |
|
|
|
let plistRaw = try Data(contentsOf: URL(fileURLWithPath: String(cString: R_CHAR(STRING_ELT(path, 0))))) |
|
|
|
|
|
|
|
// convert it to a PropertyList |
|
|
|
let plist = try PropertyListSerialization.propertyList(from: plistRaw, options: [], format: nil) as! [String:Any] |
|
|
|
|
|
|
|
// serialize it to JSON |
|
|
|
let jsonData = try JSONSerialization.data(withJSONObject: plist , options: .prettyPrinted) |
|
|
|
|
|
|
|
// setup the JSON string return |
|
|
|
String(data: jsonData, encoding: .utf8)?.withCString { |
|
|
|
cstr in out = Rf_mkString(cstr) |
|
|
|
} |
|
|
|
|
|
|
|
} catch { |
|
|
|
debugPrint("\\(error)") |
|
|
|
} |
|
|
|
|
|
|
|
return(out) |
|
|
|
|
|
|
|
} |
|
|
|
') |
|
|
|
|
|
|
|
read_plist("/Applications/RStudio.app/Contents/Info.plist") %>% |
|
|
|
jsonlite::fromJSON() %>% |
|
|
|
str(1) |
|
|
|
## List of 32 |
|
|
|
## $ NSCalendarsUsageDescription : chr "R wants to access calendars." |
|
|
|
## $ LSRequiresCarbon : logi TRUE |
|
|
|
## $ NSPhotoLibraryAddUsageDescription : chr "R wants write access to the photo library." |
|
|
|
## $ CFBundlePackageType : chr "APPL" |
|
|
|
## $ NSRemindersUsageDescription : chr "R wants to access the reminders." |
|
|
|
## $ CFBundleIdentifier : chr "org.rstudio.RStudio" |
|
|
|
## $ NSLocationWhenInUseUsageDescription : chr "R wants to access location information." |
|
|
|
## $ NSMicrophoneUsageDescription : chr "R wants to access the microphone." |
|
|
|
## $ LSApplicationCategoryType : chr "public.app-category.developer-tools" |
|
|
|
## $ NSHumanReadableCopyright : chr "RStudio 1.4.1093-1, © 2009-2020 RStudio, PBC" |
|
|
|
## $ CFBundleIconFile : chr "RStudio.icns" |
|
|
|
## $ NSAppleScriptEnabled : logi TRUE |
|
|
|
## $ CFBundleVersion : chr "1.4.1093-1" |
|
|
|
## $ CFBundleInfoDictionaryVersion : chr "6.0" |
|
|
|
## $ CFBundleGetInfoString : chr "RStudio 1.4.1093-1, © 2009-2020 RStudio, PBC" |
|
|
|
## $ CSResourcesFileMapped : logi TRUE |
|
|
|
## $ CFBundleName : chr "RStudio" |
|
|
|
## $ NSHighResolutionCapable : logi TRUE |
|
|
|
## $ NSContactsUsageDescription : chr "R wants to access contacts." |
|
|
|
## $ NSSupportsAutomaticGraphicsSwitching : logi TRUE |
|
|
|
## $ NSCameraUsageDescription : chr "R wants to access the camera." |
|
|
|
## $ NSAppleEventsUsageDescription : chr "R wants to run AppleScript." |
|
|
|
## $ NSPrincipalClass : chr "NSApplication" |
|
|
|
## $ OSAScriptingDefinition : chr "RStudio.sdef" |
|
|
|
## $ NSBluetoothPeripheralUsageDescription: chr "R wants to access bluetooth." |
|
|
|
## $ CFBundleDocumentTypes :'data.frame': 16 obs. of 8 variables: |
|
|
|
## $ CFBundleShortVersionString : chr "1.4.1093-1" |
|
|
|
## $ CFBundleDevelopmentRegion : chr "English" |
|
|
|
## $ NSPhotoLibraryUsageDescription : chr "R wants to access the photo library." |
|
|
|
## $ CFBundleLongVersionString : chr "1.4.1093-1" |
|
|
|
## $ CFBundleSignature : chr "Rstd" |
|
|
|
## $ CFBundleExecutable : chr "RStudio" |
|
|
|
``` |
|
|
|
|
|
|
|
## swiftr Metrics |
|
|
|
|
|
|
|
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | |
|
|
|
|:-----|---------:|-----:|----:|-----:|------------:|-----:|---------:|-----:| |
|
|
|
| R | 3 | 0.38 | 87 | 0.46 | 32 | 0.34 | 15 | 0.17 | |
|
|
|
| Rmd | 1 | 0.12 | 8 | 0.04 | 15 | 0.16 | 28 | 0.33 | |
|
|
|
| SUM | 4 | 0.50 | 95 | 0.50 | 47 | 0.50 | 43 | 0.50 | |
|
|
|
| R | 5 | 0.42 | 199 | 0.42 | 69 | 0.36 | 49 | 0.31 | |
|
|
|
| Rmd | 1 | 0.08 | 40 | 0.08 | 27 | 0.14 | 30 | 0.19 | |
|
|
|
| SUM | 6 | 0.50 | 239 | 0.50 | 96 | 0.50 | 79 | 0.50 | |
|
|
|
|
|
|
|
clock Package Metrics for swiftr |
|
|
|
|
|
|
|