Skip to content

Commit

Permalink
added API files
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Apr 26, 2018
1 parent 1c2f125 commit 79a6553
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onUnload <- function (libpath) {
library.dynam.unload("stringdist", libpath)
}
54 changes: 54 additions & 0 deletions pkg/inst/include/stringdist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

/* stringdist - a C library of string distance algorithms with an interface to R.
* Copyright (C) 2013 Mark van der Loo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can contact the author at: mark _dot_ vanderloo _at_ gmail _dot_ com
*/

#include <R.h>
#include <Rinternals.h>
#include <Rdefines.h>


#ifdef __cplusplus
extern "C" {
#endif

/*
FUNCTIONS
*/
SEXP R_stringdist(SEXP a, SEXP b, SEXP method
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP useBytes, SEXP nthrd);
SEXP R_amatch(SEXP x, SEXP table, SEXP method
, SEXP nomatch, SEXP matchNA
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP maxDistance, SEXP useBytes
, SEXP nthrd);
SEXP R_lower_tri(SEXP a, SEXP method
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP useBytes, SEXP nthrd);
SEXP R_soundex(SEXP x, SEXP useBytes);
SEXP R_get_qgrams(SEXP a, SEXP qq);
SEXP R_lengths(SEXP X);
SEXP R_all_int(SEXP X);


//#endif

#ifdef __cplusplus
}
#endif
102 changes: 102 additions & 0 deletions pkg/inst/include/stringdist_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

/* stringdist - a C library of string distance algorithms with an interface to R.
* Copyright (C) 2013 Mark van der Loo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can contact the author at: mark _dot_ vanderloo _at_ gmail _dot_ com
*/

#ifndef _STRINGDIST_API_H
#define _STRINGDIST_API_H

#include <stringdist.h> // also includes R.h, Rinternals.h, Rdefines.h

#include <Rconfig.h>
#include <R_ext/Rdynload.h>

#ifdef HAVE_VISIBILITY_ATTRIBUTE
# define attribute_hidden __attribute__ ((visibility ("hidden")))
#else
# define attribute_hidden
#endif

#ifdef __cplusplus
extern "C" {
#endif


SEXP attribute_hidden sd_all_int(SEXP X)
{
static SEXP(*fun)(SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP)) R_GetCCallable("stringdist","R_all_int");
return fun(X);
}

SEXP attribute_hidden sd_amatch(SEXP x, SEXP table, SEXP method
, SEXP nomatch, SEXP matchNA
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP maxDistance, SEXP useBytes
, SEXP nthrd)
{
static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)) R_GetCCallable("stringdist","R_amatch");
return fun(x, table, method, nomatch, matchNA, weight, p, bt, q, maxDistance, useBytes, nthrd);
}

SEXP attribute_hidden sd_get_qgrams(SEXP a, SEXP qq)
{
static SEXP(*fun)(SEXP, SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP, SEXP)) R_GetCCallable("stringdist","R_get_qgrams");
return fun(a, qq);
}

SEXP attribute_hidden sd_lengths(SEXP X)
{
static SEXP(*fun)(SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP)) R_GetCCallable("stringdist","R_lengths");
return fun(X);
}

SEXP attribute_hidden sd_lower_tri(SEXP a, SEXP method
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP useBytes, SEXP nthrd)
{
static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)) R_GetCCallable("stringdist","R_lower_tri");
return fun(a, method, weight, p, bt, q, useBytes, nthrd);
}

SEXP attribute_hidden sd_soundex(SEXP x, SEXP useBytes)
{
static SEXP(*fun)(SEXP, SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP, SEXP)) R_GetCCallable("stringdist","R_soundex");
return fun(x, useBytes);
}

SEXP attribute_hidden sd_stringdist(SEXP a, SEXP b, SEXP method
, SEXP weight, SEXP p, SEXP bt, SEXP q
, SEXP useBytes, SEXP nthrd)
{
static SEXP(*fun)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP) = NULL;
if (fun == NULL) fun = (SEXP(*)(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)) R_GetCCallable("stringdist","R_stringdist");
return fun(a, b, method, weight, p, bt, q, useBytes, nthrd);
}


#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 79a6553

Please sign in to comment.