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
a2cf9758
Commit
a2cf9758
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add WlString type with UTF8-conversion functions
parent
1d2043ff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Quasar/Wayland/Protocol.hs
+1
-0
1 addition, 0 deletions
src/Quasar/Wayland/Protocol.hs
src/Quasar/Wayland/Protocol/Core.hs
+26
-4
26 additions, 4 deletions
src/Quasar/Wayland/Protocol/Core.hs
with
27 additions
and
4 deletions
src/Quasar/Wayland/Protocol.hs
+
1
−
0
View file @
a2cf9758
...
...
@@ -8,6 +8,7 @@ module Quasar.Wayland.Protocol (
GenericObjectId
,
NewId
,
Fixed
(
..
),
WlString
(
..
),
-- ** Classes for generated interfaces
IsInterface
(
Request
,
Event
,
InterfaceName
,
interfaceName
),
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Protocol/Core.hs
+
26
−
4
View file @
a2cf9758
...
...
@@ -7,6 +7,9 @@ module Quasar.Wayland.Protocol.Core (
Opcode
,
ArgumentType
(
..
),
Fixed
(
..
),
WlString
(
..
),
toString
,
fromString
,
IsSide
(
..
),
Side
(
..
),
IsInterface
(
..
),
...
...
@@ -63,9 +66,11 @@ import Data.Bits ((.&.), (.|.), shiftL, shiftR)
import
Data.ByteString
(
ByteString
)
import
Data.ByteString
qualified
as
BS
import
Data.ByteString.Lazy
qualified
as
BSL
import
Data.ByteString.UTF8
qualified
as
BSUTF8
import
Data.HashMap.Strict
(
HashMap
)
import
Data.HashMap.Strict
qualified
as
HM
import
Data.Proxy
import
Data.String
(
IsString
(
..
))
import
Data.Void
(
absurd
)
import
GHC.TypeLits
import
Language.Haskell.TH.Syntax
(
Lift
)
...
...
@@ -79,6 +84,14 @@ type GenericObjectId = Word32
type
Opcode
=
Word16
newtype
NewId
(
j
::
Symbol
)
=
NewId
GenericObjectId
deriving
stock
(
Eq
,
Show
)
newtype
GenericNewId
=
GenericNewId
GenericObjectId
deriving
stock
(
Eq
,
Show
)
-- | Signed 24.8 decimal numbers.
newtype
Fixed
=
Fixed
Word32
deriving
newtype
Eq
...
...
@@ -86,11 +99,20 @@ newtype Fixed = Fixed Word32
instance
Show
Fixed
where
show
x
=
"[fixed "
<>
show
x
<>
"]"
newtype
NewId
(
j
::
Symbol
)
=
NewId
GenericObjectId
deriving
stock
(
Eq
,
Show
)
newtype
GenericNewId
=
GenericNewId
GenericObjectId
deriving
stock
(
Eq
,
Show
)
-- | A string. The encoding is not officially specified, but in practice UTF-8 is used.
--
-- Instances and functions in this library assume UTF-8, but the original data is also available by deconstructing.
newtype
WlString
=
WlString
BS
.
ByteString
instance
Show
WlString
where
show
=
show
.
toString
instance
IsString
WlString
where
fromString
=
WlString
.
BSUTF8
.
fromString
toString
::
WlString
->
String
toString
(
WlString
bs
)
=
BSUTF8
.
toString
bs
dropRemaining
::
Get
()
...
...
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