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

Commit 84ef6e7

Browse files
committed
[[ Element Chunk ]] Abstract some chunk parsing checks
1 parent 8082466 commit 84ef6e7

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

engine/src/chunk.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
224224
{
225225
if (need_target)
226226
{
227-
if (desttype == DT_ISDEST && stack == NULL && background == NULL
228-
&& card == NULL && group == NULL && object == NULL)
227+
if (desttype == DT_ISDEST && noobjectchunks())
229228
{
230229
MCExpression *newfact = NULL;
231230
// MW-2011-06-22: [[ SERVER ]] Update to use SP findvar method to take into account
@@ -269,13 +268,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
269268
// then it should be evaluated as a string. However, if the string chunk
270269
// is of a previously parsed object then we must pass as a dest so the
271270
// object resolves correctly.
272-
if (desttype != DT_ISDEST && (cline != NULL || paragraph != NULL || sentence != NULL
273-
|| item != NULL || word != NULL || trueword != NULL
274-
|| token != NULL || character != NULL || codepoint != NULL
275-
|| codeunit != NULL || byte != NULL) &&
276-
(stack == nil && background == nil &&
277-
card == nil && group == nil &&
278-
object == nil))
271+
if (desttype != DT_ISDEST && !notextchunks() && noobjectchunks())
279272
{
280273
sp.backup();
281274
if (sp.parseexp(True, False, &source) != PS_NORMAL)
@@ -544,9 +537,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
544537
if (function == F_SELECTED_LINE || function == F_SELECTED_CHUNK)
545538
{}
546539
}
547-
else if (cline != NULL || paragraph != NULL || sentence != NULL || item != NULL
548-
|| trueword != NULL || word != NULL || token != NULL || character != NULL
549-
|| codepoint != NULL || codeunit != NULL || byte != NULL)
540+
else if (!notextchunks())
550541
{
551542
sp.backup();
552543
if (sp.parseexp(True, False, &source) != PS_NORMAL)
@@ -650,8 +641,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
650641
default: /* factor */
651642
if (need_target)
652643
{
653-
if (stack != NULL || background != NULL || card != NULL
654-
|| group != NULL || object != NULL)
644+
if (!noobjectchunks())
655645
{
656646
MCperror->add
657647
(PE_CHUNK_NOCHUNK, sp);
@@ -681,8 +671,7 @@ Parse_stat MCChunk::parse(MCScriptPoint &sp, Boolean doingthe)
681671
{ /* token type != ST_ID */
682672
if (need_target)
683673
{
684-
if (stack != NULL || background != NULL || card != NULL
685-
|| group != NULL || object != NULL)
674+
if (!noobjectchunks())
686675
{
687676
MCperror->add(PE_CHUNK_NOCHUNK, sp);
688677
return PS_ERROR;
@@ -1037,7 +1026,7 @@ void MCChunk::getoptionalobj(MCExecContext& ctxt, MCObjectPtr &r_object, Boolean
10371026
break;
10381027
}
10391028
}
1040-
else if (stack == nil && background == nil && card == nil && group == nil && object == nil)
1029+
else if (noobjectchunks())
10411030
{
10421031
// Optional obj: this doesn't throw an error
10431032
// but rather leave r_object . object set to nil
@@ -3197,8 +3186,7 @@ void MCChunk::eval_ctxt(MCExecContext &ctxt, MCExecValue &r_text)
31973186

31983187
if (t_object . object == nil)
31993188
{
3200-
if (url == NULL || stack != NULL || background != NULL ||
3201-
card != NULL || group != NULL || object != NULL)
3189+
if (url == NULL || !noobjectchunks())
32023190
{
32033191
ctxt . LegacyThrow(EE_CHUNK_CANTFINDOBJECT);
32043192
return;
@@ -4253,9 +4241,7 @@ bool MCChunk::getobjforprop(MCExecContext& ctxt, MCObject*& r_object, uint4& r_p
42534241
&& function != F_SELECTED_IMAGE
42544242
&& function != F_DRAG_SOURCE && function != F_DRAG_DESTINATION)
42554243
tfunction = True;
4256-
if (!tfunction && cline == nil && paragraph == nil && sentence == nil
4257-
&& item == nil && trueword == nil && word == nil && token == nil
4258-
&& character == nil && codepoint == nil && codeunit == nil && byte == nil)
4244+
if (!tfunction && notextchunks())
42594245
{
42604246
r_object = objptr;
42614247
r_parid = parid;

engine/src/cmds.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,7 +2360,7 @@ void MCSort::exec_ctxt(MCExecContext& ctxt)
23602360
else
23612361
{
23622362
MCField *fptr = (MCField *)optr;
2363-
if (optr->gettype() != CT_FIELD || !of->nochunks()
2363+
if (optr->gettype() != CT_FIELD || !of->notextchunks()
23642364
|| fptr->sort(ep, parid, chunktype, direction,
23652365
format, by) != ES_NORMAL)
23662366
{
@@ -2431,7 +2431,7 @@ void MCSort::exec_ctxt(MCExecContext& ctxt)
24312431
}
24322432
else
24332433
{
2434-
if (t_object . object->gettype() != CT_FIELD || !of->nochunks())
2434+
if (t_object . object->gettype() != CT_FIELD || !of->notextchunks())
24352435
{
24362436
ctxt . LegacyThrow(EE_SORT_CANTSORT);
24372437
return;

0 commit comments

Comments
 (0)