Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-wayland
Commits
e302bc79
Commit
e302bc79
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Fix array serialization
parent
896f33b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Quasar/Wayland/Protocol/Core.hs
+32
-11
32 additions, 11 deletions
src/Quasar/Wayland/Protocol/Core.hs
with
32 additions
and
11 deletions
src/Quasar/Wayland/Protocol/Core.hs
+
32
−
11
View file @
e302bc79
...
...
@@ -167,13 +167,13 @@ instance WireFormat Fixed where
showArgument
=
show
instance
WireFormat
WlString
where
putArgument
(
WlString
x
)
=
putWayland
Blob
x
getArgument
=
pure
.
WlString
<$>
getWayland
Blob
putArgument
(
WlString
x
)
=
putWayland
String
x
getArgument
=
pure
.
WlString
<$>
getWayland
String
showArgument
=
show
instance
WireFormat
BS
.
ByteString
where
putArgument
x
=
putWayland
Blob
x
getArgument
=
pure
<$>
getWayland
Blob
putArgument
x
=
putWayland
Array
x
getArgument
=
pure
<$>
getWayland
Array
showArgument
array
=
"[array "
<>
show
(
BS
.
length
array
)
<>
"B]"
instance
KnownSymbol
j
=>
WireFormat
(
ObjectId
(
j
::
Symbol
))
where
...
...
@@ -760,17 +760,22 @@ getRawMessage = do
body
<-
getLazyByteString
size
pure
(
oId
,
opcode
,
body
)
getWaylandBlob
::
Get
BS
.
ByteString
getWaylandBlob
=
do
getWaylandString
::
Get
BS
.
ByteString
getWaylandString
=
do
Just
(
string
,
0
)
<-
BS
.
unsnoc
<$>
getWaylandArray
pure
string
getWaylandArray
::
Get
BS
.
ByteString
getWaylandArray
=
do
size
<-
getWord32host
Just
(
string
,
0
)
<-
BS
.
unsnoc
<$>
getByteString
(
fromIntegral
size
)
array
<-
getByteString
(
fromIntegral
size
)
skipPadding
pure
string
pure
array
putWayland
Blob
::
MonadThrow
m
=>
BS
.
ByteString
->
m
MessagePart
putWayland
Blob
blob
=
do
putWayland
String
::
MonadThrow
m
=>
BS
.
ByteString
->
m
MessagePart
putWayland
String
blob
=
do
when
(
len
>
fromIntegral
(
maxBound
::
Word16
))
$
throwM
$
ProtocolUsageError
$
"Tried to send string
or array
larger than 2^16 bytes"
throwM
$
ProtocolUsageError
$
"Tried to send string larger than 2^16 bytes"
pure
$
MessagePart
putBlob
(
4
+
len
+
pad
)
mempty
where
...
...
@@ -784,6 +789,22 @@ putWaylandBlob blob = do
putWord8
0
replicateM_
pad
(
putWord8
0
)
putWaylandArray
::
MonadThrow
m
=>
BS
.
ByteString
->
m
MessagePart
putWaylandArray
blob
=
do
when
(
len
>
fromIntegral
(
maxBound
::
Word16
))
$
throwM
$
ProtocolUsageError
$
"Tried to send array larger than 2^16 bytes"
pure
$
MessagePart
putBlob
(
4
+
len
+
pad
)
mempty
where
-- Total data length without padding
len
=
BS
.
length
blob
-- Padding length
pad
=
padding
len
putBlob
=
do
putWord32host
(
fromIntegral
len
)
putByteString
blob
replicateM_
pad
(
putWord8
0
)
skipPadding
::
Get
()
skipPadding
=
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment