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
7fe37b76
Commit
7fe37b76
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Parse wayland.xml in TH
parent
0ef3daf9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
quasar-wayland.cabal
+7
-5
7 additions, 5 deletions
quasar-wayland.cabal
src/Quasar/Wayland/Protocol.hs
+29
-0
29 additions, 0 deletions
src/Quasar/Wayland/Protocol.hs
src/Quasar/Wayland/TH.hs
+45
-0
45 additions, 0 deletions
src/Quasar/Wayland/TH.hs
with
81 additions
and
5 deletions
quasar-wayland.cabal
+
7
−
5
View file @
7fe37b76
...
...
@@ -83,19 +83,21 @@ common shared-executable-properties
library
import: shared-properties
exposed-modules:
--Quasar.Template
Quasar.Wayland.Protocol
Quasar.Wayland.TH
build-depends:
base >=4.7 && <5,
--binary,
--
bytestring,
--
exceptions,
bytestring,
exceptions,
--mtl,
--network,
--
quasar,
--
template-haskell,
quasar,
template-haskell,
--unix,
--unordered-containers,
--stm,
xml,
-- required for record-dot-preprocessor
record-dot-preprocessor,
record-hasfield,
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Protocol.hs
0 → 100644
+
29
−
0
View file @
7fe37b76
module
Quasar.Wayland.Protocol
(
ProtocolState
,
initialProtocolState
,
feedInput
,
)
where
import
Data.ByteString
(
ByteString
)
import
Data.ByteString
qualified
as
BS
import
Quasar.Prelude
import
Quasar.Wayland.TH
$
(
generateWaylandProcol
"protocols/wayland.xml"
)
data
ProtocolState
=
ProtocolState
{
bytesReceived
::
Word64
,
bytesSent
::
Word64
}
initialProtocolState
::
ProtocolState
initialProtocolState
=
ProtocolState
{
bytesReceived
=
0
,
bytesSent
=
0
}
feedInput
::
ByteString
->
ProtocolState
->
(
ProtocolState
)
feedInput
bytes
oldState
=
oldState
{
bytesReceived
=
oldState
.
bytesReceived
+
fromIntegral
(
BS
.
length
bytes
)
}
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/TH.hs
0 → 100644
+
45
−
0
View file @
7fe37b76
module
Quasar.Wayland.TH
(
generateWaylandProcol
)
where
import
Quasar.Prelude
import
Text.XML.Light
import
Data.ByteString
qualified
as
BS
import
Language.Haskell.TH
import
Language.Haskell.TH.Lib
import
Language.Haskell.TH.Syntax
(
addDependentFile
)
generateWaylandProcol
::
FilePath
->
Q
[
Dec
]
generateWaylandProcol
protocolFile
=
do
addDependentFile
protocolFile
xml
<-
liftIO
(
BS
.
readFile
protocolFile
)
protocol
<-
loadProtocol
xml
traceIO
$
show
$
(
.
name
)
<$>
(
interfaces
protocol
)
pure
[]
data
Protocol
=
Protocol
{
interfaces
::
[
Interface
]}
deriving
(
Show
)
data
Interface
=
Interface
{
name
::
String
}
deriving
(
Show
)
loadProtocol
::
MonadFail
m
=>
BS
.
ByteString
->
m
Protocol
loadProtocol
xml
=
do
(
Just
protocolEl
)
<-
pure
$
parseXMLDoc
xml
interfaces
<-
mapM
loadInterface
$
findChildren
(
blank_name
{
qName
=
"interface"
})
protocolEl
pure
$
Protocol
interfaces
loadInterface
::
MonadFail
m
=>
Element
->
m
Interface
loadInterface
interfaceEl
=
do
name
<-
interfaceName
pure
$
Interface
name
where
interfaceName
::
MonadFail
m
=>
m
String
interfaceName
=
do
(
Just
name
)
<-
pure
$
findAttr
(
blank_name
{
qName
=
"name"
})
interfaceEl
pure
name
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