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

Commit 1a57102

Browse files
committed
Further mobile refactoring
1 parent ddf138a commit 1a57102

30 files changed

+1592
-177
lines changed

engine/engine-mobile.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@
256256
4DC684BE1348EAD7002469A4 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DC684BD1348EAD7002469A4 /* OpenGLES.framework */; };
257257
4DD3E17B1040BDAF00CAC7EF /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DD3E17A1040BDAF00CAC7EF /* libz.dylib */; };
258258
4DE9499E142762490072D9C6 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DE9499D142762490072D9C6 /* CoreText.framework */; };
259+
768D66C217622FE200F203A3 /* exec-nativecontrol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 768D66C117622FE100F203A3 /* exec-nativecontrol.cpp */; };
260+
768D66C317622FE200F203A3 /* exec-nativecontrol.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 768D66C117622FE100F203A3 /* exec-nativecontrol.cpp */; };
261+
768D66C51765E11300F203A3 /* exec-pick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 768D66C41765E11300F203A3 /* exec-pick.cpp */; };
262+
768D66C61765E11300F203A3 /* exec-pick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 768D66C41765E11300F203A3 /* exec-pick.cpp */; };
259263
BE096E8B175CD7CF00F92F90 /* libfoundationmobile.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE096E85175CD79D00F92F90 /* libfoundationmobile.a */; };
260264
BE4494AE175CDCB900346B49 /* foundation-legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE4494AD175CDCB400346B49 /* foundation-legacy.cpp */; };
261265
BE4494DD175CDE7400346B49 /* exec-array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE4494B7175CDE7400346B49 /* exec-array.cpp */; };
@@ -867,6 +871,8 @@
867871
4DFFC8EE13DD909F006233A4 /* name.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = name.cpp; path = src/name.cpp; sourceTree = "<group>"; };
868872
4DFFC8F213DD90AF006233A4 /* objectpropsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = objectpropsets.cpp; path = src/objectpropsets.cpp; sourceTree = "<group>"; };
869873
4DFFC8F613DD90CE006233A4 /* syscfdate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = syscfdate.cpp; path = src/syscfdate.cpp; sourceTree = "<group>"; };
874+
768D66C117622FE100F203A3 /* exec-nativecontrol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-nativecontrol.cpp"; path = "src/exec-nativecontrol.cpp"; sourceTree = "<group>"; };
875+
768D66C41765E11300F203A3 /* exec-pick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-pick.cpp"; path = "src/exec-pick.cpp"; sourceTree = "<group>"; };
870876
BE096E7D175CD79D00F92F90 /* libfoundation-mobile.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "libfoundation-mobile.xcodeproj"; path = "../libfoundation/libfoundation-mobile.xcodeproj"; sourceTree = SOURCE_ROOT; };
871877
BE4494AD175CDCB400346B49 /* foundation-legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "foundation-legacy.cpp"; path = "src/foundation-legacy.cpp"; sourceTree = "<group>"; };
872878
BE4494B7175CDE7400346B49 /* exec-array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-array.cpp"; path = "src/exec-array.cpp"; sourceTree = "<group>"; };
@@ -1368,6 +1374,8 @@
13681374
BE4494B6175CDE4E00346B49 /* Exec */ = {
13691375
isa = PBXGroup;
13701376
children = (
1377+
768D66C41765E11300F203A3 /* exec-pick.cpp */,
1378+
768D66C117622FE100F203A3 /* exec-nativecontrol.cpp */,
13711379
BE449502175CDE7D00346B49 /* exec-interface */,
13721380
BE940439175F74D2003EAB87 /* exec-ad.cpp */,
13731381
BE94042A175F6307003EAB87 /* exec-addressbook.cpp */,
@@ -2328,6 +2336,8 @@
23282336
BE94042F175F6308003EAB87 /* exec-mail.cpp in Sources */,
23292337
BE940430175F6308003EAB87 /* exec-orientation.cpp in Sources */,
23302338
BE940431175F6308003EAB87 /* exec-sensor.cpp in Sources */,
2339+
768D66C217622FE200F203A3 /* exec-nativecontrol.cpp in Sources */,
2340+
768D66C51765E11300F203A3 /* exec-pick.cpp in Sources */,
23312341
);
23322342
runOnlyForDeploymentPostprocessing = 0;
23332343
};
@@ -2346,6 +2356,8 @@
23462356
BE940437175F65A2003EAB87 /* mbliphoneorientation.mm in Sources */,
23472357
BE940438175F6CD4003EAB87 /* mbliphonemail.mm in Sources */,
23482358
BE94043B175F74D2003EAB87 /* exec-ad.cpp in Sources */,
2359+
768D66C317622FE200F203A3 /* exec-nativecontrol.cpp in Sources */,
2360+
768D66C61765E11300F203A3 /* exec-pick.cpp in Sources */,
23492361
);
23502362
runOnlyForDeploymentPostprocessing = 0;
23512363
};

