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
9134bc22
Commit
9134bc22
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Change interface name type to WlString; remove UnknownObject
parent
2b09dd0f
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
+19
-33
19 additions, 33 deletions
src/Quasar/Wayland/Protocol/Core.hs
with
19 additions
and
33 deletions
src/Quasar/Wayland/Protocol/Core.hs
+
19
−
33
View file @
9134bc22
...
...
@@ -201,8 +201,8 @@ class (
type
WireEvent
i
type
InterfaceName
i
::
Symbol
interfaceName
::
forall
i
.
IsInterface
i
=>
String
interfaceName
=
symbolVal
@
(
InterfaceName
i
)
Proxy
interfaceName
::
forall
i
.
IsInterface
i
=>
Wl
String
interfaceName
=
fromString
$
symbolVal
@
(
InterfaceName
i
)
Proxy
class
Typeable
s
=>
IsSide
(
s
::
Side
)
where
type
MessageHandler
s
i
...
...
@@ -281,9 +281,9 @@ instance IsInterface i => Show (Object s i) where
class
IsObject
a
where
genericObjectId
::
a
->
GenericObjectId
objectInterfaceName
::
a
->
String
objectInterfaceName
::
a
->
Wl
String
showObject
::
a
->
String
showObject
object
=
objectInterfaceName
object
<>
"@"
<>
show
(
genericObjectId
object
)
showObject
object
=
toString
(
objectInterfaceName
object
)
<>
"@"
<>
show
(
genericObjectId
object
)
class
IsObjectSide
a
where
describeUpMessage
::
a
->
Opcode
->
BSL
.
ByteString
->
String
...
...
@@ -294,35 +294,25 @@ instance forall s i. IsInterface i => IsObject (Object s i) where
objectInterfaceName
_
=
interfaceName
@
i
instance
forall
s
i
.
IsInterfaceSide
s
i
=>
IsObjectSide
(
Object
s
i
)
where
describeUpMessage
object
opcode
body
=
objectInterfaceName
object
<>
"@"
<>
show
(
genericObjectId
object
)
<>
"."
<>
fromMaybe
"[invalidOpcode]"
(
opcodeName
@
(
WireUp
s
i
)
opcode
)
<>
" ("
<>
show
(
BSL
.
length
body
)
<>
"B)"
describeDownMessage
object
opcode
body
=
objectInterfaceName
object
<>
"@"
<>
show
(
genericObjectId
object
)
<>
"."
<>
fromMaybe
"[invalidOpcode]"
(
opcodeName
@
(
WireDown
s
i
)
opcode
)
<>
" ("
<>
show
(
BSL
.
length
body
)
<>
"B)"
describeUpMessage
object
opcode
body
=
mconcat
[
toString
(
objectInterfaceName
object
),
"@"
,
show
(
genericObjectId
object
)
,
"."
,
fromMaybe
"[invalidOpcode]"
(
opcodeName
@
(
WireUp
s
i
)
opcode
)
,
" ("
,
show
(
BSL
.
length
body
)
,
"B)"
]
describeDownMessage
object
opcode
body
=
mconcat
[
toString
(
objectInterfaceName
object
),
"@"
,
show
(
genericObjectId
object
)
,
"."
,
fromMaybe
"[invalidOpcode]"
(
opcodeName
@
(
WireDown
s
i
)
opcode
)
,
" ("
,
show
(
BSL
.
length
body
)
,
"B)"
]
-- | Wayland object quantification wrapper
data
SomeObject
s
=
forall
i
.
IsInterfaceSide
s
i
=>
SomeObject
(
Object
s
i
)
|
UnknownObject
String
GenericObjectId
data
SomeObject
s
=
forall
i
.
IsInterfaceSide
s
i
=>
SomeObject
(
Object
s
i
)
instance
IsObject
(
SomeObject
s
)
where
genericObjectId
(
SomeObject
object
)
=
genericObjectId
object
genericObjectId
(
UnknownObject
_
oId
)
=
oId
objectInterfaceName
(
SomeObject
object
)
=
objectInterfaceName
object
objectInterfaceName
(
UnknownObject
interface
_
)
=
interface
instance
IsObjectSide
(
SomeObject
s
)
where
describeUpMessage
(
SomeObject
object
)
=
describeUpMessage
object
describeUpMessage
(
UnknownObject
interface
oId
)
=
\
opcode
body
->
interface
<>
"@"
<>
show
oId
<>
".#"
<>
show
opcode
<>
" ("
<>
show
(
BSL
.
length
body
)
<>
"B, unknown)"
describeDownMessage
(
SomeObject
object
)
=
describeDownMessage
object
describeDownMessage
(
UnknownObject
interface
oId
)
=
\
opcode
body
->
interface
<>
"@"
<>
show
oId
<>
".#"
<>
show
opcode
<>
" ("
<>
show
(
BSL
.
length
body
)
<>
"B, unknown)"
class
(
Eq
a
,
Show
a
)
=>
IsMessage
a
where
...
...
@@ -336,8 +326,9 @@ instance IsMessage Void where
putMessage
=
absurd
invalidOpcode
::
IsInterface
i
=>
Object
s
i
->
Opcode
->
Get
a
invalidOpcode
object
opcode
=
fail
$
"Invalid opcode "
<>
show
opcode
<>
" on "
<>
objectInterfaceName
object
<>
"@"
<>
show
(
genericObjectId
object
)
invalidOpcode
object
opcode
=
fail
$
mconcat
[
"Invalid opcode "
,
show
opcode
,
" on "
,
toString
(
objectInterfaceName
object
),
"@"
,
show
(
genericObjectId
object
)]
showObjectMessage
::
(
IsObject
a
,
IsMessage
b
)
=>
a
->
b
->
String
showObjectMessage
object
message
=
...
...
@@ -568,12 +559,11 @@ newObjectFromId messageHandler (NewId oId) = do
fromSomeObject
::
forall
s
i
m
.
IsInterfaceSide
s
i
=>
SomeObject
s
->
Either
String
(
Object
s
i
)
fromSomeObject
(
UnknownObject
interface
_
)
=
Left
$
mconcat
[
"Expected object with type "
,
interfaceName
@
i
,
", but object has unknown type "
,
interface
]
fromSomeObject
(
SomeObject
someObject
)
=
case
cast
someObject
of
Nothing
->
Left
$
mconcat
[
"Expected object with type "
,
interfaceName
@
i
,
", but object has type "
,
objectInterfaceName
someObject
]
Nothing
->
Left
$
mconcat
[
"Expected object with type "
,
toString
(
interfaceName
@
i
),
", but object has type "
,
toString
(
objectInterfaceName
someObject
)]
Just
object
->
pure
object
...
...
@@ -672,7 +662,6 @@ handleRawMessage (oId, opcode, body) = do
objects
<-
readProtocolVar
(
.
objectsVar
)
case
HM
.
lookup
oId
objects
of
Nothing
->
throwM
$
ProtocolException
$
"Received message with invalid object id "
<>
show
oId
Just
(
SomeObject
object
)
->
case
runGetOrFail
(
getMessageAction
object
)
body
of
Left
(
_
,
_
,
message
)
->
...
...
@@ -680,9 +669,6 @@ handleRawMessage (oId, opcode, body) = do
Right
(
""
,
_
,
result
)
->
result
Right
(
leftovers
,
_
,
_
)
->
throwM
$
ParserFailed
(
describeDownMessage
object
opcode
body
)
(
show
(
BSL
.
length
leftovers
)
<>
"B not parsed"
)
Just
(
UnknownObject
interface
_
)
->
do
throwM
$
ProtocolException
$
"Received message for object without handler: "
<>
interface
<>
"@"
<>
show
oId
where
getMessageAction
::
forall
i
.
IsInterfaceSide
s
i
...
...
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