Skip to content

Commit c060229

Browse files
committed
Add "varargs" attribute.
1 parent 3ddee71 commit c060229

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Include/methodobject.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ extern typeobject Methodtype;
3030

3131
typedef object *(*method) FPROTO((object *, object *));
3232

33-
extern object *newmethodobject PROTO((char *, method, object *));
33+
extern object *newmethodobject PROTO((char *, method, object *, int));
3434
extern method getmethod PROTO((object *));
3535
extern object *getself PROTO((object *));
36+
extern int getvarargs PROTO((object *));
3637

3738
struct methodlist {
38-
char *ml_name;
39-
method ml_meth;
39+
char *ml_name;
40+
method ml_meth;
41+
int ml_varargs;
4042
};
4143

4244
extern object *findmethod PROTO((struct methodlist *, object *, char *));

Objects/methodobject.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3030

3131
typedef struct {
3232
OB_HEAD
33-
char *m_name;
34-
method m_meth;
35-
object *m_self;
33+
char *m_name;
34+
method m_meth;
35+
object *m_self;
36+
int m_varargs;
3637
} methodobject;
3738

3839
object *
39-
newmethodobject(name, meth, self)
40+
newmethodobject(name, meth, self, varargs)
4041
char *name; /* static string */
4142
method meth;
4243
object *self;
44+
int varargs;
4345
{
4446
methodobject *op = NEWOBJ(methodobject, &Methodtype);
4547
if (op != NULL) {
@@ -48,6 +50,7 @@ newmethodobject(name, meth, self)
4850
if (self != NULL)
4951
INCREF(self);
5052
op->m_self = self;
53+
op->m_varargs = varargs;
5154
}
5255
return (object *)op;
5356
}
@@ -74,6 +77,17 @@ getself(op)
7477
return ((methodobject *)op) -> m_self;
7578
}
7679

80+
int
81+
getvarargs(op)
82+
object *op;
83+
{
84+
if (!is_methodobject(op)) {
85+
err_badcall();
86+
return -1;
87+
}
88+
return ((methodobject *)op) -> m_varargs;
89+
}
90+
7791
/* Methods (the standard built-in methods, that is) */
7892

7993
static void
@@ -168,7 +182,8 @@ findmethod(ml, op, name)
168182
return listmethods(ml);
169183
for (; ml->ml_name != NULL; ml++) {
170184
if (strcmp(name, ml->ml_name) == 0)
171-
return newmethodobject(ml->ml_name, ml->ml_meth, op);
185+
return newmethodobject(ml->ml_name, ml->ml_meth,
186+
op, ml->ml_varargs);
172187
}
173188
err_setstr(AttributeError, name);
174189
return NULL;

Python/modsupport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ initmodule(name, methods)
4545
for (ml = methods; ml->ml_name != NULL; ml++) {
4646
sprintf(namebuf, "%s.%s", name, ml->ml_name);
4747
v = newmethodobject(strdup(namebuf), ml->ml_meth,
48-
(object *)NULL);
48+
(object *)NULL, ml->ml_varargs);
4949
/* XXX The strdup'ed memory is never freed */
5050
if (v == NULL || dictinsert(d, ml->ml_name, v) != 0) {
5151
fprintf(stderr, "initializing module: %s\n", name);

0 commit comments

Comments
 (0)