|
104 | 104 |
|
105 | 105 | (defonce mapping-type*
|
106 | 106 | (jvm-handle/py-global-delay
|
107 |
| - (with-gil |
108 |
| - (py-ffi/with-decref |
109 |
| - [mod (py-ffi/PyImport_ImportModule "collections.abc") |
110 |
| - map-type (py-ffi/PyObject_GetAttrString mod "MutableMapping")] |
| 107 | + (with-gil |
| 108 | + (py-ffi/with-decref |
| 109 | + [mod (py-ffi/PyImport_ImportModule "collections.abc") |
| 110 | + map-type (py-ffi/PyObject_GetAttrString mod "MutableMapping")] |
111 | 111 | ;;In order to make things work ingeneral
|
112 |
| - (py-class/create-class |
113 |
| - "jvm-map-as-python" |
114 |
| - [map-type] |
115 |
| - {"__init__" (py-class/wrapped-jvm-constructor) |
116 |
| - "__del__" (py-class/wrapped-jvm-destructor) |
117 |
| - "__contains__" (as-tuple-instance-fn #(.containsKey (self->map %1) |
118 |
| - (py-base/as-jvm %2))) |
119 |
| - "__eq__" (as-tuple-instance-fn #(.equals (self->map %1) (py-base/as-jvm %2))) |
120 |
| - "__getitem__" (as-tuple-instance-fn |
121 |
| - #(.get (self->map %1) (py-base/as-jvm %2))) |
122 |
| - "__setitem__" (as-tuple-instance-fn #(.put (self->map %1) (py-base/as-jvm %2) %3)) |
123 |
| - "__delitem__" (as-tuple-instance-fn #(.remove (self->map %1) (py-base/as-jvm %2))) |
124 |
| - "__hash__" (as-tuple-instance-fn #(.hashCode (self->map %1))) |
125 |
| - "__iter__" (as-tuple-instance-fn #(.iterator ^Iterable (or (keys (self->map %1)) []))) |
126 |
| - "__len__" (as-tuple-instance-fn #(.size (self->map %1))) |
127 |
| - "__str__" (as-tuple-instance-fn #(.toString (self->map %1))) |
128 |
| - "clear" (as-tuple-instance-fn #(.clear (self->map %1))) |
129 |
| - "keys" (as-tuple-instance-fn #(seq (.keySet (self->map %1)))) |
130 |
| - "values" (as-tuple-instance-fn #(seq (.values (self->map %1)))) |
131 |
| - "pop" (as-tuple-instance-fn #(.remove (self->map %1) (py-base/as-jvm %2)))}))))) |
| 112 | + (py-class/create-class |
| 113 | + "jvm-map-as-python" |
| 114 | + [map-type] |
| 115 | + {"__init__" (py-class/wrapped-jvm-constructor) |
| 116 | + "__del__" (py-class/wrapped-jvm-destructor) |
| 117 | + "__contains__" (as-tuple-instance-fn #(.containsKey (self->map %1) |
| 118 | + (py-base/as-jvm %2))) |
| 119 | + "__eq__" (as-tuple-instance-fn #(.equals (self->map %1) (py-base/as-jvm %2))) |
| 120 | + "__getitem__" (as-tuple-instance-fn |
| 121 | + #(.get (self->map %1) (py-base/as-jvm %2))) |
| 122 | + "__setitem__" (as-tuple-instance-fn #(.put (self->map %1) (py-base/as-jvm %2) %3)) |
| 123 | + "__delitem__" (as-tuple-instance-fn #(.remove (self->map %1) (py-base/as-jvm %2))) |
| 124 | + "__hash__" (as-tuple-instance-fn #(.hashCode (self->map %1))) |
| 125 | + "__iter__" (as-tuple-instance-fn #(.iterator ^Iterable (or (keys (self->map %1)) []))) |
| 126 | + "__len__" (as-tuple-instance-fn #(.size (self->map %1))) |
| 127 | + "__str__" (as-tuple-instance-fn #(.toString (self->map %1))) |
| 128 | + "clear" (as-tuple-instance-fn #(.clear (self->map %1))) |
| 129 | + "keys" (as-tuple-instance-fn #(seq (.keySet (self->map %1)))) |
| 130 | + "values" (as-tuple-instance-fn #(seq (.values (self->map %1)))) |
| 131 | + "pop" (as-tuple-instance-fn #(.remove (self->map %1) (py-base/as-jvm %2)))}))))) |
132 | 132 |
|
133 | 133 |
|
134 | 134 | (defn map-as-python
|
|
0 commit comments