APWTCL Arnulf's Preferred Web Tcl

Check-in [de8a7b84ad]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes and add separate namespace for every type instance as selfns
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:de8a7b84ad2fe851ebb227340e8b56f0199c35e2
User & Date: arnulf 2012-04-20 21:25:38
Context
2012-04-20
22:46
fixes check-in: 544886fc2f user: arnulf tags: trunk
21:25
fixes and add separate namespace for every type instance as selfns check-in: de8a7b84ad user: arnulf tags: trunk
12:34
fixes check-in: 64926c5351 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/org/apwtcl/lang/EvalStatement.java.

527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
            break;
          case TOKEN_BRACE:
            if (!in_quotes) {
              if (argc == 1) {
                /* seems to be the special of setting a variable which is a list
                 * in a ::itcl::macro and then executing the variable!!
                 */
print("BRACE NOT in quotes!"+token.get(i).obj_ptr+"!");
                int ret = evalObj(token.get(i).obj_ptr);
                eval_level--;                
                return ret;
              }
              word_obj_ptr = token.get(i).obj_ptr;
            } else {
              ArrayList<ApwtclObj> result_ptr2 = new ArrayList<ApwtclObj>();







|







527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
            break;
          case TOKEN_BRACE:
            if (!in_quotes) {
              if (argc == 1) {
                /* seems to be the special of setting a variable which is a list
                 * in a ::itcl::macro and then executing the variable!!
                 */
//print("BRACE NOT in quotes!"+token.get(i).obj_ptr+"!"+interp.frame_ptr.ns_ptr+"!");
                int ret = evalObj(token.get(i).obj_ptr);
                eval_level--;                
                return ret;
              }
              word_obj_ptr = token.get(i).obj_ptr;
            } else {
              ArrayList<ApwtclObj> result_ptr2 = new ArrayList<ApwtclObj>();

Changes to src/org/apwtcl/lang/ItclClass.java.

345
346
347
348
349
350
351

352
353
354
355
356
357
358
     *  of each delegated member function, and enter it into the table.
     */
    for (int i = 0; i < my_classes.size(); i++) {
      class_ptr = my_classes.get(i);
      for (String key: class_ptr.delegated_methods.keySet()) {
        my_delegate_obj = class_ptr.delegated_methods.get(key);
        if (delegated_methods.get(escapeKey(key)) == null) {

          delegated_methods.put(escapeKey(key), my_delegate_obj);
        }
      }
    }
//print("CL!"+toDebugString()+"!");
    return OK;
  }







>







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
     *  of each delegated member function, and enter it into the table.
     */
    for (int i = 0; i < my_classes.size(); i++) {
      class_ptr = my_classes.get(i);
      for (String key: class_ptr.delegated_methods.keySet()) {
        my_delegate_obj = class_ptr.delegated_methods.get(key);
        if (delegated_methods.get(escapeKey(key)) == null) {
print("delegate function!"+key+"!");
          delegated_methods.put(escapeKey(key), my_delegate_obj);
        }
      }
    }
//print("CL!"+toDebugString()+"!");
    return OK;
  }

Changes to src/org/apwtcl/lang/ItclObject.java.

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
122
123
124
125
126
127
128

129
130
131
132
133
134
135
...
175
176
177
178
179
180
181

182




183
184
185
186
187
188
189
190
191
192
193
194
195
...
294
295
296
297
298
299
300

301
302
303
304
305
306
307
...
310
311
312
313
314
315
316

317
318
319
320
321
322
323
    this.variables = new HashMap<String, Variable>();
    this.called_constructors = new HashMap<String, Boolean>();
    this.called_destructors = new HashMap<String, Boolean>();
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "ItclObject!"+id+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+"!";
  }
................................................................................
    boolean err = false;
    CallFrame result;
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
    ApwtclObj self_obj_ptr;
    ApwtclObj value_ptr;
    ApwtclObj this_obj_ptr;
    ApwtclObj my_obj_ptr;


//print("initItclObject!"+toDebugString()+"!");
    /* add to class instances */
    my_obj_ptr = interp.string_obj_type.newStringObj(object_name, -1, "ITCL_OBJECT_1");
    my_obj_ptr.incrRefCount("I_ITCL_OBJECT_1");
    class_info.instances.add(my_obj_ptr);
    /* Create a new call frame */
