Skip to content

Commit

Permalink
fix for add array function in cpp template
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21985 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Aug 25, 2014
1 parent 691b01e commit 4111c31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -6694,7 +6694,7 @@ template expTypeFlag(DAE.Type ty, Integer flag)
case 8 then
match ty
case T_ARRAY(dims=dims) then'BaseArray<<%expTypeShort(ty)%>>&'
else expTypeFlag(ty, 2)
else expTypeFlag(ty, 9)
end match
case 9 then
// we want the "modelica type"
Expand Down Expand Up @@ -9449,7 +9449,7 @@ template daeExpBinary(Operator it, Exp exp1, Exp exp2, Context context, Text &pr
case "" then tempDecl('DynArrayDim<%listLength(dims)%><<%type%>>', &varDecls /*BUFD*/)
else tempDecl('StatArrayDim<%listLength(dims)%><<%type%>, <%dimensions%> > ', &varDecls /*BUFD*/)
//let var = tempDecl1(type,e1,&varDecls /*BUFD*/)
let &preExp += 'assign_array(<%var%>,add_array<<%type%>,<%listLength(dims)%>>(<%e1%>, <%e2%>));<%\n%>'
let &preExp += 'add_array<<%type%>,<%listLength(dims)%>>(<%e1%>, <%e2%>,<%var%>);<%\n%>'
'<%var%>'
case SUB_ARR(ty=T_ARRAY(dims=dims)) then
let dimensions = (dims |> dim as DIM_INTEGER(integer=i) => '<%i%>';separator=",")
Expand Down
12 changes: 6 additions & 6 deletions SimulationRuntime/cpp/Include/Core/Math/Array.h
Expand Up @@ -114,11 +114,11 @@ template<typename T, std::size_t size>class StatArrayDim1 : public BaseArray<T>
}


void assign(BaseArray<T>& otherArray)
void assign(const BaseArray<T>& otherArray)
{
std::vector<size_t> v;
v = otherArray.getDims();
T* data_otherarray = otherArray.getData();
const T* data_otherarray = otherArray.getData();
//std::copy(data_otherarray,data_otherarray+size,_real_array.begin());
memcpy( _real_array.begin(), data_otherarray, size * sizeof( T ) );
/*for(unsigned int i = 1; i <= min(v[0],size); i++)
Expand Down Expand Up @@ -240,12 +240,12 @@ template<typename T ,std::size_t size1,std::size_t size2>class StatArrayDim2 : p
throw std::runtime_error("Wrong array dimension");

}
void assign(BaseArray<T>& otherArray)
void assign(const BaseArray<T>& otherArray)
{

std::vector<size_t> v;
v = otherArray.getDims();
T* data_otherarray = otherArray.getData();
const T* data_otherarray = otherArray.getData();
//std::copy(data_otherarray,data_otherarray+size1*size2,_real_array.begin());
memcpy( _real_array.begin(), data_otherarray, size1*size2 * sizeof( T ) );
/*for(int i = 1; i <= min(v[0],size1); i++)
Expand Down Expand Up @@ -336,11 +336,11 @@ template<typename T ,std::size_t size1, std::size_t size2, std::size_t size3> cl
_real_array = otherArray._real_array;
}
*/
void assign(BaseArray<T>& otherArray)
void assign(const BaseArray<T>& otherArray)
{
std::vector<size_t> v;
v = otherArray.getDims();
T* data_otherarray = otherArray.getData();
const T* data_otherarray = otherArray.getData();
//std::copy(data_otherarray,data_otherarray+size1*size2*size3,_real_array.begin());
memcpy( _real_array.begin(), data_otherarray, size1*size2*size3 * sizeof( T ) );
/*for(int i = 1; i <= min(v[0],size1); i++)
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/LibrariesConfig.h.in
Expand Up @@ -15,4 +15,4 @@
#define SIMOBJFACTORY_LIB "@SIMOBJFACTORY_LIB@"
#define DATAEXCHANGE_LIB "@DATAEXCHANGE_LIB@"
#define SIMCONRTOLLER_LIB "@SIMCONRTOLLER_LIB@"
#define EXTENSIONUTILITIES_LIB "@EXTENSIONUTILITIES_LIB"
#define EXTENSIONUTILITIES_LIB "@EXTENSIONUTILITIES_LIB@"

0 comments on commit 4111c31

Please sign in to comment.