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

Commit b40694c

Browse files
committed
[[ AndroidListeners ]] Add native method for calling back into engine from android listener invoke
1 parent 758d176 commit b40694c

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

engine/engine-sources.gypi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@
444444
'src/mblandroidinput.cpp',
445445
'src/mblandroidio.cpp',
446446
'src/mblandroidjava.cpp',
447+
'src/mblandroidlcb.cpp',
447448
'src/mblandroidmail.cpp',
448449
'src/mblandroidmediapick.cpp',
449450
'src/mblandroidmisc.cpp',

engine/kernel.gyp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@
8383
'src/mblcamera.cpp',
8484
],
8585

86-
# Force the entry point to be included in the output
86+
8787
'link_settings':
8888
{
8989
'ldflags':
9090
[
91-
'-Wl,--undefined,Java_com_runrev_android_Engine_doCreate'
91+
# Force the entry point to be included in the output
92+
'-Wl,--undefined,Java_com_runrev_android_Engine_doCreate',
93+
94+
# mblandroidlcb.cpp contains nothing other than the LCB Invocation Handler
95+
# native callback function, so force the symbol to be included as otherwise it
96+
# will be discarded by the linker because nothing in the file is used statically
97+
'-Wl,--undefined,Java_com_runrev_android_LCBInvocationHandler_doNativeListenerCallback',
9298
],
9399
},
94100
},

engine/src/mblandroidlcb.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* Copyright (C) 2017 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
#include "prefix.h"
18+
19+
#include "globdefs.h"
20+
#include "filedefs.h"
21+
#include "objdefs.h"
22+
#include "parsedef.h"
23+
24+
#include "globals.h"
25+
#include "object.h"
26+
#include "mbldc.h"
27+
28+
#include "mblandroid.h"
29+
#include "mblandroidutil.h"
30+
31+
#include "mblsyntax.h"
32+
33+
////////////////////////////////////////////////////////////////////////////////
34+
35+
extern void MCJavaPrivateDoNativeListenerCallback(jlong p_handler, jstring p_method_name, jobjectArray p_args);
36+
37+
extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_LCBInvocationHandler_doNativeListenerCallback(JNIEnv *env, jobject object, jlong handler, jstring p_method, jobjectArray p_args) __attribute__((visibility("default")));
38+
39+
JNIEXPORT void JNICALL Java_com_runrev_android_LCBInvocationHandler_doNativeListenerCallback(JNIEnv *env, jobject object, jlong p_handler, jstring p_method_name, jobjectArray p_args)
40+
{
41+
MCJavaPrivateDoNativeListenerCallback(p_handler, p_method_name, p_args);
42+
}
43+
44+
////////////////////////////////////////////////////////////////////////////////

libfoundation/src/foundation-java-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ bool MCJavaPrivateConvertJStringToStringRef(MCJavaObjectRef p_object, MCStringRe
5858
bool MCJavaPrivateConvertStringRefToJString(MCStringRef p_string, MCJavaObjectRef &r_object);
5959
bool MCJavaPrivateConvertDataRefToJByteArray(MCDataRef p_string, MCJavaObjectRef &r_object);
6060
bool MCJavaPrivateConvertJByteArrayToDataRef(MCJavaObjectRef p_object, MCDataRef &r_string);
61+
6162
void* MCJavaPrivateGetMethodId(MCNameRef p_class_name, MCStringRef p_method_name, MCStringRef p_arguments, MCStringRef p_return, int p_call_type);
6263
void MCJavaPrivateDestroyObject(MCJavaObjectRef p_object);
6364
bool MCJavaPrivateCheckSignature(MCTypeInfoRef p_signature, MCStringRef p_args, MCStringRef p_return, int p_call_type);

0 commit comments

Comments
 (0)