................................................................................
    value_ptr = class_info.class_name;
    self_obj_ptr.incrRefCount("I_ITCL_OBJECT_6");
    value_ptr.incrRefCount("I_ITCL_OBJECT_7");
    interp.variable_obj_type.setVariable(self_obj_ptr, value_ptr, var_ptr_ptr);
    self_obj_ptr.decrRefCount("D_ITCL_OBJECT_5");
    value_ptr.decrRefCount("D_ITCL_OBJECT_6");


    if (class_info.class_type == ITCL_TYPE_CLASS) {




      this_variable = new Variable(interp, "selfns", "VAR_SELF_VAR", null, class_info.ns_ptr);
      this_variable.setProtection(PROTECTION_PROTECTED);
      variables.put(escapeKey(escapeKey("selfns")), this_variable);
    }
    self_obj_ptr = interp.string_obj_type.newStringObj("selfns", -1, "ITCL_OBJECT_7");
    value_ptr = interp.string_obj_type.newStringObj(class_info.ns_ptr.full_name, -1, "ITCL_OBJECT_8");
    self_obj_ptr.incrRefCount("I_ITCL_OBJECT_8");
    value_ptr.incrRefCount("I_ITCL_OBJECT_9");
    interp.variable_obj_type.setVariable(self_obj_ptr, value_ptr, var_ptr_ptr);
    self_obj_ptr.decrRefCount("D_ITCL_OBJECT_7");
    value_ptr.decrRefCount("D_ITCL_OBJECT_8");

    if (initObjectVariables() != OK) {
................................................................................
    Namespace save_ns_ptr;
    ApwtclObj default_value_ptr = null;

//print("NS!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
    save_ns_ptr = interp.frame_ptr.ns_ptr;
    interp.frame_ptr.ns_ptr = class_obj.ns_ptr;
    for (String option_name: class_obj.options.keySet()) {

      ItclOption option_obj = class_obj.options.get(option_name);
      class_options.put(option_name, option_obj);
      /* set the itcl_options array for that option name to the defaultvalue of the option */
      obj_ptr = interp.string_obj_type.newStringObj("itcl_options("+option_name+")", -1, "ITCL_OBJECT_9");
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      if (option_obj.default_value != null) {
        obj_ptr.incrRefCount("I_ITCL_OBJECT_10");
................................................................................
          return ERROR;
        }
        obj_ptr.decrRefCount("D_ITCL_OBJECT_9");
      }
      if (class_info.class_type == ITCL_TYPE_CLASS) {
        /* set the options array for ::itcl::type for that option name to the defaultvalue of the option */
        obj_ptr = interp.string_obj_type.newStringObj("options("+option_name+")", -1, "ITCL_OBJECT_10");

        if (option_obj.default_value != null) {
          obj_ptr.incrRefCount("I_ITCL_OBJECT_11");
          if (interp.variable_obj_type.setVariable(obj_ptr, option_obj.default_value, var_ptr_ptr) != OK) {
            interp.frame_ptr.ns_ptr = save_ns_ptr;
            return ERROR;
          }
          obj_ptr.decrRefCount("D_ITCL_OBJECT_10");







|







 







>







 







>

>
>
>
>





|







 







>







 







>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
    this.variables = new HashMap<String, Variable>();
    this.called_constructors = new HashMap<String, Boolean>();
    this.called_destructors = new HashMap<String, Boolean>();
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "ItclObject!"+id+"!"+object_name+"!";
    return str;
  } 
      
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+"!";
  }
................................................................................
    boolean err = false;
    CallFrame result;
    ArrayList<CallFrame> frame_ptr_ptr = new ArrayList<CallFrame>();
    ApwtclObj self_obj_ptr;
    ApwtclObj value_ptr;
    ApwtclObj this_obj_ptr;
    ApwtclObj my_obj_ptr;
    String inst_ns_name = null;

//print("initItclObject!"+toDebugString()+"!");
    /* add to class instances */
    my_obj_ptr = interp.string_obj_type.newStringObj(object_name, -1, "ITCL_OBJECT_1");
    my_obj_ptr.incrRefCount("I_ITCL_OBJECT_1");
    class_info.instances.add(my_obj_ptr);
    /* Create a new call frame */
................................................................................
    value_ptr = class_info.class_name;
    self_obj_ptr.incrRefCount("I_ITCL_OBJECT_6");
    value_ptr.incrRefCount("I_ITCL_OBJECT_7");
    interp.variable_obj_type.setVariable(self_obj_ptr, value_ptr, var_ptr_ptr);
    self_obj_ptr.decrRefCount("D_ITCL_OBJECT_5");
    value_ptr.decrRefCount("D_ITCL_OBJECT_6");

    inst_ns_name = class_info.ns_ptr.full_name+"::itcl_inst"+class_info.ns_ptr.getAutoCount();
    if (class_info.class_type == ITCL_TYPE_CLASS) {
      Namespace self_ns_ptr = interp.global_ns_ptr.getNamespace(inst_ns_name);
      if (self_ns_ptr == null) {
        /* FIXME need error handling here !! */
      }
      this_variable = new Variable(interp, "selfns", "VAR_SELF_VAR", null, class_info.ns_ptr);
      this_variable.setProtection(PROTECTION_PROTECTED);
      variables.put(escapeKey(escapeKey("selfns")), this_variable);
    }
    self_obj_ptr = interp.string_obj_type.newStringObj("selfns", -1, "ITCL_OBJECT_7");
    value_ptr = interp.string_obj_type.newStringObj(inst_ns_name, -1, "ITCL_OBJECT_8");
    self_obj_ptr.incrRefCount("I_ITCL_OBJECT_8");
    value_ptr.incrRefCount("I_ITCL_OBJECT_9");
    interp.variable_obj_type.setVariable(self_obj_ptr, value_ptr, var_ptr_ptr);
    self_obj_ptr.decrRefCount("D_ITCL_OBJECT_7");
    value_ptr.decrRefCount("D_ITCL_OBJECT_8");

    if (initObjectVariables() != OK) {
................................................................................
    Namespace save_ns_ptr;
    ApwtclObj default_value_ptr = null;

//print("NS!"+interp.frame_ptr.ns_ptr.toDebugString()+"!");
    save_ns_ptr = interp.frame_ptr.ns_ptr;
    interp.frame_ptr.ns_ptr = class_obj.ns_ptr;
    for (String option_name: class_obj.options.keySet()) {
      default_value_ptr = null;
      ItclOption option_obj = class_obj.options.get(option_name);
      class_options.put(option_name, option_obj);
      /* set the itcl_options array for that option name to the defaultvalue of the option */
      obj_ptr = interp.string_obj_type.newStringObj("itcl_options("+option_name+")", -1, "ITCL_OBJECT_9");
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      if (option_obj.default_value != null) {
        obj_ptr.incrRefCount("I_ITCL_OBJECT_10");
................................................................................
          return ERROR;
        }
        obj_ptr.decrRefCount("D_ITCL_OBJECT_9");
      }
      if (class_info.class_type == ITCL_TYPE_CLASS) {
        /* set the options array for ::itcl::type for that option name to the defaultvalue of the option */
        obj_ptr = interp.string_obj_type.newStringObj("options("+option_name+")", -1, "ITCL_OBJECT_10");
//print("itclObject options!"+option_name+"!"+option_obj.default_value+"!");
        if (option_obj.default_value != null) {
          obj_ptr.incrRefCount("I_ITCL_OBJECT_11");
          if (interp.variable_obj_type.setVariable(obj_ptr, option_obj.default_value, var_ptr_ptr) != OK) {
            interp.frame_ptr.ns_ptr = save_ns_ptr;
            return ERROR;
          }
          obj_ptr.decrRefCount("D_ITCL_OBJECT_10");

Changes to src/org/apwtcl/lang/ItclOption.java.

202
203
204
205
206
207
208




209
210
211
212
213
214
215
    }
    if ((option_flags & ITCL_OPTION_CONFIGURE_METHODVAR) != 0) {
      configure_methodvar = command_option_list.getOptionValue(ITCL_OPTION_CONFIGURE_METHODVAR).get(0);
    }
    if ((option_flags & ITCL_OPTION_VALIDATE_METHODVAR) != 0) {
      validate_methodvar = command_option_list.getOptionValue(ITCL_OPTION_VALIDATE_METHODVAR).get(0);
    }




//print("TD!"+toDebugString()+"!");
    return OK;
  }
  
  /* ==================== delegateConfigure ================================== */
  public int delegateConfigure(ApwtclObj option_name, ApwtclObj option_val) {
print("delegateConfigure not yet implemented!");







>
>
>
>







202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
    }
    if ((option_flags & ITCL_OPTION_CONFIGURE_METHODVAR) != 0) {
      configure_methodvar = command_option_list.getOptionValue(ITCL_OPTION_CONFIGURE_METHODVAR).get(0);
    }
    if ((option_flags & ITCL_OPTION_VALIDATE_METHODVAR) != 0) {
      validate_methodvar = command_option_list.getOptionValue(ITCL_OPTION_VALIDATE_METHODVAR).get(0);
    }
    if (default_value == null) {
      default_value = interp.empty_string_obj;
      default_value.incrRefCount("ITCL_OPTION_1");
    }
//print("TD!"+toDebugString()+"!");
    return OK;
  }
  
  /* ==================== delegateConfigure ================================== */
  public int delegateConfigure(ApwtclObj option_name, ApwtclObj option_val) {
print("delegateConfigure not yet implemented!");

Changes to src/org/apwtcl/lang/Parse.java.

975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
....
1022
1023
1024
1025
1026
1027
1028

1029
1030
1031
1032
1033
1034
1035
....
1038
1039
1040
1041
1042
1043
1044

1045
1046
1047


1048
1049


1050
1051
1052
1053
1054
1055


1056
1057
1058


1059
1060
1061
1062
1063
1064
1065
....
1141
1142
1143
1144
1145
1146
1147

1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160

1161
1162
1163
1164
1165
1166
1167
      feedChar();
    }
    if (parse_info.len <= 0) {
//print("parseExpression end!"+parse_info.text.charAt(parse_info.index)+"!");
      parse_info.start = parse_info.index;
      parse_info.end = parse_info.index;
      parse_info.line = parse_info.line_no;
      if (parse_info.cur == '\n' || parse_info.cur == ']' || parse_info.len < 0) {
        parse_info.eof = true;
        parse_info.token = TOKEN_EOL;
        return OK;
      }
      parse_info.len--;
      // fall through to handle a statement not delimited by a newline!!
    }
................................................................................
      return retcode;
    case '$':
      if (parseVar() == ERROR) {
        return parseExprOperator();
      } else {
        /* Don't allow expr sugar in expressions */
        if (parse_info.token == TOKEN_EXPRSUGAR) {

          return ERROR;
        }
        return OK;
      }
    case '0':
    case '1':
    case '2':
................................................................................
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    case '.':
      int ret = parseExprNumber();

      return ret;
    case '"':
      return parseQuote();


    case '{':
      return parseBrace();


    case 'N':
    case 'I':
    case 'n':
    case 'i':
      if (parseExprIrrational() == ERROR)
        return parseExprOperator();


      break;
    default:
      return parseExprOperator();


    }
    return OK;
  }

  /* ==================== parseExprNumber ================================== */
  private int parseExprNumber() {
    boolean allowdot = true;
................................................................................
        if (parse_info.text.substring(parse_info.index, parse_info.index + op_len).equals(op_name) && op_len > best_len) {
          best_idx = i + TOKEN_EXPR_OP;
          best_len = op_len;
        }
      }
    }
    if (best_idx == -1) {

      return ERROR;
    }

    /* Validate parentheses around function arguments */
    if (best_idx >= TOKEN_EXPROP_FUNC_FIRST) {
      int idx = parse_info.index + best_len;
      int len = parse_info.len - best_len;

      while ((len > 0) && hasSpace(UCHAR(parse_info.text.charAt(idx)))) {
        len--;
        idx++;
      }
      if (parse_info.text.charAt(idx) != '(') {

        return ERROR;
      }
    }
    parse_info.start = parse_info.index;
    parse_info.end = parse_info.index + best_len - 1;
    parse_info.index += best_len;
    parse_info.len -= best_len;







