Re: libseed-list trying to read a gio stream



Ah, I just found the get_contents() and simple_read() extensions. But I would like to understand this (in Gio.simple_read):

  var fstream = file.read();
  var dstream = new Gio.DataInputStream.c_new(fstream); //<-- here
  var line = dstream.read_until("", 0);

why the need for creating a DataInputStream from the FileInputStream, and what about the use of both new operator and c_new() method?

Thanks for the pointer on taking a look in the tests tree, will do that!

BTW, are extension .js modules automatically merged when importing a C or gi module? If I have a seed module in an .so and a .js with the same name, will both be loaded by imports.<name>?

/Jonatan

Tim Horton wrote:
There are numerous examples in the seed-examples git repo that do the following:

file = Gio.file_new_for_path(filename);
content = file.read().get_contents();

I think get_contents() is a seed extension, but I don't remember. There's also Gio.simple_read (another seed extension):

http://git.gnome.org/cgit/seed/tree/extensions/Gio.js

Also, out arguments work like so:

http://git.gnome.org/cgit/seed/tree/tests/javascript/out-test.js

(there's a lot of good stuff/demonstrations of stuff that hasn't been documented yet in the tests tree)

On Nov 24, 2009, at 22:37, Jonatan Liljedahl wrote:

Here I come with more problems... Sorry. :)

I'm trying to read a file with Gio:

gio = imports.gi.Gio
[object Object]

f = gio.file_new_for_path("helloworld.js")
[object GLocalFile]
x = f.read()
[object GLocalFileInputStream]
x.read()
(seed:2637): GLib-GIO-CRITICAL **: g_input_stream_read: assertion `buffer != NULL' failed
0
buf = {}
[object Object]
x.read(buf)
(seed:2637): GLib-GIO-CRITICAL **: g_input_stream_read: assertion `buffer != NULL' failed
0
buf = []
x.read(buf)
(seed:2637): GLib-GIO-CRITICAL **: g_input_stream_read: assertion `buffer != NULL' failed
0
How does functions that take an output parameter map to javascript in seed? I thought they would return the output, or an object with a property for each output if there are several?

/Jonatan
_______________________________________________
libseed-list mailing list
libseed-list gnome org
http://mail.gnome.org/mailman/listinfo/libseed-list




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