示例#1
0
QString SwitchNode::toStringImpl(GeneratorCustomizer &customizer, int indent, QString const &indentString) const
{
	QString result;
	bool isHead = true;
	for (ZoneNode * const zone : mBranches.values().toSet()) {
		if (zone == mDefaultBranch) {
			// Branches merged with default on the diagram will be merged with it in code too
			continue;
		}

		result += generatePart(customizer, indent, indentString, zone, isHead
				? customizer.factory()->switchHeadGenerator(mId, customizer, mBranches.keys(zone))
				: customizer.factory()->switchMiddleGenerator(mId, customizer, mBranches.keys(zone)));

		isHead = false;
	}

	if (result.isEmpty()) {
		// Then all branches lead to one block, we may ignore switch construction.
		return mDefaultBranch->toString(customizer, indent, indentString);
	}

	result += generatePart(customizer, indent, indentString, mDefaultBranch
			, customizer.factory()->switchDefaultGenerator(mId, customizer));

	return result;
}
WaitForTouchSensorBlockGenerator::WaitForTouchSensorBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/touch.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->inputPortConverter())
			<< Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
			, parent)
{
}
WaitForColorBlockGenerator::WaitForColorBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/color.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->inputPortConverter())
			<< Binding::createConverting("@@COLOR@@", "Color", customizer.factory()->colorConverter())
			, parent)
{
}
WaitForLightBlockGenerator::WaitForLightBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/light.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->inputPortConverter())
			<< Binding::createConverting("@@PERCENTS@@", "Percents", customizer.factory()->intPropertyConverter())
			<< Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
			, parent)
{
}
SubprogramsSimpleGenerator::SubprogramsSimpleGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "subprograms/subprogramCall.t", QList<Binding *>()
			<< Binding::createConverting("@@NAME@@", "name", customizer.factory()->nameNormalizerConverter())
			<< Binding::createConverting("@@ARGUMENTS@@", "dynamicProperties"
						, customizer.factory()->dynamicPropertiesConverter(id))
			, parent)
{
}
WaitForSoundBlockGenerator::WaitForSoundBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/sound.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->inputPortConverter())
			<< Binding::createConverting("@@VOLUME@@", "Volume", customizer.factory()->intPropertyConverter())
			<< Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
			, parent)
{
}
示例#7
0
PrintTextBlockGenerator::PrintTextBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/printText.t", QList<Binding *>()
			<< Binding::createConverting("@@X@@", "XCoordinateText", customizer.factory()->intPropertyConverter())
			<< Binding::createConverting("@@Y@@", "YCoordinateText", customizer.factory()->intPropertyConverter())
			<< Binding::createConverting("@@TEXT@@", "PrintText", customizer.factory()->stringPropertyConverter())
			, parent)
{
}
WaitForGyroscopeBlockGenerator::WaitForGyroscopeBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/gyroscope.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->inputPortConverter())
			<< Binding::createConverting("@@DEGREES@@", "Degrees", customizer.factory()->intPropertyConverter())
			<< Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
			, parent)
{
}
WaitForMotionGenerator::WaitForMotionGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "wait/motion.t", QList<Binding *>()
			<< Binding::createConverting("@@PORT@@", "Port", customizer.factory()->portNameConverter())
			<< Binding::createConverting("@@DISTANCE@@", "Distance"
					, customizer.factory()->intPropertyConverter(id, "Distance"))
			<< Binding::createConverting("@@SIGN@@", "Sign", customizer.factory()->inequalitySignConverter())
			, parent)
{
}
示例#10
0
PlayToneGenerator::PlayToneGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "playTone.t", QList<Binding *>()
			<< Binding::createConverting("@@FREQUENCY@@", "Frequency"
					, customizer.factory()->intPropertyConverter(id, "Frequency"))
			<< Binding::createConverting("@@DURATION@@", "Duration"
					, customizer.factory()->intPropertyConverter(id, "Duration"))
			<< Binding::createConverting("@@VOLUME@@", "Volume"
					, customizer.factory()->intPropertyConverter(id, "Volume"))
			, parent)
{
}
示例#11
0
SwitchGenerator::SwitchGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const qReal::Id &id
		, const QString &part
		, const QStringList &values
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, QString("switch/%1.t").arg(part), {
			Binding::createConverting("@@EXPRESSION@@", "Expression"
					, customizer.factory()->floatPropertyConverter(id, "Expression"))
			, Binding::createConverting("@@CONDITION@@", "Expression"
					, customizer.factory()->switchConditionsMerger(values))
			}, parent)
{
}
PrintTextBlockGenerator::PrintTextBlockGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/printText.t", QList<Binding *>()
			<< Binding::createConverting("@@X@@", "XCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "XCoordinateText"))
			<< Binding::createConverting("@@Y@@", "YCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "YCoordinateText"))
			<< (repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "PrintText"
							, customizer.factory()->stringPropertyConverter(id, "PrintText"))
					: Binding::createStatic("@@TEXT@@"
							, utils::StringUtils::wrap(repo.stringProperty(id, "PrintText"))))
			, parent)
{
}
示例#13
0
QString SimpleNode::toStringImpl(GeneratorCustomizer &customizer, int indent, QString const &indentString) const
{
	switch (mSyntheticBinding) {
	case breakNode:
		return utils::StringUtils::addIndent(customizer.factory()->breakGenerator(mId
				, customizer)->generate(), indent, indentString);
	case continueNode:
		return utils::StringUtils::addIndent(customizer.factory()->continueGenerator(mId
				, customizer)->generate(), indent, indentString);
	case gotoNode:
		return utils::StringUtils::addIndent(customizer.factory()->gotoSimpleGenerator(mId
				, customizer)->generate(), indent, indentString);
	default:
		return utils::StringUtils::addIndent(customizer.factory()->simpleGenerator(mId
				, customizer)->generate(), indent, indentString);
	}
}
示例#14
0
EnginesGenerator::EnginesGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QString const &engineType
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, engineType.contains("EnginesBackward")
					? "engines/enginesBackward.t"
					: "engines/enginesForward.t"
			, QList<Binding *>()
					<< Binding::createMultiTarget("@@PORT@@", "Ports", customizer.factory()->enginesConverter())
					<< Binding::createConverting("@@POWER@@", "Power", customizer.factory()->intPropertyConverter())
					<< Binding::createConverting("@@BREAK_MODE@@", "Mode", customizer.factory()->breakModeConverter())
			, parent)
{
	mCustomizer.factory()->engines()->registerUsageOnPorts(repo.property(id, "Ports").toString());
}
示例#15
0
SubprogramsSimpleGenerator::SubprogramsSimpleGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "subprograms/subprogramCall.t", QList<Binding *>()
			<< Binding::createConverting("@@NAME@@", "name", customizer.factory()->nameNormalizerConverter())
			, parent)
{
}
示例#16
0
LabelGenerator::LabelGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "label.t"
			, { Binding::createStaticConverting("@@ID@@", id.id()
					, customizer.factory()->nameNormalizerConverter()) }
			, parent)
{
}
示例#17
0
QString SemanticNode::toString(GeneratorCustomizer &customizer, int indent, const QString &indentString) const
{
	const QString code = toStringImpl(customizer, indent, indentString);
	/// @todo: Probably some more generalized entity? Prepended and appended code generators in general?
	auto prependedCodeGenerator = customizer.factory()->labelGenerator(mId, customizer);
	const QString prependedCode = mLabeled
			? utils::StringUtils::addIndent(prependedCodeGenerator->generate(), indent, indentString)
			: QString();
	return prependedCode + code;
}
示例#18
0
BeepGenerator::BeepGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "beep.t"
			, {Binding::createConverting("@@VOLUME@@", "Volume"
					, customizer.factory()->intPropertyConverter(id, "Volume"))}
			, parent)
{
}
示例#19
0
FunctionElementGenerator::FunctionElementGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "function.t", QList<Binding *>()
			<< Binding::createConverting("@@BODY@@", "Body", customizer.factory()->functionBlockConverter())
			, parent)
	, mGenerateToInit(mRepo.property(id, "Init").toBool())
{
}
示例#20
0
VariableInitGenerator::VariableInitGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "variableInit.t", QList<Binding *>()
			<< Binding::createDirect("@@VARIABLE@@", "variable")
			<< Binding::createConverting("@@VALUE@@", "value", customizer.factory()->floatPropertyConverter())
			, parent)
{
}
示例#21
0
VariableInitGenerator::VariableInitGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "function.t"
			, { Binding::createStaticConverting("@@BODY@@"
					, repo.property(id, "variable").toString() + "=" + repo.property(id, "value").toString()
					, customizer.factory()->functionBlockConverter(id, "value")) }
			, parent)
{
}
示例#22
0
PrintTextBlockGenerator::PrintTextBlockGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/printText.t", {
			Binding::createConverting("@@X@@", "XCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "XCoordinateText"))
			, Binding::createConverting("@@Y@@", "YCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "YCoordinateText"))
			, (repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "PrintText"
							, customizer.factory()->stringPropertyConverter(id, "PrintText"))
					: Binding::createStatic("@@TEXT@@"
							, utils::StringUtils::wrap(repo.stringProperty(id, "PrintText"))))
			}, parent)
{
	// Calling virtual readTemplate() before base class constructor will cause segfault.
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}
示例#23
0
WhileLoopGenerator::WhileLoopGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, bool doWhileForm
		, bool needInverting
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, doWhileForm ? "conditional/doWhile.t" : "conditional/whileDo.t"
			, QList<Binding *>() << Binding::createConverting("@@CONDITION@@", "Condition"
					, customizer.factory()->boolPropertyConverter(needInverting))
			, parent)
{
}
示例#24
0
IfElementGenerator::IfElementGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, bool elseIsEmpty
		, bool needInverting
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, elseIsEmpty ? "conditional/if.t" : "conditional/ifElse.t"
			, QList<Binding *>() << Binding::createConverting("@@CONDITION@@", "Condition"
					, customizer.factory()->boolPropertyConverter(id, "Condition", needInverting))
			, parent)
{
}
示例#25
0
ClearScreenBlockGenerator::ClearScreenBlockGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, customizer.factory()->images()->bmpFilesCount()
					// WARNING: this may not work when we traverse here earlier than
					// into drawing block but it will be executed before this block
					? "drawing/clearUsedScreen.t"
					: "drawing/clearUnusedScreen.t"
			, QList<Binding *>(), parent)
{
}
示例#26
0
QString LoopNode::toStringImpl(GeneratorCustomizer &customizer, int indent, const QString &indentString) const
{
	simple::AbstractSimpleGenerator *generator = nullptr;
	if (mId.isNull()) {
		// Then this loop is generated by arrow back from simple block
		generator = customizer.factory()->infiniteLoopGenerator(mId, customizer);
	} else {
		if (customizer.semanticsOf(mId) == enums::semantics::loopBlock) {
			generator = customizer.factory()->forLoopGenerator(mId, customizer);
			// Then this loop is generated by a regular loop block usage
		} else {
			// Then this loop is generated by arrow back from if block
			generator = customizer.factory()->whileLoopGenerator(mId, customizer
					, mDoWhileForm, mAddNotToCondition);
		}
	}

	QString result = utils::StringUtils::addIndent(generator->generate(), indent, indentString);
	const QString bodyCode = mBodyZone->toString(customizer, indent + 1, indentString);
	result.replace("@@BODY@@", bodyCode);
	return result;
}
示例#27
0
QString IfNode::toStringImpl(GeneratorCustomizer &customizer, int indent, const QString &indentString) const
{
	if (mIsSimple) {
		return mThenZone->toString(customizer, indent, indentString);
	}

	if (mThenZone->isEmpty() && mElseZone->isEmpty()) {
		return QString();
	}

	const bool elseIsEmpty = mElseZone->isEmpty();
	QString result = utils::StringUtils::addIndent(customizer.factory()->
			ifGenerator(mId, customizer, elseIsEmpty, mAddNotToCondition)->generate(), indent, indentString);

	const QString thenBlock = mThenZone->toString(customizer, indent + 1, indentString);
	const QString elseBlock = mElseZone->toString(customizer, indent + 1, indentString);

	result.replace("@@THEN_BODY@@", thenBlock);
	result.replace("@@ELSE_BODY@@", elseBlock);
	return result;
}
示例#28
0
QString FinalNode::toStringImpl(GeneratorCustomizer &customizer, int indent, const QString &indentString) const
{
	return utils::StringUtils::addIndent(customizer.factory()->finalNodeGenerator(mId
			, customizer, mInMainDiagram)->generate(), indent, indentString);
}
示例#29
0
QString JoinNode::toStringImpl(GeneratorCustomizer &customizer, int indent, const QString &indentString) const
{
	const QString code = customizer.factory()->joinGenerator(mId, customizer
			, customizer.factory()->threads().joinedThreads(mId), mThreadId)->generate();
	return utils::StringUtils::addIndent(code, indent, indentString);
}
示例#30
0
QString DrawBlockGenerator::imageName(GeneratorCustomizer &customizer) const
{
    return "Image_" + QString::number(customizer.factory()->images()->bmpFilesCount());
}