Skip to content

Commit

Permalink
Change type.js to have a richcompare for type comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
blacatena committed Mar 5, 2013
1 parent f6e3a77 commit 8847a8e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Sk.builtin.type.makeIntoTypeObj = function(name, t)
t.tp$str = undefined;
t.tp$getattr = Sk.builtin.type.prototype.tp$getattr;
t.tp$setattr = Sk.builtin.object.prototype.GenericSetAttr;
t.tp$richcompare = Sk.builtin.type.prototype.tp$richcompare;
return t;
};

Expand Down Expand Up @@ -348,3 +349,16 @@ Sk.builtin.type.buildMRO = function(klass)
return new Sk.builtin.tuple(Sk.builtin.type.buildMRO_(klass));
};

Sk.builtin.type.prototype.tp$richcompare = function(other, op)
{
if (other.ob$type != Sk.builtin.type)
return undefined;

if (!this['$r'] || !other['$r'])
return undefined;

var r1 = this.$r();
var r2 = other.$r();

return r1.tp$richcompare(r2, op);
};

0 comments on commit 8847a8e

Please sign in to comment.