[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Tue Oct 19 18:57:39 CEST 2004
CVS commit by staikos:
infrastructure for plugins from equations. It doesn't do anything yet, but it
would work like this once it is implemented:
Equation: 2*plugin(mypluginname, asin(v), v, idx, 4.4, 0, 42, anotherscalar)
mypluginname(...) doesn't work because it's far too easy to have namespace
collisions. Also this prepares us for future equation reworkings if we decide
on it.
M +24 -6 enodes.cpp 1.16
M +5 -3 enodes.h 1.11
--- kdeextragear-2/kst/kst/enodes.cpp #1.15:1.16
@@ -249,6 +249,9 @@ static struct {
Function::Function(char *name, ArgumentList *args)
-: Node(), _name(name), _args(args), _f(0L) {
+: Node(), _name(name), _args(args), _f(0L), _plugin(false) {
//printf("%p: New Function: %s - %p\n", (void*)this, name, (void*)args);
+ if (strcasecmp("plugin", name) == 0) {
+ _plugin = true;
+ } else {
for (int i = 0; FTable[i].name; ++i) {
if (strcasecmp(FTable[i].name, name) == 0) {
@@ -257,4 +260,5 @@ Function::Function(char *name, ArgumentL
}
}
+ }
}
@@ -270,4 +274,8 @@ Function::~Function() {
double Function::value(Context *ctx) {
+ if (_plugin) {
+ return 0.0; // FIXME
+ }
+
if (!_f) {
return ctx->noPoint;
@@ -281,5 +289,10 @@ double Function::value(Context *ctx) {
bool Function::isConst() {
- return _args->isConst();
+ return !_plugin && _args->isConst();
+}
+
+
+bool Function::isPlugin() const {
+ return _plugin;
}
@@ -332,4 +345,9 @@ void ArgumentList::collectVectors(KstVec
+Node *ArgumentList::node(int idx) {
+ return _args.at(idx);
+}
+
+
/////////////////////////////////////////////////////////////////
static struct {
--- kdeextragear-2/kst/kst/enodes.h #1.10:1.11
@@ -45,5 +45,5 @@ namespace Equation {
virtual ~Node();
- virtual bool isConst() = 0;
+ virtual bool isConst() = 0; // can't be const
virtual void collectVectors(KstVectorList& c);
virtual double value(Context*) = 0;
@@ -81,4 +81,5 @@ namespace Equation {
virtual void collectVectors(KstVectorList& c);
double at(int, Context*);
+ virtual Node *node(int idx);
protected:
@@ -92,4 +93,5 @@ namespace Equation {
virtual ~Function();
+ virtual bool isPlugin() const;
virtual bool isConst();
virtual double value(Context*);
@@ -100,4 +102,5 @@ namespace Equation {
ArgumentList *_args;
void *_f;
+ bool _plugin;
};
@@ -156,6 +159,6 @@ namespace Equation {
};
- class FoldVisitor : public NodeVisitor {
+ class FoldVisitor : public NodeVisitor {
public:
FoldVisitor(Context*, Node*);
@@ -167,5 +170,4 @@ namespace Equation {
protected:
Context* _ctx;
-
};
More information about the Kst
mailing list