~shunter/wayflan#11: 
[Question/Example Request]: loading enums from other protocols

Probably not a bug, just my misunderstanding.

There are cases when used in one protocol is defined in another protocol. For example change-cause, content-hint, content-purpose defined in text-input are all used in input-method.

Questions:

  1. How do I specify wayflan to use those external enums?
  2. Or how do I just disable enum-parsing logic completely is the first is too complex case?
Status
REPORTED
Submitter
~shegeley
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.

~shegeley a month ago

*… when enums used in … (typo)

~shunter a month ago

You can load enums in other protocols by scanning those protocols first.

For example, I'll make a convoluted example where each protocol is in its own package. In the system myfoo.asd:

;; Directory tree:
;; ./myfoo.asd
;; ./packages.lisp
;; ./text-input-unstable-v3.xml
;; ./input-method-unstable-v2.xml
;; ./app.lisp - this would have your application code
(defsystem "myfoo"
  :defsystem-depends-on ("wayflan-client")
  :components ((:file "packages")
               (:wayflan-client-impl "text-input-unstable-v3"
                                     :in-package "myfoo.text-input"
                                     :export t
                                     :depends-on ("packages"))
               (:wayflan-client-impl "input-method-unstable-v2"
                                     :in-package "myfoo.input-method"
                                     :export t
                                     :depends-on ("packages" "text-input-unstable-v3"))
               (:file "app")))

(The :depends-on is unnecessary as the files are loaded in order. It's only to illustrate how each protocol depends on the other)

And in packages.lisp:

(defpackage #:myfoo.text-input
  (:use #:cl #:wayflan-client))

(defpackage #:myfoo.input-method
  (:use #:cl #:wayflan-client #:myfoo.text-input))

The package myfoo.input-method uses the package myfoo.text-input, such that it can use the enums of the previous. I can prove this by transforming the enum into a value within the package:

(defpackage #:myfoo.text-input
  (:use #:cl #:wayflan-client))

(defpackage #:myfoo.input-method
  (:use #:cl #:wayflan-client #:myfoo.text-input))

I made the example convoluted above to explicitly show which code depends on what. You can also keep things simple by putting everything in one package.

In myfoo.asd:

(defsystem "myfoo"
  :defsystem-depends-on ("wayflan-client")
  :components ((:file "package")
               (:wayflan-client-impl "text-input-unstable-v3"
                                     :in-package "myfoo")
               (:wayflan-client-impl "input-method-unstable-v2"
                                     :in-package "myfoo")
               (:file "app")))

In package.lisp:

(defpackage #:myfoo
  (:use #:cl #:wayflan-client))

~shegeley a month ago*

Thanks.

I've tried to do this before posting but I probably missed the part with adding :depends-on to input-method in :components

Will try again and post results in a few days.

Register here or Log in to comment, or comment via email.