Ejemplo n.º 1
0
int main (){
  Any a2 = Int(1);
  Any a3 = Int(3);
  sr8tup a4 = { a2, a3 };
  Any a5 = Int(4);
  Any a6 = Int(8);
  sr8tup a7 = { a5, a6 };
  Any a8[] = {a4, a7};
  Any a1 = a8;
  Any a9 = Int(0);
  Any a10 = Int(2);
  a1[a9.i] = a10;
  Any a15 = a1;
  Any a14 = toStr ( a15 );
  println ( a14 );
  return 0;
}
Ejemplo n.º 2
0
static void loadXMLController(unsigned int controller[], const char * name)
{
	item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);

	if(item)
	{
		// populate buttons
		for(int i=0; i < MAXJP; i++)
		{
			elem = mxmlFindElement(item, xml, "button", "number", toStr(i), MXML_DESCEND);
			if(elem)
			{
				const char * tmp = mxmlElementGetAttr(elem, "assignment");
				if(tmp)
					controller[i] = atoi(tmp);
			}
		}
	}
}
Ejemplo n.º 3
0
void PromelaDataModel::setVariable(void* ast, Data value) {
	PromelaParserNode* node = (PromelaParserNode*)ast;

	std::list<PromelaParserNode*>::iterator opIter = node->operands.begin();
	switch (node->type) {
	case PML_VAR_ARRAY: {
		PromelaParserNode* name = *opIter++;
		PromelaParserNode* expr = *opIter++;

		if (INVALID_ASSIGNMENT(name->value)) {
			ERROR_EXECUTION_THROW("Cannot assign to " + name->value);
		}

		int index = dataToInt(evaluateExpr(expr));

		if (_variables.compound.find(name->value) == _variables.compound.end()) {
			ERROR_EXECUTION_THROW("No variable " + name->value + " was declared");
		}

		if (!_variables[name->value].hasKey("size")) {
			ERROR_EXECUTION_THROW("Variable " + name->value + " is no array");
		}

		if (strTo<int>(_variables[name->value]["size"].atom) <= index) {
			ERROR_EXECUTION_THROW("Index " + toStr(index) + " in array " + name->value + "[" + _variables[name->value]["size"].atom + "] is out of bounds");
		}

		_variables.compound[name->value].compound["value"][index] = value;

		break;
	}
	case PML_NAME:
		if (INVALID_ASSIGNMENT(node->value)) {
			ERROR_EXECUTION_THROW("Cannot assign to " + node->value);
		}
		_variables.compound[node->value].compound["value"] = value;
		break;
	default:
		break;
	}

//	std::cout << Data::toJSON(_variables) << std::endl;
}
Ejemplo n.º 4
0
		string get181Validator(const string& mPackPath, const string& mLevelId, const string& mJsonRootPath, const string& mLuaScriptPath, float mDifficultyMultiplier)
		{
			string luaScriptContents{get181FileContents(mLuaScriptPath)}, result{""};
			unordered_set<string> luaScriptNames;
			recursiveFillIncludedLuaFileNames(luaScriptNames, mPackPath, luaScriptContents);

			result.append(get181UrlEncoded(mLevelId));
			result.append(get181MD5Hash(get181FileContents(mJsonRootPath) + serverKey182));
			result.append(get181MD5Hash(luaScriptContents + serverKey182));

			for(auto& luaScriptName : luaScriptNames)
			{
				string path{mPackPath + "/Scripts/" + luaScriptName}, contents{get181FileContents(path)}, hash{get181MD5Hash(contents + serverKey182)}, compressedHash{""};
				for(unsigned int i{0}; i < hash.length(); ++i) if(i % 3 == 0) compressedHash.append(toStr(hash[i]));
				result.append(compressedHash);
			}

			result.append(get181UrlEncoded(toStr(mDifficultyMultiplier))); return result;
		}
Ejemplo n.º 5
0
 TaskPtr Gem::updateCountdown()
 {
     if(this->mCountdown == NULL ) return TaskIgnore::make();
     
     auto pre = CCSpawn::create(CCScaleTo::create(0.25f, contentScale()*2),
                                CCFadeTo::create(0.25f, 155),
                                NULL);
     
     auto rev = CCSpawn::create(CCScaleTo::create(0.25f, contentScale()),
                                CCFadeTo::create(0.25f, 255),
                                NULL);
     
     auto action = CCCallLambda::create([=]()
     {
         this->mCountdown->setString(toStr(this->mTurn).c_str());
     });
     return TaskAnim::make(this->mCountdown,
                           CCSequence::create(pre,rev,action,NULL), false);
 }
