Exemple #1
0
int32_t Any::shr (const Any &l, const Any &r) {
	if (l.type() == Any::Int && r.type() == Any::Int) {
		int32_t a = l.getInt();
		int32_t b = r.getInt();
		uint32_t ret = *reinterpret_cast<uint32_t*>( &a ) >> *reinterpret_cast<uint32_t*>( &b );
		return *reinterpret_cast<int32_t*>( &ret );
	}
Exemple #2
0
Any Any::operator + (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() + r.getInt();
				case Any::Float: return this->getInt() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getInt()) + r.getString();
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return this->getFloat() + r.getInt();
				case Any::Float: return this->getFloat() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getFloat()) + r.getString();
			}
			break;
		case Any::String:
			switch (r.type()) {
				case Any::Int: return this->getString() + boost::lexical_cast<string>(r.getInt());
				case Any::Float: return this->getString() + boost::lexical_cast<string>(r.getFloat());
				case Any::String: return this->getString() + r.getString();
			}
			break;
	}
	FIXME("Unsupported operation %s + %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
void MathInterface::functionAbs(void) {
	Any v = cb->popValue();
	if (v.type() == Any::Float) {
		cb->pushValue(abs(v.getFloat()));
		return;
	}
	cb->pushValue(abs(v.getInt()));
	return;
}
void MathInterface::functionWrapAngle(void) {
	Any a = cb->popValue();
	if (a.type() == Any::Float) {
		cb->pushValue(wrapAngle(a.getFloat()));
	}
	else { // Has to be int
		cb->pushValue(wrapAngle(a.getInt()));
	}
}
Exemple #5
0
Any Any::operator / (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() / r.getInt();
				case Any::Float: return this->getInt() / r.getFloat();
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return this->getFloat() / r.getInt();
				case Any::Float: return this->getFloat() / r.getFloat();
			}
			break;
	}
	FIXME("Unsupported operation %s / %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
Exemple #6
0
Any Any::operator % (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() % r.getInt();
				case Any::Float: return (float)fmod((double)this->getInt(), (double)r.getFloat());
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return (float)fmod((double)this->getFloat(), (double)r.getInt());
				case Any::Float: return (float)fmod(this->getFloat(), r.getFloat());
			}
			break;
	}
	FIXME("Unsupported operation %s % %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
Exemple #7
0
Any Any::operator << (const Any &r) const {
	if (this->type() == Any::Int && r.type() == Any::Int) {
		int32_t a = this->getInt();
		int32_t b = r.getInt();
		uint32_t ret = *reinterpret_cast<uint32_t*>( &a ) << *reinterpret_cast<uint32_t*>( &b );
		return *reinterpret_cast<int32_t*>( &ret );
	}
	FIXME("Unsupported operation %s << %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
void StringInterface::functionStr(void) {
	Any a = cb->popValue();
	switch (a.type()) {
		case Any::Int:
			cb->pushValue(lexical_cast<string>(a.getInt()));
		return;
		case Any::Float:
			cb->pushValue(lexical_cast<string>(a.getFloat()));
		return;
		default:
			cb->pushValue(a);
	}
}