Skip to content

Commit

Permalink
fix(demo): Add install_github, fix build paths
Browse files Browse the repository at this point in the history
  • Loading branch information
danieledler committed Mar 19, 2020
1 parent a30e52f commit f8e2ab8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 7 additions & 5 deletions build.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
21 changes: 13 additions & 8 deletions demo/runme.R
Original file line number Diff line number Diff line change
@@ -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 -----

Expand Down Expand Up @@ -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");
sprintf("%d shapes remain", swigr::Shape_nshapes())
print ("Goodbye")

0 comments on commit f8e2ab8

Please sign in to comment.