Beispiel #1
0
void cReadObject::AddPt3dr(const std::string & aS,Pt3dr * aP,bool Required)
{
     ELISE_ASSERT(aS.size()==3,"AddPt3dr bad size");
     AddDouble(aS[0],&(aP->x),Required);
     AddDouble(aS[1],&(aP->y),Required);
     AddDouble(aS[2],&(aP->z),Required);
}
Beispiel #2
0
status_t Preferences::SetDouble (const char *name, double f)
{
	if (HasDouble (name) == true)
		return ReplaceDouble (name, 0, f);

	return AddDouble (name, f);
}
Beispiel #3
0
status_t
AttributeMessage::SetAttribute(const char* name, double value)
{
	if (ReplaceDouble(name, value) == B_OK)
		return B_OK;
	return AddDouble(name, value);
}
Beispiel #4
0
myinline ArpMessage& ArpMessage::SetDouble(const char *name, double dat)
{
	if( !this ) return *((ArpMessage*)NULL);
	if( status == B_NO_ERROR ) {
		status = AddDouble(name, dat);
	}
	return *this;
}
Beispiel #5
0
globle int EvaluateExpression(
  struct expr *problem,
  DATA_OBJECT_PTR returnValue)
  {
   struct expr *oldArgument;
   struct FunctionDefinition *fptr;
#if PROFILING_FUNCTIONS
   struct profileFrameInfo profileFrame;
#endif

   if (problem == NULL)
     {
      returnValue->type = SYMBOL;
      returnValue->value = FalseSymbol;
      return(EvaluationError);
     }

   switch (problem->type)
     {
      case STRING:
      case SYMBOL:
      case FLOAT:
      case INTEGER:
#if OBJECT_SYSTEM
      case INSTANCE_NAME:
      case INSTANCE_ADDRESS:
#endif
#if FUZZY_DEFTEMPLATES 
      case FUZZY_VALUE:
#endif
      case EXTERNAL_ADDRESS:
        returnValue->type = problem->type;
        returnValue->value = problem->value;
        break;

#if FUZZY_DEFTEMPLATES 
      case S_FUNCTION:
      case PI_FUNCTION:
      case Z_FUNCTION:
      case SINGLETON_EXPRESSION:
             /* At some time it may be worthwhile making this into an FCALL
                    but only when we allow user's to create functions that return
                        fuzzy values -- this may not happen
             */
                {
                  struct fuzzy_value *fvptr;
                  fvptr = getConstantFuzzyValue(problem, &EvaluationError);
          returnValue->type = FUZZY_VALUE;
                  if (fvptr != NULL)
                    {
              returnValue->value = (VOID *)AddFuzzyValue(fvptr);
                      /* AddFuzzyValue makes a copy of the fuzzy value -- so remove this one */
              rtnFuzzyValue(fvptr);
                        }
              else
                  {
                   returnValue->type = RVOID;
                   returnValue->value = CLIPSFalseSymbol;
                   SetEvaluationError(TRUE);
                  }
        }
        break;
#endif

      case FCALL:
        {
         fptr = (struct FunctionDefinition *) problem->value;

#if PROFILING_FUNCTIONS   
         StartProfile(&profileFrame,
                      &fptr->usrData,
                      ProfileUserFunctions);
#endif

         oldArgument = CurrentExpression;
         CurrentExpression = problem;

         switch(fptr->returnValueType)
           {
            case 'v' :
              (* (void (*)(void)) fptr->functionPointer)();
              returnValue->type = RVOID;
              returnValue->value = FalseSymbol;
              break;
            case 'b' :
              returnValue->type = SYMBOL;
              if ((* (int (*)(void)) fptr->functionPointer)())
                returnValue->value = TrueSymbol;
              else
                returnValue->value = FalseSymbol;
              break;
            case 'a' :
              returnValue->type = EXTERNAL_ADDRESS;
              returnValue->value =
                             (* (void *(*)(void)) fptr->functionPointer)();
              break;
            case 'i' :
              returnValue->type = INTEGER;
              returnValue->value = (void *)
                AddLong((long) (* (int (*)(void)) fptr->functionPointer)());
              break;
            case 'l' :
              returnValue->type = INTEGER;
              returnValue->value = (void *)
                 AddLong((* (long int (*)(void)) fptr->functionPointer)());
              break;
#if FUZZY_DEFTEMPLATES 
            case 'F' :
              {
                struct fuzzy_value *fvPtr;

                fvPtr = (* (struct fuzzy_value * (*)(VOID_ARG)) fptr->functionPointer)();
                if (fvPtr != NULL)
                  {
                   returnValue->type = FUZZY_VALUE;
                   returnValue->value = (VOID *)AddFuzzyValue( fvPtr );
                   /* AddFuzzyValue makes a copy of fv .. so return it */
                   rtnFuzzyValue( fvPtr );
                  }
                else
                  {
                   returnValue->type = RVOID;
                   returnValue->value = CLIPSFalseSymbol;
                  }
               }
              break;
#endif
            case 'f' :
              returnValue->type = FLOAT;
              returnValue->value = (void *)
                 AddDouble((double) (* (float (*)(void)) fptr->functionPointer)());
              break;
            case 'd' :
              returnValue->type = FLOAT;
              returnValue->value = (void *)
                 AddDouble((* (double (*)(void)) fptr->functionPointer)());
              break;
            case 's' :
              returnValue->type = STRING;
              returnValue->value = (void *)
                (* (SYMBOL_HN *(*)(void)) fptr->functionPointer)();
              break;
            case 'w' :
              returnValue->type = SYMBOL;
              returnValue->value = (void *)
                (* (SYMBOL_HN *(*)(void)) fptr->functionPointer)();
              break;
#if OBJECT_SYSTEM
            case 'x' :
              returnValue->type = INSTANCE_ADDRESS;
              returnValue->value =
                             (* (void *(*)(void)) fptr->functionPointer)();
              break;
            case 'o' :
              returnValue->type = INSTANCE_NAME;
              returnValue->value = (void *)
                (* (SYMBOL_HN *(*)(void)) fptr->functionPointer)();
              break;
#endif
            case 'c' :
              {
               char cbuff[2];

               cbuff[0] = (* (char (*)(void)) fptr->functionPointer)();
               cbuff[1] = EOS;
               returnValue->type = SYMBOL;
               returnValue->value = (void *) AddSymbol(cbuff);
               break;
              }

            case 'j' :
            case 'k' :
            case 'm' :
            case 'n' :
            case 'u' :
              (* (void (*)(DATA_OBJECT_PTR)) fptr->functionPointer)(returnValue);
              break;

            default :
               SystemError("EVALUATN",2);
               ExitRouter(EXIT_FAILURE);
               break;
            }

#if PROFILING_FUNCTIONS 
        EndProfile(&profileFrame);
#endif

        CurrentExpression = oldArgument;
        break;
        }

     case MULTIFIELD:
        returnValue->type = MULTIFIELD;
        returnValue->value = ((DATA_OBJECT_PTR) (problem->value))->value;
        returnValue->begin = ((DATA_OBJECT_PTR) (problem->value))->begin;
        returnValue->end = ((DATA_OBJECT_PTR) (problem->value))->end;
        break;

     case MF_VARIABLE:
     case SF_VARIABLE:
        if (GetBoundVariable(returnValue,(SYMBOL_HN *) problem->value) == FALSE)
          {
           PrintErrorID("EVALUATN",1,FALSE);
           PrintRouter(WERROR,"Variable ");
           PrintRouter(WERROR,ValueToString(problem->value));
           PrintRouter(WERROR," is unbound\n");
           returnValue->type = SYMBOL;
           returnValue->value = FalseSymbol;
           SetEvaluationError(TRUE);
          }
        break;

      default:
        if (PrimitivesArray[problem->type] == NULL)
          {
           SystemError("EVALUATN",3);
           ExitRouter(EXIT_FAILURE);
          }

        if (PrimitivesArray[problem->type]->copyToEvaluate)
          {
           returnValue->type = problem->type;
           returnValue->value = problem->value;
           break;
          }

        if (PrimitivesArray[problem->type]->evaluateFunction == NULL)
          {
           SystemError("EVALUATN",4);
           ExitRouter(EXIT_FAILURE);
          }

        oldArgument = CurrentExpression;
        CurrentExpression = problem;

#if PROFILING_FUNCTIONS 
        StartProfile(&profileFrame,
                     &PrimitivesArray[problem->type]->usrData,
                     ProfileUserFunctions);
#endif

        (*PrimitivesArray[problem->type]->evaluateFunction)(problem->value,returnValue);

#if PROFILING_FUNCTIONS
        EndProfile(&profileFrame);
#endif

        CurrentExpression = oldArgument;
        break;
     }

   PropagateReturnValue(returnValue);
   return(EvaluationError);
  }