Ejemplo n.º 6
0
guint IMInvoker::purpleEventInputAdd(int fd, PurpleInputCondition cond, PurpleInputFunction func, gpointer data) {
	PurpleEventContext* ctx = new PurpleEventContext();
	ctx->function = NULL;
	ctx->input = func;
	ctx->inputFD = fd;
	ctx->cond = cond;
	ctx->data = data;

	short opMask = 0;
	if (cond & PURPLE_INPUT_READ)
		opMask |= DelayedEventQueue::DEQ_READ;
	if (cond & PURPLE_INPUT_WRITE)
		opMask |= DelayedEventQueue::DEQ_WRITE;

	guint eventId = g_rand_int(_gRand);
//	std::cout << "-- Input add " << eventId << " --------" << fd << std::endl;
	_eventQueue->addEvent(toStr(eventId), fd, opMask, purpleCallback, ctx, true);
	return eventId;
}
Ejemplo n.º 7
0
int main (){
  Any a2 = Int(1);
  Any a3 = Int(2);
  Any a4 = Int(3);
  Any a5[] = {a2, a3, a4};
  Any *a1 = a5;
  Any a7 = Real(4.23);
  Any a8 = Real(5.5);
  Any a9[] = {a7, a8};
  Any *a6 = a9;
  Any *a10 = a6;
  Any *a11 = a1;
  #### appending arrays not yet catered for;
  a6 = Null();
  Any a17 = a6;
  Any a16 = toStr ( a17 );
  println ( a16 );
  return 0;
}
Ejemplo n.º 8
0
TQString TQtRegExpConverter::toString( RepeatRegExp* regexp, bool markSelection )
{
    RegExp* child = regexp->child();
    TQString cText = toStr( child, markSelection );
    TQString startPar;
    TQString endPar;

    if ( markSelection ) {
        if ( !regexp->isSelected() && child->isSelected()) {
            startPar = TQString::fromLatin1( "(" );
            endPar = TQString::fromLatin1( ")" );
        }
        else if ( child->precedence() < regexp->precedence() ) {
            startPar = TQString::fromLatin1( "(?:" );
            endPar = TQString::fromLatin1( ")" );
        }
    }
    else if ( child->precedence() < regexp->precedence() ) {
        startPar = TQString::fromLatin1( "(" );
        endPar = TQString::fromLatin1( ")" );
    }

    if ( regexp->min() == 0 && regexp->max() == -1) {
        return startPar + cText +endPar + TQString::fromLocal8Bit("*");
    }
    else if ( regexp->min() == 0 && regexp->max() == 1 ) {
        return startPar + cText + endPar + TQString::fromLocal8Bit("?");
    }
    else if ( regexp->min() == 1 && regexp->max() == -1 ) {
        return startPar + cText + endPar + TQString::fromLocal8Bit("+");
    }
    else if ( regexp->max() == -1 ) {
        return startPar + cText + endPar + TQString::fromLocal8Bit("{") +
            TQString::number( regexp->min() ) + TQString::fromLocal8Bit(",") +
            TQString::fromLocal8Bit("}");
    }
    else {
        return startPar + cText + endPar + TQString::fromLocal8Bit("{") +
            TQString::number( regexp->min() ) + TQString::fromLocal8Bit(",") +
            TQString::number( regexp->max() ) + TQString::fromLocal8Bit("}");
    }
}
Ejemplo n.º 9
0
void RTPPublisher::removed(const SubscriberStub& sub, const NodeStub& node) {
	RScopeLock lock(_mutex);
	int status;
	std::string ip = sub.getIP();
	uint16_t port = sub.getPort();
	if (!ip.length())		//only use separate subscriber ip (for multicast support etc.), if specified
		ip = node.getIP();

	// do we now about this sub via this node?
	bool subscriptionFound = false;
	std::pair<_domainSubs_t::iterator, _domainSubs_t::iterator> subIter = _domainSubs.equal_range(sub.getUUID());
	while(subIter.first !=  subIter.second) {
		if (subIter.first->second.first.getUUID() ==  node.getUUID()) {
			subscriptionFound = true;
			break;
		}
		subIter.first++;
	}
	if (!subscriptionFound)
		return;

	UM_LOG_INFO("%s: lost a %s subscriber (%s:%u) for channel %s", SHORT_UUID(_uuid).c_str(), sub.isMulticast() ? "multicast" : "unicast", ip.c_str(), port, _channelName.c_str());

	struct libre::sa addr;
	libre::sa_init(&addr, AF_INET);
	if ((status = libre::sa_set_str(&addr, ip.c_str(), port)))
		UM_LOG_WARN("%s: error %d in libre::sa_set_str(%s:%u): %s", SHORT_UUID(_uuid).c_str(), status, ip.c_str(), port, strerror(status));
	else
		_destinations.erase(ip+":"+toStr(port));

	if (_domainSubs.count(sub.getUUID()) ==  1) { // about to vanish
		if (_greeter !=  NULL) {
			Publisher pub(Publisher(StaticPtrCast<PublisherImpl>(shared_from_this())));
			_greeter->farewell(pub, sub);
		}
		_subs.erase(sub.getUUID());
	}

	_domainSubs.erase(subIter.first);
	UMUNDO_SIGNAL(_pubLock);
}
Ejemplo n.º 10
0
shared_ptr<ParseResult> Choice::match(TokenBuffer &buffer)
{
    QStringList errs;
    for(int i=0; i<res.count(); i++)
    {
        shared_ptr<Parser> p = res[i];
        TokenBuffer::State s;
        buffer.saveState(s);

        shared_ptr<ParseResult> result = p->match(buffer);
        if(result->success())
            return result;
        errs.append(result->toPartialString());
        buffer.restoreState(s);
    }
    QString found = buffer.eof()? "EOF" : toStr(buffer.readAhead());

    shared_ptr<ExpectedOneOf> err = expectedOneOf(buffer.GetPos(), found);
    err->what += errs;
    return err;
}
Ejemplo n.º 11
0
int main (){
  Any a3 = Int(2);
  Any a4 = neg(a3);
  Any a5 = Int(3);
  Any a6 = neg(a5);
  Any a7 = Int(1);
  Any a8 = Int(2);
  Any a9 = Int(23);
  Any a10 = neg(a9);
  Any a11 = Int(3);
  Any a12 = Int(2345);
  Any a13 = Int(4);
  Any a14 = Int(5);
  Any a15[] = {a4, a6, a7, a8, a10, a11, a12, a13, a14};
  Any a2 = extract ( a15 );
  Any a1 = a2;
  Any a20 = a1;
  Any a19 = toStr ( a20 );
  println ( a19 );
  return 0;
}
Ejemplo n.º 12
0
Archivo: cx.c Proyecto: Matt--/wyce
int main (){
  Any a2, a3, a4;
	a2 = Int(4);
  a3 = Int(5);
  a4 = Tuple( a2, a3);

	// current state of a2, pointed to by a4.ptr[0]
 	printf("\n\n");
	Any* x_address = ((Any**)a4.ptr)[0];
		printf ("x address is %d\n", x_address);
		printf ("x is %d\n", x_address->i);

	//==========================================
	// the method pass
	//==========================================
  printf("-----enter method-----\n");
  toStr ( a4 );
  printf("\n\n\n");

  return;
}
Ejemplo n.º 13
0
int main (){
  Any a2 = Byte(00000000b);
  Any a3 = Byte(00000101b);
  Any a4 = Byte(00000000b);
  Any a5 = Byte(00000110b);
  Any a6 = Byte(00000000b);
  Any a7 = Byte(00000101b);
  Any a8[] = {a2, a3, a4, a5, a6, a7};
  Any a12 = Int(0);
  Any a14 = Int( sizeof( a8 ) / sizeof( a8[0] ) );
  Any a15 = Int(2);
  Any a16 = sub( a14 , a15);
  Any a22 = Int(0);
  a22 = Int(0);
  Any a10 = match ( a8, a12, a16 );
  Any a9 = a10;
  Any a21 = a9;
  Any a20 = toStr ( a21 );
  println ( a20 );
  return 0;
}
Ejemplo n.º 14
0
void RTPPublisher::added(const SubscriberStub& sub, const NodeStub& node) {
	RScopeLock lock(_mutex);
	int status;

	std::string ip = sub.getIP();
	uint16_t port = sub.getPort();
	if (!ip.length())		//only use separate subscriber ip (for multicast support etc.), if specified
		ip = node.getIP();

	// do we already now about this sub via this node?
	std::pair<_domainSubs_t::iterator, _domainSubs_t::iterator> subIter = _domainSubs.equal_range(sub.getUUID());
	while(subIter.first !=  subIter.second) {
		if (subIter.first->second.first.getUUID() ==  node.getUUID())
			return; // we already know about this sub from this node
		subIter.first++;
	}

	UM_LOG_INFO("%s: received a new %s subscriber (%s:%u) for channel %s", SHORT_UUID(_uuid).c_str(), sub.isMulticast() ? "multicast" : "unicast", ip.c_str(), port, _channelName.c_str());

	struct libre::sa addr;
	libre::sa_init(&addr, AF_INET);
	status = libre::sa_set_str(&addr, ip.c_str(), port);

	if (status) {
		UM_LOG_WARN("%s: error %d in libre::sa_set_str(%s:%u): %s", SHORT_UUID(_uuid).c_str(), status, ip.c_str(), port, strerror(status));
	} else {
		_destinations[ip + ":" + toStr(port)] = addr;
	}

	_subs[sub.getUUID()] = sub;
	_domainSubs.insert(std::make_pair(sub.getUUID(), std::make_pair(node, sub)));

	if (_greeter !=  NULL && _domainSubs.count(sub.getUUID()) ==  1) {
		// only perform greeting for first occurence of subscriber
		Publisher pub(StaticPtrCast<PublisherImpl>(shared_from_this()));
		_greeter->welcome(pub, sub);
	}

	UMUNDO_SIGNAL(_pubLock);
}
Ejemplo n.º 15
0
void DetectionParameters::writeToStream(std::ostream& os) {
    // Only write the parameters that are set by model options
    // these are the options that a user can set
    os << "\tcachesize:" << itsSizeAvgCache;
    os << "\tminarea:" << itsMinEventArea << "\tmaxarea:" << itsMaxEventArea;
    os << "\ttrackingmode:" << trackingModeName(itsTrackingMode); 
    os << "\tsegmentalgorithminputimagetype:" << segmentAlgorithmInputImageType(itsSegmentAlgorithmInputType);
    os << "\tsegmentalgorithmtype:" << segmentAlgorithmType(itsSegmentAlgorithmType);
    os << "\tsegmentadaptiveparameters:" << itsSegmentAdaptiveParameters;
    os << "\tsaliencyinputimagetype:" << saliencyInputImageType(itsSaliencyInputType);
    os << "\tusefoamaskregion:" << itsUseFoaMaskRegion;
    os << "\tsaliencyrescale:" << toStr(itsRescaleSaliency);
    os << "\tsegmentgraphparameters:" << itsSegmentGraphParameters;
    os << "\txkalmanfilterparameters:" << itsXKalmanFilterParameters;
    os << "\tykalmanfilterparameters:" << itsYKalmanFilterParameters;
    os << "\tcleanupelementsize:" << itsCleanupStructureElementSize;
    os << "\tminframes:" << itsMinEventFrames;
    os << "\tmaxframes:" << itsMaxEventFrames;
    os << "\tmaxdist:" << itsMaxDist;
    os << "\tsaliencyframedist:" << itsSaliencyFrameDist;
    os << "\tmaxcost:" << itsMaxCost;
    os << "\tmaxevolvetime(msecs):" << itsMaxEvolveTime;
    os << "\tmaxwtapoints:" << itsMaxWTAPoints;
    os << "\tsavenoninteresting:" << itsSaveNonInteresting;
    os << "\tsaveoriginalframespec:" << itsSaveOriginalFrameSpec;
    os << "\taddgraphpoints:" << itsMaskLasers;
    os << "\tcolorspace:" << colorSpaceType(itsColorSpaceType);
    os << "\tminstddev:" << itsMinStdDev;
    os << "\teventexpirationframes:" << itsEventExpirationFrames;

    os << "\tdynamicmask:" << itsMaskDynamic;
    if (itsMaskPath.length() > 0) {
        os << "\tmaskpath:" << itsMaskPath;
        os << "\tmaskxposition:" << itsMaskXPosition;
        os << "\tmaskyposition:" << itsMaskYPosition;
        os << "\tmaskwidth:" << itsMaskWidth;
        os << "\tmaskheight:" << itsMaskHeight;
    }
    os << "\n";
}
Ejemplo n.º 16
0
  bool KineticEnergyTypesData::writeToFile(string fileName, bool useName) {
    // The name of the directory for this data
    string dirName = fileName;
    if (*fileName.rbegin()=='/') // Make sure there is a /
      dirName += dataName+"/";
    else 
      dirName += ("/"+dataName+"/");

    // Write the data
    // Create a directory for all the data
    mkdir(dirName.c_str(), 0777);
    for (int ty=0; ty<ntypes; ++ty) {
      ofstream fout(dirName+dataName+toStr(ty)+".csv");
      if (fout.fail()) return false;
      for (auto ke : keData[ty])
        fout << ke.first << "," << ke.second << endl;
      fout.close();
    }

    // Return success
    return true;
  }
