-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(hello_world) | ||
export(os_info) | ||
useDynLib(osinfo, .registration = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
# Generated by extendr: Do not edit by hand | ||
|
||
# nolint start | ||
|
||
# | ||
# This file was created with the following call: | ||
# .Call("wrap__make_osinfo_wrappers", use_symbols = TRUE, package_name = "osinfo") | ||
|
||
#' @docType package | ||
#' @usage NULL | ||
#' @useDynLib osinfo, .registration = TRUE | ||
NULL | ||
|
||
#' Return string `"Hello world!"` to R. | ||
#' @export | ||
hello_world <- function() .Call(wrap__hello_world) | ||
#' get os information | ||
os_info_impl <- function() .Call(wrap__os_info_impl) | ||
|
||
|
||
# nolint end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#' get os info | ||
#' @export | ||
os_info <- function() { | ||
os_info_impl() | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ name = 'osinfo' | |
|
||
[dependencies] | ||
extendr-api = '*' | ||
os_info = { version = "3", default-features = false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
use extendr_api::prelude::*; | ||
|
||
/// Return string `"Hello world!"` to R. | ||
/// @export | ||
#[derive(Debug, PartialEq, IntoDataFrameRow)] | ||
struct OsInfo { | ||
version: String, | ||
os_type: String, | ||
architecture: Option<String>, | ||
} | ||
/// get os information | ||
#[extendr] | ||
fn hello_world() -> &'static str { | ||
"Hello world!" | ||
fn os_info_impl() -> List { | ||
let info = os_info::get(); | ||
list!( | ||
version = info.version().to_string(), | ||
os_type = info.os_type().to_string(), | ||
architecture = info.architecture(), | ||
codename = info.codename() | ||
) | ||
} | ||
|
||
// Macro to generate exports. | ||
// This ensures exported functions are registered with R. | ||
// See corresponding C code in `entrypoint.c`. | ||
extendr_module! { | ||
mod osinfo; | ||
fn hello_world; | ||
fn os_info_impl; | ||
} |