APWTCL Arnulf's Preferred Web Tcl

Check-in [b6251dec71]
Login

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

Overview
Comment:fixes for makeing loading of gles20 PackageCommand possible. Support of some OBJ_TYPE_DOUBLE functions.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b6251dec71afa656af714e19185b0f808ece9944
User & Date: arnulf 2014-02-06 19:57:04
Context
2014-02-07
20:56
fixes for making first steps with gles20 package commands. check-in: 168f592e8c user: arnulf tags: trunk
2014-02-06
19:57
fixes for makeing loading of gles20 PackageCommand possible. Support of some OBJ_TYPE_DOUBLE functions. check-in: b6251dec71 user: arnulf tags: trunk
2014-02-03
09:04
fixes and changes for apwtcl version as eclipse library. check-in: 1d9ced18e4 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/TestApwtcl.java.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import org.apwtcl.lang.Token;
import org.apwtcl.lang.objtype.StringObjType;


public class TestApwtcl {

  public static void main (String[] args) {
    Interp intp = new Interp();

//    ApwtclClassLoader class_loader = new ApwtclClassLoader(intp, "org/apwtcl/lang/cmd");


//Class<?> my_class = class_loader.myFindClass("Puts");
//System.out.println("my_class!"+my_class+"!");
Command cmd = null;







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import org.apwtcl.lang.Token;
import org.apwtcl.lang.objtype.StringObjType;


public class TestApwtcl {

  public static void main (String[] args) {
    Interp intp = new Interp(null);

//    ApwtclClassLoader class_loader = new ApwtclClassLoader(intp, "org/apwtcl/lang/cmd");


//Class<?> my_class = class_loader.myFindClass("Puts");
//System.out.println("my_class!"+my_class+"!");
Command cmd = null;

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

54
55
56
57
58
59
60



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75




76
77
78
79
80
81
82
83
84

  /* ==================== myFindClass ===================================== */
  public Class<?> myFindClass(String name) {
    Class<?> my_class = null;
    String class_name = null;
    try {
      class_name = path.replaceAll("/",".")+"."+name;



      my_class = Class.forName(class_name, false, this);
System.out.println("found class!"+name+"!"+my_class+"!");
    } catch (Exception e) {
System.out.println("not found!"+class_name+"!"+e.getMessage()+"!");
      byte[] b = loadClassData(name);
System.out.println("name!"+name+"!");
      name = path.replaceAll("/",".")+"."+name;
System.out.println("name2!"+name+"!");
      return defineClass(name, b, 0, b.length);
    }
    return my_class;
  }

  /* ==================== loadClassData ===================================== */
  private byte[] loadClassData(String name) {




//    File file = new File("/home/arnulf/workspace/apwtcl/bin/"+path+"/"+name+".class");
    File file = new File(path+"/"+name+".class");

System.out.println("FF!"+file+"!"+file.canRead()+"!"+file.length()+"!");
    int len = (int)file.length();
    FileInputStream fin = null;
    try {
      fin = new FileInputStream(file);
    } catch (Exception e) {







>
>
>
|
|













>
>
>
>

|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

  /* ==================== myFindClass ===================================== */
  public Class<?> myFindClass(String name) {
    Class<?> my_class = null;
    String class_name = null;
    try {
      class_name = path.replaceAll("/",".")+"."+name;
//System.out.println("class_name!"+name+"!"+class_name+"!");
      my_class = Class.forName(class_name);
//System.out.println("found class!"+name+"!"+my_class+"!");
//      my_class = Class.forName(class_name, false, this);
//System.out.println("found class!"+name+"!"+my_class+"!");
    } catch (Exception e) {
System.out.println("not found!"+class_name+"!"+e.getMessage()+"!");
      byte[] b = loadClassData(name);
System.out.println("name!"+name+"!");
      name = path.replaceAll("/",".")+"."+name;
System.out.println("name2!"+name+"!");
      return defineClass(name, b, 0, b.length);
    }
    return my_class;
  }

  /* ==================== loadClassData ===================================== */
  private byte[] loadClassData(String name) {
	String my_path = "./";
System.out.println("loadCLassData: "+name+"!"+path+"!");
String classPath = System.getProperty("java.class.path");
System.out.println("classPath: "+classPath+"!");
//    File file = new File("/home/arnulf/workspace/apwtcl/bin/"+path+"/"+name+".class");
    File file = new File(my_path+path+"/"+name+".class");

System.out.println("FF!"+file+"!"+file.canRead()+"!"+file.length()+"!");
    int len = (int)file.length();
    FileInputStream fin = null;
    try {
      fin = new FileInputStream(file);
    } catch (Exception e) {

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

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39






40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
import java.util.HashMap;
import java.lang.reflect.Method;

public class Command extends Token implements Debug {
  public static int oid = 0;

  private int id;
  public String name;
  public Namespace ns_ptr;
  public int class_type;
  public int func_type;
  public int command_type;
  public boolean is_proc;
  public NativeFcn native_fcn;
  public Proc proc;
  public int cmd_ref_count;
  public int cmd_epoch;
  public int flags;
  public HashMap<String, Command> ensemble;
  public HashMap<String, ApwtclObj> ensemble_info;
  private Class<?> cmd_class;






  public Method cmd_method;
  public Object cmd_instance;
  public String file_name;
  public int line_no;
  public int last_line_no;


  public ArrayList<Trace> execution_traces;
  public ArrayList<Trace> command_traces;
  public String map_command;
  public ItclObject class_object;
  public ItclFunction function_info;
  public ItclClass class_info;

  /* ==================== Command ================================== */
  public Command(Interp interp, String name) {
    oid++;







|
|



<
<
<



|
|
|
>
>
>
>
>
>


<
<
<
>
>


<







19
20
21
22
23
24
25
26
27
28
29
30



31
32
33
34
35
36
37
38
39
40
41
42
43
44



45
46
47
48

49
50
51
52
53
54
55
import java.util.HashMap;
import java.lang.reflect.Method;

public class Command extends Token implements Debug {
  public static int oid = 0;

  private int id;
  private Class<?> cmd_class;

  public int class_type;
  public int func_type;
  public int command_type;



  public int cmd_ref_count;
  public int cmd_epoch;
  public int flags;
  public int line_no;
  public int last_line_no;
  public boolean is_proc;
  public String name;
  public String file_name;
  public String map_command;
  public Namespace ns_ptr;
  public NativeFcn native_fcn;
  public Proc proc;
  public Method cmd_method;
  public Object cmd_instance;



  public HashMap<String, Command> ensemble;
  public HashMap<String, ApwtclObj> ensemble_info;
  public ArrayList<Trace> execution_traces;
  public ArrayList<Trace> command_traces;

  public ItclObject class_object;
  public ItclFunction function_info;
  public ItclClass class_info;

  /* ==================== Command ================================== */
  public Command(Interp interp, String name) {
    oid++;

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

226
227
228
229
230
231
232


233
234
235
236
237
238
239
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("LinsertCommand ::linsert", -1, "CORE_COMMAND_PACKAGES_49"));
    cmds.put("linsert", sub_cmds);
    
//print("core!"+cmds.keySet()+"!");    
    packages.put("core", cmds);


  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "CoreCommandPackages!"+id+"!";
    return str;
  } 







>
>







226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    
    sub_cmds = new ArrayList<ApwtclObj>();
    sub_cmds.add(interp.string_obj_type.newStringObj("LinsertCommand ::linsert", -1, "CORE_COMMAND_PACKAGES_49"));
    cmds.put("linsert", sub_cmds);
    
//print("core!"+cmds.keySet()+"!");    
    packages.put("core", cmds);
    package_names.add("core");
    package_infos.put("core", this);
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "CoreCommandPackages!"+id+"!";
    return str;
  } 

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

13
14
15
16
17
18
19










20
21
22
23




24
25
26
27
28





















29
30
31
32
33
34
35
...
305
306
307
308
309
310
311
































312
313
314
315
316
317
318
...
335
336
337
338
339
340
341
342














343
344

345
346
347
348
349
350
351
352
353
354

355

356
357
358
359
360
361
362
...
384
385
386
387
388
389
390



391

392
393
394
395
396
397
398
 *
 */

package org.apwtcl.lang;

import java.io.File;
import java.io.FileInputStream;










// import java.lang.reflect.Method;
import java.util.ArrayList;

public class Helpers extends Defines {





  /* ==================== Helpers ================================== */
  public Helpers() {
  }






















  /* ==================== escapeKey ============================== */
  public static String escapeKey(String key) {
    if (key == null) {
      return key;
    }
    if (key.equals("constructor")) {
      key = "_"+key;
................................................................................
      map_res.decrRefCount("D_BASE_2");
    }
    empty_str.decrRefCount("D_BASE_3");
//    list_idx.free();
//    lists_end.free();
    return result;
  }
































  
  /* ==================== getFileContents ===================================== */
  public String getFileContents(Interp interp, String url) {
//print("getFileContents!"+url+"!");
    File file = null;
    FileInputStream file_st = null;
    try {
................................................................................
    } catch (Exception e) {
      interp.setResultString("no such file: "+url+"!");
      return null;
    }
//print("file contents!"+new String(bytes)+"!");
	return new String(bytes);  
  }
  














  /* ==================== source ===================================== */
  public int source(Interp interp, String url) {

    String response_text;
    ApwtclObj script;
  //  Method read_file = null;
  //  Method read_fcn = null;
  //  Method read = null;
    int result = ERROR;
  //  ApwtclObj my_obj_ptr;
    ApwtclObj xhr_object;

    interp.curr_file_name = url;

    url = interp.start_dir+"/"+url;

//print("source!"+url+"!win!"+interp.win+"!");
    xhr_object = null;
    if (interp.win != null) {
//    try {
//      if(interp.win.ActiveXObject != null) {    // Internet Explorer
//        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
//      }
................................................................................
//        }
//        if (read != null) {
//          read_fcn = read;
//        }
//        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
//          response_text = read_fcn(url);



          response_text = getFileContents(interp, url);

//print("source!"+url+"!"+responseText+"!");
//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+response_text, -1, "BASE_2");
//          script = interp.string_obj_type.newStringObj(response_text, -1, "BASE_2");
//print("SOURCE!"+script.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);







>
>
>
>
>
>
>
>
>
>




>
>
>
>





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
>










>
|
>







 







>
>
>
|
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
 *
 */

package org.apwtcl.lang;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.ClassLoader;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.util.Log;
// import java.lang.reflect.Method;
import java.util.ArrayList;

public class Helpers extends Defines {
    private static String TAG = "Helpers";
    private static String msgStart = "ShowArgs!";
    private static int _gles2_debug_level = 0;
    private Interp interp;

  /* ==================== Helpers ================================== */
  public Helpers() {
  }

  /* ==================== ShowArgs ================================== */
  public void ShowArgs(int level, String str, ArrayList<ApwtclObj> objv) {
      int i;
      StringBuffer outStr = new StringBuffer();

      if (level > _gles2_debug_level) {
          return;
      }
      outStr.append(str);
      for (i = 0; i < objv.size(); i++) {
          if (objv.get(i) == null) {
          	outStr.append("!??");
          } else {
      	    outStr.append("!"+objv.get(i).getString());
          }
      }
      outStr.append("!\n");
      System.out.println(msgStart+outStr.toString());
      Log.v(msgStart, outStr.toString());
  }
  
  /* ==================== escapeKey ============================== */
  public static String escapeKey(String key) {
    if (key == null) {
      return key;
    }
    if (key.equals("constructor")) {
      key = "_"+key;
................................................................................
      map_res.decrRefCount("D_BASE_2");
    }
    empty_str.decrRefCount("D_BASE_3");
//    list_idx.free();
//    lists_end.free();
    return result;
  }

  /* ==================== getAssetFileContents ===================================== */
  public String getAssetFileContents(Interp interp, String url) {

    DataInputStream dis = null;
	StringBuffer strFileContents = new StringBuffer(); 
	try {
	  int bytesRead;
      InputStream is = interp.context.getAssets().open(url);
      BufferedInputStream bis = new BufferedInputStream(is);
      dis = new DataInputStream(bis);
		
      byte[] buffer = new byte[1024];
      while( (bytesRead = dis.read(buffer)) != -1){ 
        strFileContents.append(new String(buffer, 0, bytesRead));               
      }
	System.out.println("LEN: "+strFileContents.length());
	//System.out.println("BUF: "+strFileContents.toString()+"!");
	//System.out.println("BUF: done");
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        dis.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return strFileContents.toString();	  
  }
  
  /* ==================== getFileContents ===================================== */
  public String getFileContents(Interp interp, String url) {
//print("getFileContents!"+url+"!");
    File file = null;
    FileInputStream file_st = null;
    try {
................................................................................
    } catch (Exception e) {
      interp.setResultString("no such file: "+url+"!");
      return null;
    }
//print("file contents!"+new String(bytes)+"!");
	return new String(bytes);  
  }
  
  /* ==================== listFilesForFolder ===================================== */
  public void listFilesForFolder(final File folder) {
	    int i = 0;
	    for (final File fileEntry : folder.listFiles()) {
	        if (fileEntry.isDirectory()) {
	            System.out.println("dir entry" + i + " " +fileEntry.getName());
	            listFilesForFolder(fileEntry);
	        } else {
	            System.out.println("file entry" + i + " " +fileEntry.getName());
	        }
	        i += 1;
	    }
	}
  
  /* ==================== source ===================================== */
  public int source(Interp interp, String url, boolean is_asset) {
System.out.println("Source: "+url+" "+is_asset);	  
    String response_text;
    ApwtclObj script;
  //  Method read_file = null;
  //  Method read_fcn = null;
  //  Method read = null;
    int result = ERROR;
  //  ApwtclObj my_obj_ptr;
    ApwtclObj xhr_object;

    interp.curr_file_name = url;
    if (! is_asset) {
      url = interp.start_dir+"/"+url;
    }
//print("source!"+url+"!win!"+interp.win+"!");
    xhr_object = null;
    if (interp.win != null) {
//    try {
//      if(interp.win.ActiveXObject != null) {    // Internet Explorer
//        xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
//      }
................................................................................
//        }
//        if (read != null) {
//          read_fcn = read;
//        }
//        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
//          response_text = read_fcn(url);
    	  if (is_asset) {
              response_text = getAssetFileContents(interp, url);
    	  } else {
            response_text = getFileContents(interp, url);
    	  }
//print("source!"+url+"!"+responseText+"!");
//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+response_text, -1, "BASE_2");
//          script = interp.string_obj_type.newStringObj(response_text, -1, "BASE_2");
//print("SOURCE!"+script.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);

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

15
16
17
18
19
20
21

22
23
24
25
26
27
28
..
52
53
54
55
56
57
58


59
60
61
62
63
64
65
...
140
141
142
143
144
145
146
147
148
149
150


151
152
153
154
155
156
157
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

package org.apwtcl.lang;

//#if memdebug
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;


import org.apwtcl.lang.objtype.ArrayObjType;
import org.apwtcl.lang.objtype.CoercedDoubleObjType;
import org.apwtcl.lang.objtype.CommandObjType;
import org.apwtcl.lang.objtype.ComparedStringObjType;
import org.apwtcl.lang.objtype.DictObjType;
import org.apwtcl.lang.objtype.DoubleObjType;
................................................................................

//#if memdebug
  /* keep track on how many ApwtclObjs have been created */
  static long interp_count = 0;
  /* actually keep track via weak references of all allocated ApwtclObjs */
//#endif 



  private long id;
  public ArrayObjType array_obj_type;
  public CommandObjType command_obj_type;
  public DictObjType dict_obj_type;
  public CoercedDoubleObjType coerced_double_obj_type;
  public ComparedStringObjType compared_string_obj_type;
  public DoubleObjType double_obj_type;
................................................................................
  public String current_dir;
  public ApwtclObj current_script_obj;
  public HashMap<String, ItclMacro> macros;
  public ItclMacro curr_macro;
  public Command expand_macro_cmd;

  /* ==================== Interp ================================== */
  public Interp() {
    ++interp_count;
    id = interp_count;



    /* initialise the ObjType Objects */
    array_obj_type = new ArrayObjType(this);
    coerced_double_obj_type = new CoercedDoubleObjType(this);
    compared_string_obj_type = new ComparedStringObjType(this);
    dict_obj_type = new DictObjType(this);
    expr_obj_type = new ExprObjType(this);
    double_obj_type = new DoubleObjType(this);
................................................................................
    error_code = null;
    eval_expression = new Expr(this);
    curr_class_info = null;
    loaded_class_info = new LoadedClassInfo(this);
    tcl_tests = null;
    win = null;
    xhdr_object = null;
    start_dir = "/home/arnulf/workspace/apwtcl/src/org/apwtcl/lang";
    current_dir = ".";
    current_script_obj = null;
    macros = new HashMap<String, ItclMacro>();
    curr_macro = null;
    expand_macro_cmd = null;
    source(this, "pkgIndex.tcl");
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "Interp!"+id+"!";
    return str;
  }







>







 







>
>







 







|



>
>







 







|





|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252

package org.apwtcl.lang;

//#if memdebug
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Context;

import org.apwtcl.lang.objtype.ArrayObjType;
import org.apwtcl.lang.objtype.CoercedDoubleObjType;
import org.apwtcl.lang.objtype.CommandObjType;
import org.apwtcl.lang.objtype.ComparedStringObjType;
import org.apwtcl.lang.objtype.DictObjType;
import org.apwtcl.lang.objtype.DoubleObjType;
................................................................................

//#if memdebug
  /* keep track on how many ApwtclObjs have been created */
  static long interp_count = 0;
  /* actually keep track via weak references of all allocated ApwtclObjs */
//#endif 

  public Context context;
  public boolean is_asset;
  private long id;
  public ArrayObjType array_obj_type;
  public CommandObjType command_obj_type;
  public DictObjType dict_obj_type;
  public CoercedDoubleObjType coerced_double_obj_type;
  public ComparedStringObjType compared_string_obj_type;
  public DoubleObjType double_obj_type;
................................................................................
  public String current_dir;
  public ApwtclObj current_script_obj;
  public HashMap<String, ItclMacro> macros;
  public ItclMacro curr_macro;
  public Command expand_macro_cmd;

  /* ==================== Interp ================================== */
  public Interp(Context context) {
    ++interp_count;
    id = interp_count;

    this.context = context;
    this.is_asset = true;
    /* initialise the ObjType Objects */
    array_obj_type = new ArrayObjType(this);
    coerced_double_obj_type = new CoercedDoubleObjType(this);
    compared_string_obj_type = new ComparedStringObjType(this);
    dict_obj_type = new DictObjType(this);
    expr_obj_type = new ExprObjType(this);
    double_obj_type = new DoubleObjType(this);
................................................................................
    error_code = null;
    eval_expression = new Expr(this);
    curr_class_info = null;
    loaded_class_info = new LoadedClassInfo(this);
    tcl_tests = null;
    win = null;
    xhdr_object = null;
    start_dir = "org/apwtcl/lang";
    current_dir = ".";
    current_script_obj = null;
    macros = new HashMap<String, ItclMacro>();
    curr_macro = null;
    expand_macro_cmd = null;
    source(this, "pkgIndex.tcl", true);
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "Interp!"+id+"!";
    return str;
  }

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

19
20
21
22
23
24
25
26


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
52
53
54
55
56
57
58

59
60
61
62
63
64
65
import java.util.HashMap;

public class PackageCommandInfo extends Token implements Debug {
  private static int oid = 0;

  private int id;

  public HashMap<String, HashMap<String, ArrayList<ApwtclObj>>> packages;


  

  /* ==================== PackageCommandInfo ================================== */
  public PackageCommandInfo() {
    oid++;
    id = oid;

    packages = new HashMap<String, HashMap<String, ArrayList<ApwtclObj>>>();
  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "PackageCommandInfo!"+id+"!";
    return str;
  } 
................................................................................
  }

  /* ==================== hasCommand ===================================== */
  public boolean hasCommand(String package_name, String cmd_name) {
	HashMap<String, ArrayList<ApwtclObj>> package_commands;
	package_commands = packages.get(package_name);
//print("hasCommand!"+cmd_name+"!"+package_name+"!"+package_commands+"!"+package_commands.get(cmd_name)+"!");

	if (package_commands == null) {
		/* package is not yet implemented */
		return false;
	}
	if (package_commands.get(cmd_name) == null) {
      return false;
    }







|
>
>






<
<







 







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


35
36
37
38
39
40
41
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.HashMap;

public class PackageCommandInfo extends Token implements Debug {
  private static int oid = 0;

  private int id;

  public static HashMap<String, HashMap<String, ArrayList<ApwtclObj>>> packages = new HashMap<String, HashMap<String, ArrayList<ApwtclObj>>>();
  public static ArrayList<String> package_names = new ArrayList<String>();
  public static HashMap<String, PackageCommandInfo> package_infos = new HashMap<String, PackageCommandInfo>();
  

  /* ==================== PackageCommandInfo ================================== */
  public PackageCommandInfo() {
    oid++;
    id = oid;


  }

  /* ==================== mySelf ================================== */
  public String mySelf() {
    String str = "PackageCommandInfo!"+id+"!";
    return str;
  } 
................................................................................
  }

  /* ==================== hasCommand ===================================== */
  public boolean hasCommand(String package_name, String cmd_name) {
	HashMap<String, ArrayList<ApwtclObj>> package_commands;
	package_commands = packages.get(package_name);
//print("hasCommand!"+cmd_name+"!"+package_name+"!"+package_commands+"!"+package_commands.get(cmd_name)+"!");
print("hasCommand!"+cmd_name+"!"+package_name+"!"+package_commands.get(cmd_name)+"!");
	if (package_commands == null) {
		/* package is not yet implemented */
		return false;
	}
	if (package_commands.get(cmd_name) == null) {
      return false;
    }

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

39
40
41
42
43
44
45
46
47
48
49
50
51
52
      return ERROR;
    }
    script_obj_ptr = args.get(1);
    script_obj_ptr.incrRefCount("I_PKG_CORECMD_4");
    prev_script_obj = interp.current_script_obj;

    interp.current_script_obj = script_obj_ptr;
    ret_code = source(interp, script_obj_ptr.getString());
    interp.current_script_obj = prev_script_obj;
    script_obj_ptr.decrRefCount("D_PKG_CORE_CMD_5");
    return ret_code;
  }

}







|






39
40
41
42
43
44
45
46
47
48
49
50
51
52
      return ERROR;
    }
    script_obj_ptr = args.get(1);
    script_obj_ptr.incrRefCount("I_PKG_CORECMD_4");
    prev_script_obj = interp.current_script_obj;

    interp.current_script_obj = script_obj_ptr;
    ret_code = source(interp, script_obj_ptr.getString(), true);
    interp.current_script_obj = prev_script_obj;
    script_obj_ptr.decrRefCount("D_PKG_CORE_CMD_5");
    return ret_code;
  }

}

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

51
52
53
54
55
56
57
58










































59
60
61
62
63
64
65






















66
67
68
69
70
71
72
73
74
75
76
77
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    return str.toString();
  }

  /* ==================== setFromAny ================================== */
  public int setFromAny(ApwtclObj obj_ptr) {
    print("double setFromAny not yet implemented");










































return OK;
  }

  /* ==================== updateString ===================================== */
  public void updateString(ApwtclObj obj_ptr) {
    print("double updateString not yet implemented");
  }























  /* ==================== newDoubleObj ================================== */
  public ApwtclObj newDoubleObj(double val) {
    ApwtclObj obj_ptr;

    obj_ptr = new ApwtclObj(interp);
    obj_ptr.obj_type = OBJ_TYPE_DOUBLE;
    obj_ptr.bytes = null;
    obj_ptr.doubleValue_SetValue(val);
    return obj_ptr;
  }
}







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    return str.toString();
  }

  /* ==================== setFromAny ================================== */
  public int setFromAny(ApwtclObj obj_ptr) {
    Double doubleValue;
    // wide wideValue;
    String str;

    /* Preserve the string representation.
     * Needed so we can convert back to int without loss
     */
    str = obj_ptr.getString();

// #ifdef HAVE_LONG_LONG
//     /* Assume a 53 bit mantissa */
// #define MIN_INT_IN_DOUBLE -(1LL << 53)
// #define MAX_INT_IN_DOUBLE -(MIN_INT_IN_DOUBLE + 1)
// 
//     if (objPtr->typePtr == &intObjType
//         && JimWideValue(objPtr) >= MIN_INT_IN_DOUBLE
//         && JimWideValue(objPtr) <= MAX_INT_IN_DOUBLE) {
// 
//         /* Direct conversion to coerced double */
//         objPtr->typePtr = &coercedDoubleObjType;
//         return JIM_OK;
//     }
//     else
// #endif
//     if (Jim_StringToWide(str, &wideValue, 10) == JIM_OK) {
//         /* Managed to convert to an int, so we can use this as a cooerced double */
//         Jim_FreeIntRep(interp, objPtr);
//         objPtr->typePtr = &coercedDoubleObjType;
//         objPtr->internalRep.wideValue = wideValue;
//         return JIM_OK;
//     }
//     else {
        /* Try to convert into a double */
        doubleValue = Double.valueOf(str);
//        if (Jim_StringToDouble(str, &doubleValue) != JIM_OK) {
//            Jim_SetResultFormatted(interp, "expected number but got \"%#s\"", objPtr);
//            return Defines.ERROR;
//        }
        /* Free the old internal repr and set the new one. */
        obj_ptr.freeIntRep();
//     }
    obj_ptr.obj_type = OBJ_TYPE_DOUBLE;
    obj_ptr.doubleValue_SetValue(doubleValue.doubleValue());
    return OK;
  }

  /* ==================== updateString ===================================== */
  public void updateString(ApwtclObj obj_ptr) {
    print("double updateString not yet implemented");
  }

  /* ==================== getDouble ================================== */
  public int getDouble(ApwtclObj obj_ptr, ArrayList<Double> double_ptr) {
    if (obj_ptr.obj_type == OBJ_TYPE_COERCED_DOUBLE) {
//        *doublePtr = JimWideValue(objPtr);
//        return Defines.OK;
        print("double getDouble for CORECED_DOUBLE not yet implemented");
        return ERROR;
    }
    if (obj_ptr.obj_type != OBJ_TYPE_DOUBLE && setFromAny(obj_ptr) == ERROR)
        return ERROR;

    if (obj_ptr.obj_type == OBJ_TYPE_COERCED_DOUBLE) {
//        double_ptr.set(0, WideValue(obj_ptr);
        print("double getDouble for CORECED_DOUBLE not yet implemented");
        return ERROR;
    }
    else {
        double_ptr.set(0, new Double(obj_ptr.doubleValue_GetValue()));
    }
    return OK;
  }

  /* ==================== newDoubleObj ================================== */
  public ApwtclObj newDoubleObj(double val) {
    ApwtclObj obj_ptr;

    obj_ptr = new ApwtclObj(interp);
    obj_ptr.obj_type = OBJ_TYPE_DOUBLE;
    obj_ptr.bytes = null;
    obj_ptr.doubleValue_SetValue(val);
    return obj_ptr;
  }
}