You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libscript/src/java.lcb
+69-1Lines changed: 69 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,8 @@ foreign handler MCJavaDataFromJByteArray(in pByteArray as JObject, out rData as
52
52
foreign handler MCJavaDataToJByteArray(in pData as Data, out rByteArray as JObject) returns nothing binds to "<builtin>"
53
53
54
54
foreign handler MCJavaGetClassName(in pObject as JObject, out rName as String) returns nothing binds to "<builtin>"
55
-
55
+
foreign handler MCJavaUnwrapJObject(in pObject as JObject, out rPointer as Pointer) returns nothing binds to "<builtin>"
56
+
foreign handler MCJavaWrapJObject(in pPointer as Pointer, out rObj as JObject) returns nothing binds to "<builtin>"
56
57
57
58
/**
58
59
Summary: Get Java class name of a Java object
@@ -176,4 +177,71 @@ public handler DataFromJByteArray(in pBytes as JByteArray) returns Data
176
177
return tData
177
178
end handler
178
179
180
+
/**
181
+
Summary: Convert a JObject into a Pointer
182
+
183
+
Parameters:
184
+
pObj: The JObject to convert
185
+
186
+
Returns:
187
+
The jobject Pointer wrapped by the JObject type
188
+
189
+
Example:
190
+
handler SetNativeLayerToView(in pView as JObject)
191
+
variable tViewPtr as Pointer
192
+
put PointerFromJObject(pView) into tViewPtr
193
+
set my native layer to tViewPtr
194
+
end handler
195
+
196
+
Description:
197
+
Use <PointerFromJObject> to convert a variable of type JObject to one of
198
+
type Pointer, i.e. to extract the underlying jobject pointer from a JObject
199
+
*/
200
+
201
+
public handler PointerFromJObject(in pObj as JObject) returns Pointer
202
+
variable tPointer as Pointer
203
+
unsafe
204
+
MCJavaUnwrapJObject(pObj, tPointer)
205
+
end unsafe
206
+
return tPointer
207
+
end handler
208
+
209
+
/**
210
+
Summary: Convert a Pointer into a JObject
211
+
212
+
Parameters:
213
+
pPointer: The Pointer to convert
214
+
215
+
Returns:
216
+
A JObject wrapping the jobject Pointer
217
+
218
+
Example:
219
+
foreign handler _JNI_SetTextViewText(in pView as JObject, in pValue as JString) returns nothing binds to "java:android.widget.TextView>setText(Ljava/lang/CharSequence;)V"
if (!MCNamedErrorTypeInfoCreate(MCNAME("com.livecode.java.FetchJavaClassNameError"), MCNAME("java"), MCSTR("Could not get Java object class name"), kMCJavaCouldNotGetObjectClassNameErrorTypeInfo))
111
123
returnfalse;
124
+
125
+
if (!MCNamedErrorTypeInfoCreate(MCNAME("com.livecode.java.CreateJObjectError"), MCNAME("java"), MCSTR("Could not create JObject from Pointer"), kMCJavaCouldNotCreateJObjectErrorTypeInfo))
0 commit comments