Skip to content

Commit

Permalink
Merge pull request #69 from jphickey/fix-68-binaryencoding
Browse files Browse the repository at this point in the history
Fix #68, honor BinaryDataEncoding
  • Loading branch information
jphickey authored Dec 14, 2023
2 parents 7d58f5b + 502dd88 commit e913f93
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tool/scripts/20-seds_resolve_sizes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ local function get_integer_size(encnode,rangenode)

if (encnode) then
sizebits = encnode.sizeinbits
signed = (encnode.encoding ~= "unsigned")
signed = (encnode.entity_type == "INTEGER_DATA_ENCODING" and encnode.encoding ~= "unsigned")
actualencoding = encnode.encoding
end

Expand All @@ -195,8 +195,7 @@ local function get_integer_size(encnode,rangenode)

sizecalc:flavor(signed)
if (encnode) then
if ((signed and encnode.encoding == "twoscomplement") or
(not signed and encnode.encoding == "unsigned")) then
if (not signed or encnode.encoding == "twoscomplement") then
if (encnode.byteorder == "bigendian") then
packstyle = "BE"
elseif (encnode.byteorder == "littleendian") then
Expand Down Expand Up @@ -556,7 +555,21 @@ end
-- Boolean data type size resolver
-- -------------------------------------------------------------------------
local function resolve_boolean_datatype_size(node)
node.resolved_size = SEDS.new_size_object(1) -- tbd if anything >1 bit is ever possible for boolean?

local encnode = node:find_first("BOOLEAN_DATA_ENCODING")
local sizecalc

if (encnode) then
sizecalc = get_integer_size(encnode)
else
sizecalc = SEDS.new_size_object(1) -- tbd if anything >1 bit is ever possible for boolean?
end

if (not sizecalc) then
return false
end

node.resolved_size = sizecalc
return true
end

Expand Down

0 comments on commit e913f93

Please sign in to comment.