Method: RCSimCinterface.rcsim_add_systemI_systemTs

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

.rcsim_add_systemI_systemTs(systemIV, sysVs) ⇒ Object

Adds alternate system types to a C system instance.



1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1254

VALUE rcsim_add_systemI_systemTs(VALUE mod, VALUE systemIV, VALUE sysVs) {
    /* Get the C systemI from the Ruby value. */
    SystemI systemI;
    value_to_rcsim(SystemIS,systemIV,systemI);
    // printf("rcsim_add_systemI_systemTs with systemI=%p\n",systemI);
    /* Prepare the size for the alternate system types. */
    long num = RARRAY_LEN(sysVs);
    long old_num = systemI->num_systems;
    systemI->num_systems += num;
    // printf("first systemI->systems=%p\n",systemI->systems); fflush(stdout);
    systemI->systems=realloc(systemI->systems,
            sizeof(SystemT[systemI->num_systems]));
    // systemI->systems = (SystemT*)my_realloc(systemI->systems,
    //         sizeof(SystemT[old_num]), sizeof(SystemT[systemI->num_systems]));
    // printf("now systemI->systems=%p\n",systemI->systems); fflush(stdout);
    // printf("access test: %p\n",systemI->systems[0]); fflush(stdout);
    /* Get and add the alternate system types from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SystemT sys;
        // show_access(systemI->systems,old_num+i);
        value_to_rcsim(SystemTS,rb_ary_entry(sysVs,i),sys);
        systemI->systems[old_num + i] = sys;
    }
    return systemIV;
}