Method: RCSimCinterface.rcsim_add_systemT_inouts

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

.rcsim_add_systemT_inouts(systemTV, sigVs) ⇒ Object

Adds inouts to a C systemT.



976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 976

VALUE rcsim_add_systemT_inouts(VALUE mod, VALUE systemTV, VALUE sigVs) {
    /* Get the C systemT from the Ruby value. */
    SystemT systemT;
    value_to_rcsim(SystemTS,systemTV,systemT);
    // printf("rcsim_add_systemT_inputs with systemT=%p\n",systemT);
    /* Prepare the size for the inouts. */
    long num = RARRAY_LEN(sigVs);
    long old_num = systemT->num_inouts;
    systemT->num_inouts += num;
    // printf("first systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
    systemT->inouts =realloc(systemT->inouts,
            sizeof(SignalI[systemT->num_inouts]));
    // systemT->inouts =(SignalI*)my_realloc(systemT->inouts,
    //         sizeof(SignalI[old_num]), sizeof(SignalI[systemT->num_inouts]));
    // printf("now systemT->inouts=%p\n",systemT->inouts); fflush(stdout);
    // printf("access test: %p\n",systemT->inouts[0]); fflush(stdout);
    /* Get and add the signals from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SignalI sig;
        // show_access(systemT->inouts,old_num+i);
        value_to_rcsim(SignalIS,rb_ary_entry(sigVs,i),sig);
        systemT->inouts[old_num + i] = sig;
    }
    return systemTV;
}