简体   繁体   中英

How are “out parameters” represented for Seed JavaScript GObject bindings?

I've just started using Seed for development. One thing that Seed's web page mentions is that it "Maps C-isms (say, out arguments , or enums) to things that make sense in JavaScript." Unfortunately, I can't find any documentation or examples for how out arguments should work. So, for example, the following call in Seed:

window.get_size()

Will return the error "GInvokeError Too few "out" arguments (handling out)"

In C, the call would be expressed by passing in two out arguments:

gtk_window_get_size(GTK_WINDOW(widget), &width, &height);

I've tried various permutations on the JavaScript call without success. I've also looked at the documentation and sample code, but haven't found anything. Short of looking at the code, I think I'm running out of options.

I'd appreciate any insight anyone can offer into this.

var o1 = {};
var o2 = {};
window.get_size(o1, o2);

var width = o1.value;
var height = o2.value;

There's an example in http://git.gnome.org/browse/seed/tree/tests/javascript/out-test.js (when lacking documentation it's sometimes useful to look at the tests.)

Try to call this function indirectly. From this some sort of a shell function you could then pass out params to the gtk_window_get_size method and then you can work with the retrieved results. For example return it to the calling js function which in this case wants to resolve the size of the window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM