I have the following:
void setStartValues(ModelInstance *comp) {
i(counter_) = 1;
}
Run
where **i** is defined as:
#define i(vr) comp->i[vr]
Run
I tried to implement (naively) that in nim as:
proc setStartValues(comp:ptr ModelInstance) =
comp.i[counter]
Run
and I get the following error:
prueba.nim(29, 11) Error: type mismatch: got <ptr fmi2Integer, int
literal(0)>
but expected one of:
template `[]`(s: string; i: int): char
first type mismatch at position: 0
proc `[]`[T, U, V](s: openArray[T]; x: HSlice[U, V]): seq[T]
first type mismatch at position: 0
proc `[]`[I: Ordinal; T](a: T; i: I): T
first type mismatch at position: 0
proc `[]`[T](s: openArray[T]; i: BackwardsIndex): T
first type mismatch at position: 0
proc `[]`[T](s: var openArray[T]; i: BackwardsIndex): var T
first type mismatch at position: 0
proc `[]`[Idx, T](a: var array[Idx, T]; i: BackwardsIndex): var T
first type mismatch at position: 0
proc `[]`[Idx, T, U, V](a: array[Idx, T]; x: HSlice[U, V]): seq[T]
first type mismatch at position: 0
proc `[]`[T, U](s: string; x: HSlice[T, U]): string
first type mismatch at position: 0
proc `[]`[Idx, T](a: array[Idx, T]; i: BackwardsIndex): T
first type mismatch at position: 0
proc `[]`(s: string; i: BackwardsIndex): char
first type mismatch at position: 0
expression: [](comp.i, 0)
What should I do?
Note: **ModelInstance** is defined in nim as follows (from _fmuTemplate.h_
using nimterop):
type
fmi2Integer* {.impfmuTemplate.} = cint
...
ModelInstance* {.impfmuTemplate, bycopy.} = object
r*: ptr fmi2Real
i*: ptr fmi2Integer
b*: ptr fmi2Boolean
s*: ptr fmi2String
isPositive*: ptr fmi2Boolean
time*: fmi2Real
instanceName*: fmi2String
`type`*: fmi2Type
GUID*: fmi2String
functions*: ptr fmi2CallbackFunctions
loggingOn*: fmi2Boolean
logCategories*: array[4, fmi2Boolean]
componentEnvironment*: fmi2ComponentEnvironment
state*: ModelState
eventInfo*: fmi2EventInfo
isDirtyValues*: fmi2Boolean
isNewEventIteration*: fmi2Boolean
Run