|







 







>







 







>


|
>
>

|
>
>




|
|
>
>


|
>
>







 







>













>







975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
....
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
....
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
....
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
      feedChar();
    }
    if (parse_info.len <= 0) {
//print("parseExpression end!"+parse_info.text.charAt(parse_info.index)+"!");
      parse_info.start = parse_info.index;
      parse_info.end = parse_info.index;
      parse_info.line = parse_info.line_no;
      if (parse_info.cur == '\n' || parse_info.cur == ']' || parse_info.cur == ' ' || parse_info.len < 0) {
        parse_info.eof = true;
        parse_info.token = TOKEN_EOL;
        return OK;
      }
      parse_info.len--;
      // fall through to handle a statement not delimited by a newline!!
    }
................................................................................
      return retcode;
    case '$':
      if (parseVar() == ERROR) {
        return parseExprOperator();
      } else {
        /* Don't allow expr sugar in expressions */
        if (parse_info.token == TOKEN_EXPRSUGAR) {
//print(">>parseExpr!"+TOKEN_EXPRSUGAR+"!");
          return ERROR;
        }
        return OK;
      }
    case '0':
    case '1':
    case '2':
................................................................................
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    case '.':
      int ret = parseExprNumber();
//print(">>parseExpr2!"+ret+"!");
      return ret;
    case '"':
      ret = parseQuote();
