You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider evaluating calc/try_calc before seek_before, which would enable the following setup:
#[bw(stream = st)]structMain{// need to write textures offset at 0xC...// write other fields// ...but we don't know the offset until we're here.// It would be nice if we could get the texture offset this way:#[bw(try_calc = st.stream_position())]#[br(temp)]#[brw(seek_before = SeekFrom::Start(0xC), restore_position)]textures_offset:u32,// textures written here...textures:Textures,}
Currently, try_calc is evaluated afterseek_before, so the value of st.stream_position() is always 0xC.
I think it would make sense to switch the order of operations here, considering the argument to SeekFrom is either a constant or a field (it wouldn't make sense to use the old stream position, you'd use SeekFrom::Current instead), so it shouldn't break existing use cases.
The text was updated successfully, but these errors were encountered:
This is related to the general problem of writing offsets, #4.
Other than actually fixing #4 so there is a simple blessed way to handle this case, I am not really sure what to do, and I am struggling to think through the ramifications of making a change here. From a logical perspective, the current order of operations is correct: value calculation replaces reading/writing, and reading/writing occurs after seeking in the file, so calculation also occurs after seeking. But then, to do what you are doing here, you have to get silly and use an extra temporary field.
I guess the place where this would break the most obviously is if someone was e.g. using SeekFrom::Current and then wanted to get the offset from there, but I can’t think of a format off the top of my head where it would make sense to do this.
Consider evaluating
calc
/try_calc
beforeseek_before
, which would enable the following setup:Currently,
try_calc
is evaluated afterseek_before
, so the value ofst.stream_position()
is always0xC
.I think it would make sense to switch the order of operations here, considering the argument to
SeekFrom
is either a constant or a field (it wouldn't make sense to use the old stream position, you'd useSeekFrom::Current
instead), so it shouldn't break existing use cases.The text was updated successfully, but these errors were encountered: