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

Commit 5a50cac

Browse files
[[ RefactorSyntax ]] Complete removal of MCBlock::setatts
1 parent dd8fbeb commit 5a50cac

6 files changed

Lines changed: 60 additions & 28 deletions

File tree

engine/Makefile.kernel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ SOURCES=\
88
cdata.cpp chunk.cpp cmds.cpp cmdsc.cpp cmdse.cpp cmdsf.cpp \
99
cmdsm.cpp cmdsp.cpp cmdss.cpp constant.cpp control.cpp cpalette.cpp \
1010
customprinter.cpp date.cpp debug.cpp dispatch.cpp dllst.cpp \
11-
# execpt.cpp express.cpp field.cpp fieldf.cpp fieldh.cpp fields.cpp \
1211
express.cpp field.cpp fieldf.cpp fieldh.cpp fields.cpp \
1312
font.cpp funcs.cpp funcsm.cpp globals.cpp graphic.cpp \
1413
graphicscontext.cpp \

engine/src/block.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3636
#include "font.h"
3737
#include "path.h"
3838

39+
#include "exec-interface.h"
40+
3941
// Default MCBlock constructor - makes a block with everything initialized
4042
// to zero.
4143
MCBlock::MCBlock(void)
@@ -1357,6 +1359,7 @@ bool MCBlock::hasfontattrs(void) const
13571359
return (flags & F_HAS_ALL_FATTR) != 0;
13581360
}
13591361

1362+
#ifdef LEGACY_EXEC
13601363
void MCBlock::setatts(Properties which, void *value)
13611364
{
13621365
// MW-2012-05-04: [[ Values ]] linkText / imageSource / metaData are now uniqued
@@ -1522,6 +1525,7 @@ void MCBlock::setatts(Properties which, void *value)
15221525
atts = nil;
15231526
}
15241527
}
1528+
#endif
15251529

15261530
Boolean MCBlock::getshift(int2 &out)
15271531
{
@@ -2017,6 +2021,7 @@ void MCBlock::exportattrs(MCFieldCharacterStyle& x_style)
20172021
// those described by the style struct.
20182022
void MCBlock::importattrs(const MCFieldCharacterStyle& p_style)
20192023
{
2024+
MCExecContext ctxt(nil, nil, nil);
20202025
if (p_style . has_text_color)
20212026
{
20222027
MCColor t_color;
@@ -2032,17 +2037,24 @@ void MCBlock::importattrs(const MCFieldCharacterStyle& p_style)
20322037
setbackcolor(&t_color);
20332038
}
20342039
if (p_style . has_link_text)
2035-
setatts(P_LINK_TEXT, (void *)p_style . link_text);
2040+
SetLinktext(ctxt, p_style . link_text);
20362041
if (p_style . has_image_source)
2037-
setatts(P_IMAGE_SOURCE, (void *)p_style . image_source);
2042+
SetImageSource(ctxt, p_style . image_source);
20382043
if (p_style . has_metadata)
2039-
setatts(P_METADATA, (void *)p_style . metadata);
2044+
SetMetadata(ctxt, p_style . metadata);
20402045
if (p_style . has_text_font)
2041-
setatts(P_TEXT_FONT, (void *)MCNameGetCString(p_style . text_font));
2046+
SetTextFont(ctxt, MCNameGetString(p_style . text_font));
20422047
if (p_style . has_text_style)
2043-
setatts(P_TEXT_STYLE, (void *)p_style . text_style);
2044-
if (p_style . has_text_size)
2045-
setatts(P_TEXT_SIZE, (void *)p_style . text_size);
2048+
{
2049+
MCInterfaceTextStyle t_style;
2050+
t_style . style = p_style . text_style;
2051+
SetTextStyle(ctxt, t_style);
2052+
}
2053+
if (p_style . has_text_size)
2054+
{
2055+
uinteger_t t_size = p_style . text_size;
2056+
SetTextSize(ctxt, &t_size);
2057+
}
20462058
// MW-2012-05-09: [[ Bug ]] Setting the textShift of a block is done with 'setshift'
20472059
// not 'setatts'.
20482060
if (p_style . has_text_shift)

engine/src/block.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ class MCBlock : public MCDLlist
139139
// MW-2012-03-04: [[ StackFile5500 ]] Measure the size of the serialized attributes.
140140
uint32_t measureattrs(void);
141141

142+
#ifdef LEGACY_EXEC
142143
void setatts(Properties which, void *value);
144+
#endif
143145
Boolean getshift(int2 &out);
144146
void setshift(int2 in);
145147
Boolean getcolor(const MCColor *&color);

engine/src/fieldh.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3737

3838
//#include "textbuffer.h"
3939
#include "variable.h"
40+
#include "exec-interface.h"
4041

4142
////////////////////////////////////////////////////////////////////////////////
4243

@@ -994,17 +995,17 @@ bool MCField::converttoparagraphs(void *p_context, const MCTextParagraph *p_para
994995
t_block -> setbackcolor(&t_color);
995996
}
996997

998+
MCExecContext ctxt(nil, nil, nil);
999+
9971000
if (p_block -> text_shift != 0)
9981001
t_block -> setshift(p_block -> text_shift);
9991002

10001003
if (p_block -> text_link != nil)
1001-
t_block -> setatts(P_LINK_TEXT, (void *)MCNameGetCString(p_block -> text_link));
1004+
t_block -> SetLinktext(ctxt, MCNameGetString(p_block -> text_link));
10021005

10031006
if (p_block -> text_metadata != nil)
10041007
{
1005-
MCAutoPointer<char> t_metadata;
1006-
/* UNCHECKED */ MCStringConvertToCString(p_block -> text_metadata, &t_metadata);
1007-
t_block -> setatts(P_METADATA, (void *)*t_metadata);
1008+
t_block -> SetMetadata(ctxt, p_block -> text_metadata);
10081009
}
10091010

10101011
const char *t_font_name;
@@ -1018,14 +1019,23 @@ bool MCField::converttoparagraphs(void *p_context, const MCTextParagraph *p_para
10181019
t_font_name = t_derived_font_name;
10191020
#endif
10201021

1021-
t_block -> setatts(P_TEXT_FONT, (void *)t_font_name);
1022+
MCAutoStringRef t_font_name_ref;
1023+
MCStringCreateWithCString(t_font_name, &t_font_name_ref);
1024+
t_block -> SetTextFont(ctxt, *t_font_name_ref);
10221025

10231026
if (p_block -> font_size != 0)
1024-
t_block -> setatts(P_TEXT_SIZE, (void *)p_block -> font_size);
1027+
{
1028+
uinteger_t t_size;
1029+
t_size = p_block -> font_size;
1030+
t_block -> SetTextSize(ctxt, &t_size);
1031+
}
10251032

10261033
if (p_block -> font_style != 0)
1027-
t_block -> setatts(P_TEXT_STYLE, (void *)p_block -> font_style);
1028-
1034+
{
1035+
MCInterfaceTextStyle t_style;
1036+
t_style . style = p_block -> font_style;
1037+
t_block -> SetTextStyle(ctxt, t_style);
1038+
}
10291039
}
10301040

10311041
return true;

engine/src/fieldstyledtext.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3333

3434
#include "globals.h"
3535
#include "unicode.h"
36+
#include "exec-interface.h"
3637

3738
////////////////////////////////////////////////////////////////////////////////
3839

@@ -620,7 +621,7 @@ void MCField::parsestyledtextappendblock(MCParagraph *p_paragraph, MCArrayRef p_
620621

621622
// Set metadata
622623
if (p_metadata != nil)
623-
t_block -> setatts(P_METADATA, (void *)p_metadata);
624+
t_block -> SetMetadata(ctxt, p_metadata);
624625

625626
if (p_style == nil)
626627
return;
@@ -667,17 +668,17 @@ void MCField::parsestyledtextappendblock(MCParagraph *p_paragraph, MCArrayRef p_
667668
if (!MCValueIsEmpty(t_valueref))
668669
{
669670
MCAutoStringRef t_string;
670-
/* UNCHECKED */ ctxt . ConvertToString(t_valueref, &t_string);
671-
MCAutoPointer<char> temp;
672-
/* UNCHECKED */ MCStringConvertToCString(*t_string, &temp);
673-
t_block -> setatts(P_TEXT_FONT, (void *)*temp);
671+
/* UNCHECKED */ ctxt . ConvertToString(t_valueref, &t_string);
672+
t_block -> SetTextFont(ctxt, *t_string);
674673
}
675674

676675
// Set textsize
677676
{
678677
MCAutoNumberRef t_number;
678+
uinteger_t t_size;
679679
convert_array_value_to_number_if_non_empty(ctxt, p_style, MCNAME("textSize"), &t_number);
680-
t_block -> setatts(P_TEXT_SIZE, (void *)MCNumberFetchAsInteger(*t_number));
680+
t_size = MCNumberFetchAsUnsignedInteger(*t_number);
681+
t_block -> SetTextSize(ctxt, &t_size);
681682
}
682683

683684
// Set textstyle
@@ -689,23 +690,29 @@ void MCField::parsestyledtextappendblock(MCParagraph *p_paragraph, MCArrayRef p_
689690
MCAutoStringRef fname;
690691
uint2 height;
691692
uint2 size;
692-
uint2 style;
693+
uint2 style;
693694

694695
MCF_parsetextatts(P_TEXT_STYLE, *t_string, flags, &fname, height, size, style);
695696

696-
t_block -> setatts(P_TEXT_STYLE, (void *)style);
697+
MCInterfaceTextStyle t_style;
698+
t_style . style;
699+
t_block -> SetTextStyle(ctxt, t_style);
697700
}
698701

699702
// Set linktext
700703
if (MCArrayFetchValue(p_style, false, MCNAME("linkText"), t_valueref))
701704
{
702-
t_block -> setatts(P_LINK_TEXT, (void *)t_valueref);
705+
MCAutoStringRef t_string;
706+
if (ctxt . ConvertToString(t_valueref, &t_string))
707+
t_block -> SetLinktext(ctxt, *t_string);
703708
}
704709

705710
// Set imagesource
706711
if (MCArrayFetchValue(p_style, false, MCNAME("imageSource"), t_valueref))
707712
{
708-
t_block -> setatts(P_IMAGE_SOURCE, (void *)t_valueref);
713+
MCAutoStringRef t_string;
714+
if (ctxt . ConvertToString(t_valueref, &t_string))
715+
t_block -> SetImageSource(ctxt, *t_string);
709716
}
710717

711718
}

engine/src/paragraf.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,9 +1556,10 @@ MCBlock *MCParagraph::indextoblock(findex_t tindex, Boolean forinsert)
15561556
// first
15571557
if (t_block == blocks)
15581558
{
1559+
MCExecContext ctxt(nil, nil, nil);
15591560
MCBlock *t_new_block;
15601561
t_new_block = new MCBlock(*t_block);
1561-
t_new_block -> setatts(P_IMAGE_SOURCE, (void *)kMCEmptyString);
1562+
t_new_block -> SetImageSource(ctxt, kMCEmptyString);
15621563

15631564
// MW-2012-02-14: [[ FontRefs ]] If the block is open, pass in the parent's
15641565
// fontref so it can compute its.
@@ -1583,9 +1584,10 @@ MCBlock *MCParagraph::indextoblock(findex_t tindex, Boolean forinsert)
15831584
// then we may need to insert a new block if there are no more.
15841585
if (t_block -> next() == blocks)
15851586
{
1587+
MCExecContext ctxt(nil, nil, nil);
15861588
MCBlock *t_new_block;
15871589
t_new_block = new MCBlock(*t_block);
1588-
t_new_block -> setatts(P_IMAGE_SOURCE, (void *)kMCEmptyString);
1590+
t_new_block -> SetImageSource(ctxt, kMCEmptyString);
15891591

15901592
// MW-2012-02-14: [[ FontRefs ]] If the block is open, pass in the parent's
15911593
// fontref so it can compute its.

0 commit comments

Comments
 (0)