Beispiel #6
0
status_t TPreferences::SetDouble(const char *name, double f) {
	if (HasDouble(name)) {
		return ReplaceDouble(name, 0, f);
	}
	return AddDouble(name, f);
}
Beispiel #7
0
/*-deref or pk_tpn can fill malloced space, then can use this to get to a m.f.*/
VOID tpn_to_mf(DATA_OBJECT_PTR rp)
{
int num=1,stride=1,*pi,offset=0,i;
float *pf;
double *pd;
char tstr[9],type,*pc,t1[2];
VOID *mfp;
    t1[1]='\0';
    /*get the type*/
    sprintf(tstr,"%s",(char *)RtnLexeme(1)); 
    type = tolower(tstr[0]);
    if(type!='i' && type!='f' && type!='d' && type!='b')
    {	
	printf("[1st arg=type:i or f or d]");
	return;
    }

    /*get number (& offset & stride) to put to a m.f.*/
    if(RtnArgCount() > 2) num=(int)RtnLong(3);
    if(RtnArgCount() > 3) offset=(int)RtnLong(4);
    if(RtnArgCount() > 4) stride=(int)RtnLong(5);
    /*could use SetMultifieldErrorValue(rp); return;*/
    mfp = CreateMultifield(num);

    /*get the ptr, and set the MF*/
    switch(type)
    {
	case 'i' :  pi = (int *)get_ptr(2);  
		    for(i=0; i<num; i++)
		    {
			SetMFType(mfp,i,INTEGER);
			SetMFValue(mfp,i,AddLong(pi[offset+i]));
		    }
		    break;
	case 'f' :  pf = (float *)get_ptr(2);  
		    for(i=0; i<num; i++)
		    {
			printf("%f to mf,",pf[offset+i]); fflush(stdout);
			SetMFType(mfp,i,FLOAT);
			SetMFValue(mfp,i,AddDouble((double)pf[offset+i]));
		    }
		    break;
	case 'd' :  pd = (double *)get_ptr(2);  
		    for(i=0; i<num; i++)
		    {
			SetMFType(mfp,i,FLOAT);
			SetMFValue(mfp,i,AddDouble(pd[offset+i]));
		    }
		    break;
	/*this one could go per char or by stride or by space breaks*/
	/*go by char for now*/
	case 'b' :  pc = (char *)get_ptr(2);  
		    for(i=0; i<num; i++)
		    {
			SetMFType(mfp,i,SYMBOL);
			t1[0]=pc[offset+i];
			SetMFValue(mfp,i,AddSymbol(t1));
		    }
		    break;
    } /*gets past this and dies when printing out the result-
	-looks liked capped ok though*/
    SetpType(rp,MULTIFIELD);
    SetpValue(rp,mfp);
    SetpDOBegin(rp,1);
    SetpDOEnd(rp,num);
    return;
}
Beispiel #8
0
void cReadObject::AddDouble(char aC,double * anAdr,bool Required)
{
     std::string aS;
     aS += aC;
     AddDouble(aS,anAdr,Required);
}