Skip to content

Commit 89b0f70

Browse files
author
Fraser J. Gordon
committed
Merge remote-tracking branch 'upstream/refactor-syntax_unicode' into refactor-syntax_unicode_findname
Conflicts: engine/src/exec-interface.cpp
2 parents c5f1b39 + e71071c commit 89b0f70

File tree

95 files changed

+2234
-2086
lines changed

Some content is hidden

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

95 files changed

+2234
-2086
lines changed

engine/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LOCAL_SRC_FILES := $(addprefix src/,\
5656
exec-sensor.cpp exec-sound.cpp exec-store.cpp exec-textmessaging.cpp \
5757
exec-array.cpp exec-datetime.cpp exec-engine.cpp exec-files.cpp exec-filters.cpp exec-interface.cpp \
5858
exec-logic.cpp exec-math.cpp exec-multimedia.cpp exec-network.cpp exec-pasteboard.cpp exec-scripting.cpp \
59-
exec-strings.cpp exec-text.cpp exec-graphics.cpp exec-security.cpp exec-printing.cpp exec-debugging.cpp \
59+
exec-strings.cpp exec-strings-chunk.cpp exec-text.cpp exec-graphics.cpp exec-security.cpp exec-printing.cpp exec-debugging.cpp \
6060
exec-ide.cpp exec-server.cpp exec-interface2.cpp exec.cpp \
6161
exec-interface-aclip.cpp exec-interface-button.cpp exec-interface-card.cpp exec-interface-control.cpp \
6262
exec-interface-field.cpp exec-interface-graphic.cpp exec-interface-group.cpp exec-interface-image.cpp \

engine/Makefile.kernel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ SOURCES=\
4646
fonttable.cpp fieldrtf.cpp fieldhtml.cpp syslnxfs.cpp stackcache.cpp \
4747
exec-array.cpp exec-datetime.cpp exec-engine.cpp exec-files.cpp exec-filters.cpp exec-interface.cpp \
4848
exec-logic exec-math.cpp exec-multimedia.cpp exec-network.cpp exec-pasteboard.cpp exec-scripting \
49-
exec-strings.cpp exec-text.cpp exec-graphics.cpp exec-security.cpp exec-printing.cpp exec-debugging.cpp \
49+
exec-strings.cpp exec-strings-chunk.cpp exec-text.cpp exec-graphics.cpp exec-security.cpp exec-printing.cpp exec-debugging.cpp \
5050
exec-ide.cpp exec-server.cpp exec-interface2.cpp exec.cpp \
5151
exec-interface-aclip.cpp exec-interface-button.cpp exec-interface-card.cpp exec-interface-control.cpp \
5252
exec-interface-field.cpp exec-interface-graphic.cpp exec-interface-group.cpp exec-interface-image.cpp \

engine/engine.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,6 +4054,7 @@
40544054
MODE_INSTALLER,
40554055
);
40564056
INFOPLIST_FILE = "rsrc/Installer-Info.plist";
4057+
OTHER_LDFLAGS = "-ObjC";
40574058
PRODUCT_NAME = Installer;
40584059
};
40594060
name = Debug;
@@ -4066,6 +4067,7 @@
40664067
MODE_INSTALLER,
40674068
);
40684069
INFOPLIST_FILE = "rsrc/Installer-Info.plist";
4070+
OTHER_LDFLAGS = "-ObjC";
40694071
PRODUCT_NAME = Installer;
40704072
};
40714073
name = Release;
@@ -4088,6 +4090,7 @@
40884090
isa = XCBuildConfiguration;
40894091
buildSettings = {
40904092
INFOPLIST_FILE = "rsrc/Revolution-Info.plist";
4093+
OTHER_LDFLAGS = "-ObjC";
40914094
PRODUCT_NAME = "LiveCode-Community";
40924095
WRAPPER_EXTENSION = app;
40934096
};
@@ -4097,6 +4100,7 @@
40974100
isa = XCBuildConfiguration;
40984101
buildSettings = {
40994102
INFOPLIST_FILE = "rsrc/Revolution-Info.plist";
4103+
OTHER_LDFLAGS = "-ObjC";
41004104
PRODUCT_NAME = "LiveCode-Community";
41014105
WRAPPER_EXTENSION = app;
41024106
};
@@ -4106,6 +4110,7 @@
41064110
isa = XCBuildConfiguration;
41074111
buildSettings = {
41084112
INFOPLIST_FILE = "rsrc/Standalone-Info.plist";
4113+
OTHER_LDFLAGS = "-ObjC";
41094114
PRODUCT_NAME = "Standalone-Community";
41104115
};
41114116
name = Debug;
@@ -4114,6 +4119,7 @@
41144119
isa = XCBuildConfiguration;
41154120
buildSettings = {
41164121
INFOPLIST_FILE = "rsrc/Standalone-Info.plist";
4122+
OTHER_LDFLAGS = "-ObjC";
41174123
PRODUCT_NAME = "Standalone-Community";
41184124
};
41194125
name = Release;
@@ -4136,6 +4142,7 @@
41364142
isa = XCBuildConfiguration;
41374143
buildSettings = {
41384144
GLOBAL_GCC_PREPROCESSOR_DEFINITIONS = "_SERVER _MAC_SERVER";
4145+
OTHER_LDFLAGS = "-ObjC";
41394146
PRODUCT_NAME = "Server-Community";
41404147
};
41414148
name = Debug;
@@ -4144,6 +4151,7 @@
41444151
isa = XCBuildConfiguration;
41454152
buildSettings = {
41464153
GLOBAL_GCC_PREPROCESSOR_DEFINITIONS = "_SERVER _MAC_SERVER";
4154+
OTHER_LDFLAGS = "-ObjC";
41474155
PRODUCT_NAME = "Server-Community";
41484156
};
41494157
name = Release;

