Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 320a5cc

Browse files
committed
Fixed a bit (still no warranties).
1 parent 59b3590 commit 320a5cc

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

Objects/xxobject.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
/* Use this file as a template to start implementing a new object type.
2+
If your objects will be called foobar, start by copying this file to
3+
foobarobject.c, changing all occurrences of xx to foobar and all
4+
occurrences of Xx by Foobar. You will probably want to delete all
5+
references to 'x_attr' and add your own types of attributes
6+
instead. Maybe you want to name your local variables other than
7+
'xp'. If your object type is needed in other files, you'll have to
8+
create a file "foobarobject.h"; see intobject.h for an example. */
9+
10+
111
/* Xx objects */
212

13+
#include "allobjects.h"
14+
315
typedef struct {
416
OB_HEAD
517
object *x_attr; /* Attributes dictionary */
618
} xxobject;
719

820
extern typeobject Xxtype; /* Really static, forward */
921

22+
#define is_xxobject(v) ((v)->ob_type == &Xxtype)
23+
1024
static xxobject *
1125
newxxobject(arg)
1226
object *arg;
@@ -25,8 +39,7 @@ static void
2539
xx_dealloc(xp)
2640
xxobject *xp;
2741
{
28-
if (xp->x_attr != NULL)
29-
DECREF(xp->x_attr);
42+
XDECREF(xp->x_attr);
3043
DEL(xp);
3144
}
3245

@@ -70,7 +83,7 @@ xx_setattr(xp, name, v)
7083
if (xp->x_attr == NULL) {
7184
xp->x_attr = newdictobject();
7285
if (xp->x_attr == NULL)
73-
return errno;
86+
return -1;
7487
}
7588
if (v == NULL)
7689
return dictremove(xp->x_attr, name);

0 commit comments

Comments
 (0)