Source Code Cross Referenced for PyBuiltinFunction.java in  » Testing » Marathon » org » python » core » 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 » Testing » Marathon » org.python.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.python.core;
002:
003:        public abstract class PyBuiltinFunction extends PyObject implements 
004:                PyType.Newstyle {
005:
006:            public static final String exposed_name = "builtin_function_or_method";
007:
008:            public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
009:                dict.__setitem__("__name__", new PyGetSetDescr("__name__",
010:                        PyBuiltinFunction.class, "fastGetName", null));
011:                dict.__setitem__("__self__", new PyGetSetDescr("__self__",
012:                        PyBuiltinFunction.class, "getSelf", null));
013:                dict.__setitem__("__doc__", new PyGetSetDescr("__doc__",
014:                        PyBuiltinFunction.class, "fastGetDoc", null));
015:                dict.__setitem__("__call__", new PyGetSetDescr("__call__",
016:                        PyBuiltinFunction.class, "makeCall", null));
017:            }
018:
019:            public interface Info {
020:
021:                String getName();
022:
023:                int getMaxargs();
024:
025:                int getMinargs();
026:
027:                PyException unexpectedCall(int nargs, boolean keywords);
028:            }
029:
030:            public static class DefaultInfo implements  Info {
031:
032:                public DefaultInfo(String name, int minargs, int maxargs) {
033:                    this .name = name;
034:                    this .minargs = minargs;
035:                    this .maxargs = maxargs;
036:                }
037:
038:                public DefaultInfo(String name, int nargs) {
039:                    this (name, nargs, nargs);
040:                }
041:
042:                private String name;
043:
044:                private int maxargs, minargs;
045:
046:                public String getName() {
047:                    return name;
048:                }
049:
050:                public int getMaxargs() {
051:                    return maxargs;
052:                }
053:
054:                public int getMinargs() {
055:                    return minargs;
056:                }
057:
058:                public static boolean check(int nargs, int minargs, int maxargs) {
059:                    if (nargs < minargs)
060:                        return false;
061:                    if (maxargs != -1 && nargs > maxargs)
062:                        return false;
063:                    return true;
064:                }
065:
066:                public static PyException unexpectedCall(int nargs,
067:                        boolean keywords, String name, int minargs, int maxargs) {
068:                    if (keywords)
069:                        return Py.TypeError(name
070:                                + "() takes no keyword arguments");
071:                    String argsblurb;
072:                    if (minargs == maxargs) {
073:                        if (minargs == 0)
074:                            argsblurb = "no arguments";
075:                        else if (minargs == 1)
076:                            argsblurb = "exactly one argument";
077:                        else
078:                            argsblurb = minargs + " arguments";
079:                    } else if (maxargs == -1) {
080:                        return Py.TypeError(name + "() requires at least "
081:                                + minargs + " (" + nargs + " given)");
082:                    } else {
083:                        if (minargs <= 0)
084:                            argsblurb = "at most " + maxargs + " arguments";
085:                        else
086:                            argsblurb = minargs + "-" + maxargs + " arguments";
087:                    }
088:                    return Py.TypeError(name + "() takes " + argsblurb + " ("
089:                            + nargs + " given)");
090:                }
091:
092:                public PyException unexpectedCall(int nargs, boolean keywords) {
093:                    return unexpectedCall(nargs, keywords, name, minargs,
094:                            maxargs);
095:                }
096:            }
097:
098:            protected PyBuiltinFunction(Info info) {
099:                this .info = info;
100:            }
101:
102:            protected Info info;
103:
104:            public void setInfo(Info info) {
105:                this .info = info;
106:            }
107:
108:            /**
109:             * @return a new instance of this type of PyBuiltinFunction bound to self
110:             */
111:            abstract protected PyBuiltinFunction bind(PyObject self);
112:
113:            public PyObject getSelf() {
114:                return Py.None;
115:            }
116:
117:            public String toString() {
118:                PyObject self = getSelf();
119:                if (self == null)
120:                    return "<built-in function " + info.getName() + ">";
121:                else {
122:                    String typename = self.getType().fastGetName();
123:                    return "<built-in method " + info.getName() + " of "
124:                            + typename + " object>";
125:                }
126:            }
127:
128:            public PyObject fastGetName() {
129:                return Py.newString(this .info.getName());
130:            }
131:
132:            public PyObject fastGetDoc() {
133:                return Py.None;
134:            }
135:
136:            public PyObject makeCall() {
137:                return this;
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.