engine/src/ans.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
4444
//
4545
// The Revolution sytax that uses this call is deprecated.
4646
//
47-
extern int MCA_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_filter, const char *p_initial, unsigned int p_options);
48-
extern int MCA_ask_file(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_filter, const char *p_initial, unsigned int p_options); //const char *prompt, char *fn, MCExecPoint& ep, Boolean sheet);
47+
extern int MCA_file(MCStringRef p_title, MCStringRef p_prompt, MCStringRef p_filter, MCStringRef p_initial, unsigned int p_options, MCStringRef &r_value, MCStringRef &r_result);
48+
extern int MCA_ask_file(MCStringRef p_title, MCStringRef p_prompt, MCStringRef p_filter, MCStringRef p_initial, unsigned int p_options, MCStringRef &r_value, MCStringRef &r_result); //const char *prompt, char *fn, MCExecPoint& ep, Boolean sheet);
4949

5050
// Display a system file open dialog with a list of file types.
5151
// p_title - this string should appear in the titlebar
@@ -67,8 +67,8 @@ extern int MCA_ask_file(MCExecPoint& ep, const char *p_title, const char *p_prom
6767
// If MCA_OPTION_RETURN_FILTER is specified MCresult should contain the label of the
6868
// filetype in effect when the dialog was closed (but not cancelled).
6969
//
70-
extern int MCA_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options);
71-
extern int MCA_ask_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options);
70+
extern int MCA_file_with_types(MCStringRef p_title, MCStringRef p_prompt, MCStringRef *p_types, uint4 p_type_count, MCStringRef p_initial, unsigned int p_options, MCStringRef &r_value, MCStringRef &r_result);
71+
extern int MCA_ask_file_with_types(MCStringRef p_title, MCStringRef p_prompt, MCStringRef *p_types, uint4 p_type_count, MCStringRef p_initial, unsigned int p_options, MCStringRef &r_value, MCStringRef &r_result);
7272