Ejemplo n.º 17
0
std::string XPathDataModel::evalAsString(const std::string& expr) {

    XPathValue<std::string> result;
    try {
        result = _xpath.evaluate_expr(expr, _doc);
    } catch(SyntaxException e) {
        ERROR_EXECUTION_THROW(e.what());
    } catch(std::runtime_error e) {
        ERROR_EXECUTION_THROW(e.what());
    }
    switch (result.type()) {
    case STRING:
        return result.asString();
        break;
    case Arabica::XPath::BOOL: // MSVC croaks with ambiguous symbol without qualified name
        return (result.asBool() ? "true" : "false");
        break;
    case NUMBER:
        return toStr(result.asNumber());
        break;
    case NODE_SET: {
        NodeSet<std::string> nodeSet = result.asNodeSet();
        std::stringstream ss;
        for (size_t i = 0; i < nodeSet.size(); i++) {
            ss << nodeSet[i];
            if (nodeSet[i].getNodeType() != Node_base::TEXT_NODE) {
                ss << std::endl;
            }
        }
        return ss.str();
        break;
    }
    case ANY:
        ERROR_EXECUTION_THROW("Type ANY not supported to evaluate as string");
        break;
    }
    return "undefined";
}
Ejemplo n.º 18
0
/**
 * A ServiceManager was removed.
 */
