Skip to content

Commit

Permalink
- minor changes in Qt API interface.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24403 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Feb 4, 2015
1 parent c43b629 commit cf61794
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -2185,8 +2185,8 @@ algorithm
end matchcontinue;
end for;
s1 := Tpl.tplString(GenerateAPIFunctionsTpl.getCevalScriptInterface, tys);
s2 := Tpl.tplString2(GenerateAPIFunctionsTpl.getQtInterface, tys, "OMCProxy::");
s3 := Tpl.tplString2(GenerateAPIFunctionsTpl.getQtInterfaceHeaders, tys, "OMCProxy");
s2 := Tpl.tplString3(GenerateAPIFunctionsTpl.getQtInterface, tys, "OMCInterface::", "OMCInterface");
s3 := Tpl.tplString2(GenerateAPIFunctionsTpl.getQtInterfaceHeaders, tys, "OMCInterface");
then (cache,Values.TUPLE({Values.BOOL(true),Values.STRING(s1),Values.STRING(s2),Values.STRING(s3)}),st);

case (cache,env,"generateScriptingAPI",{Values.CODE(Absyn.C_TYPENAME(className))},st as GlobalScript.SYMBOLTABLE(ast = p),_)
Expand Down
30 changes: 21 additions & 9 deletions Compiler/Template/GenerateAPIFunctionsTpl.tpl
Expand Up @@ -115,15 +115,18 @@ template getCevalScriptInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Ty
>>
end getCevalScriptInterfaceFunc;

template getQtInterface(list<DAE.Type> tys, String className)
template getQtInterface(list<DAE.Type> tys, String classNameWithColons, String className)
::=
let funcs = tys |> ty as T_FUNCTION(source=path::_) => '<%getQtInterfaceFunc(pathLastIdent(path), ty.funcArg, ty.funcResultType, className)%><%\n%>'
let funcs = tys |> ty as T_FUNCTION(source=path::_) => '<%getQtInterfaceFunc(pathLastIdent(path), ty.funcArg, ty.funcResultType, classNameWithColons)%><%\n%>'
<<
#include <Qt/QtCore>
#include "OpenModelicaScriptingAPI.h"
#include <stdexcept>
#include "OpenModelicaScriptingAPIQt.h"

<%classNameWithColons%><%className%>(threadData_t *td, void *symbolTable)
: threadData(td), st(symbolTable)
{
}
<%funcs%>
>>
end getQtInterface;
Expand All @@ -133,15 +136,23 @@ template getQtInterfaceHeaders(list<DAE.Type> tys, String className)
let heads = tys |> ty as T_FUNCTION(source=path::_) => '<%getQtInterfaceHeader(pathLastIdent(path), "", ty.funcArg, ty.funcResultType, className, true)%>;<%\n%>'
<<
#include <Qt/QtCore>
#include "OpenModelicaScriptingAPI.h"

class <%className%> {
threadData_t *threadData;
void *st;
<%heads%>
class <%className%> : public QObject
{
Q_OBJECT
private:
threadData_t *threadData;
void *st;
public:
<%className%>(threadData_t *td, void *symbolTable);
<%heads%>
signals:
void finished();
};
>>
end getQtInterfaceHeaders;

template getQtType(DAE.Type ty)
::=
match ty
Expand Down Expand Up @@ -277,9 +288,10 @@ template getQtInterfaceFunc(String name, list<DAE.FuncArg> args, DAE.Type res, S
MMC_TRY_TOP_INTERNAL()
st = omc_OpenModelicaScriptingAPI_<%replaceDotAndUnderscore(name)%>(threadData, st<%inArgs%><%outArgs%>);
emit finished();
<%postCall%>
MMC_CATCH_TOP(throw std::runtime_error("getClassInformation failed");)
MMC_CATCH_TOP(throw std::runtime_error("<%replaceDotAndUnderscore(name)%> failed");)
<%if outArgs then "return result;"%>
}
Expand Down

0 comments on commit cf61794

Please sign in to comment.