mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix Compile error in DataFilter without Python/R
.. recent commits to add scripting to datafilter using Python or R code didn't honor the fact that both are optional at compile time. Fixes #2775
This commit is contained in:
@@ -28,8 +28,15 @@
|
||||
#include <QDebug>
|
||||
#include <QMutex>
|
||||
|
||||
#ifdef GC_WANT_PYTHON
|
||||
#include "PythonEmbed.h"
|
||||
QMutex pythonMutex;
|
||||
#endif
|
||||
|
||||
#ifdef GC_WANT_R
|
||||
#include "RTool.h"
|
||||
QMutex RMutex;
|
||||
#endif
|
||||
|
||||
#include "Zones.h"
|
||||
#include "PaceZones.h"
|
||||
@@ -38,7 +45,6 @@
|
||||
#include "DataFilter_yacc.h"
|
||||
|
||||
// control access to runtimes to avoid calls from multiple threads
|
||||
QMutex pythonMutex, RMutex;
|
||||
|
||||
// v4 functions
|
||||
static struct {
|
||||
@@ -2528,9 +2534,14 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
|
||||
case Leaf::Script :
|
||||
{
|
||||
|
||||
// run a python script
|
||||
// run a script
|
||||
#ifdef GC_WANT_PYTHON
|
||||
if (leaf->function == "python") return Result(df->runPythonScript(m->context, *leaf->lvalue.s));
|
||||
#endif
|
||||
#ifdef GC_WANT_R
|
||||
if (leaf->function == "R") return Result(df->runRScript(m->context, *leaf->lvalue.s));
|
||||
#endif
|
||||
return Result(0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3012,6 +3023,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
|
||||
return Result(0); // false
|
||||
}
|
||||
|
||||
#ifdef GC_WANT_PYTHON
|
||||
double
|
||||
DataFilterRuntime::runPythonScript(Context *context, QString script)
|
||||
{
|
||||
@@ -3051,7 +3063,9 @@ DataFilterRuntime::runPythonScript(Context *context, QString script)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GC_WANT_R
|
||||
double
|
||||
DataFilterRuntime::runRScript(Context *context, QString script)
|
||||
{
|
||||
@@ -3095,3 +3109,4 @@ DataFilterRuntime::runRScript(Context *context, QString script)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -142,11 +142,15 @@ public:
|
||||
// pd models for estimates
|
||||
QList <PDModel*>models;
|
||||
|
||||
#ifdef GC_WANT_PYTHON
|
||||
// embedded python runtime
|
||||
double runPythonScript(Context *context, QString script);
|
||||
#endif
|
||||
|
||||
#ifdef GC_WANT_R
|
||||
// embedded R runtime
|
||||
double runRScript(Context *context, QString script);
|
||||
#endif
|
||||
};
|
||||
|
||||
class DataFilter : public QObject
|
||||
|
||||
@@ -54,7 +54,7 @@ int DataFiltercolumn = 1;
|
||||
|
||||
"#"[^\r\n]* ; /* ignore single-line comments */
|
||||
"%%python"(.|[\n\r\t])*"%%" DataFilterlval.op = PYTHON; return PYTHON;
|
||||
"%%R"(.|[\n\r\t])*"%%" DataFilterlval.op = R; return R;
|
||||
"%%R"(.|[\n\r\t])*"%%" DataFilterlval.op = RSCRIPT; return RSCRIPT;
|
||||
"=" DataFilterlval.op = EQ; return EQ;
|
||||
"<>" DataFilterlval.op = NEQ; return NEQ;
|
||||
"<" DataFilterlval.op = LT; return LT;
|
||||
|
||||
@@ -50,7 +50,7 @@ extern Leaf *DataFilterroot; // root node for parsed statement
|
||||
%}
|
||||
|
||||
// Symbol can be meta or metric name
|
||||
%token <leaf> SYMBOL R PYTHON
|
||||
%token <leaf> SYMBOL RSCRIPT PYTHON
|
||||
|
||||
// Constants can be a string or a number
|
||||
%token <leaf> DF_STRING DF_INTEGER DF_FLOAT
|
||||
@@ -189,7 +189,7 @@ python_script:
|
||||
|
||||
r_script:
|
||||
|
||||
R { $$ = new Leaf(@1.first_column, @1.last_column);
|
||||
RSCRIPT { $$ = new Leaf(@1.first_column, @1.last_column);
|
||||
$$->type = Leaf::Script;
|
||||
$$->function = "R";
|
||||
QString full(DataFiltertext);
|
||||
|
||||
Reference in New Issue
Block a user