Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
fb7d6429
Commit
fb7d6429
authored
Mar 30, 2016
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table.lua: Add support for decoding bitfield types
parent
e6b7c740
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
src/lua/bcc/table.lua
src/lua/bcc/table.lua
+14
-8
No files found.
src/lua/bcc/table.lua
View file @
fb7d6429
...
...
@@ -273,25 +273,31 @@ local function _decode_table_type(desc)
return
t
end
local
fields
=
""
local
fields
=
{}
local
struct
=
t
[
3
]
or
"struct"
for
_
,
value
in
ipairs
(
t
[
2
])
do
local
f
=
nil
if
#
value
==
2
then
f
ields
=
fields
..
string.format
(
"%s %s;
"
,
_dec
(
value
[
2
]),
value
[
1
])
f
=
string.format
(
"%s %s;
"
,
_dec
(
value
[
2
]),
value
[
1
])
elseif
#
value
==
3
then
if
type
(
value
[
3
])
==
"table"
then
fields
=
fields
..
string.format
(
"%s %s[%d]; "
,
_dec
(
value
[
2
]),
value
[
1
],
value
[
3
][
1
])
else
error
(
"not implemented: "
..
json_desc
)
f
=
string.format
(
"%s %s[%d];"
,
_dec
(
value
[
2
]),
value
[
1
],
value
[
3
][
1
])
elseif
type
(
value
[
3
])
==
"number"
then
local
t
=
_dec
(
value
[
2
])
assert
(
t
==
"int"
or
t
==
"unsigned int"
,
"bitfields can only appear in [unsigned] int types"
)
f
=
string.format
(
"%s %s:%d;"
,
t
,
value
[
1
],
value
[
3
])
end
else
error
(
"failed to decode type "
..
json_desc
)
end
assert
(
f
~=
nil
,
"failed to decode type "
..
json_desc
)
table.insert
(
fields
,
f
)
end
assert
(
struct
==
"struct"
or
struct
==
"union"
,
"unknown complex type: "
..
struct
)
return
string.format
(
"%s { %s
}"
,
struct
,
fields
)
return
string.format
(
"%s { %s
}"
,
struct
,
table.concat
(
fields
,
" "
)
)
end
return
_dec
(
json
.
parse
(
json_desc
))
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment