diff options
| author | Opportunity <[email protected]> | 2020-01-17 11:55:43 +0800 |
|---|---|---|
| committer | Opportunity <[email protected]> | 2020-01-17 11:55:43 +0800 |
| commit | 1e36d6b2290a8ad67c34b5a549dcbf87f99d31f1 (patch) | |
| tree | df37a6526c271e2ec1189f2ddef6c3757f2feef2 /xmake/core/base/bytes.lua | |
| parent | 19fef8183e250a49628a4281264753a7da1338dc (diff) | |
improve dump
Diffstat (limited to 'xmake/core/base/bytes.lua')
| -rw-r--r-- | xmake/core/base/bytes.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 894f701d4..bdf9b80d6 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -23,10 +23,11 @@ local bytes = bytes or {} local _instance = _instance or {} -- load modules -local bit = require('bit') -local ffi = require('ffi') -local os = require("base/os") -local utils = require("base/utils") +local bit = require('bit') +local ffi = require('ffi') +local os = require("base/os") +local utils = require("base/utils") +local todisplay = require("base/todisplay") -- define ffi interfaces ffi.cdef[[ @@ -409,8 +410,8 @@ function _instance:__concat(other) return new end --- tostring(bytes) -function _instance:__tostring() +-- todisplay(bytes) +function _instance:__todisplay() local parts = {} local size = self:size() if size > 8 then @@ -419,7 +420,7 @@ function _instance:__tostring() for i = 1, size do parts[i] = "0x" .. bit.tohex(self[i], 2) end - return "<bytes(" .. self:size() .. "): " .. table.concat(parts, " ") .. (self:size() > 8 and "..>" or ">") + return "bytes${reset}(" .. todisplay(self:size()) .. ") <${color.dump.number}" .. table.concat(parts, " ") .. (self:size() > 8 and "${reset} ..>" or "${reset}>") end -- new an bytes instance |
