]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add "varargs" attribute.
authorGuido van Rossum <guido@python.org>
Mon, 16 Dec 1991 13:07:24 +0000 (13:07 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 16 Dec 1991 13:07:24 +0000 (13:07 +0000)
Include/methodobject.h
Objects/methodobject.c
Python/modsupport.c

index 262208daba9e9feccd348f6933af8457ebbcc181..e8d795ecafe63c5c5d3ba4a696a4033878376ecd 100644 (file)
@@ -30,13 +30,15 @@ extern typeobject Methodtype;
 
 typedef object *(*method) FPROTO((object *, object *));
 
-extern object *newmethodobject PROTO((char *, method, object *));
+extern object *newmethodobject PROTO((char *, method, object *, int));
 extern method getmethod PROTO((object *));
 extern object *getself PROTO((object *));
+extern int getvarargs PROTO((object *));
 
 struct methodlist {
-       char *ml_name;
-       method ml_meth;
+       char    *ml_name;
+       method  ml_meth;
+       int     ml_varargs;
 };
 
 extern object *findmethod PROTO((struct methodlist *, object *, char *));
index 3ebdb37792221fa9e237dbd2806885418ec4c1e7..98b70a6d8d268f8e5d7797000bdfe272db604cda 100644 (file)
@@ -30,16 +30,18 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 typedef struct {
        OB_HEAD
-       char *m_name;
-       method m_meth;
-       object *m_self;
+       char    *m_name;
+       method  m_meth;
+       object  *m_self;
+       int     m_varargs;
 } methodobject;
 
 object *
-newmethodobject(name, meth, self)
+newmethodobject(name, meth, self, varargs)
        char *name; /* static string */
        method meth;
        object *self;
+       int varargs;
 {
        methodobject *op = NEWOBJ(methodobject, &Methodtype);
        if (op != NULL) {
@@ -48,6 +50,7 @@ newmethodobject(name, meth, self)
                if (self != NULL)
                        INCREF(self);
                op->m_self = self;
+               op->m_varargs = varargs;
        }
        return (object *)op;
 }
@@ -74,6 +77,17 @@ getself(op)
        return ((methodobject *)op) -> m_self;
 }
 
+int
+getvarargs(op)
+       object *op;
+{
+       if (!is_methodobject(op)) {
+               err_badcall();
+               return -1;
+       }
+       return ((methodobject *)op) -> m_varargs;
+}
+
 /* Methods (the standard built-in methods, that is) */
 
 static void
@@ -168,7 +182,8 @@ findmethod(ml, op, name)
                return listmethods(ml);
        for (; ml->ml_name != NULL; ml++) {
                if (strcmp(name, ml->ml_name) == 0)
-                       return newmethodobject(ml->ml_name, ml->ml_meth, op);
+                       return newmethodobject(ml->ml_name, ml->ml_meth,
+                                       op, ml->ml_varargs);
        }
        err_setstr(AttributeError, name);
        return NULL;
index 5d56241e2736dbe2fdb3e3d146079214f0d2bf9e..7deded44b78770d207e6ece76e53be9462657bc8 100644 (file)
@@ -45,7 +45,7 @@ initmodule(name, methods)
        for (ml = methods; ml->ml_name != NULL; ml++) {
                sprintf(namebuf, "%s.%s", name, ml->ml_name);
                v = newmethodobject(strdup(namebuf), ml->ml_meth,
-                                               (object *)NULL);
+                                       (object *)NULL, ml->ml_varargs);
                /* XXX The strdup'ed memory is never freed */
                if (v == NULL || dictinsert(d, ml->ml_name, v) != 0) {
                        fprintf(stderr, "initializing module: %s\n", name);