vala-lang / valadoc-org

Build tools used to generate valadoc.org
https://valadoc.org
GNU Lesser General Public License v2.1
84 stars 25 forks source link

Fix documentation of FileStream.read/write() #380

Closed ricotz closed 1 year ago

ricotz commented 1 year ago

See https://gitlab.gnome.org/GNOME/vala/-/issues/1410

AlynxZhou commented 1 year ago

This is still open. Could this be merged soon?

benwaffle commented 1 year ago

fwrite and fread take 4 arguments - https://linux.die.net/man/3/fwrite

are we sure the vala binding is right?

AlynxZhou commented 1 year ago

fwrite and fread take 4 arguments - https://linux.die.net/man/3/fwrite

are we sure the vala binding is right?

The binding itself is correct, the object (FileStream) is the last FILE pointer, nmemb is calculated by vala's compiler, and the size is provided by the default argument, and the buf is the ptr.

Actually the size in the API is useless, vala always casts the array into uint8 array, so it should always be 1.

If you are still not sure, check https://gitlab.gnome.org/GNOME/vala/-/issues/1410. You may also try compile the code and debug it, you'll find if you pass array length as current doc, you'll write length * length bytes instead of length * size bytes.