summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-01-02 15:11:48 (GMT)
committerGuido van Rossum <guido@python.org>1991-01-02 15:11:48 (GMT)
commit320a5ccbdcf4a0eb06657a43edd71c9010ccca72 (patch)
treebfbec097ca82c680277fb2642b79475df93e39ce
parent59b3590711b11eec91a67941cd2bdfd814d7d918 (diff)
downloadcpython-320a5ccbdcf4a0eb06657a43edd71c9010ccca72.zip
cpython-320a5ccbdcf4a0eb06657a43edd71c9010ccca72.tar.gz
cpython-320a5ccbdcf4a0eb06657a43edd71c9010ccca72.tar.bz2
Fixed a bit (still no warranties).
-rw-r--r--Objects/xxobject.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Objects/xxobject.c b/Objects/xxobject.c
index ffafcd7..c3714e0 100644
--- a/Objects/xxobject.c
+++ b/Objects/xxobject.c
@@ -1,5 +1,17 @@
+/* Use this file as a template to start implementing a new object type.
+ If your objects will be called foobar, start by copying this file to
+ foobarobject.c, changing all occurrences of xx to foobar and all
+ occurrences of Xx by Foobar. You will probably want to delete all
+ references to 'x_attr' and add your own types of attributes
+ instead. Maybe you want to name your local variables other than
+ 'xp'. If your object type is needed in other files, you'll have to
+ create a file "foobarobject.h"; see intobject.h for an example. */
+
+
/* Xx objects */
+#include "allobjects.h"
+
typedef struct {
OB_HEAD
object *x_attr; /* Attributes dictionary */
@@ -7,6 +19,8 @@ typedef struct {
extern typeobject Xxtype; /* Really static, forward */
+#define is_xxobject(v) ((v)->ob_type == &Xxtype)
+
static xxobject *
newxxobject(arg)
object *arg;
@@ -25,8 +39,7 @@ static void
xx_dealloc(xp)
xxobject *xp;
{
- if (xp->x_attr != NULL)
- DECREF(xp->x_attr);
+ XDECREF(xp->x_attr);
DEL(xp);
}
@@ -70,7 +83,7 @@ xx_setattr(xp, name, v)
if (xp->x_attr == NULL) {
xp->x_attr = newdictobject();
if (xp->x_attr == NULL)
- return errno;
+ return -1;
}
if (v == NULL)
return dictremove(xp->x_attr, name);