@@ -76,8 +76,9 @@ public boolean isPointer(
76
76
77
77
@ ExportMessage
78
78
public long asPointer (
79
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
79
80
@ CachedLibrary (limit = "1" ) InteropLibrary interopLibrary ) throws UnsupportedMessageException {
80
- Object nativePointer = this .getNativePointer ();
81
+ Object nativePointer = lib .getNativePointer (this );
81
82
if (nativePointer instanceof Long ) {
82
83
return (long ) nativePointer ;
83
84
}
@@ -86,11 +87,12 @@ public long asPointer(
86
87
87
88
@ ExportMessage
88
89
public void toNative (
90
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
89
91
@ Exclusive @ Cached CExtNodes .AsCharPointerNode asCharPointerNode ,
90
92
@ Exclusive @ Cached InvalidateNativeObjectsAllManagedNode invalidateNode ) {
91
93
invalidateNode .execute ();
92
- if (!isNative ()) {
93
- setNativePointer (asCharPointerNode .execute (getDelegate ()));
94
+ if (!lib . isNative (this )) {
95
+ setNativePointer (asCharPointerNode .execute (lib . getDelegate (this )));
94
96
}
95
97
}
96
98
}
@@ -109,13 +111,10 @@ public CStringWrapper(String delegate) {
109
111
super (delegate );
110
112
}
111
113
112
- public String getString () {
113
- return (String ) getDelegate ();
114
- }
115
-
116
114
@ ExportMessage
117
- final long getArraySize () {
118
- return this .getString ().length ();
115
+ final long getArraySize (
116
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) {
117
+ return ((String ) lib .getDelegate (this )).length ();
119
118
}
120
119
121
120
@ ExportMessage
@@ -125,10 +124,11 @@ final boolean hasArrayElements() {
125
124
}
126
125
127
126
@ ExportMessage
128
- final Object readArrayElement (long index ) throws InvalidArrayIndexException {
127
+ final Object readArrayElement (long index ,
128
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) throws InvalidArrayIndexException {
129
129
try {
130
130
int idx = PInt .intValueExact (index );
131
- String s = getString ( );
131
+ String s = ( String ) lib . getDelegate ( this );
132
132
if (idx >= 0 && idx < s .length ()) {
133
133
return s .charAt (idx );
134
134
} else if (idx == s .length ()) {
@@ -141,8 +141,9 @@ final Object readArrayElement(long index) throws InvalidArrayIndexException {
141
141
}
142
142
143
143
@ ExportMessage
144
- final boolean isArrayElementReadable (long identifier ) {
145
- return 0 <= identifier && identifier < getArraySize ();
144
+ final boolean isArrayElementReadable (long identifier ,
145
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) {
146
+ return 0 <= identifier && identifier < getArraySize (lib );
146
147
}
147
148
148
149
@ ExportMessage
@@ -153,8 +154,9 @@ protected boolean hasNativeType() {
153
154
154
155
@ ExportMessage
155
156
protected Object getNativeType (
157
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ,
156
158
@ Exclusive @ Cached PCallCapiFunction callByteArrayTypeIdNode ) {
157
- return callByteArrayTypeIdNode .call (FUN_GET_BYTE_ARRAY_TYPE_ID , getString ( ).length ());
159
+ return callByteArrayTypeIdNode .call (FUN_GET_BYTE_ARRAY_TYPE_ID , (( String ) lib . getDelegate ( this ) ).length ());
158
160
}
159
161
}
160
162
@@ -170,13 +172,13 @@ public CByteArrayWrapper(byte[] delegate) {
170
172
super (delegate );
171
173
}
172
174
173
- public byte [] getByteArray () {
174
- return (byte []) getDelegate ();
175
+ public final byte [] getByteArray (PythonNativeWrapperLibrary lib ) {
176
+ return (( byte []) lib . getDelegate (this ) );
175
177
}
176
178
177
179
@ ExportMessage
178
- final long getArraySize () {
179
- return this . getByteArray ().length ;
180
+ final long getArraySize (@ CachedLibrary ( "this" ) PythonNativeWrapperLibrary lib ) {
181
+ return getByteArray (lib ).length ;
180
182
}
181
183
182
184
@ ExportMessage
@@ -186,10 +188,11 @@ final boolean hasArrayElements() {
186
188
}
187
189
188
190
@ ExportMessage
189
- Object readArrayElement (long index ) throws InvalidArrayIndexException {
191
+ Object readArrayElement (long index ,
192
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) throws InvalidArrayIndexException {
190
193
try {
191
194
int idx = PInt .intValueExact (index );
192
- byte [] arr = getByteArray ();
195
+ byte [] arr = getByteArray (lib );
193
196
if (idx >= 0 && idx < arr .length ) {
194
197
return arr [idx ];
195
198
} else if (idx == arr .length ) {
@@ -202,8 +205,9 @@ Object readArrayElement(long index) throws InvalidArrayIndexException {
202
205
}
203
206
204
207
@ ExportMessage
205
- final boolean isArrayElementReadable (long identifier ) {
206
- return 0 <= identifier && identifier < getArraySize ();
208
+ final boolean isArrayElementReadable (long identifier ,
209
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) {
210
+ return 0 <= identifier && identifier < getArraySize (lib );
207
211
}
208
212
209
213
@ ExportMessage
0 commit comments