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 561573 - Add non-default constructors and upcoming static methods to "class"
Add non-default constructors and upcoming static methods to "class"
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2008-11-19 19:05 UTC by Colin Walters
Modified: 2008-11-19 21:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add non-default constructors and upcoming static methods to "class" (4.83 KB, patch)
2008-11-19 19:05 UTC, Colin Walters
none Details | Review
Add non-default constructors and upcoming static methods to "class" (4.68 KB, patch)
2008-11-19 19:43 UTC, Colin Walters
none Details | Review
Add non-default constructors and upcoming static methods to "class" (4.77 KB, patch)
2008-11-19 21:48 UTC, Colin Walters
accepted-commit_now Details | Review

Description Colin Walters 2008-11-19 19:05:38 UTC
We want to support things like Clutter.Texture.new_from_file.  This
change attaches them to the JavaScript constructor (which vaguely
corresponds to the concept of a class in a sensible language).

Implementation suggested by hp.
Comment 1 Colin Walters 2008-11-19 19:05:41 UTC
Created attachment 123061 [details] [review]
Add non-default constructors and upcoming static methods to "class"
Comment 2 Colin Walters 2008-11-19 19:43:30 UTC
Created attachment 123063 [details] [review]
Add non-default constructors and upcoming static methods to "class"

We want to support things like Clutter.Texture.new_from_file.  This
change attaches them to the JavaScript constructor (which vaguely
corresponds to the concept of a class in a sensible language).

Implementation suggested by hp.
Comment 3 Havoc Pennington 2008-11-19 20:59:05 UTC
Comment on attachment 123063 [details] [review]
Add non-default constructors and upcoming static methods to "class"

I think gjs_debug() is trying to print the constructor before it's gotten. The first "get" of constructor is just trying to avoid registering the class a second time, so we return after that one.

+    if (constructor == NULL) {

constructor can therefore never be null here unless we threw an exception, I think.
Comment 4 Johan Bilien 2008-11-19 21:27:10 UTC
static JSBool
gjs_define_static_methods(JSContext    *context,
                          JSObject     *constructor_p,
                          GIObjectInfo *object_info)

constructor is not an out argument here I think, so maybe not _p (as opposed to gjs_define_object_class)


obj_name = g_base_info_get_name ((GIBaseInfo*)object_info);
(and a few others):
no space before the parenthesis
Comment 5 Colin Walters 2008-11-19 21:48:47 UTC
Created attachment 123074 [details] [review]
Add non-default constructors and upcoming static methods to "class"

We want to support things like Clutter.Texture.new_from_file.  This
change attaches them to the JavaScript constructor (which vaguely
corresponds to the concept of a class in a sensible language).

Implementation suggested by hp.
Comment 6 Colin Walters 2008-11-19 21:49:32 UTC
Updated for review comments.
Comment 7 Colin Walters 2008-11-19 21:57:12 UTC
Thanks for the review!