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

Commit d0e97af

Browse files
committed
Merge remote-tracking branch 'mark/feature-externals_api_v5' into refactor-syntax_unicode_externals
Conflicts: .gitignore engine/src/dispatch.cpp engine/src/externalv1.cpp engine/src/java/com/runrev/android/Engine.java engine/src/mblandroiddc.cpp rules/Global Mobile.xcconfig rules/Global.xcconfig rules/common.linux.makefile stage.sln
2 parents fd77a4e + 9a8385b commit d0e97af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10040
-1226
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,3 @@ prebuilt/lib
9696
prebuilt/build
9797
prebuilt/packaged
9898
prebuilt/fetched
99-

engine/engine.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@
12451245
4D6F92F412AA5CC000026A72 /* w32sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = w32sound.cpp; path = src/w32sound.cpp; sourceTree = "<group>"; };
12461246
4D6F92F512AA5CC000026A72 /* w32textlayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = w32textlayout.cpp; path = src/w32textlayout.cpp; sourceTree = "<group>"; };
12471247
4D6F92FA12AA5E2600026A72 /* textlayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textlayout.h; path = src/textlayout.h; sourceTree = "<group>"; };
1248+
4D7667AC17A137D500E692E0 /* EngineApi.java */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.java; path = EngineApi.java; sourceTree = "<group>"; };
12481249
4D7740F21226B930001C9150 /* lnxans.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lnxans.cpp; path = src/lnxans.cpp; sourceTree = "<group>"; };
12491250
4D7740F31226B930001C9150 /* lnxans.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lnxans.h; path = src/lnxans.h; sourceTree = "<group>"; };
12501251
4D7740F41226B930001C9150 /* lnxaudio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lnxaudio.cpp; path = src/lnxaudio.cpp; sourceTree = "<group>"; };
@@ -2328,6 +2329,7 @@
23282329
4DD54D1C134F591500981610 /* LiveCodeActivity.java */,
23292330
4DD54D1D134F591500981610 /* ShakeEventListener.java */,
23302331
4DD54D1E134F591500981610 /* URLLoader.java */,
2332+
4D7667AC17A137D500E692E0 /* EngineApi.java */,
23312333
);
23322334
path = android;
23332335
sourceTree = "<group>";

engine/engine.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/src/externalv1.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,10 @@ static MCExternalError MCExternalContextQuery(MCExternalContextQueryTag op, void
15751575
case kMCExternalContextQueryWholeMatches:
15761576
*(bool *)result = MCECptr -> GetWholeMatches();
15771577
break;
1578+
// MW-2013-06-13: [[ ExternalsApiV5 ]] Implementation of 'the wholeMatches' query.
1579+
case kMCExternalContextQueryWholeMatches:
1580+
*(bool *)result = MCEPptr -> getwholematches() == True;
1581+
break;
15781582
case kMCExternalContextQueryItemDelimiter:
15791583
*(MCStringRef *)result = MCECptr -> GetItemDelimiter();
15801584
break;
@@ -1619,8 +1623,7 @@ static MCExternalError MCExternalContextQuery(MCExternalContextQueryTag op, void
16191623

16201624
// MW-2013-06-13: [[ ExternalsApiV5 ]] Implementation of context_evaluate method.
16211625
MCExternalError MCExternalContextEvaluate(const char *p_expression, unsigned int p_options, MCExternalVariableRef *p_binds, unsigned int p_bind_count, MCExternalVariableRef p_result)
1622-
{
1623-
MCAutoStringRef t_expr;
1626+
{ MCAutoStringRef t_expr;
16241627
if (!MCStringCreateWithCString(p_expression, &t_expr))
16251628
return kMCExternalErrorOutOfMemory;
16261629

@@ -1727,6 +1730,16 @@ static MCExternalError MCExternalVariableQuery(MCExternalVariableRef var, MCExte
17271730
case kMCExternalVariableQueryIsASequence:
17281731
*(bool *)r_result = MCValueIsEmpty(var -> GetValueRef()) || (MCValueIsArray(var -> GetValueRef()) && MCArrayIsSequence((MCArrayRef)var -> GetValueRef()));
17291732
break;
1733+
1734+
// MW-2013-06-13: [[ ExternalsApiV5 ]] Implementation of IsEmpty variable query.
1735+
case kMCExternalVariableQueryIsEmpty:
1736+
*(bool *)r_result = var -> is_empty();
1737+
break;
1738+
1739+
// MW-2013-06-13: [[ ExternalsApiV5 ]] Implementation of IsASequence variable query.
1740+
case kMCExternalVariableQueryIsASequence:
1741+
*(bool *)r_result = var -> is_array() && var -> get_array() -> issequence();
1742+
break;
17301743

17311744
default:
17321745
return kMCExternalErrorInvalidVariableQuery;
@@ -2586,7 +2599,7 @@ static MCExternalError MCExternalInterfaceQuery(MCExternalInterfaceQueryTag op,
25862599
*(void **)r_value = MCAndroidGetEngine();
25872600
break;
25882601
#endif
2589-
2602+
25902603
default:
25912604
return kMCExternalErrorInvalidInterfaceQuery;
25922605
}

engine/src/java/com/runrev/android/Engine.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,69 @@ private void onRunActivityResult(int p_result_code, Intent p_data)
28902890
doProcess(false);
28912891
}
28922892

2893+
////////////////////////////////////////////////////////////////////////////////
2894+
2895+
// EngineApi implementation
2896+
2897+
public Activity getActivity()
2898+
{
2899+
return (LiveCodeActivity)getContext();
2900+
}
2901+
2902+
public ViewGroup getContainer()
2903+
{
2904+
return (ViewGroup)getParent();
2905+
}
2906+
2907+
private boolean m_pending_activity_running = false;
2908+
private int m_pending_activity_result_code = 0;
2909+
private Intent m_pending_activity_data = null;
2910+
public void runActivity(Intent p_intent, ActivityResultCallback p_callback)
2911+
{
2912+
// We aren't re-entrant, so just invoke the callback as 'cancelled' if one is
2913+
// already running.
2914+
if (m_pending_activity_running)
2915+
{
2916+
p_callback . handleActivityResult(Activity.RESULT_CANCELED, null);
2917+
return;
2918+
}
2919+
2920+
// Mark an activity as running.
2921+
m_pending_activity_running = true;
2922+
2923+
// Run the activity.
2924+
((LiveCodeActivity)getContext()) . startActivityForResult(p_intent, RUN_ACTIVITY_RESULT);
2925+
2926+
// Wait until the activity returns.
2927+
while(m_pending_activity_running)
2928+
doWait(60.0, false, true);
2929+
2930+
// Take local copies of the instance vars (to stop hanging data).
2931+
Intent t_data;
2932+
int t_result_code;
2933+
t_data = m_pending_activity_data;
2934+
t_result_code = m_pending_activity_result_code;
2935+
2936+
// Reset the instance vars (to stop hanging data and so that the callback
2937+
// can start another activity if it wants).
2938+
m_pending_activity_data = null;
2939+
m_pending_activity_result_code = 0;
2940+
2941+
p_callback . handleActivityResult(t_result_code, t_data);
2942+
}
2943+
2944+
private void onRunActivityResult(int p_result_code, Intent p_data)
2945+
{
2946+
// Store the result details.
2947+
m_pending_activity_data = p_data;
2948+
m_pending_activity_result_code = p_result_code;
2949+
m_pending_activity_running = false;
2950+
2951+
// Make sure we signal a switch back to the script thread.
2952+
if (m_wake_on_event)
2953+
doProcess(false);
2954+
}
2955+
28932956
////////////////////////////////////////////////////////////////////////////////
28942957

28952958
// url launch callback

engine/src/mbliphonedc.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,11 @@ static void MCIPhoneDoBreakWaitOnCorrectThread(void *context)
17841784
MCFiberCall(s_main_fiber, MCIPhoneDoBreakWait, nil);
17851785
}
17861786

1787+
static void MCIPhoneDoBreakWaitOnCorrectThread(void *context)
1788+
{
1789+
MCFiberCall(s_main_fiber, MCIPhoneDoBreakWait, nil);
1790+
}
1791+
17871792
void MCIPhoneBreakWait(void)
17881793
{
17891794
if (s_break_wait_pending)

lcidlc/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
NAME=lcidlc
2+
TYPE=application
3+
4+
SOURCES=\
5+
Error.cpp Interface.cpp InterfaceGenerate.cpp Main.cpp \
6+
NativeType.cpp Parser.cpp Position.cpp Scanner.cpp \
7+
Value.cpp EncodedSupport.c EncodedJavaSupport.c
8+
9+
CUSTOM_LIBS=core
10+
CUSTOM_STATIC_LIBS=stdc++
11+
12+
EncodedSupport.c: Support.mm
13+
../prebuilt/bin/Revolution.lnx "./encode_source.rev" "$SRCROOT/src/Support.mm" "$SRCROOT/src/EncodedSupport.c" "g_support_template"
14+
15+
EncodedJavaSupport.c: Support.mm
16+
../prebuilt/bin/Revolution.lnx "./encode_source.rev" "$SRCROOT/src/Support.java" "$SRCROOT/src/EncodedJavaSupport.c" "g_java_support_template"
17+
18+
include $(dir $(lastword $(MAKEFILE_LIST)))/../rules/application.linux.makefile

lcidlc/encode_source.rev

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ on generate
1919
local tInput, tOutput, tLength
2020
put url ("file:" & $1) into tInput
2121

22-
put "const char *" & $3 & " =" & return after tOutput
22+
put "const char *" & $3 & "[] =" & return after tOutput
23+
put "{" & return after tOutput
2324
repeat for each line tLine in tInput
25+
replace "\" with "\\" in tLine
2426
replace quote with "\" & quote in tLine
25-
put tab & quote & tLine & "\n" & quote & return after tOutput
27+
put tab & quote & tLine & "\n" & quote & comma & return after tOutput
2628
end repeat
29+
put tab & 0 & return after tOutput
30+
put "}" & return after tOutput
2731
put ";" & return after tOutput
2832

2933
put tOutput into url ("file:" & $2)

0 commit comments

Comments
 (0)