File tree 1 file changed +33
-1
lines changed
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -969,6 +969,38 @@ tgl_Peer_repr(tgl_Peer *self)
969
969
return ret ;
970
970
}
971
971
972
+ PyObject *
973
+ tgl_Peer_RichCompare (PyObject * self , PyObject * other , int cmp )
974
+ {
975
+ PyObject * result = NULL ;
976
+
977
+ if (!PyObject_TypeCheck (other , & tgl_PeerType )) {
978
+ result = Py_False ;
979
+ } else {
980
+ if (((tgl_Peer * )self )-> peer == NULL ||
981
+ ((tgl_Peer * )other )-> peer == NULL ) {
982
+ result = Py_False ; // If either object is not properly instantiated, compare is false
983
+ } else {
984
+ switch (cmp ) {
985
+ case Py_EQ :
986
+ result = ((tgl_Peer * )self )-> peer -> id .id == ((tgl_Peer * )other )-> peer -> id .id ? Py_True : Py_False ;
987
+ break ;
988
+ case Py_NE :
989
+ result = ((tgl_Peer * )self )-> peer -> id .id == ((tgl_Peer * )other )-> peer -> id .id ? Py_False : Py_True ;
990
+ break ;
991
+ case Py_LE :
992
+ case Py_GE :
993
+ case Py_GT :
994
+ case Py_LT :
995
+ default :
996
+ Py_RETURN_NOTIMPLEMENTED ;
997
+ }
998
+ }
999
+ }
1000
+ Py_XINCREF (result );
1001
+ return result ;
1002
+ }
1003
+
972
1004
973
1005
PyTypeObject tgl_PeerType = {
974
1006
PyVarObject_HEAD_INIT (NULL , 0 )
@@ -994,7 +1026,7 @@ PyTypeObject tgl_PeerType = {
994
1026
"tgl Peer" , /* tp_doc */
995
1027
0 , /* tp_traverse */
996
1028
0 , /* tp_clear */
997
- 0 , /* tp_richcompare */
1029
+ ( richcmpfunc ) tgl_Peer_RichCompare , /* tp_richcompare */
998
1030
0 , /* tp_weaklistoffset */
999
1031
0 , /* tp_iter */
1000
1032
0 , /* tp_iternext */
You can’t perform that action at this time.
0 commit comments