01: /*
02: * JavaCallCmd.java
03: *
04: * Implements the built-in "java::call" command.
05: *
06: * Copyright (c) 1997 Sun Microsystems, Inc.
07: *
08: * See the file "license.terms" for information on usage and
09: * redistribution of this file, and for a DISCLAIMER OF ALL
10: * WARRANTIES.
11: *
12: * RCS: @(#) $Id: JavaCallCmd.java,v 1.2 2002/12/07 20:46:58 mdejong Exp $
13: *
14: */
15:
16: package tcl.lang;
17:
18: /*
19: * Implements the built-in "java::call" command.
20: */
21:
22: class JavaCallCmd implements Command {
23:
24: /*----------------------------------------------------------------------
25: *
26: * cmdProc --
27: *
28: * This procedure is invoked to process the "java::call" Tcl
29: * command. See the user documentation for details on what it
30: * does.
31: *
32: * Results:
33: * None.
34: *
35: * Side effects:
36: * A standard Tcl result is stored in the interpreter.
37: *
38: *----------------------------------------------------------------------
39: */
40:
41: public void cmdProc(Interp interp, // Current interpreter.
42: TclObject argv[]) // Argument list.
43: throws TclException // A standard Tcl exception.
44: {
45: boolean convert;
46: int classIdx;
47:
48: if (argv.length < 3) {
49: throw new TclNumArgsException(interp, 1, argv,
50: "?-noconvert? class signature ?arg arg ...?");
51: }
52:
53: String arg1 = argv[1].toString();
54: if ((arg1.length() >= 2) && ("-noconvert".startsWith(arg1))) {
55: convert = false;
56: classIdx = 2;
57: } else {
58: convert = true;
59: classIdx = 1;
60: }
61:
62: if (argv.length < classIdx + 2) {
63: throw new TclNumArgsException(interp, 1, argv,
64: "?-noconvert? class signature ?arg arg ...?");
65: }
66:
67: int startIdx = classIdx + 2;
68: int count = argv.length - startIdx;
69:
70: TclObject result = JavaInvoke.callStaticMethod(interp,
71: argv[classIdx], argv[classIdx + 1], argv, startIdx,
72: count, convert);
73:
74: if (result == null)
75: interp.resetResult();
76: else
77: interp.setResult(result);
78: }
79:
80: } // end JavaCallCmd
|