Ejemplo n.º 1
0
int Winapi
ec_resume_long(long int *to_c)
{
    int res;
    pword * pw;

    if (g_emu_.nesting_level > 1)
	ec_panic("can't resume nested engine","ec_resume_long()");

    if (ec_running())
	return PRUNNING;

    A[1] = _get_posted_goals();
    Make_Integer(&A[2], RESUME_CONT);

    res = restart_emulc();
    if (res != PYIELD)
	ec_panic("eclipse emulator did not yield properly","ec_resume_long()");

    pw = &A[2];
    Dereference_(pw)
    if (IsInteger(pw->tag))
    	*to_c = pw->val.nint;
    else
    	*to_c = 0;

    pw = &A[1];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	return pw->val.nint;
    else
	return  TYPE_ERROR;
}
Ejemplo n.º 2
0
int Winapi
ec_wait_resume_status_long(long int *to_c, int timeout)
{
    pword *pw;
    int res;

#ifdef _WIN32
    /* This is supposed to be called only after a resume_async! */
    if (!resume_thread)
    	return PERROR;
    if (!ec_thread_wait(resume_thread, &res, timeout))
	return PRUNNING;
#else
    /* We don't have threads: resume here in order to make resume_async-
     * resume_status sequences work anyway, so we can write portable code.
     */
    res = restart_emulc();
#endif
    if (res != PYIELD)
	ec_panic("eclipse emulator did not yield properly","ec_resume_long()");

    pw = &A[2];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	*to_c = pw->val.nint;
    else
	*to_c = 0;

    pw = &A[1];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	return pw->val.nint;
    else
	return TYPE_ERROR;
}
Ejemplo n.º 3
0
int Winapi
ec_handle_events(long int *to_c)
{
    int res;
    pword * pw;

    if (g_emu_.nesting_level > 1)
	ec_panic("can't resume nested engine","ec_handle_events()");

    if (ec_running())
	return PRUNNING;

    Make_Nil(&A[1])		/* don't care */
    Make_Integer(&A[2], RESUME_SIMPLE);
    res = restart_emulc();
    if (res != PYIELD)
	ec_panic("eclipse emulator did not yield properly","ec_handle_events()");

    pw = &A[2];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	*to_c = pw->val.nint;
    else
	*to_c = 0;

    pw = &A[1];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	return pw->val.nint;
    else
	return TYPE_ERROR;
}
Ejemplo n.º 4
0
//===========================================================================//
void GroupParameters::AddGroupParameter(int param_num, char * param)
{

    switch(param_num) {
    case 1 :	// code
	if ( strcmp(param, "0") == 0 &&  strlen(param) > 7 ) {
	    code = (char *) calloc(7, sizeof(char));
	    strcpy(code, "null");
	    error_param = true;
	    break;
	}
	
	if ( strcmp(param, "") && strcmp(param, "0") )    {
	    if ( IsInteger(param) )	{
		code = (char *) calloc(strlen(param) + 1, sizeof(char));
		strcpy(code, param);
		break;
	    }	
	}   
	code = (char *) calloc(6, sizeof(char));
	strcpy(code, "null");
	error_param = true;
	break;
    case 3 : // longtitle
	longtitle = (char *) calloc((strlen(param) + 2 +  1)*2, sizeof(char));
	strcpy(longtitle, "'");
	strcat(longtitle, DbCodec->fromUnicode(CP1251Codec->toUnicode(param)));
	strcat(longtitle, "'");  
	//  str_cp1251_to_koi8r(longtitle);
	break;
    case 4 : // shortcut
	shortcut = (char *) calloc((strlen(param) + 2 + 1)*2, sizeof(char));
	strcpy(shortcut, "'");
	strcat(shortcut, DbCodec->fromUnicode(CP1251Codec->toUnicode(param)));
	strcat(shortcut, "'");
	
	// str_cp1251_to_koi8r(shortcut);
	break;
    case 16 :
	if ( strcmp(param, "") && strcmp(param, "0") )      {
	    if ( IsInteger(param) )	{
	    group_code = (char *) calloc(strlen(param) + 1, sizeof(char));
	    strcpy(group_code, param);
	    break;
	    }
	}      
        group_code = (char *) calloc(5, sizeof(char));
        strcpy(group_code, "null");
	break;
    }	
}
Ejemplo n.º 5
0
CString CWhiteInfoBox::InfoText() {
  double sym_bblind		= p_symbol_engine_tablelimits->bblind();
	double sym_sblind		= p_symbol_engine_tablelimits->sblind();
	double sym_ante			= p_symbol_engine_tablelimits->ante();
	int sym_lim				  = p_symbol_engine_gametype->gametype();
	CString sym_handnumber = p_handreset_detector->GetHandNumber();
	double sym_pot			= p_symbol_engine_chip_amounts->pot();
  CString result, s;
	// handnumber
	if (sym_handnumber != "") {
		s.Format("  Hand #: %s\n", sym_handnumber);
	}	else 	{
		s.Format("  Hand #: -\n");
	}
	result.Append(s);

  // blinds, game-type
	CString format_string;
  if (IsInteger(sym_sblind) && IsInteger(sym_bblind)) {
    // Display as integer numbers
		format_string = "  %s %.0f/%.0f/%.0f\n";
  }
  else {
		// Fractional nunbers: use 2.00 digits  
		format_string = "  %s %.2f/%.2f/%.2f\n";
	}
	s.Format(format_string,
		p_symbol_engine_gametype->GetGameTypeAsString(),
		sym_sblind, sym_bblind, p_symbol_engine_tablelimits->bigbet());
	result.Append(s);

	// ante
	if (sym_ante != 0) {
		s.Format("  Ante: %s\n", Number2CString(sym_ante));
		result.Append(s);
	}

	// Pot
	s.Format("  Pot: %s\n", Number2CString(sym_pot));
	result.Append(s);

  // logged symbols
	if (kMaxLogSymbolsForWhiteBox > 0) {
    result.Append("  ");
    result.Append(_custom_log_message);
	}
  return result;
}
Ejemplo n.º 6
0
static
p_char_int(value chval, type chtag, value ival, type itag)
{

        /* Case of: converting an integer to a character. */ 	

	if (IsRef(chtag))
	{
	    value		v;
	    register char	*s;

	    if (IsRef(itag))
		{ Bip_Error(PDELAY_1_2); }
	    else if (!IsInteger(itag))
		{ Bip_Error(TYPE_ERROR); }
	    if ((ival.nint < 0) || (ival.nint > 255)) 
	    {
		Bip_Error(RANGE_ERROR)
	    }
	    Make_Stack_String(1, v, s);
	    *s++ = ival.nint;
	    *s = '\0';
	    Return_Unify_String(chval, chtag, v.ptr);
	}
	else if (IsString(chtag) && StringLength(chval) == 1)
Ejemplo n.º 7
0
int CSettings::GetInteger(String strSetting)
{
	if(IsInteger(strSetting))
		return GetSetting(strSetting)->iValue;

	return 0;
}
Ejemplo n.º 8
0
/*
 * 	error_id(+Number, ?Message)
 *
 *		Returns the appropriate error message. Fails if the
 *		message string is empty or out of range, so that it
 *		can be used to check whether the given error exists.
 */
static int
p_error_id(value valn, type tagn, value vale, type tage)
{
    Error_If_Ref(tagn);
    Check_Output_String(tage);
    if (IsInteger(tagn))
    {
	if
	(
		valn.nint < 1
		||
		valn.nint >= MAX_ERRORS
		||
		!ErrorMessage[valn.nint]
	)
	{
		Fail_;
	}
	{
	    value v;
	    Cstring_To_Prolog(ErrorMessage[valn.nint], v);
	    Return_Unify_String(vale, tage, v.ptr);
	}
    }
    else if (IsAtom(tagn))
    {
	Return_Unify_String(vale, tage, DidString(valn.did));
    }
    else
    {
	Bip_Error(TYPE_ERROR);
    }
}
Ejemplo n.º 9
0
	int command::IsUserBuy(){
		if (IsBuy(ArrayOfCommand[1]) &&  IsMark(ArrayOfCommand[4])&& JumlahString == 3){
			if (IsInteger(ArrayOfCommand[3]) ){
				if (IsGanja(ArrayOfCommand[2])){
					return 1;
				}
				else if (IsOpium(ArrayOfCommand[2])){
					return 2;				
				}
				else if(IsCoca(ArrayOfCommand[2])){
					return 3;
				
				}
				else if(IsTobacco(ArrayOfCommand[2])){
					return 4;
				}
				else if(IsAnggur(ArrayOfCommand[2])){
					return 5;
				}
				else if(IsMushroom(ArrayOfCommand[2])){
					return 6;
				}
				
			}
		
		
		}
		else return 0;
	}
Ejemplo n.º 10
0
int
p_sincos(value val_arg, type tag_arg,
	value val_sin, type tag_sin,
	value val_cos, type tag_cos)
{
        extern void sincos();       /* from the math library */
        double s, c;
        Prepare_Requests;

        Error_If_Ref(tag_arg);
        Check_Output_Float(tag_sin);
        Check_Output_Float(tag_cos);

        if (IsDouble(tag_arg))
            sincos(Dbl(val_arg), &s, &c);
        else if (IsInteger(tag_arg))
            sincos((double) val_arg.nint, &s, &c);
        else
        {
            Error(TYPE_ERROR);
        }
        Request_Unify_Float(val_sin, tag_sin, s);
        Request_Unify_Float(val_cos, tag_cos, c);
        Return_Unify;
}
Ejemplo n.º 11
0
	bool _IsInteger(const ComplexRational &x)
	{
		if (RatEqual(x.image, RatZero))
			return IsInteger(x.real);
			
		return false;
	}
Ejemplo n.º 12
0
int Winapi
ec_resume2(const pword term, ec_ref chp)
{
    int res;
    pword * pw;
    pword tterm;
    /* this assignment is needed to get around a compiler bug on Alpha Linux
       that otherwise corrupts chp
    */
    tterm = term;

    if (g_emu_.nesting_level > 1)
	ec_panic("can't resume nested engine","ec_resume2()");

    if (ec_running())
	return PRUNNING;

    A[1] = tterm;
    Make_Integer(&A[2], RESUME_CONT);
    res = restart_emulc();
    if (res != PYIELD)
	ec_panic("eclipse emulator did not yield properly","ec_resume()");

    if (chp)
	ec_ref_set(chp,A[2]);

    pw = &A[1];
    Dereference_(pw)
    if (IsInteger(pw->tag))
	return pw->val.nint;
    else
	return  TYPE_ERROR;
}
Ejemplo n.º 13
0
 bool ConvertFromString(const String& str, StringType& res)
 {
   if (!IsInteger(str) && !IsData(str))
   {
     res = StringFromString(str);
     return true;
   }
   return false;
 }
Ejemplo n.º 14
0
	Integer RationalCeiling(Rational &x)
	{
		if (IsInteger(x)) return x.numer;

		if (RatBiggerOrEqual(x, RatZero))
			return (IntPlus(RationalTruncate(x), IntOne));

		return RationalTruncate(x);
	}
Ejemplo n.º 15
0
	Integer RationalFloor(Rational &x)
	{
		if (IsInteger(x)) return x.numer;

		if (RatBiggerOrEqual(x, RatZero))
			return RationalTruncate(x);

		return IntMinus(RationalTruncate(x), IntOne);
	}
Ejemplo n.º 16
0
void TUniform::Animate(int period)
{
    if (!duration)
        return;

    elapsed += period;
    while (elapsed > duration)
        elapsed -= duration;
    
    int total = 0;
    for (TMotionList::iterator i = motions.begin(); i != motions.end(); ++i) {
        if (elapsed < total + i->duration) {
            int numFloatComponents = 0;
            int numIntComponents = 0;

            if (IsInteger())
                numIntComponents = NumComponents();
            else
                numFloatComponents = NumComponents();

            //
            // All three progressions satisfy these conditions:
            //
            //   f(0) = start
            //   f(length) = stop
            //
            //      Linear: f(t) = start + t * (stop - start) / length;
            // Exponential: f(t) = TBD
            // Logarithmic: f(t) = TBD
            //

            if (i->type == Linear) {
                for (int c = 0; c < numFloatComponents; ++c) {
                    float start = i->start.f[c];
                    float stop = i->stop.f[c];
                    value.f[c] = start + (float) (elapsed - total) * (stop - start) / i->duration;
                }

                for (int c = 0; c < numIntComponents; ++c) {
                    int start = i->start.i[c];
                    int stop = i->stop.i[c];
                    float f = (float) (elapsed - total) * (float) (stop - start) / i->duration;
                    value.i[c] = start + (int) f;
                }
            } else if (i->type == Exponential) {
                wxGetApp().Errorf("Exponential motion is not yet implemented.");
            } else if (i->type == Logarithmic) {
                wxGetApp().Errorf("Logarthmic motion is not yet implemented.");
            } else {
                wxGetApp().Errorf("Unknown motion type.");
            }

            break;
        }
        total += i->duration;
    }
}
Ejemplo n.º 17
0
 bool ConvertFromString(const String& str, IntType& res)
 {
   if (IsInteger(str))
   {
     res = IntegerFromString(str);
     return true;
   }
   return false;
 }
Ejemplo n.º 18
0
CString Number2CString(double number, int default_precision) {
	assert(default_precision >= 0);
	CString result;
	if (IsInteger(number)) {
		result.Format("%d", int(number));
	}	else {
		CString format_string;
		format_string.Format("%%1.%if", default_precision);
		result.Format(format_string, number);
	}
	return result;
}
Ejemplo n.º 19
0
    std::string SEXPR::AsString( size_t aLevel )
    {
        std::string result;

        if( IsList() )
        {
            if( aLevel != 0 )
            {
                result = "\n";
            }

            result.append( aLevel* 4, ' ' );
            aLevel++;
            result += "(";

            SEXPR_VECTOR const* list = GetChildren();

            for( std::vector<SEXPR *>::const_iterator it = list->begin(); it != list->end(); ++it )
            {
                result += (*it)->AsString( aLevel );

                if( it != list->end() - 1 )
                {
                    result += " ";
                }
            }
            result += ")";

            aLevel--;
        }
        else if( IsString() )
        {
            result += "\"" + GetString() + "\"";
        }
        else if( IsSymbol() )
        {
            result += GetSymbol();
        }
        else if( IsInteger() )
        {
            std::stringstream out;
            out << GetInteger();
            result += out.str();
        }
        else if( IsDouble() )
        {
            std::stringstream out;
            out << std::setprecision( 16 ) << GetDouble();
            result += out.str();
        }

        return result;
    }
Ejemplo n.º 20
0
bool ValidateLimitations::validateForLoopInit(TIntermLoop* node,
                                              TLoopInfo* info)
{
	TIntermNode* init = node->getInit();
	if (!init) {
		error(node->getLine(), "Missing init declaration", "for");
		return false;
	}

	//
	// init-declaration has the form:
	//     type-specifier identifier = constant-expression
	//
	TIntermAggregate* decl = init->getAsAggregate();
	if (!decl || (decl->getOp() != EOpDeclaration)) {
		error(init->getLine(), "Invalid init declaration", "for");
		return false;
	}
	// To keep things simple do not allow declaration list.
	TIntermSequence& declSeq = decl->getSequence();
	if (declSeq.size() != 1) {
		error(decl->getLine(), "Invalid init declaration", "for");
		return false;
	}
	TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
	if (!declInit || (declInit->getOp() != EOpInitialize)) {
		error(decl->getLine(), "Invalid init declaration", "for");
		return false;
	}
	TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
	if (!symbol) {
		error(declInit->getLine(), "Invalid init declaration", "for");
		return false;
	}
	// The loop index has type int or float.
	TBasicType type = symbol->getBasicType();
	if (!IsInteger(type) && (type != EbtFloat)) {
		error(symbol->getLine(),
			  "Invalid type for loop index", getBasicString(type));
		return false;
	}
	// The loop index is initialized with constant expression.
	if (!isConstExpr(declInit->getRight())) {
		error(declInit->getLine(),
			  "Loop index cannot be initialized with non-constant expression",
			  symbol->getSymbol().c_str());
		return false;
	}

	info->index.id = symbol->getId();
	return true;
}
Ejemplo n.º 21
0
void TUniform::UpdateSlider()
{
    if (!slider.IsValid())
        return;

    if (IsInteger()) {
        for (int c = 0; c < NumComponents(); ++c)
            value.i[c] = slider.current.i[c];
    } else {
        for (int c = 0; c < NumComponents(); ++c)
            value.f[c] = slider.current.f[c];
    }
}
CString CParseTreeTerminalNodeNumber::EvaluateToString(bool log /* = false */) {
  double numerical_result = Evaluate(log);
  CString result;
  if (IsInteger(numerical_result) && EvaluatesToBinaryNumber()) {
    // Generqate binary representation;
    result.Format("%s", IntToBinaryString(int(numerical_result)));
  } else {
    // Generate floating-point representation
    // with 3 digits precision
    result.Format("%.3f", numerical_result);
  }
  return result;
}
Ejemplo n.º 23
0
bool OTVariable::SetValue(const int32_t & nValue)
{
	if (!IsInteger())
	{
		OTLog::vError("OTVariable::SetValue(int64_t): Error: This variable (%s) is not an integer.\n",
					  m_strName.Get());
		return false;
	}

	m_nValue = m_nValueBackup = nValue;

	return true;
}
Ejemplo n.º 24
0
bool Json::operator == (const Json& other) const {
    if (this == &other) return true;
    if (IsNull()) return other.IsNull();
    if (other.IsNull()) return false;
    if (value_->type() != other.value_->type()) return false;
    if (IsInteger()) return integer() == other.integer();
    if (IsUInteger()) return uinteger() == other.uinteger();
    if (IsReal()) return real() == other.real();
    if (IsString()) return string() == other.string();
    if (IsArray())  return array() == other.array();
    if (IsObject()) return object() == other.object();
    return false;
}
Ejemplo n.º 25
0
//============================================================================
//		NNumber::GetFloat64 : Get a Float64 value.
//----------------------------------------------------------------------------
Float64 NNumber::GetFloat64(void) const
{	Float64		theValue;



	// Get the value
	if (IsInteger())
		theValue = (Float64) mValue.integer;
	else
		theValue = (Float64) mValue.real;
	
	return(theValue);
}
Ejemplo n.º 26
0
//============================================================================
//		NNumber::GetInt64 : Get an int64_t value.
//----------------------------------------------------------------------------
int64_t NNumber::GetInt64(void) const
{	int64_t		theValue;



	// Get the value
	if (IsInteger())
		theValue = (int64_t) mValue.integer;
	else
		theValue = (int64_t) mValue.real;
	
	return(theValue);
}
Ejemplo n.º 27
0
//============================================================================
//		NNumber::GetFloat32 : Get a float32_t value.
//----------------------------------------------------------------------------
float32_t NNumber::GetFloat32(void) const
{	float32_t		theValue;



	// Get the value
	if (IsInteger())
		theValue = (float32_t) mValue.integer;
	else
		theValue = (float32_t) mValue.real;
	
	return(theValue);
}
Ejemplo n.º 28
0
void g_DetectTypeAndSet(CJsonNode& node,
        const CTempString& key, const CTempString& value)
{
    if (IsInteger(value))
        node.SetNumber(key, NStr::StringToInt8(value));
    else if (NStr::CompareNocase(value, "FALSE") == 0)
        node.SetBoolean(key, false);
    else if (NStr::CompareNocase(value, "TRUE") == 0)
        node.SetBoolean(key, true);
    else if (NStr::CompareNocase(value, "NONE") == 0)
        node.SetNull(key);
    else
        node.SetString(key, UnquoteIfQuoted(value));
}
Ejemplo n.º 29
0
// Returns the variable type from a string value
// For example: "3" returns integer, "3.14" float and "Hello" string
eVariableTypes CParser::GetVariableType(std::string sValue)
{
    // Either an integer or float
    if(IsFloatOrInteger(sValue))
    {
        // Integer
        if(IsInteger(sValue))
            return VARIABLE_TYPE_INTEGER;

        // Float
        return VARIABLE_TYPE_FLOAT;
    }
    // String
    else return VARIABLE_TYPE_STRING;
}
Ejemplo n.º 30
0
void CPreferences::SetValue(int index_of_variable, double value)
{
	ENT 
	AssertRange(index_of_variable, 0, k_prefs_last_numerical_value);
	prefs_numerical_values[index_of_variable] = value;
	if (IsInteger(value))
	{
		WriteReg(k_registry_keys_for_numerical_values[index_of_variable], int(value));
	}
	else
	{
		WriteReg(k_registry_keys_for_numerical_values[index_of_variable], value);
	}
	write_log(debug_preferences(), "[CPreferences] %s = %s\n",
		k_registry_keys_for_numerical_values[index_of_variable], Number2CString(value));
}