void ServiceManager::farewell(Publisher& pub, const SubscriberStub& subStub) {
	RScopeLock lock(_mutex);
	UM_LOG_INFO("removed remote ServiceManager - notifying", _localQueries.size());

	// did this publisher responded to our queries before?
	if (_remoteSvcDesc.find(subStub.getUUID()) != _remoteSvcDesc.end()) {

		// check all local queries if the remote services matched and notify about removal
		std::map<ServiceFilter, ResultSet<ServiceDescription>*>::iterator queryIter = _localQueries.begin();
		while(queryIter != _localQueries.end()) {

			std::map<std::string, ServiceDescription>::iterator remoteSvcIter = _remoteSvcDesc[subStub.getUUID()].begin();
			while(remoteSvcIter != _remoteSvcDesc[subStub.getUUID()].end()) {
				if (queryIter->first.matches(remoteSvcIter->second)) {
					queryIter->second->remove(remoteSvcIter->second, toStr(this));
				}
				remoteSvcIter++;
			}
			queryIter++;
		}
	}
	_remoteSvcDesc.erase(subStub.getUUID());
}
Ejemplo n.º 19
0
  //! \param dirName is the name of the directory that we should create our new directory of data in
  //! \param fileName is the name of the new directory, and the files in that directory are called [fileName][#].csv
  bool writeVectorToDirectory(vector<RealType*>& record, const vector<int>& elements, 
    int width, string dirName, const string fileName) 
  {
    // Create the directory
    if (*dirName.rbegin()=='/') // Make sure there is a /
      dirName += fileName+"/";
    else 
      dirName += ("/"+fileName+"/");
    // --> Dir name is now the name of the directory we are creating
    // Create a directory for all the data
    mkdir(dirName.c_str(), 0777);

    // Create the data files in the directory
    for (uint iter=0; iter<record.size(); ++iter) {
      // The name of the file for this data
      string subfile = dirName+fileName+toStr(iter)+".csv";
      // Create the file [fileName] (inside directory [dirName]) containing the data from record.at(iter)
      if (!writeArrayDataToFile(record.at(iter), elements.at(iter), width, subfile)) return false;
    }

    // Return success
    return true;
  }
