Esempio n. 1
0
 double ffi_cmdval_s(const char *name, int n_args, const char* p0, ...)
 {
   va_list ap;
   int i;
   char st[MAXDISPARGS][100];
   double p[MAXDISPARGS];
   void *retval;
   strcpy(st[0], p0);
   p[0] = STRING_TO_DOUBLE(st[0]);
   va_start(ap, p0); // start variable list after p0
   for (i = 1; i < n_args; i++) {
     strcpy(st[i], va_arg(ap, char*));
     p[i] = STRING_TO_DOUBLE(st[i]);
   }
   va_end(ap);
   return ::dispatch(name, p, n_args, &retval);
 }
Esempio n. 2
0
void Argument::get (const std::string &name, double &value)
{
    char v[BUFSIZ];
    sprintf_s(v, BUFSIZ, "%f", value);
    std::string temp(v);

    get(name, temp);

    if (temp != "") value = STRING_TO_DOUBLE(temp);
}
Esempio n. 3
0
// This is s duplicate of the RTcmix::cmd() string-passing function, except
// that instead of returning an Inst*, it returns the double value
// of the RTcmix command that was invoked
double
RTcmix::cmdval(const char *name, int n_args, const char* p0, ...)
{
	// these are not time-stamped as above... change if we need to!
	va_list ap;
	int i;
	char st[MAXDISPARGS][100];
	double p[MAXDISPARGS];
	void *retval;

	// this kludge dates from the olden days!
	strcpy(st[0], p0);
	p[0] = STRING_TO_DOUBLE(st[0]);
	va_start(ap, p0); // start variable list after p0
	for (i = 1; i < n_args; i++) {
		strcpy(st[i], va_arg(ap, char*));
		p[i] = STRING_TO_DOUBLE(st[i]);
	}
	va_end(ap);

	return ::dispatch(name, p, n_args, &retval);
}
Esempio n. 4
0
 void *ffi_cmd_l(const char *name, const char *luaname, int n_args, ...)
 {
   double p[MAXDISPARGS];
   void   *retval;
   p[0] = STRING_TO_DOUBLE(luaname);
   va_list ap;
   va_start(ap, n_args);
   for (int i = 0; i < n_args; i++) {
     p[i + 1] = va_arg(ap, double);
   }
   va_end(ap);
   n_args++;
   (void) ::dispatch(name, p, n_args, &retval);
   return retval;
 }
Esempio n. 5
0
void Argument::get (const std::string &name, std::vector<double> &value)
{
    std::vector<std::string> temp;
    for (unsigned int i=0; i<value.size(); i++)
    {
        char v[BUFSIZ];
        sprintf_s(v, BUFSIZ, "%f", value[i]);
        temp.push_back(v);
    }

    get(name, temp);

    for (unsigned int i=0; i<temp.size(); i++)
        value.push_back(STRING_TO_DOUBLE(temp[i]));
}
Esempio n. 6
0
int
RTcmix::findAndLoadFunction(const char *funcname)
{
	const char *path;
	int status = -1;
	if ((path = ::getDSOPath(_functionRegistry, funcname)) != NULL) {
		char fullDSOPath[128];
		float p[1];
		double pp[1];
		sprintf(fullDSOPath, "%s.so", path);
		p[0] = 0;
		pp[0] = STRING_TO_DOUBLE(fullDSOPath);
		if (m_load(p, 1, pp) == 1)
			status = 0;
		else
			status = -1; 
	}
	return status;
}
Esempio n. 7
0
void *ffi_cmd_l_15(const char *name, const char *luaname, double p1, double p2, double p3, double p4, double p5, double p6, double p7, double p8, double p9, double p10, double p11, double p12, double p13, double p14, double p15)
  {
    double p[MAXDISPARGS];
    void   *retval;
    p[ 0] = STRING_TO_DOUBLE(luaname);
    p[ 1] = p1;
    p[ 2] = p2;
    p[ 3] = p3;
    p[ 4] = p4;
    p[ 5] = p5;
    p[ 6] = p6;
    p[ 7] = p7;
    p[ 8] = p8;
    p[ 9] = p9;
    p[10] = p10;
    p[11] = p11;
    p[12] = p12;
    p[13] = p13;
    p[14] = p14;
    p[15] = p15;
    (void) ::dispatch(name, p, 16, &retval);
    return retval;
  }
Esempio n. 8
0
/* ------------------------------------------------------------- checkfunc -- */
int
RTcmix::checkfunc(const char *funcname, const Arg arglist[], const int nargs,
		          Arg *retval)
{
   RTcmixFunction *func;

   func = ::findfunc(_func_list, funcname);

   // If we did not find it, try loading it from our list of registered DSOs.
   if (func == NULL) {
      if (findAndLoadFunction(funcname) == 0) {
         func = ::findfunc(_func_list, funcname);
            if (func == NULL)
               return -1;
      }
      else
         return -1;
   }

   /* function found, so call it */

   ::_printargs(funcname, arglist, nargs);

   switch (func->return_type) {
   case DoubleType:
      if (func->legacy) {
         /* for old (float p[], int nargs, double pp[]) signature */
         #include <maxdispargs.h>
         float p[MAXDISPARGS];
         double pp[MAXDISPARGS];
         for (int i = 0; i < nargs; i++) {
			const Arg &theArg = arglist[i];
            p[i] = (float) theArg;
			switch (theArg.type()) {
            case DoubleType:
               pp[i] = (double) theArg;
			   break;
            case StringType:
               pp[i] = STRING_TO_DOUBLE(theArg);
			   break;
            default:
               die(NULL, "%s: arguments must be numbers or strings.", funcname);
               return -1;
            }
         }
         /* some functions rely on zero contents of args > nargs */
         for (int i = nargs; i < MAXDISPARGS; i++) {
            p[i] = 0.0;
            pp[i] = 0.0;
         }
         *retval = (double) (*(func->func_ptr.legacy_return))
                                                      (p, nargs, pp);
      }
      else
         *retval = (double) (*(func->func_ptr.number_return))
                                                      (arglist, nargs);
      break;
   case HandleType:
      *retval = (Handle) (*(func->func_ptr.handle_return))
                                                      (arglist, nargs);
      break;
   case StringType:
      *retval = (const char *) (*(func->func_ptr.string_return))
                                                      (arglist, nargs);
      break;
   default:
      break;
   }

   return 0;
}