Re: Void type?



void* type in theory is a array of bytes, seed is not supposed to be able to read this, I think I put some hacky code in seed to make an effort at converting this to a byte array (into a string)

The big issue you will have with bytestreams like this, is that Javascript normally does not have any 'clean' way to handle non 'utf8' strings, so representing the return value as a string is a bit risky here.

Technically we should return an array of numbers (each number representing 1 char)..  but that is rather messy...

you might have some luck with read_line() if the return data is readable text. Otherwise you will have to look at the bindings and introspection data to see if you can solve that problem.

Regards
Alan  

 --- On 09/May/2011, Nicolas wrote: 
> Hi,
> 
> i'am trying with gjs or seed to read data from a socket. But i'am stuck with the
> read method from Gio.DataInputSteam. The read method need as first argument a
> pointer (http://www.roojs.org/seed/gir-1.1-gtk-2.0/Gio.DataInputStream.html) but
> how can i do this with javascript? 
> 
> Here is my code : 
> 
> const GLib = imports.gi.GLib;
> const Gio = imports.gi.Gio;
> var client = new Gio.SocketClient()
> var adress = new Gio.NetworkAddress({'hostname': '127.0.0.1', 'port':26});
> var conn = client.connect(adress, null);
> var response = new Gio.DataInputStream({base_stream: conn.get_input_stream()});
> var b = String('');
> var readByte = response.read(b, 256, null)
> print(b);
> 
> This code fail in gjs telling me that b is null. It execute fine in seed, but
> print(b) doesn't output anything.
> 
> Thanks.
> 
> _______________________________________________
> javascript-list mailing list
> javascript-list gnome org
> http://mail.gnome.org/mailman/listinfo/javascript-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]