示例#1
0
int
isValidIOProcInvocation(Symbol *s, struct ElementArray *ea)
{
	Symbol *param = NULL;
	type_t type;
	int i, nArgs, valid = 1;

	nArgs = ea->nElements;

	// TODO use is isElementArraySimple() to do type checking?
	for (i = 0; i < nArgs; i++) {
		param = ((struct treeNode *)getElementAt(ea, i))->symbol;
		type = getType(param);
		
		if (!isArgTypeValidInIOFunc(s, param)) {
			errMsg = customErrorString("Invalid argument "
			    "of type %s passed to procedure %s.",
			    typeToString(type), s->name);
			recordError(errMsg, yylineno, colno, SEMANTIC);
			valid = 0;
		}
	}
	if (!valid) return 0;
	return 1;
}
示例#2
0
/* ea is an array of nodes now */
ProxySymbol *isValidPreDefFuncInvocation(Symbol *s, struct ElementArray *ea)
{
	Symbol *param = NULL;
	Symbol * type;
	int i = 0;
	int nArgs = 0;

	nArgs = ea->nElements;

	// check argument count
	if (nArgs != 1) {
		errMsg = customErrorString("Function %s expected "
		    "1 argument but %d given.", s->name, nArgs);
		recordError(errMsg, yylineno, colno, SEMANTIC);
		return 0;
	}
	
	param = ((struct treeNode *)getElementAt(ea, i))->symbol;
	type = getTypeSym(param);
	
	if (isArgTypeValidInPreDefFunc(s, param)) {
		return getPreDefFuncReturnType(s, type);
			
	} else {
		errMsg = customErrorString("Function %s cannot be "
		    "called with argument of type %s.", s->name,
		    typeToString(getType(type)));
		recordError(errMsg, yylineno, colno, SEMANTIC);
		return 0;
	}
}
示例#3
0
bool QLCInputChannel::saveXML(QDomDocument* doc, QDomElement* root) const
{
	QDomElement subtag;
	QDomElement tag;
	QDomText text;
	QString str;

	Q_ASSERT(doc != NULL);
	Q_ASSERT(root != NULL);

	/* The channel tag */
	tag = doc->createElement(KXMLQLCInputChannel);
	root->appendChild(tag);

	/* Channel number attribute */
	tag.setAttribute(KXMLQLCInputChannelNumber,
			 QString("%1").arg(m_channel));

	/* Name */
	subtag = doc->createElement(KXMLQLCInputChannelName);
	tag.appendChild(subtag);
	text = doc->createTextNode(m_name);
	subtag.appendChild(text);

	/* Type */
	subtag = doc->createElement(KXMLQLCInputChannelType);
	tag.appendChild(subtag);
	text = doc->createTextNode(typeToString(m_type));
	subtag.appendChild(text);

	return true;
}
示例#4
0
rc_t ProcessOneDo (ProcessOne * self)
{
    static const char F[] = PLOG_2(PLOG_S(p),PLOG_S(t));
    enum KPathType type;
    rc_t rc = 0;
    
    type = KDirectoryPathType (self->dir, self->path);

    switch (type)
    {
    case kptFile:
	rc = ProcessOneDoFile (self);
 	break;
/*     case kptDir: */
/* 	break; */
/*     case kptAlias|kptFile: */
/* 	break; */
/*     case kptAlias|kptDir: */
/* 	break; */
    default:
	PLOGMSG (klogInfo, "+ Skipping $(p) of type $(t)", F, self->path, typeToString(type));
	break;
    }
    return rc;
}
void ofApp::draw(){
    ofSetColor(255, 255, 255, alpha);
    if((type==MOVIE)&&(state!=STOPPED)) {
        videoPlayer.draw(x, y, w, h);
    } else if((type==IMAGE)&&(state!=STOPPED)) {
        stillImage.draw(x, y, w, h);
    } else if(type==NOTFOUND) {
        ofSetHexColor(0xFFFFFF);
        ofDrawBitmapString("file '"+fileName+"' not found!", 300, 300);
    }
    if(info) {
        ofSetHexColor(0xFFFFFF);
        ofDrawBitmapString("listening on port: "+ofToString(PORT), 30, 30);
        ofDrawBitmapString("last osc: "+message, 30, 50);
        ofDrawBitmapString("screen resolution: "+ofToString(ofGetScreenWidth())+"x"+ofToString(ofGetScreenHeight()), 30, 70);
        ofDrawBitmapString("framerate: "+ofToString(ofGetFrameRate()), 30, 90);
        ofDrawBitmapString("fileName: "+fileName, 30, 110);
        ofDrawBitmapString("media type: "+typeToString(type), 30, 130);
        ofDrawBitmapString("media resolution: "+ofToString(ow)+"x"+ofToString(oh), 30, 150);
        ofDrawBitmapString("mode: "+modeToString(mode), 30, 170);
        ofDrawBitmapString("loopMode: "+ofToString(loopMode), 30, 190);
        ofDrawBitmapString("frames: "+ofToString(frames), 30, 210);
        ofDrawBitmapString("speed: "+ofToString(speed), 30, 230);
        ofDrawBitmapString("alpha: "+ofToString(alpha), 30, 250);
        ofDrawBitmapString("state: "+stateToString(state), 30, 270);
    }
}
示例#6
0
bool Collection::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::Collection))
    {
        qWarning() << Q_FUNC_INFO << root.attribute(KXMLQLCFunctionType)
                   << "is not a collection";
        return false;
    }

    /* Load collection contents */
    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCFunctionStep)
            addFunction(tag.text().toInt());
        else
            qWarning() << Q_FUNC_INFO << "Unknown collection tag:" << tag.tagName();

        node = node.nextSibling();
    }

    return true;
}
void printHashtable(Hashtable *env, char* buf2) {
    int i;
    char typeNameBuf[128];
    sprintf(buf2, "len: %d\n", env->len);
    int k = 0;
    for (i = 0; i < env->size; i++) {
        struct bucket *b = env->buckets[i];
        while (b != NULL) {
            Res *res = (Res *) b->value;
            if (k != 0)strncat(buf2, "\n", MAX_NAME_LEN - strlen(buf2));
            strncat(buf2, b->key, MAX_NAME_LEN - strlen(buf2));
            strncat(buf2, "=", MAX_NAME_LEN - strlen(buf2));
            if (res == NULL) {
                strncat(buf2, "<null>", MAX_NAME_LEN - strlen(buf2));
            } else {
                char *buf4 = convertResToString(res);
                strncat(buf2, buf4, MAX_NAME_LEN - strlen(buf2));
                strncat(buf2, ":", MAX_NAME_LEN - strlen(buf2));
                strncat(buf2, res->exprType == NULL? "<null>" : typeToString(res->exprType, NULL, typeNameBuf, 128), MAX_NAME_LEN - strlen(buf2));
                free(buf4);
            }
            k++;
            b = b->next;
        }
    }
}
示例#8
0
QString Function::path(bool simplified) const
{
    if (simplified == true)
        return m_path;
    else
        return QString("%1/%2").arg(typeToString(type())).arg(m_path);
}
示例#9
0
//
// Name: reportError()
// Discription: This helper function is used to output a error in a common way
//              accross all instructions.
// Parameters: char* error - The error to ouput.
//             int* num - If num is non NULL it will be printed directly after
//             the error.
// Returns: void
//
void Instruction::reportError(const char *error, int *num) {
    cerr << "Line:" << lineNumber << " Command:" << typeToString(type)
    << " Error: " << error ;
    if (num != NULL) {
        cerr << (*num);
    }
    cerr << endl;
}
示例#10
0
QDebug operator<<(QDebug dbg, const CoverInfo& info) {
    return dbg.maybeSpace() << QString("CoverInfo(%1,%2,%3,%4,%5,%6)")
            .arg(typeToString(info.type))
            .arg(sourceToString(info.source))
            .arg(info.coverLocation)
            .arg(QString::number(info.hash))
            .arg(info.trackLocation);
}
示例#11
0
Symbol *
isValidFuncInvocation(Symbol *s, struct ElementArray *ea)
{
	struct ElementArray *params = NULL;
	Symbol *passedParam, *expectedParam = NULL;
	int i;

	// make sure we're given a func and not a proc
	if (s->kind != FUNC_KIND) {
		errMsg = customErrorString("Identifier %s cannot be "
 			"called as a function.", s->name);
		e = recordError(errMsg, yylineno, colno, SEMANTIC);
		return 0;
	}

	params = s->kindPtr.FuncKind->params;
	if (!params) {
		// special case of predefined-function
		// TODO check what types are acceptable,
		// for now assuming all types
		return getTypeSym(s);
	} else if (params->nElements != ea->nElements) {
		errMsg = customErrorString("Procedure %s expects %d "
		    "parameters, got %d", s->name, params->nElements,
		    ea->nElements);
		e = recordError(errMsg, yylineno, colno, SEMANTIC);
		return NULL;	
	}

	// TODO: should'nt call to is areSameType below be a call to
	// are assignment compatible? 
	for (i = 0; i < params->nElements; i++) {
		passedParam = ((struct treeNode *)getElementAt(ea, i))->symbol;
		expectedParam = (Symbol *) getElementAt(params, i);
		if (!isAssignmentCompat(expectedParam,passedParam)) {
			errMsg = customErrorString("Procedure %s expects "
			    "argument of type %s at index %d, but got "
			    "argument of type %s", s->name,
			    typeToString(getType(expectedParam)),i,
			    typeToString(getType(passedParam)));
			e = recordError(errMsg, yylineno, colno, SEMANTIC);
			return NULL;
		}
	}
	return getTypeSym(s);
}
示例#12
0
bool RGBMatrix::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::RGBMatrix))
    {
        qWarning() << Q_FUNC_INFO << "Function is not an RGB matrix";
        return false;
    }

    /* Load matrix contents */
    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(tag);
        }
        else if (tag.tagName() == KXMLQLCRGBAlgorithm)
        {
            setAlgorithm(RGBAlgorithm::loader(doc(), tag));
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixFixtureGroup)
        {
            setFixtureGroup(tag.text().toUInt());
        }
        else if (tag.tagName() == KXMLQLCFunctionDirection)
        {
            loadXMLDirection(tag);
        }
        else if (tag.tagName() == KXMLQLCFunctionRunOrder)
        {
            loadXMLRunOrder(tag);
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixStartColor)
        {
            setStartColor(QColor::fromRgb(QRgb(tag.text().toUInt())));
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixEndColor)
        {
            setEndColor(QColor::fromRgb(QRgb(tag.text().toUInt())));
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGB matrix tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}
示例#13
0
std::string Scene::Mesh::toString() const {
    return tfm::format(
        "Mesh[\n"
        "  type = %s,\n"
        "  filename = %s\n"
        "]",
        typeToString(type), filename
    );
}
示例#14
0
std::string Scene::Box::toString() const {
    return tfm::format(
        "Box[\n"
        "  type = %s,\n"
        "  bounds = %s\n"
        "]",
        typeToString(type), bounds
    );
}
示例#15
0
int Stats::getTypeCount(type_t t) {
    std::string k = typeToString(t);
    if (stats_.find(k) == stats_.end()) {
        return -1;
    }
    else {
        return stats_[k];
    }
}
示例#16
0
void check_failed_MatType(const int v, const CheckContext& ctx)
{
    std::stringstream ss;
    ss  << ctx.message << ":" << std::endl
        << "    '" << ctx.p2_str << "'" << std::endl
        << "where" << std::endl
        << "    '" << ctx.p1_str << "' is " << v << " (" << typeToString(v) << ")";
    cv::errorNoReturn(cv::Error::StsError, ss.str(), ctx.func, ctx.file, ctx.line);
}
void SemanticAnalyzer::visit(AssignStatement& node)
{
	std::string varName = node.varID;
	for(unsigned i=0; i<symbolTable.size(); i++)
	{
		if(!symbolTable.at(i).name.compare(varName))
		{
			ValueType type = node.expression->typeCheck(*this);
			if(symbolTable.at(i).declType != type)
			{
				std::cout << "Trying to assign type " << typeToString(type) 
					<< " to type " << typeToString(symbolTable.at(i).declType) << " at line " << node.lineNumber << "." << std::endl;
				errors = true;
			};
			symbolTable.at(i).type = type;
		}
	}
};
void SemanticAnalyzer::visit(PrintStatement& node)
{
	ValueType type = node.expression->typeCheck(*this);
	if(type == ValueType::undefined || type == ValueType::undeclared)
	{
		std::cout << "Trying to print an " << typeToString(type) << " identifier at line " << node.lineNumber << std::endl;
		errors = true;
	}
};
示例#19
0
std::string Scene::Sphere::toString() const {
    return tfm::format(
        "Sphere[\n"
        "  type = %s,\n"
        "  position = %s,\n"
        "  radius = %f\n"
        "]",
        typeToString(type), position, radius
    );
}
示例#20
0
/*
 * Return 1 if valid invocation, 0 otherwise.
 */
int isValidProcInvocation(Symbol *s, struct ElementArray *ea)
{
	struct ElementArray *params = NULL;
	Symbol *passedParam, *expectedParam = NULL;
	int i;

	// make sure we're given a proc and not a func or any other symbol
	if (s->kind != PROC_KIND) {
		errMsg = customErrorString("Identifier %s cannot be called "
		    "as a procedure.", s->name);
		e = recordError(errMsg, yylineno, colno, SEMANTIC);
		return 0;
	}

	params = s->kindPtr.ProcKind->params;
	if (!params) {
		// special built-in proc that takes unlimited args
		// TODO for now just assuming all arguments are valid
		return 1;
	} else if (params->nElements != ea->nElements) {
		errMsg = customErrorString("Procedure %s expects %d "
		    "parameters, got %d", s->name, params->nElements,
		    ea->nElements);
		e = recordError(errMsg, yylineno, colno, SEMANTIC);
		return 0;	
	}

	for (i = 0; (i < params->nElements) && (i < ea->nElements); i++) {
		passedParam = ((struct treeNode *)getElementAt(ea, i))->symbol;
		expectedParam = (Symbol *) getElementAt(params, i);
		if (!isAssignmentCompat(expectedParam, passedParam)) {
			errMsg = customErrorString("Procedure %s expects "
			    "argument of type %s at index %d, but got "
			    "argument of type %s", s->name,
			    typeToString(getType(expectedParam)), i,
			    typeToString(getType(passedParam)));
			e = recordError(errMsg, yylineno, colno,
			     SEMANTIC);
			return 0;
		}
	}
	return 1;
}
示例#21
0
XmlDomElement* GridProperties::serializeToXmlDomElement() const throw (Exception)
{
    if (!checkAttributesValidity()) throw LogicError(__FILE__, __LINE__);

    QScopedPointer<XmlDomElement> root(new XmlDomElement("grid_properties"));
    root->setAttribute("type", typeToString(mType));
    root->setAttribute("interval", mInterval);
    root->setAttribute("unit", mUnit);
    return root.take();
}
示例#22
0
文件: value.cpp 项目: Krolcom/mongo
 Status Value::get(double* val) const {
     if (_type != Double) {
         StringBuilder sb;
         sb << "Attempting to get Value as type: Double, but Value is of type: "
            << typeToString();
         return Status(ErrorCodes::TypeMismatch, sb.str());
     }
     *val = _doubleVal;
     return Status::OK();
 }
示例#23
0
文件: value.cpp 项目: Krolcom/mongo
 Status Value::get(std::string* val) const {
     if (_type != String) {
         StringBuilder sb;
         sb << "Attempting to get Value as type: string, but Value is of type: "
            << typeToString();
         return Status(ErrorCodes::TypeMismatch, sb.str());
     }
     *val = _stringVal;
     return Status::OK();
 }
示例#24
0
文件: value.cpp 项目: Krolcom/mongo
 Status Value::get(bool* val) const {
     if (_type != Bool) {
         StringBuilder sb;
         sb << "Attempting to get Value as type: Bool, but Value is of type: "
            << typeToString();
         return Status(ErrorCodes::TypeMismatch, sb.str());
     }
     *val = _boolVal;
     return Status::OK();
 }
示例#25
0
文件: value.cpp 项目: Krolcom/mongo
 Status Value::get(unsigned* val) const {
     if (_type != Unsigned) {
         StringBuilder sb;
         sb << "Attempting to get Value as type: Unsigned, but Value is of type: "
            << typeToString();
         return Status(ErrorCodes::TypeMismatch, sb.str());
     }
     *val = _unsignedVal;
     return Status::OK();
 }
示例#26
0
bool FootprintPad::checkAttributesValidity() const noexcept
{
    if (mUuid.isNull())                     return false;
    if (typeToString(mType).isEmpty())      return false;
    if (mWidth <= 0)                        return false;
    if (mHeight <= 0)                       return false;
    if (mDrillDiameter < 0)                 return false;
    if (mNames.value("en_US").isEmpty())    return false;
    if (!mDescriptions.contains("en_US"))   return false;
    return true;
}
示例#27
0
ServerInfo_Zone::ServerInfo_Zone(const QString &_name, ZoneType _type, bool _hasCoords, int _cardCount, const QList<ServerInfo_Card *> &_cardList)
	: SerializableItem_Map("zone")
{
	insertItem(new SerializableItem_String("name", _name));
	insertItem(new SerializableItem_String("zone_type", typeToString(_type)));
	insertItem(new SerializableItem_Bool("has_coords", _hasCoords));
	insertItem(new SerializableItem_Int("card_count", _cardCount));
	
	for (int i = 0; i < _cardList.size(); ++i)
		itemList.append(_cardList[i]);
}
示例#28
0
/* given a name and a functiontype, assembles a function signature */
String FunctionMap::getFunctionSignature(const String name, const DataType* type) {
    /* this returns the whole type including return */
    String signature = name + typeToString(&((*(type->subtypes))[0]));

    /* if there is an arrow in it, remove it */
    int idx = signature.indexOf("->");
    if (idx != -1) {
        signature = signature.substring(0, idx);
    }

    return signature;
}
示例#29
0
void SnarlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
	int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
	int notificationID = snarl.EZNotify(
			typeToString(type).c_str(),
			subject.c_str(),
			description.c_str(),
			timeout,
			picture.string().c_str());
	if (notificationID > 0) {
		notifications.insert(std::make_pair(notificationID, callback));
	}
}
json_t *CalaosEvent::toJson() const
{
    json_t *ret;

    ret = json_pack("{s:s, s:s, s:s, s:o}",
                    "event_raw", toString().c_str(),
                    "type", Utils::to_string(getType()).c_str(),
                    "type_str", typeToString(getType()).c_str(),
                    "data", evParams.toJson());

    return ret;
}