Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into runestone
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmnetp committed Sep 29, 2012
2 parents 9c71318 + 00fd66c commit 60f968a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,29 @@ goog.exportSymbol("Sk.abstr.objectSetItem", Sk.abstr.objectSetItem);

Sk.abstr.gattr = function(obj, nameJS)
{
var ret = obj.tp$getattr(nameJS);
var ret;
if(obj['__getattr__']) {
ret = Sk.misceval.callsim(obj['__getattr__'],obj,nameJS)
} else {
ret = obj.tp$getattr(nameJS);
}
if (ret === undefined)
throw new Sk.builtin.AttributeError("'" + obj.tp$name + "' object has no attribute '" + nameJS + "'");
return ret;

};
goog.exportSymbol("Sk.abstr.gattr", Sk.abstr.gattr);

Sk.abstr.sattr = function(obj, nameJS, data)
{
obj.tp$setattr(nameJS, data);
if(obj['__setattr__']) {
print('trying to set ' + nameJS + ' to ' + data);
ret = Sk.misceval.callsim(obj['__setattr__'],obj, nameJS, data)
} else {
obj.tp$setattr(nameJS, data);
}
};

goog.exportSymbol("Sk.abstr.sattr", Sk.abstr.sattr);

Sk.abstr.iter = function(obj)
Expand Down
2 changes: 1 addition & 1 deletion src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Sk.builtin.object.prototype.GenericGetAttr = function(name)
var res;
if (this['$d'].mp$subscript)
res = this['$d'].mp$subscript(new Sk.builtin.str(name));
else if (typeof this['$d'] === "object") // todo; definitely the wrong place for this. other custom tp$getattr won't work on object
else if (typeof this['$d'] === "object") // todo; definitely the wrong place for this. other custom tp$getattr won't work on object -- bnm -- implemented custom __getattr__ in abstract.js
res = this['$d'][name];
if (res !== undefined)
return res;
Expand Down

0 comments on commit 60f968a

Please sign in to comment.