Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 5033a9b

Browse files
Add functions to lcidlc to allow externals to attach auxiliary threads to the Java VM on Android
1 parent e36bcb0 commit 5033a9b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

lcidlc/include/LiveCode.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,30 @@ LCError LCArrayRemoveKeyWithPath(LCArrayRef array, unsigned int options, const c
470470

471471
////////////////////////////////////////////////////////////////////////////////
472472

473+
#ifdef __ANDROID__
474+
475+
// Function:
476+
// LCAttachCurrentThread
477+
// Parameters:
478+
// none
479+
// Errors:
480+
// Failed - System was unable to attach the current thread to the Java VM
481+
//
482+
LCError LCAttachCurrentThread(void);
483+
484+
// Function:
485+
// LCDetachCurrentThread
486+
// Parameters:
487+
// none
488+
// Errors:
489+
// Failed - System was unable to detach the current thread from the Java VM
490+
//
491+
LCError LCDetachCurrentThread(void);
492+
493+
#endif
494+
495+
////////////////////////////////////////////////////////////////////////////////
496+
473497
typedef struct __LCObject *LCObjectRef;
474498

475499
// Parameters:

lcidlc/src/Support.mm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,6 +3218,25 @@ static bool verify__out_parameter(const char *arg, MCVariableRef var)
32183218
{ kJavaNativeTypeData, "java/nio/ByteBuffer", "array", "()[B", nil, nil },
32193219
};
32203220

3221+
LCError LCAttachCurrentThread(void)
3222+
{
3223+
JNIEnv *t_env;
3224+
3225+
t_env = nil;
3226+
if (s_java_vm -> AttachCurrentThread(&t_env, nil) < 0)
3227+
return kLCErrorFailed;
3228+
3229+
return kLCErrorNone;
3230+
}
3231+
3232+
LCError LCDetachCurrentThread(void)
3233+
{
3234+
if (s_java_vm -> DetachCurrentThread() < 0)
3235+
return kLCErrorFailed;
3236+
3237+
return kLCErrorNone;
3238+
}
3239+
32213240
static bool java__initialize(JNIEnv *env)
32223241
{
32233242
for(uint32_t i = 0; i < sizeof(s_native_mappings) / sizeof(s_native_mappings[0]); i++)

0 commit comments

Comments
 (0)