engine/engine.xcodeproj/project.pbxproj

Lines changed: 142 additions & 2 deletions
Large diffs are not rendered by default.

engine/src/date.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,12 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
320320
// MW-2008-03-24: [[ Bug 6183 ]] Hmmm... Wishful thinking here - there are definitely 7 days of
321321
// the week, not 12 as was previously asserted.
322322
if (t_loose_components)
323+
{
323324
if (!match_prefix(p_locale -> weekday_names, 7, t_input, t_input_length, t_dayofweek))
324325
t_skip = true; // Weekday names are optional, so skip to the next specifier
325326
else
326327
t_valid = true;
328+
}
327329
}
328330
else
329331
t_valid = true;
@@ -334,10 +336,12 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
334336
// MW-2008-03-24: [[ Bug 6183 ]] Hmmm... Wishful thinking here - there are definitely 7 days of
335337
// the week, not 12 as was previously asserted.
336338
if (t_loose_components)
339+
{
337340
if (!match_prefix(p_locale -> abbrev_weekday_names, 7, t_input, t_input_length, t_dayofweek))
338341
t_skip = true; // Weekday names are optional, so skip to the next specifier
339342
else
340343
t_valid = true;
344+
}
341345
}
342346
else
343347
t_valid = true;
@@ -662,11 +666,13 @@ static void datetime_normalize(MCDateTime& x_datetime)
662666
while(t_datetime . day > s_datetime_month_length[t_datetime . month - 1])
663667
{
664668
if (t_datetime . month == 2 && datetime_get_gregorian_leap_year(t_datetime . year))
669+
{
665670
if (t_datetime . day == 29)
666671
break;
667672
else
668673
t_datetime . day -= 1;
669-
674+
}
675+
670676
t_datetime . day -= s_datetime_month_length[t_datetime . month - 1];
671677
t_datetime . month += 1;
672678
if (t_datetime . month > 12)
@@ -1061,6 +1067,12 @@ static bool convert_parse_time(MCExecPoint& p_context, const MCDateTimeLocale *p
10611067
return false;
10621068
}
10631069

1070+
/* WRAPPER */ bool MCD_convert_to_datetime(MCExecContext& ctxt, MCStringRef p_input, Convert_form p_primary_from, Convert_form p_secondary_from, MCDateTime &r_datetime)
1071+
{
1072+
/* UNCHECKED */ ctxt . GetEP() . setvalueref(p_input);
1073+
return MCD_convert_to_datetime(ctxt . GetEP(), p_primary_from, p_secondary_from, r_datetime);
1074+
}
1075+
10641076
bool MCD_convert_to_datetime(MCExecPoint &p_context, Convert_form p_primary_from, Convert_form p_secondary_from, MCDateTime &r_datetime)
10651077
{
10661078
bool t_success = true;
@@ -1302,6 +1314,14 @@ bool MCD_convert_to_datetime(MCExecPoint &p_context, Convert_form p_primary_from
13021314
return t_success;
13031315
}
13041316

1317+
/* WRAPPER */ bool MCD_convert_from_datetime(MCExecContext& ctxt, MCDateTime p_datetime, Convert_form p_primary_from, Convert_form p_secondary_from, MCStringRef &r_output)
1318+
{
1319+
if (MCD_convert_to_datetime(ctxt . GetEP(), p_primary_from, p_secondary_from, p_datetime))
1320+
return ctxt . GetEP() . copyasstringref(r_output);
1321+
1322+
return false;
1323+
}
1324+
13051325
bool MCD_convert_from_datetime(MCExecPoint &p_context, Convert_form p_primary_to, Convert_form p_secondary_to, MCDateTime &p_datetime)
13061326
{
13071327
bool t_success = true;

engine/src/date.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ extern Boolean MCD_convert(MCExecPoint &, Convert_form f, Convert_form fs,
163163
extern bool MCD_convert_to_datetime(MCExecPoint &ep, Convert_form p_primary_from, Convert_form p_secondary_from, MCDateTime &r_datetime);
164164
extern bool MCD_convert_from_datetime(MCExecPoint &ep, Convert_form p_primary_to, Convert_form p_secondary_to, MCDateTime &p_datetime);
165165

166+
/* WRAPPER */ extern bool MCD_convert_to_datetime(MCExecContext& ctxt, MCStringRef p_input, Convert_form p_primary_from, Convert_form p_secondary_from, MCDateTime &r_datetime);
167+
/* WRAPPER */ extern bool MCD_convert_from_datetime(MCExecContext& ctxt, MCDateTime p_datetime, Convert_form p_primary_from, Convert_form p_secondary_from, MCStringRef &r_output);
168+
166169
extern void MCD_getlocaleformats();
167170

168171
#endif

engine/src/exec-addressbook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void MCAddressBookExecUpdateContact(MCExecContext& ctxt, MCArrayRef p_contact, M
8484

8585
void MCAddressBookGetContactData(MCExecContext& ctxt, int32_t p_contact_id, MCArrayRef& r_contact_data)
8686
{
87-
MCSystemGetContactData(ctxt, p_contact_id, r_contact_data);
87+
MCSystemGetContactData(p_contact_id, r_contact_data);
8888
}
8989

9090
void MCAddressBookExecRemoveContact(MCExecContext& ctxt, int32_t p_contact_id)

engine/src/exec-mail.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ void MCMailExecSendEmail(MCExecContext& ctxt, MCStringRef p_to, MCStringRef p_cc
113113
bool t_can_send;
114114
MCMailGetCanSendMail(ctxt, t_can_send);
115115

116+
MCAutoStringRef t_result;
116117
if (t_can_send)
117-
MCSystemSendMail(p_to, p_cc, p_subject, p_body);
118+
MCSystemSendMail(p_to, p_cc, p_subject, p_body, &t_result);
119+
120+
if (*t_result != nil)
121+
ctxt . SetTheResultToValue(*t_result);
118122
else
119123
ctxt . SetTheResultToStaticCString("not supported");
120124
}

engine/src/exec-nativecontrol.cpp

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/* Copyright (C) 2003-2013 Runtime Revolution 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+
#include "mcio.h"
24+
#include "util.h"
25+
26+
#include "globals.h"
27+
#include "debug.h"
28+
#include "handler.h"
29+
30+
#include "mblsyntax.h"
31+
#include "mblcontrol.h"
32+
33+
////////////////////////////////////////////////////////////////////////////////
34+
35+
MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, CreateControl, 2)
36+
MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, DeleteControl, 1)
37+
MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, SetProperty, 2)
38+
MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, GetProperty, 2)
39+
MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, Do, 0)
40+
MC_EXEC_DEFINE_GET_METHOD(NativeControl, Target, 1)
41+
MC_EXEC_DEFINE_GET_METHOD(NativeControl, ControlList, 1)
42+
43+
////////////////////////////////////////////////////////////////////////////////
44+
45+
void MCNativeControlExecCreateControl(MCExecContext& ctxt, MCStringRef p_type_name, MCStringRef p_control_name)
46+
{
47+
ctxt . SetTheResultToEmpty();
48+
49+
// Make sure the name is valid.
50+
if (MCStringIsEqualTo(p_control_name, kMCEmptyString, kMCCompareCaseless))
51+
return;
52+
53+
int2 t_integer;
54+
if (MCU_stoi2(p_control_name, t_integer))
55+
return;
56+
57+
// Make sure a control does not already exist with the name
58+
MCNativeControl *t_control;
59+
if (MCNativeControl::FindByNameOrId(MCStringGetCString(p_control_name), t_control))
60+
return;
61+
62+
MCNativeControlType t_type;
63+
if (!MCNativeControl::LookupType(MCStringGetCString(p_type_name), t_type))
64+
return;
65+
66+
MCNativeControl *t_new_control;
67+
t_new_control = nil;
68+
if (MCNativeControl::CreateWithType(t_type, t_new_control))
69+
{
70+
extern MCExecPoint *MCEPptr;
71+
t_control -> SetOwner(MCEPptr -> getobj());
72+
t_control -> SetName(p_control_name);
73+
ctxt . SetTheResultToNumber(t_new_control -> GetId());
74+
return;
75+
}
76+
77+
if (t_control != nil)
78+
t_control -> Delete();
79+
}
80+
81+
void MCNativeControlExecDeleteControl(MCExecContext& ctxt, MCStringRef p_control_name)
82+
{
83+
MCNativeControl *t_control;
84+
if (!MCNativeControl::FindByNameOrId(MCStringGetCString(p_control_name), t_control))
85+
return;
86+
87+
t_control -> Delete();
88+
t_control -> Release();
89+
}
90+
91+
void MCNativeControlExecSetProperty(MCExecContext& ctxt, MCStringRef p_property, MCValueRef p_value)
92+
{
93+
ctxt . Unimplemented();
94+
}
95+
96+
void MCNativeControlExecGetProperty(MCExecContext& ctxt, MCStringRef p_property, MCValueRef& r_value)
97+
{
98+
ctxt . Unimplemented();
99+
}
100+
101+
void MCNativeControlExecDo(MCExecContext& ctxt)
102+
{
103+
ctxt . Unimplemented();
104+
}
105+
106+
void MCNativeControlGetTarget(MCExecContext& ctxt, MCStringRef& r_target)
107+
{
108+
// UNION TYPE!
109+
ctxt . Unimplemented();
110+
}
111+
112+
void MCNativeControlGetControlList(MCExecContext& ctxt, MCStringRef& r_list)
113+
{
114+
if (MCNativeControl::GetControlList(r_list))
115+
return;
116+
117+
ctxt . Throw();
118+
}
119+
120+
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)