//print(">>parseExpr3!"+ret+"!");
      return ret;
    case '{':
      ret = parseBrace();
//print(">>parseExpr3!"+ret+"!");
      return ret;
    case 'N':
    case 'I':
    case 'n':
    case 'i':
      if (parseExprIrrational() == ERROR) {
        ret = parseExprOperator();
        return ret;
      }
      break;
    default:
      ret = parseExprOperator();
//print(">>parseExpr5!"+ret+"!");
      return ret;
    }
    return OK;
  }

  /* ==================== parseExprNumber ================================== */
  private int parseExprNumber() {
    boolean allowdot = true;
................................................................................
        if (parse_info.text.substring(parse_info.index, parse_info.index + op_len).equals(op_name) && op_len > best_len) {
          best_idx = i + TOKEN_EXPR_OP;
          best_len = op_len;
        }
      }
    }
    if (best_idx == -1) {
print("parseExprOperator2!"+parse_info.index+"!"+parse_info.text.substring(parse_info.index)+"!"+parse_info.text+"!");
      return ERROR;
    }

    /* Validate parentheses around function arguments */
    if (best_idx >= TOKEN_EXPROP_FUNC_FIRST) {
      int idx = parse_info.index + best_len;
      int len = parse_info.len - best_len;

      while ((len > 0) && hasSpace(UCHAR(parse_info.text.charAt(idx)))) {
        len--;
        idx++;
      }
      if (parse_info.text.charAt(idx) != '(') {
print("parseExprOperator3!"+parse_info.text.substring(parse_info.index)+"!");
        return ERROR;
      }
    }
    parse_info.start = parse_info.index;
    parse_info.end = parse_info.index + best_len - 1;
    parse_info.index += best_len;
    parse_info.len -= best_len;

Changes to src/org/apwtcl/lang/cmd/ItclCommand.java.

731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
...
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
...
842
843
844
845
846
847
848

849
850
851
852
853
854
855
    ArrayList<ApwtclObj> option_name_ptr = null;
    ApwtclObj opt_name;
    ArrayList<ApwtclObj> option_val_ptr = null;
    ApwtclObj opt_val;
    ApwtclObj lst_ptr;
    int ret_code = OK;

print("::itcl::internal::classconfigurelist!"+args+"!"+args.size()+"!ns!"+interp.frame_ptr.ns_ptr+"!");
    if (args.size() != 2) {
      interp.wrongNumArgs(1, args, "optionList");
      return ERROR;
    }
    lst_ptr = args.get(1);
    lgth = interp.list_obj_type.listLength(lst_ptr);
    if (lgth % 2 != 0) {
................................................................................
      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      my_args.add(args.get(0));
      my_args.get(0).incrRefCount("ITCL_COMMAND_10");
      my_args.add(opt_name);
      opt_name.incrRefCount("ITCL_COMMAND_11");
      my_args.add(opt_val);
      opt_val.incrRefCount("ITCL_COMMAND_12");
print("configurelist!"+i+"!"+lgth+"!"+my_args+"!");
      ret_code = (Integer)cmd_obj.call(interp, my_args, false);
//print("configurelist after call!"+i+"!"+lgth+"!"+my_args+"!");
    }
