Commit bd34e6d0 authored by Denis Khachko's avatar Denis Khachko

Merge branch 'master' of gitorious.org:kumir2/kumir2

parents b6bd9d20 55e42234
......@@ -17,6 +17,15 @@ RequestExecutionLevel admin
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "Russian"
!define SHCNE_ASSOCCHANGED 0x08000000
!define SHCNF_IDLIST 0
Function RefreshShellIcons
; By jerome tremblay - april 2003
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v \
(${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
FunctionEnd
Section "Kumir" Kumir
SetOutPath "$INSTDIR"
......@@ -31,6 +40,17 @@ Section "Kumir" Kumir
ExecWait '"$INSTDIR\vcredist_x86.exe" /passive'
Delete /REBOOTOK "$INSTDIR\vcredist_x86.exe"
WriteRegStr HKCR ".kum" "" "ru.niisi.kumir2.program"
WriteRegStr HKCR "ru.niisi.kumir2.program" "" " "
WriteRegStr HKCR "ru.niisi.kumir2.program\shell\open\command" "" '"$INSTDIR\bin\kumir2-open.exe" "%1"'
WriteRegStr HKCR "ru.niisi.kumir2.program\DefaultIcon" "" "$INSTDIR\share\icons\kumir2-kum.ico"
WriteRegStr HKCR ".kod" "" "ru.niisi.kumir2.bytecode"
WriteRegStr HKCR "ru.niisi.kumir2.bytecode" "" " "
WriteRegStr HKCR "ru.niisi.kumir2.bytecode\shell\open\command" "" '"$INSTDIR\bin\kumir2-run.exe" "%1" "%*"'
WriteRegStr HKCR "ru.niisi.kumir2.bytecode\DefaultIcon" "" "$INSTDIR\share\icons\kumir2-kod.ico"
Call RefreshShellIcons
CreateDirectory "$SMPROGRAMS\2"
CreateShortCut "$SMPROGRAMS\2\-.lnk" "$INSTDIR\bin\kumir2-classic.exe"
......@@ -38,4 +58,4 @@ Section "Kumir" Kumir
CreateShortCut "$SMPROGRAMS\2\-.lnk" "$INSTDIR\bin\kumir2-ide.exe"
CreateShortCut "$SMPROGRAMS\2\ .lnk" "$INSTDIR\bin\kumir2-teacher.exe"
SectionEnd
\ No newline at end of file
SectionEnd
......@@ -270,6 +270,8 @@ class Name:
return "OperatorSLASH"
elif ascii == "=":
return "OperatorEQUAL"
elif ascii == "<>":
return "OperatorNOTEQUAL"
elif ascii == "<":
return "OperatorLESS"
elif ascii == ">":
......@@ -444,7 +446,7 @@ $fields
};
""", {"name": nameDecl, "fields": fieldsDecl})
def cppCustomTypeCreation(self, variableToAppend):
def cppCustomTypeCreation(self, variableToAppend, variableToAssign):
"""
For non-standard types creates kumir type declaration, an empty string otherwise
......@@ -456,7 +458,9 @@ $fields
if self._standard:
return ""
else:
assert isinstance(variableToAppend, str)
assert variableToAppend is None or isinstance(variableToAppend, str)
assert variableToAssign is None or isinstance(variableToAssign, str)
assert variableToAssign or variableToAppend
result = "{\n"
result += " Shared::ActorInterface::CustomType custom;\n"
result += " Shared::ActorInterface::Record record;\n"
......@@ -469,10 +473,54 @@ $fields
if typee[0].lower() == 'q':
typee = typee[1:]
typee = typee[0].upper() + typee[1:]
result += " record.push_back(Field(QString::fromUtf8(\"%s\"), %s));\n" % (name, typee)
result += " record.push_back(Field(QByteArray(\"%s\"), %s));\n" % (name, typee)
typeName = self._name.kumirValue()
result += " custom = Shared::ActorInterface::CustomType(QString::fromUtf8(\"%s\"), record);\n" % typeName
result += " %s.push_back(custom);\n" % variableToAppend
if variableToAppend:
result += " %s.push_back(custom);\n" % variableToAppend
elif variableToAssign:
result += " %s = custom;\n" % variableToAssign
result += "}\n"
return result
def cppRecordSpecCreation(self, variableToAppend, variableToAssign):
"""
For non-standard types creates kumir type declaration, an empty string otherwise
:type variableToAppend: str
:param variableToAppend: C++ variable name (std::list or QList) to store result
:rtype: unicode
:return: an empty string for standard type or Shared::ActorInterface::CustomType implementation code
"""
if self._standard:
return ""
else:
assert variableToAppend is None or isinstance(variableToAppend, str)
assert variableToAssign is None or isinstance(variableToAssign, str)
assert variableToAssign or variableToAppend
result = "{\n"
result += " Shared::ActorInterface::RecordSpecification recordSpec;\n"
for fieldName, fieldType in self._fields:
assert isinstance(fieldName, Name)
assert isinstance(fieldType, BaseType)
assert fieldType.qtName() in ["int", "qreal", "bool", "QChar", "QString"]
name = fieldName.kumirValue()
typee = fieldType.qtName()
if typee[0].lower() == 'q':
typee = typee[1:]
typee = typee[0].upper() + typee[1:]
result += " recordSpec.record.push_back(Field(QByteArray(\"%s\"), %s));\n" % (name, typee)
result += " recordSpec.asciiName = QByteArray(\"%s\");\n" % self._name.asciiValue()
for key, value in self._name.data.items():
qlocale = None
if key == "ru_RU":
qlocale = "QLocale::Russian"
if qlocale:
result += " recordSpec.localizedNames[%s] = QString::fromUtf8(\"%s\");\n" % (qlocale, value)
if variableToAppend:
result += " %s.push_back(recordSpec);\n" % variableToAppend
elif variableToAssign:
result += " %s = recordSpec;\n" % variableToAssign
result += "}\n"
return result
......@@ -1064,7 +1112,7 @@ class Settings:
result += entry.cppEntryImplementation("entries")
result += """
%s = new Widgets::DeclarativeSettingsPage(
name(),
localizedModuleName(QLocale::Russian),
mySettings(),
entries
);
......@@ -1381,7 +1429,15 @@ private:
}
""" % (self.className, guiRequired)
def nameCppImplementation(self):
def asciiModuleNameCppImplementation(self):
return """
/* public */ QByteArray %s::asciiModuleName() const
{
return QByteArray("%s");
}
""" % (self.className, self._module.name.asciiValue())
def localizedModuleNameCppImplementation(self):
"""
Creates implementation of name
......@@ -1389,32 +1445,83 @@ private:
:return: implementation of QString name() const
"""
# TODO non-Russian language implementation
body = "return QString::fromUtf8(\"%s\");" % self._module.name.kumirValue()
return """
/* public */ QString %s::name() const
/* public */ QString %s::localizedModuleName(const QLocale::Language ) const
{
%s
// TODO non-Russian languages not implemented yet
return QString::fromUtf8("%s");
}
""" % (self.className, _addIndent(body))
""" % (self.className, self._module.name.kumirValue())
def funcListCppImplementation(self):
"""
Creates implementation of funcList
:rtype: unicode
:return: implementation of QStringList funcList() const
"""
@property
def functionListCppImplementation(self):
methods = self._module.methods
lines = map(lambda x: "result << QString::fromUtf8(\"" + x.kumirDeclaration() + "\");", methods)
body = _addIndent(string.join(lines, '\n'))
body = ""
for method in methods:
body += "\n/* " + method.kumirDeclaration() + " */\n"
body += "result.push_back(Function());\n"
body += "result.last().id = result.size() - 1;\n"
if method.name.kumirValue().startswith("@"):
body += "result.last().accessType = TeacherModeFunction;\n"
else:
body += "result.last().accessType = PublicFunction;\n"
body += 'result.last().asciiName = QByteArray("%s");\n' % method.name.asciiValue()
assert isinstance(method.name.data, dict)
for key, value in method.name.data.items():
qlocale = None
if key == "ru_RU":
qlocale = "QLocale::Russian"
if qlocale:
body += 'result.last().localizedNames[%s] = QString::fromUtf8("%s");\n' % (qlocale, value)
if method.returnType:
assert isinstance(method.returnType, BaseType)
if method.returnType._name.asciiValue() == "int":
body += "result.last().returnType = Int;\n"
elif method.returnType._name.asciiValue() == "double":
body += "result.last().returnType = Real;\n"
elif method.returnType._name.asciiValue() == "bool":
body += "result.last().returnType = Bool;\n"
elif method.returnType._name.asciiValue() == "char":
body += "result.last().returnType = Char;\n"
elif method.returnType._name.asciiValue() == "string":
body += "result.last().returnType = String;\n"
else:
body += "result.last().returnType = RecordType;\n"
body += method.returnType.cppRecordSpecCreation(None, "result.last().returnTypeSpecification")
else:
body += "result.last().returnType = Void;\n"
for argument in method.arguments:
body += "result.last().arguments.push_back(Argument());\n"
if argument.kumirArgumentDeclaration().startswith(u'аргрез '):
body += "result.last().arguments.last().accessType = InOutArgument;\n"
elif argument.kumirArgumentDeclaration().startswith(u'рез '):
body += "result.last().arguments.last().accessType = OutArgument;\n"
else:
body += "result.last().arguments.last().accessType = InArgument;\n"
assert isinstance(argument.baseType._name, Name)
if argument.baseType._name.asciiValue() == "int":
body += "result.last().arguments.last().type = Int;\n"
elif argument.baseType._name.asciiValue() == "double":
body += "result.last().arguments.last().type = Real;\n"
elif argument.baseType._name.asciiValue() == "bool":
body += "result.last().arguments.last().type = Bool;\n"
elif argument.baseType._name.asciiValue() == "char":
body += "result.last().arguments.last().type = Char;\n"
elif argument.baseType._name.asciiValue() == "string":
body += "result.last().arguments.last().type = String;\n"
else:
body += "result.last().arguments.last().type = RecordType;\n"
body += argument.baseType.cppRecordSpecCreation(None, "result.last().arguments.last().typeSpecification")
body += "result.last().arguments.last().dimension = %du;\n" % argument.dimension
return """
/* public */ QStringList %s::funcList() const
/* public */ Shared::ActorInterface::FunctionList %s::functionList() const
{
QStringList result;
FunctionList result;
%s;
return result;
}
""" % (self.className, body)
""" % (self.className, _addIndent(body))
def typeListCppImplementation(self):
"""
......@@ -1430,8 +1537,8 @@ private:
for typee in self._module.types:
assert isinstance(typee, BaseType)
if typee._module == self._module:
if typee.cppCustomTypeCreation("result"):
body += typee.cppCustomTypeCreation("result")
if typee.cppRecordSpecCreation("result", None):
body += typee.cppRecordSpecCreation("result", None)
return """
/* public */ Shared::ActorInterface::TypeList %s::typeList() const
{
......@@ -1462,11 +1569,11 @@ private:
assert not argument.baseType.isStandardType()
if body:
body += " else "
body += " if (clazz.first==QString::fromUtf8(\"%s\")) {\n" % argument.baseType.kumirName()
body += " if (clazz==QByteArray(\"%s\")) {\n" % argument.baseType._name.asciiValue()
body += " %s x = decode(value);\n" % argument.baseType.qtName()
body += " result = module_->runOperatorOUTPUT(x);\n }\n"
return """
/* public */ QString %s::customValueToString(const CustomType & %s, const QVariant & %s) const
/* public */ QString %s::customValueToString(const QByteArray & %s, const QVariant & %s) const
{
QString result;
%s
......@@ -1497,7 +1604,7 @@ private:
assert argument.baseType.qtName() == "QString"
if body:
body += " else "
body += " if (clazz.first==QString::fromUtf8(\"%s\")) {\n" % rtype.kumirName()
body += " if (clazz==QByteArray(\"%s\")) {\n" % rtype._name.asciiValue()
body += " %s x; bool ok = false;\n" % rtype.qtName()
body += " x = module_->runOperatorINPUT(stringg, ok);\n"
body += " if (ok) {\n"
......@@ -1505,7 +1612,7 @@ private:
body += " }\n"
body += " }\n"
return """
/* public */ QVariant %s::customValueFromString(const CustomType & %s, const QString & %s) const
/* public */ QVariant %s::customValueFromString(const QByteArray & %s, const QString & %s) const
{
QVariant result;
%s
......@@ -2393,13 +2500,22 @@ class ModuleBaseCppClass(CppClassBase):
:return: implementation of ExtensionSystem::SettingsPtr mySettings() const
"""
return """
/* protected */ ExtensionSystem::SettingsPtr %s::mySettings() const
/* public */ ExtensionSystem::SettingsPtr %s::mySettings() const
{
%s* plugin = qobject_cast<%s*>(parent());
return plugin->mySettings();
}
""" % (self.className, self._module.pluginClassName(), self._module.pluginClassName())
def myResourcesDirCppImplementation(self):
return """
/* public */ QDir %s::myResourcesDir() const
{
%s* plugin = qobject_cast<%s*>(parent());
return plugin->myResourcesDir();
}
""" % (self.className, self._module.pluginClassName(), self._module.pluginClassName())
def sleepCppImplementation(self):
"""
Creates sleep implementation
......@@ -3213,6 +3329,7 @@ target_link_libraries(
${QT_LIBRARIES}
ExtensionSystem
Widgets
${STDCXX_LIB} ${STDMATH_LIB}
)
copyResources(actors/$actorDir)
......
......@@ -7,6 +7,7 @@ TS_MODULES = {
"Widgets": "src/shared/widgets",
"ActorPainter": "src/actors/painter",
"ActorRobot": "src/actors/robot",
"ActorIsometricRobot": "src/actors/isometricrobot",
"Browser": "src/plugins/browser",
"CoreGUI": "src/plugins/coregui",
"Editor": "src/plugins/editor",
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<context>
<name>Robot25DWindow</name>
<message>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="14"/>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.cpp" line="25"/>
<source>Isometric Robot</source>
<translation>Вертун</translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="23"/>
<source>Загрузить...</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="26"/>
<source>Загрузить</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="29"/>
<source>Загрузить обстановку или набор из файла</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="34"/>
<source>Следующая обстановка</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="37"/>
<source>Вперед</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="42"/>
<source>Предыдущая обстановка</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="45"/>
<source>Назад</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="50"/>
<source>Вернуть обстановку к начальной</source>
<translation type="unfinished"></translation>
</message>
<message utf8="true">
<location filename="../../../src/actors/isometricrobot/robot25dwindow.ui" line="53"/>
<source>Вернуть обстановку</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.cpp" line="172"/>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.cpp" line="178"/>
<source>Can&apos;t load environment</source>
<translation>Не могу загрузить обстановку</translation>
</message>
<message>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.cpp" line="187"/>
<source>Load environment</source>
<translation>Загрузить обстановку</translation>
</message>
<message>
<location filename="../../../src/actors/isometricrobot/robot25dwindow.cpp" line="189"/>
<source>Environments</source>
<translation>Обстановки</translation>
</message>
</context>
</TS>
add_subdirectory(_colorer)
add_subdirectory(painter)
add_subdirectory(robot)
add_subdirectory(complexnumbers)
add_subdirectory(robot25d)
add_subdirectory(draw)
add_subdirectory(vodoley)
file(GLOB entries *)
foreach(entry ${entries})
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
add_subdirectory(${entry})
endif()
endforeach(entry)
......@@ -85,6 +85,7 @@ target_link_libraries(
${QT_LIBRARIES}
ExtensionSystem
Widgets
${STDCXX_LIB} ${STDMATH_LIB}
)
copyResources(actors/_colorer)
......
......@@ -25,6 +25,22 @@
"arguments": [
{ "name": "x", "baseType": "color" }
]
},
{
"name": {"ascii": "="},
"returnType": "bool",
"arguments": [
{ "name": "x", "baseType": "color" },
{ "name": "y", "baseType": "color" }
]
},
{
"name": {"ascii": "<>"},
"returnType": "bool",
"arguments": [
{ "name": "x", "baseType": "color" },
{ "name": "y", "baseType": "color" }
]
}
]
}
......@@ -247,6 +247,19 @@ static quint32 colorToUintValue(const Color &x)
}
bool _ColorerModule::runOperatorEQUAL(const Color &x, const Color &y)
{
return x.a == y.a &&
x.r == y.r &&
x.g == y.g &&
x.b == y.b;
}
bool _ColorerModule::runOperatorNOTEQUAL(const Color &x, const Color &y)
{
return ! runOperatorEQUAL(x, y);
}
} // namespace Actor_Colorer
......@@ -36,7 +36,8 @@ public slots:
void reset();
Color runOperatorINPUT(const QString& x, bool& ok);
QString runOperatorOUTPUT(const Color& x);
bool runOperatorEQUAL(const Color& x, const Color& y);