diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2003-05-21 23:58:31 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2003-05-21 23:58:31 +0400 |
commit | 89e9090c861839e7f4289c13f26ab12d4b503610 (patch) | |
tree | d9127dc65337136f6f2fc39da0ad44dc046e99dc | |
parent | 000f92e204b54d117789209b00fee88f279be6e1 (diff) |
Implemented the compare callback for Camera, Image, Lamp and Text types:
Following a suggestion made by Jordi Rovira i Bonet, the comparison
now is made via the pointers to the Blender objects, not their py wrappers.
-rw-r--r-- | source/blender/python/api2_2x/Camera.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Camera.h | 3 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.h | 33 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.c | 20 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Lamp.h | 23 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Text.h | 33 | ||||
-rw-r--r-- | source/blender/python/api2_2x/vector.h | 1 |
9 files changed, 108 insertions, 47 deletions
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index d942d34e256..836b5408d87 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -583,6 +583,20 @@ static int CameraSetAttr (C_Camera *self, char *name, PyObject *value) } /*****************************************************************************/ +/* Function: CameraCompare */ +/* Description: This is a callback function for the C_Camera type. It */ +/* compares two Camera_Type objects. Only the "==" and "!=" */ +/* comparisons are meaninful. Returns 0 for equality and -1 if */ +/* they don't point to the same Blender Camera struct. */ +/* In Python it becomes 1 if they are equal, 0 otherwise. */ +/*****************************************************************************/ +static int CameraCompare (C_Camera *a, C_Camera *b) +{ + Camera *pa = a->camera, *pb = b->camera; + return (pa == pb) ? 0:-1; +} + +/*****************************************************************************/ /* Function: CameraPrint */ /* Description: This is a callback function for the C_Camera type. It */ /* builds a meaninful string to 'print' camera objects. */ diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h index 94a70313b89..419cd9f0f6d 100644 --- a/source/blender/python/api2_2x/Camera.h +++ b/source/blender/python/api2_2x/Camera.h @@ -192,6 +192,7 @@ static void CameraDeAlloc (C_Camera *self); static int CameraPrint (C_Camera *self, FILE *fp, int flags); static int CameraSetAttr (C_Camera *self, char *name, PyObject *v); static PyObject *CameraGetAttr (C_Camera *self, char *name); +static int CameraCompare (C_Camera *a, C_Camera *b); static PyObject *CameraRepr (C_Camera *self); /*****************************************************************************/ @@ -218,7 +219,7 @@ static PyTypeObject Camera_Type = (printfunc)CameraPrint, /* tp_print */ (getattrfunc)CameraGetAttr, /* tp_getattr */ (setattrfunc)CameraSetAttr, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)CameraCompare, /* tp_compare */ (reprfunc)CameraRepr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 9d679672f78..56eec3caebb 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -318,6 +318,20 @@ static int ImageSetAttr (C_Image *self, char *name, PyObject *value) } /*****************************************************************************/ +/* Function: ImageCompare */ +/* Description: This is a callback function for the C_Image type. It */ +/* compares two Image_Type objects. Only the "==" and "!=" */ +/* comparisons are meaninful. Returns 0 for equality and -1 if */ +/* they don't point to the same Blender Image struct. */ +/* In Python it becomes 1 if they are equal, 0 otherwise. */ +/*****************************************************************************/ +static int ImageCompare (C_Image *a, C_Image *b) +{ + Image *pa = a->image, *pb = b->image; + return (pa == pb) ? 0:-1; +} + +/*****************************************************************************/ /* Function: ImagePrint */ /* Description: This is a callback function for the C_Image type. It */ /* builds a meaninful string to 'print' image objects. */ diff --git a/source/blender/python/api2_2x/Image.h b/source/blender/python/api2_2x/Image.h index ccda946055f..23a8220d83f 100644 --- a/source/blender/python/api2_2x/Image.h +++ b/source/blender/python/api2_2x/Image.h @@ -130,11 +130,12 @@ static PyMethodDef C_Image_methods[] = { /*****************************************************************************/ /* Python Image_Type callback function prototypes: */ /*****************************************************************************/ -static void ImageDeAlloc (C_Image *cam); -static int ImagePrint (C_Image *cam, FILE *fp, int flags); -static int ImageSetAttr (C_Image *cam, char *name, PyObject *v); -static PyObject *ImageGetAttr (C_Image *cam, char *name); -static PyObject *ImageRepr (C_Image *cam); +static void ImageDeAlloc (C_Image *self); +static int ImagePrint (C_Image *self, FILE *fp, int flags); +static int ImageSetAttr (C_Image *self, char *name, PyObject *v); +static PyObject *ImageGetAttr (C_Image *self, char *name); +static int ImageCompare (C_Image *a, C_Image *b); +static PyObject *ImageRepr (C_Image *self); /*****************************************************************************/ /* Python Image_Type structure definition: */ @@ -142,26 +143,26 @@ static PyObject *ImageRepr (C_Image *cam); static PyTypeObject Image_Type = { PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ + 0, /* ob_size */ "Image", /* tp_name */ - sizeof (C_Image), /* tp_basicsize */ - 0, /* tp_itemsize */ + sizeof (C_Image), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)ImageDeAlloc, /* tp_dealloc */ (printfunc)ImagePrint, /* tp_print */ (getattrfunc)ImageGetAttr, /* tp_getattr */ (setattrfunc)ImageSetAttr, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)ImageCompare, /* tp_compare */ (reprfunc)ImageRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ 0,0,0,0,0,0, - 0, /* tp_doc */ + 0, /* tp_doc */ 0,0,0,0,0,0, - C_Image_methods, /* tp_methods */ - 0, /* tp_members */ + C_Image_methods, /* tp_methods */ + 0, /* tp_members */ }; #endif /* EXPP_IMAGE_H */ diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 111d01266cf..6d5da492fe4 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -172,9 +172,9 @@ PyObject *M_Lamp_Init (void) /* Three Python Lamp_Type helper functions needed by the Object module: */ /*****************************************************************************/ -/* Function: Lamp_createPyObject */ -/* Description: This function will create a new C_Lamp from an existing */ -/* Blender camera structure. */ +/* Function: Lamp_createPyObject */ +/* Description: This function will create a new C_Lamp from an existing */ +/* Blender lamp structure. */ /*****************************************************************************/ PyObject *Lamp_createPyObject (Lamp *lamp) { @@ -936,6 +936,20 @@ static int LampSetAttr (C_Lamp *self, char *name, PyObject *value) } /*****************************************************************************/ +/* Function: LampCompare */ +/* Description: This is a callback function for the C_Lamp type. It */ +/* compares two Lamp_Type objects. Only the "==" and "!=" */ +/* comparisons are meaninful. Returns 0 for equality and -1 if */ +/* they don't point to the same Blender Lamp struct. */ +/* In Python it becomes 1 if they are equal, 0 otherwise. */ +/*****************************************************************************/ +static int LampCompare (C_Lamp *a, C_Lamp *b) +{ + Lamp *pa = a->lamp, *pb = b->lamp; + return (pa == pb) ? 0:-1; +} + +/*****************************************************************************/ /* Function: LampPrint */ /* Description: This is a callback function for the C_Lamp type. It */ /* builds a meaninful string to 'print' lamp objects. */ diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h index e225c66258b..456d2587061 100644 --- a/source/blender/python/api2_2x/Lamp.h +++ b/source/blender/python/api2_2x/Lamp.h @@ -290,6 +290,7 @@ static PyMethodDef C_Lamp_methods[] = { static void LampDeAlloc (C_Lamp *lamp); static PyObject *LampGetAttr (C_Lamp *lamp, char *name); static int LampSetAttr (C_Lamp *lamp, char *name, PyObject *v); +static int LampCompare (C_Lamp *a, C_Lamp *b); static PyObject *LampRepr (C_Lamp *lamp); static int LampPrint (C_Lamp *lamp, FILE *fp, int flags); @@ -308,26 +309,26 @@ int LampCheckPyObject (PyObject *pyobj); static PyTypeObject Lamp_Type = { PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ + 0, /* ob_size */ "Lamp", /* tp_name */ - sizeof (C_Lamp), /* tp_basicsize */ - 0, /* tp_itemsize */ + sizeof (C_Lamp), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)LampDeAlloc, /* tp_dealloc */ (printfunc)LampPrint, /* tp_print */ (getattrfunc)LampGetAttr, /* tp_getattr */ (setattrfunc)LampSetAttr, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)LampCompare, /* tp_compare */ (reprfunc)LampRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ 0,0,0,0,0,0, - 0, /* tp_doc */ + 0, /* tp_doc */ 0,0,0,0,0,0, - C_Lamp_methods, /* tp_methods */ - 0, /* tp_members */ + C_Lamp_methods, /* tp_methods */ + 0, /* tp_members */ }; #endif /* EXPP_LAMP_H */ diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c index a447a4ff6ce..49f871cdef0 100644 --- a/source/blender/python/api2_2x/Text.c +++ b/source/blender/python/api2_2x/Text.c @@ -443,6 +443,20 @@ static int TextSetAttr (C_Text *self, char *name, PyObject *value) } /*****************************************************************************/ +/* Function: TextCompare */ +/* Description: This is a callback function for the C_Text type. It */ +/* compares two Text_Type objects. Only the "==" and "!=" */ +/* comparisons are meaninful. Returns 0 for equality and -1 if */ +/* they don't point to the same Blender Text struct. */ +/* In Python it becomes 1 if they are equal, 0 otherwise. */ +/*****************************************************************************/ +static int TextCompare (C_Text *a, C_Text *b) +{ + Text *pa = a->text, *pb = b->text; + return (pa == pb) ? 0:-1; +} + +/*****************************************************************************/ /* Function: TextPrint */ /* Description: This is a callback function for the C_Text type. It */ /* builds a meaninful string to 'print' text objects. */ diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h index 3e704ef663b..723d77a7cb7 100644 --- a/source/blender/python/api2_2x/Text.h +++ b/source/blender/python/api2_2x/Text.h @@ -142,11 +142,12 @@ static PyMethodDef C_Text_methods[] = { /*****************************************************************************/ /* Python Text_Type callback function prototypes: */ /*****************************************************************************/ -static void TextDeAlloc (C_Text *cam); -static int TextPrint (C_Text *cam, FILE *fp, int flags); -static int TextSetAttr (C_Text *cam, char *name, PyObject *v); -static PyObject *TextGetAttr (C_Text *cam, char *name); -static PyObject *TextRepr (C_Text *cam); +static void TextDeAlloc (C_Text *self); +static int TextPrint (C_Text *self, FILE *fp, int flags); +static int TextSetAttr (C_Text *self, char *name, PyObject *v); +static PyObject *TextGetAttr (C_Text *self, char *name); +static int TextCompare (C_Text *a, C_Text *b); +static PyObject *TextRepr (C_Text *self); /*****************************************************************************/ /* Python Text_Type structure definition: */ @@ -154,26 +155,26 @@ static PyObject *TextRepr (C_Text *cam); static PyTypeObject Text_Type = { PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ + 0, /* ob_size */ "Text", /* tp_name */ - sizeof (C_Text), /* tp_basicsize */ - 0, /* tp_itemsize */ + sizeof (C_Text), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)TextDeAlloc, /* tp_dealloc */ (printfunc)TextPrint, /* tp_print */ (getattrfunc)TextGetAttr, /* tp_getattr */ (setattrfunc)TextSetAttr, /* tp_setattr */ - 0, /* tp_compare */ + (cmpfunc)TextCompare, /* tp_compare */ (reprfunc)TextRepr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_as_hash */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ 0,0,0,0,0,0, - 0, /* tp_doc */ + 0, /* tp_doc */ 0,0,0,0,0,0, - C_Text_methods, /* tp_methods */ - 0, /* tp_members */ + C_Text_methods, /* tp_methods */ + 0, /* tp_members */ }; #endif /* EXPP_TEXT_H */ diff --git a/source/blender/python/api2_2x/vector.h b/source/blender/python/api2_2x/vector.h index e8f9b97b988..24e35505359 100644 --- a/source/blender/python/api2_2x/vector.h +++ b/source/blender/python/api2_2x/vector.h @@ -33,6 +33,7 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** * */ + #ifndef EXPP_vector_h #define EXPP_vector_h |