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 761517 - Implement parameter prediction
Implement parameter prediction
Status: RESOLVED FIXED
Product: seed
Classification: Bindings
Component: libseed
git master
Other Linux
: Normal normal
: ---
Assigned To: seed-maint
seed-maint
Depends on:
Blocks:
 
 
Reported: 2016-02-03 19:23 UTC by Danilo Cesar
Modified: 2016-02-26 02:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: argument prediction draft (11.12 KB, patch)
2016-02-03 19:23 UTC, Danilo Cesar
none Details | Review
new patch (10.85 KB, patch)
2016-02-19 16:35 UTC, Danilo Cesar
none Details | Review
patch v3 (10.69 KB, patch)
2016-02-23 13:53 UTC, Danilo Cesar
none Details | Review

Description Danilo Cesar 2016-02-03 19:23:54 UTC
Created attachment 320389 [details] [review]
WIP: argument prediction draft

A simple example from gjs:

let handler = function(server, msg, path, query, client) {
  msg.response_body.append('<html><body>Greetings, visitor from <br>What is your name?<form action="/hello"><input name="myname"></form></body></html>\n');
  msg.status_code = 200;
  msg.response_headers.set_content_type('text/html', {});
};

let server = new Soup.Server({ port: 1080 });
server.add_handler('/', handler);
server.run();

It uses libsoup to reply to http requests. The response-body-append method requires the buffer itself and the size of its buffer. Seed is able to use this as long as we also give to it the size of the string:
    msg.response_body.append("foobar", 7)

Gjs can get that information from the array itself.

So, this is what I'm proposing here in this draft patch: basically the same approach: get the buffer size from the array itself.

A did run some smoke test on some examples and they didn't broke. But I would like to have a second opinion on it before writing a final version.

(It's already on top of that reformat commit, not a big problem as it's simple and it's still a draft. If that one doesn't make to the tree, fixing this one is easy)
Comment 1 Alan Knowles 2016-02-11 02:14:08 UTC
only comment is that normally the SeedException* is the last argument to most methods that pass it.. - might be worth 'trying' to keep that consistency?

Otherwise looks fine.

Regards
Alan
Comment 2 Danilo Cesar 2016-02-11 13:00:22 UTC
Ok, hold this for a few days. I will come back to it next week.
Comment 3 Danilo Cesar 2016-02-19 16:34:33 UTC
Ok, so I did a few changes here:

Basically the old version of the patch was breaking the old API.

And I also implemented what you mentioned regarding the excpeptions... new patch in a few minutes...
Comment 4 Danilo Cesar 2016-02-19 16:35:02 UTC
Created attachment 321673 [details] [review]
new patch

new patch
Comment 5 Alan Knowles 2016-02-23 05:07:01 UTC
want to apply the same logic to seed_gi_make_array_from_string - exception last arg..
Comment 6 Danilo Cesar 2016-02-23 13:52:55 UTC
(In reply to Alan Knowles from comment #5)
> want to apply the same logic to seed_gi_make_array_from_string - exception
> last arg..

Sorry, I missed that. Thanks for bringing it up.

Sending a new version....
Comment 7 Danilo Cesar 2016-02-23 13:53:16 UTC
Created attachment 321959 [details] [review]
patch v3
Comment 8 Alan Knowles 2016-02-26 02:19:58 UTC
Committed