//print("configurelist after for");
    name_ptr.decrRefCount("D_PKG_ITCLCMD_4");
//print("configurelist return!"+ret_code+"!");
    return ret_code;
................................................................................
    my_args = new ArrayList<ApwtclObj>();
    my_args.add(type_ptr);
    my_args.add(object_name);
    for (i = 5; i < args.size(); i++) {
      my_args.add(args.get(i));
      args.get(i).incrRefCount("ITCL_COMMAND_12");
    }

    ret_code = interp.itcl_obj_type.classCommand(my_args);
    if (ret_code == OK) {
      /* set the component to the object */
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      ret_code = interp.variable_obj_type.setVariable(component_ptr, object_name, var_ptr_ptr);
    }
    return ret_code;







|







 







|







 







>







731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
...
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
...
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
    ArrayList<ApwtclObj> option_name_ptr = null;
    ApwtclObj opt_name;
    ArrayList<ApwtclObj> option_val_ptr = null;
    ApwtclObj opt_val;
    ApwtclObj lst_ptr;
    int ret_code = OK;

//print("::itcl::internal::classconfigurelist!"+args+"!"+args.size()+"!ns!"+interp.frame_ptr.ns_ptr+"!");
    if (args.size() != 2) {
      interp.wrongNumArgs(1, args, "optionList");
      return ERROR;
    }
    lst_ptr = args.get(1);
    lgth = interp.list_obj_type.listLength(lst_ptr);
    if (lgth % 2 != 0) {
................................................................................
      ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
      my_args.add(args.get(0));
      my_args.get(0).incrRefCount("ITCL_COMMAND_10");
      my_args.add(opt_name);
      opt_name.incrRefCount("ITCL_COMMAND_11");
      my_args.add(opt_val);
      opt_val.incrRefCount("ITCL_COMMAND_12");
//print("configurelist!"+i+"!"+lgth+"!"+my_args+"!");
      ret_code = (Integer)cmd_obj.call(interp, my_args, false);
//print("configurelist after call!"+i+"!"+lgth+"!"+my_args+"!");
    }
//print("configurelist after for");
    name_ptr.decrRefCount("D_PKG_ITCLCMD_4");
//print("configurelist return!"+ret_code+"!");
    return ret_code;
................................................................................
    my_args = new ArrayList<ApwtclObj>();
    my_args.add(type_ptr);
    my_args.add(object_name);
    for (i = 5; i < args.size(); i++) {
      my_args.add(args.get(i));
      args.get(i).incrRefCount("ITCL_COMMAND_12");
    }
//print("install 2!"+my_args+"!");
    ret_code = interp.itcl_obj_type.classCommand(my_args);
    if (ret_code == OK) {
      /* set the component to the object */
      ArrayList<Variable> var_ptr_ptr = new ArrayList<Variable>();
      ret_code = interp.variable_obj_type.setVariable(component_ptr, object_name, var_ptr_ptr);
    }
    return ret_code;

