Ron! Thank you for the interesting example. I myself come to a simple
solution, based on storing reference to the class object in THIS Var.
(:gen-class
:name com.bbn.openmap.layer.etopo.ETOPOEleLayer
:extends com.bbn.openmap.layer.etopo.ETOPOLayer
:exposes {dataBuffer {:get getDataBuffer}
bufferWidth {:get getBufferWidth}
bufferHeight {:get getBufferHeight}}
:post-init pinit)
(defn -pinit [this]
*(def THIS this)*)
(defn elevation [[lat lon]]
(let [bwd (or BUFWID (do (def BUFWID *(.getBufferWidth THIS))* BUFWID))
scy (or SCY (do (def SCY (float (/ *(.getBufferHeight THIS)*
180.0))) SCY))
scx (or SCX (do (def SCX (float (/ bwd 360.0))) SCX))
lat_idx (int (* (- 90.0 lat) scy))
lon_idx (int (* lon scx))
ofs (+ lon_idx (* lat_idx bwd))]
(aget *(.getDataBuffer THIS)* ofs)))
суббота, 9 июля 2016 г., 15:39:00 UTC+3 пользователь ru написал:
>
> How I can access protected field of superclass from my generated by
> "gen-class" subclass. Explanation in API documentaion quite obscure:
>
> "...
> :exposes {protected-field-name {:get name :set name}, ...}
>
> Since the implementations of the methods of the generated class
> occur in Clojure functions, they have no access to the inherited
> protected fields of the superclass. This parameter can be used to
> generate public getter/setter methods exposing the protected field(s)
>
> for use in the implementation.
> ..."
>
> I did not find examples :( My straightforward implementation gives error
> messages :( Can somebody point me out working examples, please. Thanks in
> advance.
>
> Sincerely,
> Ru
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.