After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 664437 - Improvements to the class framework
Improvements to the class framework
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks: 664436
 
 
Reported: 2011-11-20 20:09 UTC by Giovanni Campagna
Modified: 2011-11-21 14:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Class: improve prototype property descriptors (3.36 KB, patch)
2011-11-20 20:10 UTC, Giovanni Campagna
none Details | Review
Class: introduce abstract classes (2.75 KB, patch)
2011-11-20 20:10 UTC, Giovanni Campagna
none Details | Review
Class: fix for reentrant calls (2.00 KB, patch)
2011-11-20 20:10 UTC, Giovanni Campagna
none Details | Review
Class: improve prototype property descriptors (3.81 KB, patch)
2011-11-20 20:53 UTC, Giovanni Campagna
committed Details | Review
Class: introduce abstract classes (2.86 KB, patch)
2011-11-20 20:53 UTC, Giovanni Campagna
reviewed Details | Review
Class: fix for reentrant calls (2.03 KB, patch)
2011-11-20 20:53 UTC, Giovanni Campagna
reviewed Details | Review
Class: introduce abstract classes (3.10 KB, patch)
2011-11-21 13:01 UTC, Giovanni Campagna
committed Details | Review
Class: fix for reentrant calls (2.56 KB, patch)
2011-11-21 13:01 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2011-11-20 20:09:33 UTC
Various things I found when using Lang.Class in gnome-shell.
Comment 1 Giovanni Campagna 2011-11-20 20:10:08 UTC
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.
Comment 2 Giovanni Campagna 2011-11-20 20:10:16 UTC
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.
Comment 3 Giovanni Campagna 2011-11-20 20:10:31 UTC
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.
Comment 4 Jasper St. Pierre (not reading bugmail) 2011-11-20 20:40:50 UTC
Use four spaces for indentation, not tabs.
Comment 5 Giovanni Campagna 2011-11-20 20:53:22 UTC
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.
Comment 6 Giovanni Campagna 2011-11-20 20:53:37 UTC
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.
Comment 7 Giovanni Campagna 2011-11-20 20:53:47 UTC
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.
Comment 8 Jasper St. Pierre (not reading bugmail) 2011-11-21 00:50:17 UTC
Review of attachment 201768 [details] [review]:

LGTM.
Comment 9 Jasper St. Pierre (not reading bugmail) 2011-11-21 00:51:33 UTC
Review of attachment 201769 [details] [review]:

Can you make sure that a subclass with no _init will still work?
Comment 10 Jasper St. Pierre (not reading bugmail) 2011-11-21 00:55:26 UTC
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 11 Giovanni Campagna 2011-11-21 13:01:28 UTC
Comment on attachment 201768 [details] [review]
Class: improve prototype property descriptors

Attachment 201768 [details] pushed as 9ec2adb - Class: improve prototype property descriptors
Comment 12 Giovanni Campagna 2011-11-21 13:01:49 UTC
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.
Comment 13 Giovanni Campagna 2011-11-21 13:01:59 UTC
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.
Comment 14 Jasper St. Pierre (not reading bugmail) 2011-11-21 13:32:59 UTC
Review of attachment 201801 [details] [review]:

Yep.
Comment 15 Jasper St. Pierre (not reading bugmail) 2011-11-21 13:35:45 UTC
Review of attachment 201802 [details] [review]:

::: modules/lang.js
@@ +137,3 @@
 }
 
+_Base.prototype._init = function() { }

Missing semi.
Comment 16 Giovanni Campagna 2011-11-21 14:57:16 UTC
Attachment 201801 [details] pushed as 95947ea - Class: introduce abstract classes
Attachment 201802 [details] pushed as 378e7b9 - Class: fix for reentrant calls