Ejemplo n.º 20
0
	void HexagonGame::drawText()
	{
		ostringstream s;
		s << "time: " << toStr(status.currentTime).substr(0, 5) << endl;
		if(getOfficial()) s << "official mode" << endl;
		if(getDebug()) s << "debug mode" << endl;
		if(status.scoreInvalid) s << "score invalidated (performance issues)" << endl;
		if(status.hasDied) s << "press r to restart" << endl;

		Vector2f pos{15, 3};
		vector<Vector2f> offsets{{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};

		Color offsetColor{getColor(1)};
		if(getBlackAndWhite()) offsetColor = Color::Black;
		text.setString(s.str());
		text.setCharacterSize(25 / getZoomFactor());
		text.setOrigin(0, 0);

		text.setColor(offsetColor);
		for(const auto& o : offsets) { text.setPosition(pos + o); render(text); }

		text.setColor(getColorMain());
		text.setPosition(pos);
		render(text);
		
		if(messageTextPtr == nullptr) return;

		text.setString(messageTextPtr->getString());
		text.setCharacterSize(messageTextPtr->getCharacterSize());
		text.setOrigin(text.getGlobalBounds().width / 2, 0);

		text.setColor(offsetColor);
		for(const auto& o : offsets) { text.setPosition(messageTextPtr->getPosition() + o); render(text); }

		messageTextPtr->setColor(getColorMain());
		render(*messageTextPtr);
	}
Ejemplo n.º 21
0
    Physostigmine::Physostigmine(double age, double height, double weight) : Antidote(age, height, weight) {
        a = "Physostigmine Antidote Algorithm \n",
        b = string("As a secondary treatment of anticholinergic syndrome.  ") + FDA + "\n\n",
        c = "";//getRef();
        Question *physWarning = new Question(a+b+
                                             "Warning: Physostigmine Salicylate Injection should not be used in the " +
                                             "presence of asthma, gangrene, diabetes, cardiovascular disease, mechanical " +
                                             "obstruction of the intestine or urogenital tract or any vagotonic state, " +
                                             "and in patients receiving choline esters and depolarizing neuromuscular " +
                                             "blocking agents (decamethonium, succinylcholine).Patient must have normal " +
                                             "QRS on ECG to receive physostigmine.");
        physWarning->setType("warning");
        insertToMap("physWarning", physWarning);
        
        Question *physChildWarning = new Question(a+b+
                                                  "Administration of physostigmine in children should reserved for " +
                                                  "life-threatening conditions.");
        physChildWarning->setType("warning");
        insertToMap("physChildWarning", physChildWarning);
        
        string physChild = a+b+
        "Recommended dosage is "+toStr(physCalcChild())+"mg (0.02 mg/kg max 2mg) of physostigmine intramuscularly or by " +
        "slow intravenous injection, no more than 0.5 mg per minute. If the toxic " +
        "effects persist, and there is no sign of cholinergic effects, the dosage may " +
        "be repeated at 5 to 10 minute intervals until a therapeutic effect is " +
        "obtained or a maximum of 2 mg dosage is attained."+c;
        insertToMap("physChild", physChild);
        
        string physAdult = a+b+
        "Adult dosing: When administering IV give no faster than 1mg/minute to avoid " +
        "adverse events.  Recommended dosage 0.5-2mg IV,IM.  May repeat every 10-30 " +
        "minutes until desired response."+c;
        insertToMap("physAdult", physAdult);

        
    }
Ejemplo n.º 22
0
void LogicAnalyzerDisplay::populateChannel(const int channel, const Pothos::Packet &packet)
{
    //convert buffer (does not convert when type matches)
    const auto numericBuff = packet.payload.convert(typeid(T));
    assert(_chData.size() > channel);
    _chData[channel] = packet;
    _chData[channel].payload = numericBuff;

    //load element data into table
    for (size_t i = 0; i < numericBuff.elements(); i++)
    {
        const auto num = numericBuff.as<const T *>()[i];
        const auto s = toStr(num, _chBase.at(channel));
        auto item = new QTableWidgetItem(s);
        auto flags = item->flags();
        flags &= ~Qt::ItemIsEditable;
        item->setFlags(flags);
        item->setTextAlignment(Qt::AlignRight);
        _tableView->setItem(channel, i, item);
    }

    //inspect labels to decorate table
    for (const auto &label : packet.labels)
    {
        const int column = label.index;
        assert(column < _tableView->columnCount());
        auto item = _tableView->item(channel, column);

        //highlight and display label id
        item->setBackground(Qt::yellow);
        item->setText(QString("%1\n%2")
            .arg(item->text())
            .arg(QString::fromStdString(label.id)));
        _tableView->resizeColumnToContents(column);
    }
}
Ejemplo n.º 23
0
SimpleLogger::SimpleLogger(enum LogLevel ll, char const* filename, int line, bool lBreak)
{
    struct OutputSettings settings = outputSettings[ll];
    level = ll;
    lineBreak = lBreak;

    if (settings.enableTime)
        ostr << "[" << getTime() << "] ";
    if (settings.enableLevel)
        ostr << "[" << toStr(ll) << "] ";
    if (settings.enableSource)
        ostr << filename << ":" << line << " ";

    if (logger) {
        t = getTime();
        std::ostringstream oss;
        oss << filename;
        if(line >= 0)
        {
            oss << ":" << line;
        }
        fname = oss.str();
    }
}
Ejemplo n.º 24
0
void printNode(Node * a)
{
	static int startOfList = 1;
	if (a == NULL) return ;
	switch (a->type) {
		case SYMBOL : printf("%s", refer2Str(toSym(a)->name)); 	  break;
		case STR    : printf("%s", refer2Str(toStr(a)->name)); 	  break;
		case NUMBER : printf("%d", toNum(a)->value); 			  break;
		case ATOM	: printf("\'%s", refer2Str(toAtom(a)->name)); break;
		case BOOL	: printf("#%c",toBool(a)->value == 0 ? 'f' : 't'); break;
		case LIST   : 
			if (a == (Node *) &nil) {
				printf("()"); 
				break; 
			}
			if (startOfList) printf("(");
			startOfList = 1;
			printNode(car(a));
			startOfList = 0;

			if (toList(a)->cdr == &nil) printf(")");
			else printf(" "), printNode(cdr(a));
			startOfList = 1;
			break;
		case PAIR   :
			printf("(");
			printNode(car(a));
			printf(" . ");
			printNode(cdr(a));
			printf(")");
			break;
		case PROC   :
			printf("#<procedure :>" );
		default : ;
	}
}
Ejemplo n.º 25
0
void Pragma::dump(std::ostream& out, const clang::SourceManager& sm) const {
	out << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" <<
		   "|~> Pragma: " << getType() << " -> " << std::flush << toStr(sm) << "\n";
}
Ejemplo n.º 26
0
bool InjectedBundlePage::shouldApplyStyle(WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range)
{
    if (!InjectedBundle::shared().isTestRunning())
        return true;

    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldApplyStyle:" << style << " toElementsInDOMRange:" << toStr(m_page, m_world.get(), range)  << "\n";
    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
}
Ejemplo n.º 27
0
bool InjectedBundlePage::shouldChangeSelectedRange(WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting)
{
    if (!InjectedBundle::shared().isTestRunning())
        return true;

    static const char *affinitystring[] = {
        "NSSelectionAffinityUpstream",
        "NSSelectionAffinityDownstream"
    };
    static const char *boolstring[] = {
        "FALSE",
        "TRUE"
    };

    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldChangeSelectedDOMRange:" << toStr(m_page, m_world.get(), fromRange) << " toDOMRange:" << toStr(m_page, m_world.get(), toRange) << " affinity:" << affinitystring[affinity] << " stillSelecting:" << boolstring[stillSelecting] << "\n";
    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
}
Ejemplo n.º 28
0
bool InjectedBundlePage::shouldDeleteRange(WKBundleRangeHandleRef range)
{
    if (!InjectedBundle::shared().isTestRunning())
        return true;

    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldDeleteDOMRange:" << toStr(m_page, m_world.get(), range) << "\n";
    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
}
Ejemplo n.º 29
0
bool InjectedBundlePage::shouldInsertText(WKStringRef text, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action)
{
    if (!InjectedBundle::shared().isTestRunning())
        return true;

    static const char *insertactionstring[] = {
        "WebViewInsertActionTyped",
        "WebViewInsertActionPasted",
        "WebViewInsertActionDropped",
    };

    if (InjectedBundle::shared().layoutTestController()->shouldDumpEditingCallbacks())
        InjectedBundle::shared().os() << "EDITING DELEGATE: shouldInsertText:" << text << " replacingDOMRange:" << toStr(m_page, m_world.get(), rangeToReplace) << " givenAction:" << insertactionstring[action] << "\n";
    return InjectedBundle::shared().layoutTestController()->shouldAllowEditing();
}
string tensorEntryToExpression::toExpr(const entry &e)
{
    const primitiveEntry &pe=dynamicCast<const primitiveEntry&>(e);

    return toStr(tensor(pe.stream()),"tensor");
}