@@ -1300,65 +1300,6 @@ void MCBitmapEffectsComputeBounds(MCBitmapEffectsRef self, const MCRectangle& p_
13001300
13011301// //////////////////////////////////////////////////////////////////////////////
13021302
1303- static bool MCBitmapEffectLookup (MCBitmapEffectsRef& self, MCNameRef p_prop, MCBitmapEffectType p_type, MCBitmapEffectProperty& r_prop, MCBitmapEffect*& r_effect)
1304- {
1305- // Now fetch the bitmap effect we are processing - note that if this is
1306- // NULL it means it isn't set. In this case we still carry on since we
1307- // need to report a invalid key error (if applicable).
1308- MCBitmapEffect *t_effect;
1309- if (self != nil && (self -> mask & (1 << p_type)) != 0 )
1310- r_effect = &self -> effects[p_type];
1311- else
1312- r_effect = nil;
1313-
1314- if (MCBitmapEffectLookupProperty (p_type, p_prop, r_prop) != ES_NORMAL)
1315- return false ;
1316-
1317- return true ;
1318- }
1319-
1320-
1321- static bool MCBitmapEffectLookupForSet (MCBitmapEffectsRef& self, MCNameRef p_prop, MCBitmapEffectType p_type, MCBitmapEffectProperty& r_prop, MCBitmapEffect& r_effect, bool & r_dirty)
1322- {
1323- // Now fetch the bitmap effect we are processing - note that if this is
1324- // NULL it means it isn't set. In this case we still carry on since we
1325- // need to report a invalid key error (if applicable).
1326- if (self != nil && (self -> mask & (1 << p_type)) != 0 )
1327- {
1328- r_effect = self -> effects[p_type];
1329- r_dirty = false ;
1330- }
1331- else
1332- {
1333- MCBitmapEffectDefault (&r_effect, p_type);
1334- // If the effect doesn't yet exist, it means we will dirty the object
1335- // regardless.
1336- r_dirty = true ;
1337- }
1338-
1339- // Lookup the property and ensure it is appropriate for our type.
1340- if (MCBitmapEffectLookupProperty (p_type, p_prop, r_prop) != ES_NORMAL)
1341- return false ;
1342- }
1343-
1344- static bool MCBitmapEffectCommitChanges (MCBitmapEffectsRef& self, MCBitmapEffectType p_type, MCBitmapEffect p_new_effect)
1345- {
1346- // If we are currently empty, then allocate a new object
1347- if (self == nil)
1348- {
1349- self = new MCBitmapEffects;
1350- if (self == nil)
1351- return false ;
1352-
1353- // Only need to initialize the mask.
1354- self -> mask = 0 ;
1355- }
1356-
1357- // Now copy in the updated effect.
1358- self -> mask |= (1 << p_type);
1359- self -> effects[p_type] = p_new_effect;
1360- }
1361-
13621303static void MCBitmapEffectFetchProperty (MCExecContext& ctxt, MCBitmapEffect *effect, MCBitmapEffectProperty p_prop, MCExecValue& r_value)
13631304{
13641305 if (effect == nil)
@@ -1428,9 +1369,6 @@ static void MCBitmapEffectFetchProperty(MCExecContext& ctxt, MCBitmapEffect *eff
14281369
14291370bool MCBitmapEffectsGetProperty (MCExecContext& ctxt, MCBitmapEffectsRef& self, MCNameRef p_index, Properties which, MCExecValue& r_value)
14301371{
1431- MCBitmapEffectProperty t_prop;
1432- MCBitmapEffect* effect;
1433-
14341372 // First map the property type
14351373 MCBitmapEffectType t_type;
14361374 t_type = (MCBitmapEffectType)(which - P_BITMAP_EFFECT_DROP_SHADOW);
@@ -1439,45 +1377,56 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
14391377 bool t_is_array;
14401378 t_is_array = MCNameIsEqualTo (p_index, kMCEmptyName , kMCCompareCaseless );
14411379
1442- if (MCBitmapEffectLookup (self, p_index, t_type, t_prop, effect))
1380+ // Now fetch the bitmap effect we are processing - note that if this is
1381+ // NULL it means it isn't set. In this case we still carry on since we
1382+ // need to report a invalid key error (if applicable).
1383+ MCBitmapEffect *t_effect;
1384+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
1385+ t_effect = &self -> effects[t_type];
1386+ else
1387+ t_effect = nil;
1388+
1389+ MCBitmapEffectProperty t_prop;
1390+ if (!MCNameIsEmpty (p_index) && MCBitmapEffectLookupProperty (t_type, p_index, t_prop) != ES_NORMAL)
1391+ return false ;
1392+
1393+ if (t_is_array)
14431394 {
1444- if (t_is_array )
1395+ if (t_effect == nil )
14451396 {
1446- if (effect == nil)
1447- {
1448- r_value . arrayref_value = MCValueRetain (kMCEmptyArray );
1449- r_value . type = kMCExecValueTypeArrayRef ;
1450- return true ;
1451- }
1452-
1453- // Otherwise we have an array get, so first create a new value
1454- MCAutoArrayRef v;
1455- if (MCArrayCreateMutable (&v))
1397+ r_value . stringref_value = MCValueRetain (kMCEmptyString );
1398+ r_value . type = kMCExecValueTypeStringRef ;
1399+ return true ;
1400+ }
1401+
1402+ // Otherwise we have an array get, so first create a new value
1403+ MCAutoArrayRef v;
1404+ if (MCArrayCreateMutable (&v))
1405+ {
1406+ // Now loop through all the properties, getting the ones applicable to this type.
1407+ for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
14561408 {
1457- // Now loop through all the properties, getting the ones applicable to this type.
1458- for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
1409+ if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
14591410 {
1460- if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
1461- {
1462- MCExecValue t_value;
1463- MCAutoValueRef t_valueref;
1464- // Fetch the property, then store it into the array.
1465- MCBitmapEffectFetchProperty (ctxt, effect, s_bitmap_effect_properties[i] . value, t_value);
1466- MCExecTypeConvertAndReleaseAlways (ctxt, t_value . type, &t_value . type + 1 , kMCExecValueTypeValueRef , &(&t_valueref));
1467- MCArrayStoreValue (*v, ctxt . GetCaseSensitive (), MCNAME (s_bitmap_effect_properties[i] . token), *t_valueref);
1468- }
1411+ MCExecValue t_value;
1412+ MCAutoValueRef t_valueref;
1413+ // Fetch the property, then store it into the array.
1414+ MCBitmapEffectFetchProperty (ctxt, t_effect, s_bitmap_effect_properties[i] . value, t_value);
1415+ MCExecTypeConvertAndReleaseAlways (ctxt, t_value . type, &t_value . type + 1 , kMCExecValueTypeValueRef , &(&t_valueref));
1416+ MCArrayStoreValue (*v, ctxt . GetCaseSensitive (), MCNAME (s_bitmap_effect_properties[i] . token), *t_valueref);
14691417 }
1470- r_value . arrayref_value = MCValueRetain (*v);
1471- r_value . type = kMCExecValueTypeArrayRef ;
1472- return true ;
14731418 }
1474- }
1475- else
1476- {
1477- MCBitmapEffectFetchProperty (ctxt, effect, t_prop, r_value);
1419+ r_value . arrayref_value = MCValueRetain (*v);
1420+ r_value . type = kMCExecValueTypeArrayRef ;
14781421 return true ;
14791422 }
14801423 }
1424+ else
1425+ {
1426+ MCBitmapEffectFetchProperty (ctxt, t_effect, t_prop, r_value);
1427+ return true ;
1428+ }
1429+
14811430 return false ;
14821431}
14831432
@@ -1654,9 +1603,6 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
16541603 // First map the property type
16551604 MCBitmapEffectType t_type;
16561605 t_type = (MCBitmapEffectType)(which - P_BITMAP_EFFECT_DROP_SHADOW);
1657-
1658- MCBitmapEffectProperty t_prop;
1659- MCBitmapEffect effect;
16601606
16611607 // If 'p_index' is the empty name, this is a whole array op.
16621608 bool t_is_array;
@@ -1680,48 +1626,82 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
16801626 return true ;
16811627 }
16821628
1629+ MCBitmapEffectProperty t_prop;
1630+ MCBitmapEffect effect;
16831631 bool t_dirty;
1684- if (MCBitmapEffectLookupForSet (self, p_index, t_type, t_prop, effect, t_dirty))
1632+
1633+ // Now fetch the bitmap effect we are processing - note that if this is
1634+ // NULL it means it isn't set. In this case we still carry on since we
1635+ // need to report a invalid key error (if applicable).
1636+ if (self != nil && (self -> mask & (1 << t_type)) != 0 )
16851637 {
1686- if (t_is_array)
1687- {
1688- bool t_dirty_array;
1689- t_dirty_array = false ;
1690- MCAutoArrayRef t_array;
1691- MCExecTypeConvertAndReleaseAlways (ctxt, p_value . type, &p_value . type + 1 , kMCExecValueTypeArrayRef , &(&t_array));
1692- // Loop through all the properties in the table and apply the relevant
1693- // ones.
1694- for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
1695- if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
1696- {
1697- MCValueRef t_prop_value;
1698- MCNewAutoNameRef t_key;
1699-
1700- /* UNCHECKED */ MCNameCreateWithCString (s_bitmap_effect_properties[i] . token, &t_key);
1701- // If we don't have the given element, then move to the next one
1702- if (!MCArrayFetchValue (*t_array, kMCCompareExact , *t_key, t_prop_value))
1703- continue ;
1704-
1705- // Otherwise, fetch the keys value and attempt to set the property
1706- MCExecValue t_value;
1707- t_value . valueref_value = MCValueRetain (t_prop_value);
1708- t_value . type = kMCExecValueTypeValueRef ;
1709- MCBitmapEffectStoreProperty (ctxt, effect, s_bitmap_effect_properties[i] . value, t_value, t_dirty_array);
1710- }
1711- if (t_dirty_array)
1712- t_dirty = true ;
1713-
1714- }
1715- else
1716- MCBitmapEffectStoreProperty (ctxt, effect, t_prop, p_value, t_dirty);
1638+ effect = self -> effects[t_type];
1639+ t_dirty = false ;
1640+ }
1641+ else
1642+ {
1643+ MCBitmapEffectDefault (&effect, t_type);
1644+ // If the effect doesn't yet exist, it means we will dirty the object
1645+ // regardless.
1646+ t_dirty = true ;
1647+ }
1648+
1649+ // Lookup the property and ensure it is appropriate for our type.
1650+ if (!MCNameIsEmpty (p_index) && MCBitmapEffectLookupProperty (t_type, p_index, t_prop) != ES_NORMAL)
1651+ return false ;
1652+
1653+ if (t_is_array)
1654+ {
1655+ bool t_dirty_array;
1656+ t_dirty_array = false ;
1657+ MCAutoArrayRef t_array;
1658+ MCExecTypeConvertAndReleaseAlways (ctxt, p_value . type, &p_value . type + 1 , kMCExecValueTypeArrayRef , &(&t_array));
1659+ // Loop through all the properties in the table and apply the relevant
1660+ // ones.
1661+ for (uint32_t i = 0 ; i < ELEMENTS (s_bitmap_effect_properties); i++)
1662+ if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0 )
1663+ {
1664+ MCValueRef t_prop_value;
1665+ MCNewAutoNameRef t_key;
1666+
1667+ /* UNCHECKED */ MCNameCreateWithCString (s_bitmap_effect_properties[i] . token, &t_key);
1668+ // If we don't have the given element, then move to the next one
1669+ if (!MCArrayFetchValue (*t_array, kMCCompareExact , *t_key, t_prop_value))
1670+ continue ;
1671+
1672+ // Otherwise, fetch the keys value and attempt to set the property
1673+ MCExecValue t_value;
1674+ t_value . valueref_value = MCValueRetain (t_prop_value);
1675+ t_value . type = kMCExecValueTypeValueRef ;
1676+ MCBitmapEffectStoreProperty (ctxt, effect, s_bitmap_effect_properties[i] . value, t_value, t_dirty_array);
1677+ }
1678+ if (t_dirty_array)
1679+ t_dirty = true ;
17171680
1718- if (!t_dirty || MCBitmapEffectCommitChanges (self, t_type, effect))
1681+ }
1682+ else
1683+ MCBitmapEffectStoreProperty (ctxt, effect, t_prop, p_value, t_dirty);
1684+
1685+ if (t_dirty)
1686+ {
1687+ // If we are currently empty, then allocate a new object
1688+ if (self == nil)
17191689 {
1720- r_dirty = t_dirty;
1721- return true ;
1690+ self = new MCBitmapEffects;
1691+ if (self == nil)
1692+ return false ;
1693+
1694+ // Only need to initialize the mask.
1695+ self -> mask = 0 ;
17221696 }
1697+
1698+ // Now copy in the updated effect.
1699+ self -> mask |= (1 << t_type);
1700+ self -> effects[t_type] = effect;
17231701 }
1724- return false ;
1702+
1703+ r_dirty = t_dirty;
1704+ return true ;
17251705}
17261706
17271707// //////////////////////////////////////////////////////////////////////////////
0 commit comments