Skip to content

Commit

Permalink
R 3.4.0 Support
Browse files Browse the repository at this point in the history
.. the C runtime declarations changed in R-base which broke
   the RTool.cpp build.

.. fixed up to support 3.4.0 onwards with new structure whilst
   still working for earlier versions.
  • Loading branch information
liversedge committed Apr 22, 2017
1 parent 6f1dd8e commit 558b36a
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions src/R/RTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
#include "HrZones.h"
#include "PaceZones.h"

// From version 3.4.0 of R the structure for declaring C functions
// has changed to have fewer members. I'm not sure the guys maintaining
// the codebase understand how to manage a legacy codebase. Sigh.
#if R_VERSION >= R_Version(3,4,0)
#define CDEFCOMPAT
#else
#define CDEFCOMPAT ,0
#endif

RTool::RTool()
{
// setup the R runtime elements
Expand Down Expand Up @@ -82,23 +91,23 @@ RTool::RTool()

// register our functions
R_CMethodDef cMethods[] = {
{ "GC.display", (DL_FUNC) &RGraphicsDevice::GCdisplay, 0 ,0, 0 },
{ "GC.page", (DL_FUNC) &RTool::pageSize, 0 ,0, 0 },
{ "GC.size", (DL_FUNC) &RTool::windowSize, 0 ,0, 0 },
{ "GC.athlete", (DL_FUNC) &RTool::athlete, 0 ,0, 0 },
{ "GC.athlete.zones", (DL_FUNC) &RTool::zones, 0 ,0, 0 },
{ "GC.activities", (DL_FUNC) &RTool::activities, 0 ,0, 0 },
{ "GC.activity", (DL_FUNC) &RTool::activity, 0 ,0, 0 },
{ "GC.activity.metrics", (DL_FUNC) &RTool::activityMetrics, 0 ,0, 0 },
{ "GC.activity.meanmax", (DL_FUNC) &RTool::activityMeanmax, 0 ,0, 0 },
{ "GC.activity.wbal", (DL_FUNC) &RTool::activityWBal, 0 ,0, 0 },
{ "GC.season", (DL_FUNC) &RTool::season, 0 ,0, 0 },
{ "GC.season.metrics", (DL_FUNC) &RTool::metrics, 0 ,0, 0 },
{ "GC.season.intervals", (DL_FUNC) &RTool::seasonIntervals, 0 ,0, 0 },
{ "GC.season.pmc", (DL_FUNC) &RTool::pmc, 0 ,0, 0 },
{ "GC.season.meanmax", (DL_FUNC) &RTool::seasonMeanmax, 0 ,0, 0 },
{ "GC.season.peaks", (DL_FUNC) &RTool::seasonPeaks, 0 ,0, 0 },
{ NULL, NULL, 0, 0, 0 }
{ "GC.display", (DL_FUNC) &RGraphicsDevice::GCdisplay, 0,0 CDEFCOMPAT },
{ "GC.page", (DL_FUNC) &RTool::pageSize, 0,0 CDEFCOMPAT },
{ "GC.size", (DL_FUNC) &RTool::windowSize, 0,0 CDEFCOMPAT },
{ "GC.athlete", (DL_FUNC) &RTool::athlete, 0,0 CDEFCOMPAT },
{ "GC.athlete.zones", (DL_FUNC) &RTool::zones, 0,0 CDEFCOMPAT },
{ "GC.activities", (DL_FUNC) &RTool::activities, 0,0 CDEFCOMPAT },
{ "GC.activity", (DL_FUNC) &RTool::activity, 0,0 CDEFCOMPAT },
{ "GC.activity.metrics", (DL_FUNC) &RTool::activityMetrics, 0,0 CDEFCOMPAT },
{ "GC.activity.meanmax", (DL_FUNC) &RTool::activityMeanmax, 0,0 CDEFCOMPAT },
{ "GC.activity.wbal", (DL_FUNC) &RTool::activityWBal, 0,0 CDEFCOMPAT },
{ "GC.season", (DL_FUNC) &RTool::season, 0,0 CDEFCOMPAT },
{ "GC.season.metrics", (DL_FUNC) &RTool::metrics, 0,0 CDEFCOMPAT },
{ "GC.season.intervals", (DL_FUNC) &RTool::seasonIntervals, 0,0 CDEFCOMPAT },
{ "GC.season.pmc", (DL_FUNC) &RTool::pmc, 0,0 CDEFCOMPAT },
{ "GC.season.meanmax", (DL_FUNC) &RTool::seasonMeanmax, 0,0 CDEFCOMPAT },
{ "GC.season.peaks", (DL_FUNC) &RTool::seasonPeaks, 0,0 CDEFCOMPAT },
{ NULL, NULL, 0,0 CDEFCOMPAT }
};
R_CallMethodDef callMethods[] = {
{ "GC.display", (DL_FUNC) &RGraphicsDevice::GCdisplay, 0 },
Expand Down

0 comments on commit 558b36a

Please sign in to comment.