7373
// Display a system folder selection dialog.
7474
// p_title - this string should appear in the titlebar
@@ -82,7 +82,7 @@ extern int MCA_ask_file_with_types(MCExecPoint& ep, const char *p_title, const c
8282
// ep should contain the revolution path of the folder selected, or empty if the
8383
// dialog was cancelled.
8484
//
85-
extern int MCA_folder(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_initial, unsigned int p_options);
85+
extern int MCA_folder(MCStringRef p_title, MCStringRef p_prompt, MCStringRef p_initial, unsigned int p_options, MCStringRef &r_value, MCStringRef &r_result);
8686

8787
// Display a system color selection dialog.
8888
// p_title - this string should appear in the titlebar

engine/src/button.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,21 +3459,19 @@ void MCButton::openmenu(Boolean grab)
34593459
#ifdef _MOBILE
34603460
if (menumode == WM_OPTION)
34613461
{
3462-
// loop counter
3463-
int i;
34643462
// result of picker action
34653463
long t_result;
34663464
// item selection
34673465
uint32_t t_selected, t_chosen_option;
3468-
// temporary options string from which to select the new label
3469-
MCString t_menustringcopy;
3466+
34703467
// the selected item
34713468
// get a pointer to this
34723469
MCButton *pptr;
34733470
pptr = this;
3471+
34743472
// get the label and menu item strings
34753473
MCStringRef t_menustring;
3476-
t_menustring = getmenustring();
3474+
t_menustring = pptr->getmenustring();
34773475

34783476
// process data using the pick wheel
34793477
t_selected = menuhistory;

engine/src/chunk.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,8 +2722,9 @@ static int4 countwords(MCExecPoint &ep, const char *sptr, const char *eptr)
27222722
static int4 counttokens(MCExecPoint &ep, const char *sptr, const char *eptr)
27232723
{
27242724
int4 tokens = 0;
2725-
MCString s(sptr, eptr - sptr);
2726-
MCScriptPoint sp(s);
2725+
MCAutoStringRef s;
2726+
/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t *) sptr, eptr - sptr, &s);
2727+
MCScriptPoint sp(*s);
27272728
Parse_stat ps = sp.nexttoken();
27282729
while (ps != PS_ERROR && ps != PS_EOF)
27292730
{
@@ -3085,8 +3086,10 @@ Exec_stat MCChunk::mark_legacy(MCExecPoint &ep, int4 &start, int4 &end, Boolean
30853086
return ES_ERROR;
30863087
}
30873088
uint4 offset = sptr - startptr;
3088-
MCString string(sptr, eptr - sptr);
3089-
MCScriptPoint sp(string);
3089+
MCAutoStringRef string;
3090+
/* UNCHECKED */ MCStringCreateWithNativeChars((const char_t *) sptr, eptr - sptr, &string);
3091+
3092+
MCScriptPoint sp(*string);
30903093
MCerrorlock++;
30913094

30923095
Parse_stat ps = sp.nexttoken();
@@ -4797,17 +4800,8 @@ Exec_stat MCChunk::evalobjectchunk(MCExecPoint& ep, bool p_whole_chunk, bool p_f
47974800
MCExecContext ctxt(ep);
47984801
if (t_function)
47994802
MCInterfaceMarkFunction(ctxt, t_object, function, p_whole_chunk, r_chunk . mark);
4800-
else if (cline != nil || item != nil || token != nil || word != nil || character!= nil)
4801-
MCInterfaceMarkObject(ctxt, t_object, p_whole_chunk, r_chunk . mark);
48024803
else
4803-
{
4804-
r_chunk . chunk = CT_UNDEFINED;
4805-
r_chunk . object = t_object . object;
4806-
r_chunk . part_id = t_object . part_id;
4807-
r_chunk . mark . start = 0;
4808-
r_chunk . mark . finish = INDEX_MAX;
4809-
return ES_NORMAL;
4810-
}
4804+
MCInterfaceMarkObject(ctxt, t_object, p_whole_chunk, r_chunk . mark);
48114805

48124806
if (mark(ep, p_force, p_whole_chunk, r_chunk . mark) != ES_NORMAL)
48134807
{

engine/src/cmds.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,9 +2438,8 @@ void MCSort::additem(MCExecContext &ctxt, MCSortnode *items, uint4 &nitems, Sort
24382438
MCAutoValueRef t_value;
24392439
if (by != NULL)
24402440
{
2441-
MCerrorlock++;
2442-
ctxt.GetEP().setvalueref(p_value);
2443-
MCeach->set(ctxt.GetEP());
2441+
MCerrorlock++;
2442+
MCeach -> setvalueref(p_value);
24442443
if (by->eval(ctxt.GetEP()) == ES_NORMAL)
24452444
t_value = ctxt.GetEP().getvalueref();
24462445
else

engine/src/customprinter.cpp

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2626
#include "mcerror.h"
2727
#include "globals.h"
2828
#include "execpt.h"
29+
#include "exec.h"
2930
#include "metacontext.h"
3031
#include "printer.h"
3132
#include "customprinter.h"
@@ -899,17 +900,11 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
899900
dotextmark_callback_state *context;
900901
context = (dotextmark_callback_state *)p_context;
901902

902-
// Note we can use 'setstaticbytes' here because the execpoint is immediately
903-
// modified.
904-
MCExecPoint ep(nil, nil, nil);
905-
ep . setstaticbytes((const char *)p_span -> chars, p_span -> char_count * 2);
906-
ep . utf16toutf8();
907-
908-
// Get the UTF-8 string pointer and length
909-
const uint8_t *t_bytes;
910-
uint32_t t_byte_count;
911-
t_bytes = (const uint8_t *)ep . getcstring();
912-
t_byte_count = ep . getsvalue() . getlength();
903+
MCAutoStringRef t_string;
904+
/* UNCHECKED */ MCStringCreateWithCString((const char *)p_span -> chars, &t_string);
905+
byte_t *t_bytes;
906+
uindex_t t_byte_count;
907+
/* UNCHECKED */ MCStringConvertToBytes(*t_string, kMCStringEncodingUTF8, false, t_bytes, t_byte_count);
913908

914909
// Allocate a cluster index for every UTF-8 byte
915910
uint32_t *t_clusters;
@@ -983,18 +978,16 @@ static bool dotextmark_callback(void *p_context, const MCTextLayoutSpan *p_span)
983978

984979
void MCCustomMetaContext::dotextmark(MCMark *p_mark)
985980
{
986-
// Note we can use 'setstaticbytes' here because the ep is just being used
987-
// for conversion.
988-
MCExecPoint ep(nil, nil, nil);
989-
ep . setstaticbytes(p_mark -> text . data, p_mark -> text . length);
990-
if (!p_mark -> text . font -> unicode && !p_mark -> text . unicode_override)
991-
ep . nativetoutf16();
992-
993-
const unichar_t *t_chars;
994-
uint32_t t_char_count;
995-
t_chars = (const unichar_t *)ep . getsvalue() . getstring();
996-
t_char_count = ep . getsvalue() . getlength() / 2;
981+
bool t_is_unicode;
982+
t_is_unicode = p_mark -> text . font -> unicode || p_mark -> text . unicode_override;
983+
984+
MCAutoStringRef t_text_str;
985+
/* UNCHECKED */ MCStringCreateWithBytes((const byte_t*)p_mark -> text . data, p_mark -> text . length, t_is_unicode ? kMCStringEncodingUTF16 : kMCStringEncodingNative, false, &t_text_str);
997986

987+
unichar_t *t_chars;
988+
uindex_t t_char_count;
989+
/* UNCHECKED */ MCStringConvertToUnicode(*t_text_str, t_chars, t_char_count);
990+
998991
dotextmark_callback_state t_state;
999992
t_state . device = m_device;
1000993

@@ -1127,13 +1120,15 @@ static bool convert_options_array(void *p_context, MCArrayRef p_array, MCNameRef
11271120
convert_options_array_t *ctxt;
11281121
ctxt = (convert_options_array_t *)p_context;
11291122

1130-
MCExecPoint ep(nil, nil, nil);
11311123
if (!MCCStringClone(MCStringGetCString(MCNameGetString(p_key)), ctxt -> option_keys[ctxt -> index]))
11321124
return false;
1133-
if (!ep . setvalueref(p_value))
1134-
return false;
1135-
if (!MCCStringClone(ep . getcstring(), ctxt -> option_values[ctxt -> index]))
1125+
MCStringRef t_value;
1126+
if (MCValueGetTypeCode(p_value) != kMCValueTypeCodeString)
11361127
return false;
1128+
t_value = (MCStringRef) MCValueRetain(p_value);
1129+
1130+
ctxt -> option_values[ctxt -> index] = strdup(MCStringGetCString(t_value));
1131+
MCValueRelease(t_value);
11371132
ctxt -> index += 1;
11381133
return true;
11391134
}

engine/src/debug.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int2 depth;
7676

7777
#include "srvdebug.h"
7878

79-
void MCB_setmsg(MCStringRef p_msg)
79+
void MCB_setmsg(MCExecContext& ctxt, MCStringRef p_msg)
8080
{
8181

8282
}
@@ -122,11 +122,10 @@ void MCB_setvar(MCExecContext &ctxt, MCValueRef p_value, MCNameRef name)
122122

123123
#else
124124

125-
void MCB_setmsg(MCStringRef p_msg)
125+
void MCB_setmsg(MCExecContext& ctxt, MCStringRef p_msg)
126126
{
127-
MCExecPoint ep(nil, nil, nil);
128-
ep . setvalueref(p_msg);
129-
MCB_setmsg(ep);
127+
ctxt . GetEP() . setvalueref(p_msg);
128+
MCB_setmsg(ctxt . GetEP());
130129
}
131130

132131
void MCB_setmsg(MCExecPoint &ep)

engine/src/debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern uint2 MCnexecutioncontexts;
6262
extern uint2 MCdebugcontext;
6363
extern Boolean MCmessagemessages;
6464

65-
extern void MCB_setmsg(MCStringRef p_string);
65+
extern void MCB_setmsg(MCExecContext& ctxt, MCStringRef p_msg);
6666
extern void MCB_setmsg(MCExecPoint &ep);
6767
extern void MCB_message(MCExecPoint &ep, MCNameRef message, MCParameter *p);
6868
extern void MCB_prepmessage(MCExecPoint &ep, MCNameRef message, uint2 line, uint2 pos, uint2 id, MCStringRef p_info = kMCEmptyString);

0 commit comments

Comments
 (0)