Changes to src/org/apwtcl/lang/cmd/TraceCommand.java.

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
    }
    cmd_obj.addExecutionTrace(trace_obj);
    return OK;
  }

  /* ==================== traceAddVariableCmd ===================================== */
  public int traceAddVariableCmd(Interp interp, ArrayList<ApwtclObj> args) {
print("trace add variable called");
    Variable var_ptr = null;

    if (args.size() != 4) {
      interp.wrongNumArgs(1, args, "add variable");
      return ERROR;
    }
    ApwtclObj var_name = args.get(1);







|







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
    }
    cmd_obj.addExecutionTrace(trace_obj);
    return OK;
  }

  /* ==================== traceAddVariableCmd ===================================== */
  public int traceAddVariableCmd(Interp interp, ArrayList<ApwtclObj> args) {
//print("trace add variable called");
    Variable var_ptr = null;

    if (args.size() != 4) {
      interp.wrongNumArgs(1, args, "add variable");
      return ERROR;
    }
    ApwtclObj var_name = args.get(1);

Changes to src/org/apwtcl/lang/objtype/ItclObjType.java.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
...
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497
498
499
500
...
611
612
613
614
615
616
617
618

619
620
621
622
623
624
625
626
627
628
629

630
631
632
633

634
635
636
637
638
639
640
...
644
645
646
647
648
649
650

651
652

653
654
655
656
657
658
659

660
661
662
663
664
665
666
...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
...
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729

730
731
732
733
734
735
736
737
    return str.toString();
  }

  /* ==================== setFromAny ================================== */
  public int setFromAny(ApwtclObj obj_ptr) {
//print("CLNAME!"+this.class_name+"!");
    ApwtclObj class_name = this.class_name;
    int class_type = this.class_type;
    ApwtclObj full_class_name;
    Namespace ns_ptr;
    Namespace class_ns_ptr;
    Command cmd_ptr;
    String class_name_str = this.class_name.getString();
    String tail;
    String head;
    ItclClass class_info;
    int ret_code;

    if (obj_ptr.obj_type == OBJ_TYPE_ITCL) {
      return OK;
    }
    /*
................................................................................
      break;
    }
    return OK;
  }

  /* ==================== classCommand ================================== */
  public int classCommand(ArrayList<ApwtclObj> args) {
//print("classCommand!"+args+"!");
    String class_name = args.get(0).getString();
    ApwtclObj cmd_name_ptr = args.get(1);
    String cmd_name = cmd_name_ptr.getString();
    ArrayList<ApwtclObj> constructor_args = new ArrayList<ApwtclObj>();
    for (int i = 2; i < args.size(); i++) {
      constructor_args.add(args.get(i)); 
    }
................................................................................
    if (ns_ptr == null) {
      interp.setResultString("INTERNAL ERROR in classCommand: namespace not found for: "+class_name+"!");
      return ERROR;
    }
    class_name = ns_ptr.name;
    cmd_obj = interp.global_ns_ptr.getClassCommand(ns_ptr, cmd_name, class_only);
    if (cmd_obj == null) {

      /* command not found seems to be creation of a class */
      Pattern re = Pattern.compile("(.*)(#auto)(.*)");
      Matcher res = re.matcher(cmd_name);
     if (!res.matches()) {
        re = Pattern.compile("(.*)(%AUTO%)(.*)");
        res = re.matcher(cmd_name);
      }
      if (res.matches()) {
        String head = res.group(1);
        String trailer = res.group(3);
        class_name = this.class_name.getString();
................................................................................
    }
    interp.setResultString(cmd_name);
    return OK;
  }

  /* ==================== callClassCommand ========================================= */
  public int callClassCommand(Namespace ns_ptr, String fcn_name, ItclObject class_object, ArrayList<ApwtclObj> args) {
//print("callClassCommand1!"+ns_ptr+"!"+fcn_name+"!"+class_object+"!"+args+"!");

  try {
    boolean class_only = true;
    int ret_code;
    Command cmd_obj;
    Namespace my_ns_ptr;
    ApwtclObj name_ptr = interp.string_obj_type.newStringObj(fcn_name, -1, "ITCL_OBJ_TYPE_3");
    /* we need to add the command as the first argument !!! */
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    ItclObject save_class_object;

    cmd_obj = ns_ptr.getClassCommand(ns_ptr, fcn_name, class_only);

//print("cmd_obj1!"+ns_ptr.toDebugString()+"!"+fcn_name+"!"+cmd_obj+"!");
    if (cmd_obj == null) {
      my_ns_ptr = interp.frame_ptr.ns_ptr.getNamespace("::itcl::internal");
      cmd_obj = my_ns_ptr.getClassCommand(my_ns_ptr, fcn_name, class_only);

    }
//print("cmd_obj2!"+cmd_obj+"!");
    if (cmd_obj == null) {
      /* check if we are in a type, widget, widgetadaptor or extendedclass
       * and if we have a delegation for methods
       */
      ItclClass class_ptr = class_object.class_info;
................................................................................
        dlg_info = class_ptr.delegated_methods.get(escapeKey(fcn_name));
        to_part = dlg_info.to_part.getString();
      }
      if (class_ptr.delegated_methods.get("*") != null) {
        dlg_info = class_ptr.delegated_methods.get("*");
        to_part = dlg_info.to_part.getString();
      }

      if (to_part != null) {
        Variable var_ptr = class_object.variables.get(escapeKey(to_part));

        ItclObject obj2 = interp.class_objects.get(escapeKey(var_ptr.obj_ptr.getString()));
        my_args = new ArrayList<ApwtclObj>();
        my_args.add(interp.string_obj_type.newStringObj(obj2.object_name, -1, "ITCL_OBJ_TYPE_4"));
        my_args.add(interp.string_obj_type.newStringObj(fcn_name, -1, "ITCL_OBJ_TYPE_5"));
        for (int j = 0; j < args.size(); j++) {
          my_args.add(args.get(j));
        }

        ret_code = classObjectCommand(obj2.class_info.ns_ptr, obj2, my_args);
        return ret_code;
      }
    }
    name_ptr.incrRefCount("I_ITCL_OBJ_TYPE_7");
    my_args.add(name_ptr);
//print("args!"+args+"!");
................................................................................
      my_args.add(args.get(k));
      args.get(k).incrRefCount("I_ITCL_OBJ_TYPE_8");
    }
    save_class_object = interp.frame_ptr.class_object;
    if (cmd_obj != null) {
      interp.frame_ptr.setClassObject(class_object);
      cmd_obj.incrCmdRefCount();
//print("cmd_obj3!"+cmd_obj+"!"+cmd_obj.is_proc+"!");
//print("cmd_obj4!"+cmd_obj.toDebugString()+"!");
      if (cmd_obj.is_proc) {
//        ret_code = (Integer)cmd_obj.call(interp, my_args, /* ensemble_expand */ true);
        ret_code = interp.command_obj_type.callProcedure(cmd_obj, null, 0, my_args.size(), my_args);
      } else {
        /* Create a new call frame */
        ArrayList<CallFrame>frame_ptr_ptr = new ArrayList<CallFrame>();
................................................................................
    return ERROR;
  }
  }


  /* ==================== classObjectCommand ================================== */
  public int classObjectCommand(Namespace ns_ptr, ItclObject class_object, ArrayList<ApwtclObj> args) {
//print("classObjectCommand!"+ns_ptr+"!"+class_object+"!"+args+"!");
    ApwtclObj class_object_name = args.get(0);
    ApwtclObj sub_cmd = args.get(1);
    args.remove(0);
    args.remove(0);
    ArrayList<ApwtclObj> my_args = args;
    int ret_code;
    ArrayList<ItclObject> class_object_ptr = new ArrayList<ItclObject>();

    if (interp.getItclObject(class_object_name.getString(), class_object_ptr) != OK) {
      return ERROR;
    }
    ItclObject my_class_object = class_object_ptr.get(0);

    ret_code = callClassCommand(ns_ptr, sub_cmd.getString(), class_object, my_args);
    return ret_code;
  }

  /* ==================== getSuperClasses ================================== */
  public int getSuperClasses(ItclClass class_ptr, ArrayList<ItclClass> result_ptr) {
    if (class_ptr.heritage != null) {
      for (int i = 0; i < class_ptr.heritage.size(); i++) {







<






<







 







|







 







>



|







 







|
>











>




>







 







>


>







>







 







|







 







|












>
|







74
75
76
77
78
79
80

81
82
83
84
85
86

87
88
89
90
91
92
93
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
...
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
...
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
...
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
...
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
    return str.toString();
  }

  /* ==================== setFromAny ================================== */
  public int setFromAny(ApwtclObj obj_ptr) {
//print("CLNAME!"+this.class_name+"!");
    ApwtclObj class_name = this.class_name;

    ApwtclObj full_class_name;
    Namespace ns_ptr;
    Namespace class_ns_ptr;
    Command cmd_ptr;
    String class_name_str = this.class_name.getString();
    String tail;

    ItclClass class_info;
    int ret_code;

    if (obj_ptr.obj_type == OBJ_TYPE_ITCL) {
      return OK;
    }
    /*
................................................................................
      break;
    }
    return OK;
  }

  /* ==================== classCommand ================================== */
  public int classCommand(ArrayList<ApwtclObj> args) {
//print(">>classCommand!"+args+"!"+interp.class_objects+"!");
    String class_name = args.get(0).getString();
    ApwtclObj cmd_name_ptr = args.get(1);
    String cmd_name = cmd_name_ptr.getString();
    ArrayList<ApwtclObj> constructor_args = new ArrayList<ApwtclObj>();
    for (int i = 2; i < args.size(); i++) {
      constructor_args.add(args.get(i)); 
    }
................................................................................
    if (ns_ptr == null) {
      interp.setResultString("INTERNAL ERROR in classCommand: namespace not found for: "+class_name+"!");
      return ERROR;
    }
    class_name = ns_ptr.name;
    cmd_obj = interp.global_ns_ptr.getClassCommand(ns_ptr, cmd_name, class_only);
    if (cmd_obj == null) {
//print(">>create object for class!"+cmd_name+"!");
      /* command not found seems to be creation of a class */
      Pattern re = Pattern.compile("(.*)(#auto)(.*)");
      Matcher res = re.matcher(cmd_name);
      if (!res.matches()) {
        re = Pattern.compile("(.*)(%AUTO%)(.*)");
        res = re.matcher(cmd_name);
      }
      if (res.matches()) {
        String head = res.group(1);
        String trailer = res.group(3);
        class_name = this.class_name.getString();
................................................................................
    }
    interp.setResultString(cmd_name);
    return OK;
  }

  /* ==================== callClassCommand ========================================= */
  public int callClassCommand(Namespace ns_ptr, String fcn_name, ItclObject class_object, ArrayList<ApwtclObj> args) {
//print("callClassCommand1!"+args+"!");
//print("callClassCommand1a!"+ns_ptr+"§fcn_name§"+fcn_name+"§class_object§"+class_object+"!");
  try {
    boolean class_only = true;
    int ret_code;
    Command cmd_obj;
    Namespace my_ns_ptr;
    ApwtclObj name_ptr = interp.string_obj_type.newStringObj(fcn_name, -1, "ITCL_OBJ_TYPE_3");
    /* we need to add the command as the first argument !!! */
    ArrayList<ApwtclObj> my_args = new ArrayList<ApwtclObj>();
    ItclObject save_class_object;

    cmd_obj = ns_ptr.getClassCommand(ns_ptr, fcn_name, class_only);
//print("++++getClassCommand1!"+fcn_name+"!"+cmd_obj+"!");
//print("cmd_obj1!"+ns_ptr.toDebugString()+"!"+fcn_name+"!"+cmd_obj+"!");
    if (cmd_obj == null) {
      my_ns_ptr = interp.frame_ptr.ns_ptr.getNamespace("::itcl::internal");
      cmd_obj = my_ns_ptr.getClassCommand(my_ns_ptr, fcn_name, class_only);
//print("++++getClassCommand2!"+fcn_name+"!"+cmd_obj+"!");
    }
//print("cmd_obj2!"+cmd_obj+"!");
    if (cmd_obj == null) {
      /* check if we are in a type, widget, widgetadaptor or extendedclass
       * and if we have a delegation for methods
       */
      ItclClass class_ptr = class_object.class_info;
................................................................................
        dlg_info = class_ptr.delegated_methods.get(escapeKey(fcn_name));
        to_part = dlg_info.to_part.getString();
      }
      if (class_ptr.delegated_methods.get("*") != null) {
        dlg_info = class_ptr.delegated_methods.get("*");
        to_part = dlg_info.to_part.getString();
      }
//print("++++to_part!"+fcn_name+"!"+to_part+"!"+current_object+"!");
      if (to_part != null) {
        Variable var_ptr = class_object.variables.get(escapeKey(to_part));
//print("++++to_part2!"+var_ptr.obj_ptr.getString()+"!");
        ItclObject obj2 = interp.class_objects.get(escapeKey(var_ptr.obj_ptr.getString()));
        my_args = new ArrayList<ApwtclObj>();
        my_args.add(interp.string_obj_type.newStringObj(obj2.object_name, -1, "ITCL_OBJ_TYPE_4"));
        my_args.add(interp.string_obj_type.newStringObj(fcn_name, -1, "ITCL_OBJ_TYPE_5"));
        for (int j = 0; j < args.size(); j++) {
          my_args.add(args.get(j));
        }
//print("++++call classObjectComand!"+my_args+"!");
        ret_code = classObjectCommand(obj2.class_info.ns_ptr, obj2, my_args);
        return ret_code;
      }
    }
    name_ptr.incrRefCount("I_ITCL_OBJ_TYPE_7");
    my_args.add(name_ptr);
//print("args!"+args+"!");
................................................................................
      my_args.add(args.get(k));
      args.get(k).incrRefCount("I_ITCL_OBJ_TYPE_8");
    }
    save_class_object = interp.frame_ptr.class_object;
    if (cmd_obj != null) {
      interp.frame_ptr.setClassObject(class_object);
      cmd_obj.incrCmdRefCount();
//print("cmd_obj3!"+cmd_obj+"!"+cmd_obj.is_proc+"!"+my_args+"!");
//print("cmd_obj4!"+cmd_obj.toDebugString()+"!");
      if (cmd_obj.is_proc) {
//        ret_code = (Integer)cmd_obj.call(interp, my_args, /* ensemble_expand */ true);
        ret_code = interp.command_obj_type.callProcedure(cmd_obj, null, 0, my_args.size(), my_args);
      } else {
        /* Create a new call frame */
        ArrayList<CallFrame>frame_ptr_ptr = new ArrayList<CallFrame>();
................................................................................
    return ERROR;
  }
  }


  /* ==================== classObjectCommand ================================== */
  public int classObjectCommand(Namespace ns_ptr, ItclObject class_object, ArrayList<ApwtclObj> args) {
//print("@@@classObjectCommand!"+ns_ptr+"!"+class_object+"!"+args+"!");
    ApwtclObj class_object_name = args.get(0);
    ApwtclObj sub_cmd = args.get(1);
    args.remove(0);
    args.remove(0);
    ArrayList<ApwtclObj> my_args = args;
    int ret_code;
    ArrayList<ItclObject> class_object_ptr = new ArrayList<ItclObject>();

    if (interp.getItclObject(class_object_name.getString(), class_object_ptr) != OK) {
      return ERROR;
    }
    ItclObject my_class_object = class_object_ptr.get(0);
//print("+++callClass from Object!"+my_class_object+"!");
    ret_code = callClassCommand(ns_ptr, sub_cmd.getString(), my_class_object, my_args);
    return ret_code;
  }

  /* ==================== getSuperClasses ================================== */
  public int getSuperClasses(ItclClass class_ptr, ArrayList<ItclClass> result_ptr) {
    if (class_ptr.heritage != null) {
      for (int i = 0; i < class_ptr.heritage.size(); i++) {

Changes to src/org/apwtcl/lang/objtype/StringObjType.java.

173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  public int appendString(ApwtclObj obj_ptr, String str, int len) {
    panic(obj_ptr.isShared(), "appendString called with shared object");
    if (obj_ptr.obj_type != OBJ_TYPE_STRING) {
      setFromAny(obj_ptr);
    }
if (obj_ptr.value2 == null) {
print("appendString value2 == null!");
print("VAL2 NULL!"+obj_ptr.toDebugString()+"!");
obj_ptr.strValue_SetCharLength(obj_ptr.len);
}
    _appendString(obj_ptr, str, len);
    return OK;
  }
  /* ==================== stringMap ================================== */
  /* does the [string map] operation. On error null is returned,







|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  public int appendString(ApwtclObj obj_ptr, String str, int len) {
    panic(obj_ptr.isShared(), "appendString called with shared object");
    if (obj_ptr.obj_type != OBJ_TYPE_STRING) {
      setFromAny(obj_ptr);
    }
if (obj_ptr.value2 == null) {
print("appendString value2 == null!");
//print("VAL2 NULL!"+obj_ptr.toDebugString()+"!");
obj_ptr.strValue_SetCharLength(obj_ptr.len);
}
    _appendString(obj_ptr, str, len);
    return OK;
  }
  /* ==================== stringMap ================================== */
  /* does the [string map] operation. On error null is returned,