[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Thu Mar 3 00:46:33 CET 2005


CVS commit by staikos: 

add support for functions with != 1 argument, but we don't have any, so they're
unused.


  M +14 -3     enodes.cpp   1.43
  M +1 -0      enodes.h   1.28


--- kdeextragear-2/kst/kst/enodes.cpp  #1.42:1.43
@@ -338,4 +338,5 @@ static struct {
 Function::Function(char *name, ArgumentList *args)
 : Node(), _name(name), _args(args), _f(0L), _plugin(0L) {
+  _argCount = 1; // Presently no functions take != 1 argument
   _inPid = 0L;
   _inScalars = 0L;
@@ -523,7 +524,17 @@ double Function::value(Context *ctx) {
   }
 
-  // FIXME: support multiple arguments
+  if (_argCount == 1) {
   double x = _args->at(0, ctx);
   return ((double (*)(double))_f)(x);
+  } else if (_argCount > 1) {
+    double *x = new double[_argCount];
+    for (int i = 0; i < _argCount; ++i) {
+      x[i] = _args->at(i, ctx);
+    }
+    delete[] x;
+    return ((double (*)(double*))_f)(x);
+  } else {
+    return ((double (*)())_f)();
+  }
 }
 

--- kdeextragear-2/kst/kst/enodes.h  #1.27:1.28
@@ -135,4 +135,5 @@ namespace Equation {
       int _outputIndex; // -1 = scalar 0, -424242 = none/error, +0...n = vector
       void *_localData;
+      int _argCount;
   };
 




More information about the Kst mailing list