Source Code Cross Referenced for ProcCmd.java in  » Scripting » jacl » tcl » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » jacl » tcl.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ProcCmd.java
003:         *
004:         * Copyright (c) 1997 Cornell University.
005:         * Copyright (c) 1997 Sun Microsystems, Inc.
006:         *
007:         * See the file "license.terms" for information on usage and
008:         * redistribution of this file, and for a DISCLAIMER OF ALL
009:         * WARRANTIES.
010:         * 
011:         * RCS: @(#) $Id: ProcCmd.java,v 1.6 2005/11/21 01:14:17 mdejong Exp $
012:         *
013:         */
014:
015:        package tcl.lang;
016:
017:        /**
018:         * This class implements the built-in "proc" command in Tcl.
019:         */
020:
021:        class ProcCmd implements  Command {
022:            /**
023:             *
024:             * Tcl_ProcObjCmd -> ProcCmd.cmdProc
025:             *
026:             * Creates a new Tcl procedure.
027:             *
028:             * @param interp the current interpreter.
029:             * @param objv command arguments.
030:             * @exception TclException If incorrect number of arguments.
031:             */
032:
033:            public void cmdProc(Interp interp, TclObject[] objv)
034:                    throws TclException {
035:                Procedure proc;
036:                String fullName;
037:                Command cmd;
038:                FindCommandNamespaceResult result;
039:
040:                if (objv.length != 4) {
041:                    throw new TclNumArgsException(interp, 1, objv,
042:                            "name args body");
043:                }
044:
045:                // Determine the namespace where the procedure should reside. Unless
046:                // the command name includes namespace qualifiers, this will be the
047:                // current namespace.
048:
049:                fullName = objv[1].toString();
050:                result = FindCommandNamespace(interp, fullName);
051:
052:                //  Create the data structure to represent the procedure.
053:
054:                proc = new Procedure(interp, result.ns, result.cmdName,
055:                        objv[2], objv[3], interp.getScriptFile(), interp
056:                                .getArgLineNumber(3));
057:
058:                // Now create a command for the procedure. This will be in
059:                // the current namespace unless the procedure's name included namespace
060:                // qualifiers. To create the new command in the right namespace, we
061:                // use fully qualified name for it.
062:
063:                interp.createCommand(result.cmdFullName, proc);
064:
065:                // Now initialize the new procedure's cmdPtr field. This will be used
066:                // later when the procedure is called to determine what namespace the
067:                // procedure will run in. This will be different than the current
068:                // namespace if the proc was renamed into a different namespace.
069:
070:                WrappedCommand wcmd = Namespace.findCommand(interp,
071:                        result.cmdFullName, result.ns, TCL.NAMESPACE_ONLY);
072:                proc.wcmd = wcmd;
073:
074:                return;
075:            }
076:
077:            // Helper class used to return namespace lookup results for
078:            // a command name.
079:
080:            static class FindCommandNamespaceResult {
081:                String fullName; // Initial name of command: like "foo" or "::one::two::foo"
082:                String cmdName; // Result short name of command: like "foo"
083:                String cmdFullName; // Result full name of command: like "::one::two::foo"
084:                Namespace ns; // Result namespace the command lives in
085:            }
086:
087:            // Helper used to lookup the namespace and associated info for a command.
088:            // Use when defining a new command.
089:
090:            static FindCommandNamespaceResult FindCommandNamespace(
091:                    Interp interp, String fullName) throws TclException {
092:                String procName;
093:                Namespace ns, altNs, cxtNs;
094:                StringBuffer ds;
095:
096:                Namespace.GetNamespaceForQualNameResult gnfqnr = interp.getnfqnResult;
097:                Namespace.getNamespaceForQualName(interp, fullName, null, 0,
098:                        gnfqnr);
099:
100:                ns = gnfqnr.ns;
101:                altNs = gnfqnr.altNs;
102:                cxtNs = gnfqnr.actualCxt;
103:                procName = gnfqnr.simpleName;
104:
105:                if (ns == null) {
106:                    throw new TclException(interp, "can't create procedure \""
107:                            + fullName + "\": unknown namespace");
108:                }
109:                if (procName == null) {
110:                    throw new TclException(interp, "can't create procedure \""
111:                            + fullName + "\": bad procedure name");
112:                }
113:                // FIXME : could there be a problem with a command named ":command" ?
114:                if ((ns != Namespace.getGlobalNamespace(interp))
115:                        && (procName != null)
116:                        && ((procName.length() > 0) && (procName.charAt(0) == ':'))) {
117:                    throw new TclException(
118:                            interp,
119:                            "can't create procedure \""
120:                                    + procName
121:                                    + "\" in non-global namespace with name starting with \":\"");
122:                }
123:
124:                // Return the command info, if the command is defined in a namespace
125:                // other than the global namespace then cmdFullName will be the
126:                // fully qualified name for the command.
127:
128:                ds = new StringBuffer();
129:                if (ns != Namespace.getGlobalNamespace(interp)) {
130:                    ds.append(ns.fullName);
131:                    ds.append("::");
132:                }
133:                ds.append(procName);
134:
135:                FindCommandNamespaceResult result = new FindCommandNamespaceResult();
136:                result.fullName = fullName;
137:                result.cmdName = procName;
138:                result.cmdFullName = ds.toString();
139:                result.ns = ns;
140:
141:                return result;
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.