Create Birb.StringStream

Review Request #3840 — Created Feb. 16, 2025 and updated

Information

birb/birb
default

Reviewers

This is a simple Gio.InputStream that is backed by a GLib.String.

Ran the tests under valgrind and called in the turtles.

Summary ID
Create Birb.StringStream
This is a simple Gio.InputStream that is backed by a GLib.String.
5ebcf43193cb4bec8ab2bf79ecf8cd5a8bd1f3f3
Description From Last Updated

From the API as it is tested, I'm not really sure I see the difference here with GMemoryInputStream?

QuLogicQuLogic

A 0 return here (without input count of 0) should indicate EOF. That would imply the stream could not get …

QuLogicQuLogic
grim
  1. 
      
  2. I'm not sure I have the read function implemented correctly. It works but https://docs.gtk.org/gio/method.InputStream.read.html says that 0 should only be returned if count is 0 or on EOF and we're not hitting either of those. Maybe we need to return an error with something like EAGAIN but I can't seem to find an error message for that.

    I also skipped implementing/testing closing the stream and skipping bytes, but not sure we actually need those?

  3. 
      
QuLogic
  1. 
      
  2. Show all issues

    From the API as it is tested, I'm not really sure I see the difference here with GMemoryInputStream?

    1. You can't add more data to a GMemoryInputStream, it's initial and then that's it unless something changed with in the past year. Although looking at https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gmemoryinputstream.c?ref_type=heads#L288 that seems like it should be able to keep working. Guess I'll need to do some testing.

    2. Isn't that what g_memory_input_stream_add_data/g_memory_input_stream_add_bytes is for?

    3. Yeah, I'm seeing that now. I think previously I tried to do this with GMemoryOutputStream and that definitely is a one and one thing.

  3. birb/tests/test_string_stream.c (Diff revision 1)
     
     
    Show all issues

    A 0 return here (without input count of 0) should indicate EOF. That would imply the stream could not get any new data after that, though that is happening now.

    Maybe this should be G_IO_ERROR_PENDING, G_IO_ERROR_PARTIAL_INPUT, or G_IO_ERROR_WOULD_BLOCK (and/or possibly with implementing GPollableInputStream for the latter.)

    1. I mentioned in my general comment above that this might be a problem, but I hadn't found G_IO_ERROR_PARTIAL_INPUT at the time, and that does look to be the solution there.

  4.