From f8e2ab87323859283194c2d0661970cc65cbf893 Mon Sep 17 00:00:00 2001 From: Daniel Edler Date: Thu, 19 Mar 2020 14:54:23 +0100 Subject: [PATCH] fix(demo): Add install_github, fix build paths --- DESCRIPTION | 2 +- build.R | 12 +++++++----- demo/runme.R | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 588ee5a..c71c186 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: swigr Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.9000 +Version: 0.0.1 Authors@R: person(given = "First", family = "Last", diff --git a/build.R b/build.R index 902613c..7de3a8e 100644 --- a/build.R +++ b/build.R @@ -3,7 +3,8 @@ install.packages("roxygen2") vignette("namespace") -setwd("~/dev/projects/icelab/code/test/swig") +# Create repo +setwd("~/dev/R/swig") devtools::create("swigr") usethis::use_vignette("introduction") @@ -14,12 +15,13 @@ devtools::build() devtools::build(binary = T) -setwd("~/dev/projects/icelab/code/test/swig") +# Install local repo +setwd("~/dev/R/swig") devtools::install("swigr") -setwd("~/dev/projects/icelab/code/test/swig/swigr") -# test: -swigr::test_r() +setwd("~/dev/R/swig/swigr") +# Test package +swigr::test_r() swigr::test_example() devtools::load_all() diff --git a/demo/runme.R b/demo/runme.R index de82e05..ac6ad86 100644 --- a/demo/runme.R +++ b/demo/runme.R @@ -1,21 +1,26 @@ # This file illustrates the proxy class C++ interface generated -# by SWIG. +# by SWIG, with some additional R functions added to the package # dyn.load(paste("example", .Platform$dynlib.ext, sep="")) # source("example.R") # cacheMetaData(1) +install.packages("devtools") +devtools::install_github("danieledler/swigr") + +swigr::test_example() + # ----- Object creation ----- print("Creating some objects:") -circle <- Circle(10) +circle <- swigr::Circle(10) print (" Created circle") -square <- Square(10) +square <- swigr::Square(10) print (" Created square") # ----- Access a static member ----- -sprintf("A total of %d shapes were created", Shape_nshapes()) +sprintf("A total of %d shapes were created", swigr::Shape_nshapes()) # ----- Member data access ----- @@ -44,8 +49,8 @@ sprintf(" area = %f perimeter = %f", o$area(), o$perimeter()) }) print("Guess I'll clean up now") -delete(circle) -delete(square) +swigr::delete(circle) +swigr::delete(square) -sprintf("%d shapes remain", Shape_nshapes()) -print ("Goodbye"); \ No newline at end of file +sprintf("%d shapes remain", swigr::Shape_nshapes()) +print ("Goodbye")