GNOME Bugzilla – Bug 664437
Improvements to the class framework
Last modified: 2011-11-21 14:57:23 UTC
Various things I found when using Lang.Class in gnome-shell.
Created attachment 201756 [details] [review] Class: improve prototype property descriptors Use ES5 reflection methods to obtain and manipulate property descriptors, instead of copying the property values with for-in. This allows for non-enumerable properties, prevents Object.prototype properties from being iterated, allows setting .configurable, and most important allows accessor properties with the usual syntax.
Created attachment 201757 [details] [review] Class: introduce abstract classes By setting Abstract: true in the class parameters, you can now obtain a class that will throw upon instantiation. The class can still have an _init (that derived class can call) and otherwise works like all other classes.
Created attachment 201758 [details] [review] Class: fix for reentrant calls Uponing entering a method from another on the same object, the function wrapper must save the previous value of __caller__, or susbsequents calls to parent() would fail.
Use four spaces for indentation, not tabs.
Created attachment 201768 [details] [review] Class: improve prototype property descriptors Use ES5 reflection methods to obtain and manipulate property descriptors, instead of copying the property values with for-in. This allows for non-enumerable properties, prevents Object.prototype properties from being iterated, allows setting .configurable, and most important allows accessor properties with the usual syntax.
Created attachment 201769 [details] [review] Class: introduce abstract classes By setting Abstract: true in the class parameters, you can now obtain a class that will throw upon instantiation. The class can still have an _init (that derived class can call) and otherwise works like all other classes.
Created attachment 201770 [details] [review] Class: fix for reentrant calls Uponing entering a method from another on the same object, the function wrapper must save the previous value of __caller__, or susbsequents calls to parent() would fail.
Review of attachment 201768 [details] [review]: LGTM.
Review of attachment 201769 [details] [review]: Can you make sure that a subclass with no _init will still work?
Review of attachment 201770 [details] [review]: ::: modules/lang.js @@ +163,2 @@ function wrapper() { + let prevCaller = this.__caller__ || null; I'd prefer to explicitly set __caller__ to null, rather than having it undefined sometimes and null others.
Comment on attachment 201768 [details] [review] Class: improve prototype property descriptors Attachment 201768 [details] pushed as 9ec2adb - Class: improve prototype property descriptors
Created attachment 201801 [details] [review] Class: introduce abstract classes By setting Abstract: true in the class parameters, you can now obtain a class that will throw upon instantiation. The class can still have an _init (that derived class can call) and otherwise works like all other classes.
Created attachment 201802 [details] [review] Class: fix for reentrant calls Uponing entering a method from another on the same object, the function wrapper must save the previous value of __caller__, or susbsequents calls to parent() would fail.
Review of attachment 201801 [details] [review]: Yep.
Review of attachment 201802 [details] [review]: ::: modules/lang.js @@ +137,3 @@ } +_Base.prototype._init = function() { } Missing semi.
Attachment 201801 [details] pushed as 95947ea - Class: introduce abstract classes Attachment 201802 [details] pushed as 378e7b9 - Class: fix for reentrant calls