Skip to content

Commit

Permalink
more cpp11
Browse files Browse the repository at this point in the history
  • Loading branch information
jayhesselberth committed Dec 21, 2024
1 parent 0e29efd commit 22f461d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
PKG_CPPFLAGS = -IlibBigWig
PKG_LIBS = libBigWig/libBigWig.a
PKG_CPPFLAGS = -Wpointer-arith
PKG_LIBS = libBigWig.a

LIBBIGWIG_SOURCE_DIR=libbigwig
LIBBIGWIG_MAKEFILE=libbigwig/Makefile

# libbigwig:
# cd "${LIBBIGWIG_SOURCE_DIR}" && $(MAKE) -f "${LIBBIGWIG_MAKEFILE}"

# all: libbigwig
4 changes: 2 additions & 2 deletions src/bigwig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ writable::data_frame read_bigwig_impl(std::string bwfname, std::string chrom, in
bwf = bwOpen(&bwfile[0], NULL, &mode) ;

if (!bwf)
stop("Failed to open file: %s\n", bwfname) ;
stop("Failed to open file: %s\n", bwfname.c_str()) ;

std::vector<std::string> chroms ;
std::vector<int> starts ;
Expand All @@ -42,7 +42,7 @@ writable::data_frame read_bigwig_impl(std::string bwfname, std::string chrom, in
intervals = bwGetValues(bwf, cur_chrom, start, end, 0) ;

if (!intervals)
stop("Failed to retreived intervals for %s\n", chrom) ;
stop("Failed to retreived intervals for %s\n", chrom.c_str()) ;

int nint = intervals->l ;
for(int i=0; i<nint; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <R_ext/Visibility.h>

// bigwig.cpp
cpp11::writable::data_frame read_bigwig_impl(std::string bwfname, std::string chrom, int start, int end);
writable::data_frame read_bigwig_impl(std::string bwfname, std::string chrom, int start, int end);
extern "C" SEXP _cpp11bigwig_read_bigwig_impl(SEXP bwfname, SEXP chrom, SEXP start, SEXP end) {
BEGIN_CPP11
return cpp11::as_sexp(read_bigwig_impl(cpp11::as_cpp<cpp11::decay_t<std::string>>(bwfname), cpp11::as_cpp<cpp11::decay_t<std::string>>(chrom), cpp11::as_cpp<cpp11::decay_t<int>>(start), cpp11::as_cpp<cpp11::decay_t<int>>(end)));
Expand Down

0 comments on commit 22f461d

Please sign in to comment.