Method: RCSimCinterface.rcsim_add_scope_systemIs

Defined in:
ext/hruby_sim/hruby_rcsim_build.c

.rcsim_add_scope_systemIs(scopeV, sysVs) ⇒ Object

Adds system instances to a C scope.



1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1060

VALUE rcsim_add_scope_systemIs(VALUE mod, VALUE scopeV, VALUE sysVs) {
    /* Get the C scope from the Ruby value. */
    Scope scope;
    value_to_rcsim(ScopeS,scopeV,scope);
    // printf("rcsim_add_scope_systemIs with scope=%p\n",scope);
    /* Prepare the size for the system instances. */
    long num = RARRAY_LEN(sysVs);
    long old_num = scope->num_systemIs;
    scope->num_systemIs += num;
    // printf("first scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
    scope->systemIs = realloc(scope->systemIs,
                               sizeof(SystemI[scope->num_systemIs]));
    // scope->systemIs = (SystemI*)my_realloc(scope->systemIs,
    //         sizeof(SystemI[old_num]), sizeof(SystemI[scope->num_systemIs]));
    // printf("now scope->systemIs=%p\n",scope->systemIs); fflush(stdout);
    // printf("access test: %p\n",scope->systemIs[0]); fflush(stdout);
    /* Get and add the system instances from the Ruby value. */
    for(long i=0; i< num; ++i) {
        SystemI sys;
        // show_access(scope->systemIs,old_num+i);
        value_to_rcsim(SystemIS,rb_ary_entry(sysVs,i),sys);
        scope->systemIs[old_num + i] = sys;
    }
    return scopeV;
}