v2.0-beta.1 Buffer object
v2.0-beta.1 Buffer object
Thanks for releasing the v2 beta, I didn't expect to live to see it.
I started to work with Buffer objects. Once I did it, I'm missing a built-in method to reinitialize an object, e.g. Buffer.Init(0). Any chance to get it?
I started to work with Buffer objects. Once I did it, I'm missing a built-in method to reinitialize an object, e.g. Buffer.Init(0). Any chance to get it?
Re: v2.0-beta.1 Buffer object
Code: Select all
#Requires AutoHotkey v2.0-beta.1
Buffer.Prototype.DefineProp('Init', {Call: (this, FillByte := 0) => DllCall('ntdll\RtlFillMemory', 'Ptr', this, 'Ptr', this.Size, 'Int', FillByte)})
Re: v2.0-beta.1 Buffer object
@swagfag, I'd prefer a built-in method and if not available
which does not touch the prototype.
Code: Select all
Class ReusableBuffer Extends Buffer {
Clear(FillByte := 0) => DllCall('Ntdll.dll\RtlFillMemory', 'Ptr', This, 'Ptr', This.Size, 'Int', FillByte)
}
Re: v2.0-beta.1 Buffer object
You can just call __New.
https://lexikos.github.io/v2/docs/objects/Buffer.htm#__New
https://lexikos.github.io/v2/docs/objects/Buffer.htm#__New
Re: v2.0-beta.1 Buffer object
u can. if u dont care about .Ptr possibly (likely) changing
Re: v2.0-beta.1 Buffer object
If you specify only the second parameter, __New will just call memset, and the value of Ptr cannot change.
Re: v2.0-beta.1 Buffer object
This method exists to support Call, and is not intended to be called directly.
Re: v2.0-beta.1 Buffer object
ah, nifty. but that ought to be documented then. otherwise its unexpected that specifying a bytecount the same as the old one would result in a realloc, whereas not specifying it wouldnt