diff options
| author | ruki <[email protected]> | 2021-09-21 00:36:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-21 00:36:08 +0800 |
| commit | 930124472561d7c4e84ee7fd2b1bee8ac1b64ba2 (patch) | |
| tree | 7e9cc6efb02600b5368ac7a3620d29316d3369ba /xmake/core | |
| parent | de47ad0121ca4155777005976b05debeda67aca6 (diff) | |
add setbyte
Diffstat (limited to 'xmake/core')
| -rw-r--r-- | xmake/core/base/bytes.lua | 2 | ||||
| -rw-r--r-- | xmake/core/base/libc.lua | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 0486f0178..300d2a073 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -411,7 +411,7 @@ function _instance:__newindex(key, value) if key < 1 or key > self:size() then os.raise("%s: index(%d/%d) out of bounds!", self, key, self:size()) end - self._CDATA[key - 1] = value + libc.setbyte(self._CDATA, key - 1, value) return elseif type(key) == "table" then local start, last = key[1], key[2] diff --git a/xmake/core/base/libc.lua b/xmake/core/base/libc.lua index d3f02d7f5..6e69dd203 100644 --- a/xmake/core/base/libc.lua +++ b/xmake/core/base/libc.lua @@ -31,6 +31,7 @@ libc._dataptr = libc._dataptr or libc.dataptr libc._ptraddr = libc._ptraddr or libc.ptraddr libc._diffptr = libc._diffptr or libc.diffptr libc._byteof = libc._byteof or libc.byteof +libc._setbyte = libc._setbyte or libc.setbyte -- load modules local ffi = xmake._LUAJIT and require("ffi") @@ -103,6 +104,14 @@ function libc.byteof(data, offset) end end +function libc.setbyte(data, offset, value) + if ffi then + data[offset] = value + else + return libc._setbyte(data, offset, value) + end +end + function libc.diffptr(data, offset) if ffi then return data + offset |
