annotate Modules/newmodule.c @ 3720:b341def4eef8 legacy-trunk

Ignore latex intermediate products.
author Guido van Rossum <guido@python.org>
date Wed, 26 Jun 1996 19:30:01 +0000
parents bddbaa51aa5a
children 65d2d8e67da3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
1 /***********************************************************
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
3 The Netherlands.
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
4
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
5 All Rights Reserved
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
6
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
8 documentation for any purpose and without fee is hereby granted,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
9 provided that the above copyright notice appear in all copies and that
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
10 both that copyright notice and this permission notice appear in
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
13 distribution of the software without specific, written prior permission.
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
14
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
22
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
23 ******************************************************************/
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
24
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
25 /* Module new -- create new objects of various types */
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
26
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 #include "allobjects.h"
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 #include "compile.h"
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
3678
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
30 static char new_instance_doc[] =
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
31 "Create an instance object from (CLASS, DICT) without calling its __init__().";
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
32
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
33 static object *
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
34 new_instance(unused, args)
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
35 object* unused;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
36 object* args;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
37 {
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
38 object* klass;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
39 object *dict;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
40 instanceobject *inst;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
41 if (!newgetargs(args, "O!O!",
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
42 &Classtype, &klass,
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
43 &Dicttype, &dict))
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
44 return NULL;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
45 inst = NEWOBJ(instanceobject, &Instancetype);
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
46 if (inst == NULL)
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
47 return NULL;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
48 INCREF(klass);
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
49 INCREF(dict);
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
50 inst->in_class = (classobject *)klass;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
51 inst->in_dict = dict;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
52 return (object *)inst;
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
53 }
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
54
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
55 static char new_im_doc[] =
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
56 "Create a instance method object from (FUNCTION, INSTANCE, CLASS).";
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
57
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
58 static object *
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 new_instancemethod(unused, args)
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
60 object* unused;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
61 object* args;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 {
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
63 object* func;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
64 object* self;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
65 object* classObj;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
66
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
67 if (!newgetargs(args, "O!O!O!",
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
68 &Functype, &func,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
69 &Instancetype, &self,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
70 &Classtype, &classObj))
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
71 return NULL;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
72 return newinstancemethodobject(func, self, classObj);
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 }
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
74
2871
0534025cefe5 \temporary 'fix' for brokenness
Guido van Rossum <guido@python.org>
parents: 2150
diff changeset
75 /* XXX These internal interfaces have changed -- who'll fix this code? */
0534025cefe5 \temporary 'fix' for brokenness
Guido van Rossum <guido@python.org>
parents: 2150
diff changeset
76 #if 0
0534025cefe5 \temporary 'fix' for brokenness
Guido van Rossum <guido@python.org>
parents: 2150
diff changeset
77
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
78 static char new_function_doc[] =
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
79 "Create a function object from (CODE, GLOBALS, [NAME, ARGCOUNT, ARGDEFS]).";
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
80
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
81 static object *
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 new_function(unused, args)
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
83 object* unused;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
84 object* args;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 {
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
86 object* code;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
87 object* globals;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
88 object* name = None;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
89 int argcount = -1;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
90 object* argdefs = None;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
91 funcobject* newfunc;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
93 if (!newgetargs(args, "O!O!|SiO!",
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
94 &Codetype, &code,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
95 &Mappingtype, &globals,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
96 &name,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
97 &argcount,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
98 &Tupletype, &argdefs))
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
99 return NULL;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
100
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
101 newfunc = (funcobject *)newfuncobject(code, globals);
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
102 if (newfunc == NULL)
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
103 return NULL;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
105 if (name != None) {
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
106 XINCREF(name);
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
107 XDECREF(newfunc->func_name);
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
108 newfunc->func_name = name;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
109 }
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
110 newfunc->func_argcount = argcount;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
111 if (argdefs != NULL) {
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
112 XINCREF(argdefs);
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
113 XDECREF(newfunc->func_argdefs);
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
114 newfunc->func_argdefs = argdefs;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
115 }
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
116
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
117 return (object *)newfunc;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
118 }
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
119 #endif
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
120
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
121 static char new_code_doc[] =
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
122 "Create a code object from (ARGCOUNT, NLOCALS, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FILENAME, NAME).";
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
123
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
124 static object *
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 new_code(unused, args)
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
126 object* unused;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
127 object* args;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 {
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
129 int argcount;
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
130 int nlocals;
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
131 int flags;
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
132 object* code;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
133 object* consts;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
134 object* names;
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
135 object* varnames;
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
136 object* filename;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
137 object* name;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
138
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
139 #if 0
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
140 if (!newgetargs(args, "SO!O!SS",
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
141 &code, &Tupletype, &consts, &Tupletype, &names,
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
142 &filename, &name))
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
143 return NULL;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
144 return (object *)newcodeobject(code, consts, names, filename, name);
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
145 #else
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
146 if (!newgetargs(args, "iiiSO!O!O!SS",
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
147 &argcount, &nlocals, &flags, /* These are new */
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
148 &code, &Tupletype, &consts, &Tupletype, &names,
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
149 &Tupletype, &varnames, /* These are new */
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
150 &filename, &name))
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
151 return NULL;
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
152 return (object *)newcodeobject(argcount, nlocals, flags,
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
153 code, consts, names, varnames, filename, name);
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
154 #endif
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 }
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
156
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
157 static char new_module_doc[] =
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
158 "Create a module object from (NAME).";
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
160 static object *
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 new_module(unused, args)
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
162 object* unused;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
163 object* args;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 {
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
165 char *name;
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
166
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
167 if (!newgetargs(args, "s", &name))
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
168 return NULL;
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
169 return newmoduleobject(name);
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 }
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
171
3337
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
172 static char new_class_doc[] =
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
173 "Create a class object from (NAME, BASE_CLASSES, DICT).";
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
174
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
175 static object *
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
176 new_class(unused, args)
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
177 object* unused;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
178 object* args;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
179 {
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
180 object * name;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
181 object * classes;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
182 object * dict;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
183
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
184 if (!newgetargs(args, "SO!O!", &name, &Tupletype, &classes,
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
185 &Mappingtype, &dict))
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
186 return NULL;
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
187 return newclassobject(classes, dict, name);
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
188 }
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
189
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
190 static struct methodlist new_methods[] = {
3678
bddbaa51aa5a Added new.instance(class, dict).
Guido van Rossum <guido@python.org>
parents: 3337
diff changeset
191 {"instance", new_instance, 1, new_instance_doc},
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
192 {"instancemethod", new_instancemethod, 1, new_im_doc},
2871
0534025cefe5 \temporary 'fix' for brokenness
Guido van Rossum <guido@python.org>
parents: 2150
diff changeset
193 #if 0
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
194 {"function", new_function, 1, new_function_doc},
3135
999fcce496f8 re-enable new.code(...) with new args
Guido van Rossum <guido@python.org>
parents: 2871
diff changeset
195 #endif
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
196 {"code", new_code, 1, new_code_doc},
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
197 {"module", new_module, 1, new_module_doc},
3337
201de8455c2b added new.classobj()
Guido van Rossum <guido@python.org>
parents: 3135
diff changeset
198 {"classobj", new_class, 1, new_class_doc},
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
199 {NULL, NULL} /* sentinel */
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
200 };
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
201
2077
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
202 char new_doc[] =
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
203 "Functions to create new objects used by the interpreter.\n\
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
204 \n\
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
205 You need to know a great deal about the interpreter to use this!";
3848094f259c totally revamped
Guido van Rossum <guido@python.org>
parents: 2008
diff changeset
206
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 void
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
208 initnew()
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 {
2096
d5c935b9a7b5 initmodule3 -> initmodule3
Guido van Rossum <guido@python.org>
parents: 2077
diff changeset
210 initmodule4("new", new_methods, new_doc, (object *)NULL,
d5c935b9a7b5 initmodule3 -> initmodule3
Guido van Rossum <guido@python.org>
parents: 2077
diff changeset
211 PYTHON_API_VERSION);
1650
51a06fdfff78 Added some new modules
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 }