Method: RCSimCinterface.rcsim_add_scope_behaviors
- Defined in:
- ext/hruby_sim/hruby_rcsim_build.c
.rcsim_add_scope_behaviors(scopeV, behVs) ⇒ Object
Adds behaviors to a C scope.
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
# File 'ext/hruby_sim/hruby_rcsim_build.c', line 1030 VALUE rcsim_add_scope_behaviors(VALUE mod, VALUE scopeV, VALUE behVs) { // printf("rcsim_add_scope_behaviors\n"); /* Get the C scope from the Ruby value. */ Scope scope; value_to_rcsim(ScopeS,scopeV,scope); // printf("rcsim_add_scope_behaviors with scope=%p\n",scope); /* Prepare the size for the behaviors. */ long num = RARRAY_LEN(behVs); long old_num = scope->num_behaviors; // printf("num=%lu old_num=%lu\n",num,old_num); // printf("scope->behaviors=%p\n",scope->behaviors); scope->num_behaviors += num; // printf("first scope->behaviors=%p\n",scope->behaviors); fflush(stdout); scope->behaviors = realloc(scope->behaviors, sizeof(Behavior[scope->num_behaviors])); // scope->behaviors = (Behavior*)my_realloc(scope->behaviors, // sizeof(Behavior[old_num]), sizeof(Behavior[scope->num_behaviors])); // printf("now scope->behaviors=%p\n",scope->behaviors); fflush(stdout); // printf("access test: %p\n",scope->behaviors[0]); fflush(stdout); /* Get and add the behaviors from the Ruby value. */ for(long i=0; i< num; ++i) { Behavior beh; // show_access(scope->behaviors,old_num+i); value_to_rcsim(BehaviorS,rb_ary_entry(behVs,i),beh); scope->behaviors[old_num + i] = beh; } return scopeV; } |