MCReferencedImageRep::~MCReferencedImageRep() { MCValueRelease(m_file_name); MCValueRelease(m_search_key); MCMemoryDeallocate(m_url_data); }
MCPlayer::~MCPlayer() { removefromplayers(); MCValueRelease(filename); MCValueRelease(userCallbackStr); }
RTFReader::~RTFReader(void) { MCValueRelease(m_attributes . text_link); MCValueRelease(m_attributes . text_metadata); if (m_font_name != NULL) free(m_font_name); if (m_field_inst != NULL) free(m_field_inst); }
MCScreenDC::~MCScreenDC() { MCNotifyFinalize(); showtaskbar(); while (opened) close(True); if (ncolors != 0) { uint2 i; for (i = 0 ; i < ncolors ; i++) { if (colornames[i] != NULL) MCValueRelease(colornames[i]); } delete colors; delete colornames; delete allocs; } while (pendingevents != NULL) { MCEventnode *tptr =(MCEventnode *)pendingevents->remove(pendingevents); delete tptr; } }
static void getfilter(MCStringRef p_filter, MCStringRef &r_filter) { if (p_filter != nil && !MCStringIsEmpty(p_filter)) { static MCAutoStringRef t_filterstring; if (*t_filterstring != nil) MCValueRelease(*t_filterstring); /* UNCHECKED */ MCStringMutableCopy(p_filter, &t_filterstring); uindex_t t_offset; if (!MCStringFirstIndexOfChar(*t_filterstring, '\n', 0, kMCStringOptionCompareExact, t_offset) && !MCStringFirstIndexOfChar(*t_filterstring, ',', 0, kMCStringOptionCompareExact, t_offset)) { MCStringAppendChar(*t_filterstring, '\0'); MCStringAppend(*t_filterstring, p_filter); } /* UNCHECKED */ MCStringAppendChar(*t_filterstring, '\0'); /* UNCHECKED */ MCStringFindAndReplaceChar(*t_filterstring, '\n', '\0', kMCStringOptionCompareExact); /* UNCHECKED */ MCStringFindAndReplaceChar(*t_filterstring, ',', '\0', kMCStringOptionCompareExact); MCStringCopy(*t_filterstring, r_filter); } else /* UNCHECKED */ MCStringCreateWithNativeChars((const char_t *)"All Files (*.*)\0*.*\0", 20, r_filter); }
size_t regerror(int errcode, const regex_t *preg, MCStringRef &errbuf) { const char *message, *addmessage; size_t length, addlength; message = (errcode >= (int)(sizeof(pstring)/sizeof(char *))) ? "unknown error code" : pstring[errcode]; length = strlen(message) + 1; addmessage = " at offset "; addlength = (preg != NULL && (int)preg->re_erroffset != -1) ? strlen(addmessage) + 6 : 0; if (addlength > 0) { MCAutoStringRef t_error_string; MCStringFormat(&t_error_string, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset); MCValueAssign(errbuf, *t_error_string); } else { if (errbuf != nil) MCValueRelease(errbuf); /* UNCHECKED */ MCStringCreateWithNativeChars((const char_t *) message, strlen(message), errbuf); } return length + addlength; }
MCExternalHandlerList::~MCExternalHandlerList(void) { for(uint32_t i = 0; i < m_externals . Count(); i++) MCExternal::Unload(m_externals[i]); for(uint32_t i = 0; i < m_handlers . Count(); i++) MCValueRelease(m_handlers[i] . name); }
void MCButton::SetStyle(MCExecContext& ctxt, intenum_t p_style) { flags &= ~(F_STYLE | F_DISPLAY_STYLE | F_ALIGNMENT); if (entry != NULL) deleteentry(); switch (p_style) { case kMCButtonStyleStandard: flags |= F_STANDARD | F_SHOW_BORDER | F_OPAQUE | F_ALIGN_CENTER | F_HILITE_BOTH | F_ARM_BORDER; break; case kMCButtonStyleMenu: case kMCButtonStylePopup: flags |= F_MENU | F_SHOW_BORDER | F_OPAQUE | F_ALIGN_CENTER | F_ARM_BORDER; if (menumode == WM_COMBO) createentry(); if (menumode == WM_TOP_LEVEL) { MCValueRelease(tabs); /* UNCHECKED */ MCStringSplit(menustring, MCSTR("\n"), nil, kMCStringOptionCompareExact, tabs); } break; case kMCButtonStyleCheck: flags |= F_CHECK | F_ALIGN_LEFT; break; case kMCButtonStyleRadio: flags |= F_RADIO | F_ALIGN_LEFT; flags &= ~F_SHARED_HILITE; break; case kMCButtonStyleRoundrect: flags |= F_ROUNDRECT | F_SHOW_BORDER | F_OPAQUE | F_ALIGN_CENTER | F_HILITE_FILL; break; case kMCButtonStyleRectangle: flags |= F_RECTANGLE | F_SHOW_BORDER | F_OPAQUE | F_ALIGN_CENTER | F_HILITE_BOTH | F_ARM_BORDER; break; case kMCButtonStyleOval: flags |= F_OVAL_BUTTON | F_HILITE_FILL; break; case kMCButtonStyleTransparent: flags |= F_STANDARD | F_ALIGN_CENTER; break; case kMCButtonStyleShadow: flags |= F_STANDARD | F_SHOW_BORDER | F_OPAQUE | F_SHADOW | F_ALIGN_CENTER | F_HILITE_BOTH | F_ARM_BORDER; break; case kMCButtonStyleShowBorder: flags |= F_STANDARD | F_OPAQUE | F_ALIGN_CENTER | F_HILITE_FILL | F_ARM_BORDER; break; default: break; } // MW-2011-09-21: [[ Layers ]] Make sure the layerattrs are recomputed. m_layer_attr_changed = true; Redraw(); }
void MCButton::GetEffectiveUnicodeLabel(MCExecContext& ctxt, MCDataRef& r_label) { MCStringRef t_label = nil; GetEffectiveLabel(ctxt, t_label); if (MCStringEncodeAndRelease(t_label, kMCStringEncodingUTF16, false, r_label)) return; MCValueRelease(t_label); ctxt.Throw(); }
void MCR_free(regexp *prog) { if (prog) { regfree(&prog->rexp); // MW-2013-07-01: [[ EnhancedFilter ]] Release the pattern. MCValueRelease(prog->pattern); delete prog; } }
// JS-2013-07-01: [[ EnhancedFilter ]] Updated to support case-sensitivity and caching. // MW-2013-07-01: [[ EnhancedFilter ]] Tweak to take 'const char *' and copy pattern as required. // MW-2013-07-01: [[ EnhancedFilter ]] Removed 'usecache' parameter as there's // no reason not to use the cache. regexp *MCR_compile(MCStringRef exp, bool casesensitive) { Boolean found = False; regexp *re = nil; int flags = REG_EXTENDED; if (!casesensitive) flags |= REG_ICASE; // Search the cache. uint2 i; for (i = 0 ; i < PATTERN_CACHE_SIZE ; i++) { if (MCregexcache[i] && MCStringIsEqualTo(exp, MCregexcache[i]->pattern, casesensitive ? kMCStringOptionCompareExact : kMCStringOptionCompareCaseless) && flags == MCregexcache[i]->flags) { found = True; re = MCregexcache[i]; break; } } // If the pattern isn't found with the given flags, then create a new one. if (re == nil) { /* UNCHECKED */ re = new regexp; /* UNCHECKED */ re->pattern = MCValueRetain(exp); re->flags = flags; int status; status = regcomp(&re->rexp, exp, flags); if (status != REG_OKAY) { regerror(status, nil, regexperror); MCValueRelease(re->pattern); delete re; return(nil); } } // If the pattern is new, put it in the cache. if (!found) { uint2 i; MCR_free(MCregexcache[PATTERN_CACHE_SIZE - 1]); for (i = PATTERN_CACHE_SIZE - 1 ; i ; i--) { MCregexcache[i] = MCregexcache[i - 1]; } MCregexcache[0] = re; } return re; }
static bool __MCValueInter(__MCValue *self, bool p_release, MCValueRef& r_unique_self) { // Compute the hash code for the value. hash_t t_hash; t_hash = MCValueHash(self); // See if the value is already in the table. uindex_t t_target_slot; t_target_slot = __MCValueFindUniqueValueBucket(self, t_hash); // If a slot wasn't found, then rehash. if (t_target_slot == UINDEX_MAX) { if (!__MCValueRehashUniqueValues(1)) return false; t_target_slot = __MCValueFindUniqueValueBucketAfterRehash(self, t_hash); } // If we still don't have a slot then just fail (this could happen if // memory is exhausted). if (t_target_slot == UINDEX_MAX) return false; // If the slot is not empty and not deleted then take that value. if (s_unique_values[t_target_slot] . value != UINTPTR_MIN && s_unique_values[t_target_slot] . value != UINTPTR_MAX) { if (p_release) MCValueRelease(self); r_unique_self = MCValueRetain((MCValueRef)s_unique_values[t_target_slot] . value); return true; } // Otherwise we must first ensure we have an immutable version of the // value and then insert it into the table. if (!__MCValueImmutableCopy(self, p_release, self)) return false; self -> flags |= kMCValueFlagIsInterred; s_unique_values[t_target_slot] . hash = t_hash; s_unique_values[t_target_slot] . value = (uintptr_t)self; s_unique_value_count += 1; // Finally return the value in the target slot. r_unique_self = self; return true; }
void __MCValueFinalize(void) { for(uindex_t i = 0; i < sizeof(s_value_pools) / sizeof(s_value_pools[0]); i++) while(s_value_pools[i] . count > 0) { __MCValue *t_value; t_value = s_value_pools[i] . values; s_value_pools[i] . values = *(__MCValue **)t_value; s_value_pools[i] . count -= 1; MCMemoryDelete(t_value); } MCMemoryDeleteArray(s_unique_values); s_unique_values = nil; MCValueRelease(kMCFalse); kMCFalse = nil; MCValueRelease(kMCTrue); kMCTrue = nil; MCValueRelease(kMCNull); kMCNull = nil; }
void MCSessionDisposeIndex(MCSessionIndexRef p_index) { if (p_index == NULL) return; MCValueRelease(p_index->save_path); if (p_index->session != NULL) { for (uint32_t i = 0; i < p_index->session_count; i++) { MCSessionDisposeSession(p_index->session[i]); } } MCMemoryDelete(p_index); }
void MCPurchaseFinalize(MCPurchase *p_purchase) { if (p_purchase == nil) return; MCAndroidPurchase *t_android_data = (MCAndroidPurchase*)p_purchase->platform_data; if (t_android_data == nil) return; MCValueRelease(t_android_data->product_id); MCValueRelease(t_android_data->developer_payload); MCValueRelease(t_android_data->signed_data); MCValueRelease(t_android_data->signature); MCValueRelease(t_android_data->notification_id); MCValueRelease(t_android_data->order_id); MCValueRelease(t_android_data->error); MCMemoryDelete(t_android_data); }
void MCButton::SetMenuMode(MCExecContext& ctxt, intenum_t p_mode) { if (entry != nil) deleteentry(); else freemenu(False); setmenumode((uint1)p_mode); if (p_mode == WM_COMBO) createentry(); else if (p_mode == WM_TOP_LEVEL) { if (getstyleint(flags) == F_MENU) { MCValueRelease(tabs); /* UNCHECKED */ MCStringSplit(menustring, MCSTR("\n"), nil, kMCStringOptionCompareExact, tabs); } } Redraw(); }
void RTFReader::ProcessField(void) { if (m_field_inst == nil) return; char *t_type, *t_data; t_type = m_field_inst; while(isspace(*t_type)) t_type++; t_data = strchr(t_type, ' '); if (t_data != nil) { char *t_type_end; t_type_end = t_data; while(isspace(*t_data)) t_data++; *t_type_end = '\0'; if (*t_data == '"') { char *t_data_end; t_data += 1; t_data_end = t_data; while(*t_data_end != '\0' && *t_data_end != '\"') t_data_end++; if (*t_data_end == '\"') *t_data_end = '\0'; else t_data = nil; } else t_data = nil; } if (t_type != nil && t_data != nil) { MCNameRef t_name; /* UNCHECKED */ MCNameCreateWithNativeChars((const char_t *)t_data, strlen(t_data), t_name); MCAutoStringRef t_string; /* UNCHECKED */ MCStringCreateWithCString(t_data, &t_string); if (MCU_strcasecmp(t_type, "HYPERLINK") == 0) { m_state . SetHyperlink(t_name); m_state . SetFontStyle(m_state . GetFontStyle() | kRTFFontStyleLink); } else if (MCU_strcasecmp(t_type, "LCANCHOR") == 0) { m_state . SetHyperlink(t_name); } else if (MCU_strcasecmp(t_type, "LCMETADATA") == 0) { m_state . SetMetadata(*t_string); } else if (MCU_strcasecmp(t_type, "LCLINEMETADATA") == 0) { m_state . SetParagraphMetadata(*t_string); } MCValueRelease(t_name); } free(m_field_inst); m_field_inst = nil; }
~MCSensorErrorEvent() { MCValueRelease(m_error); }
void MCLicenseSetRevLicenseLimits(MCExecContext& ctxt, MCArrayRef p_settings) { if(!MCenvironmentactive) return; bool t_case_sensitive = ctxt . GetCaseSensitive(); MCValueRef t_value; MCStringRef t_string; if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("token"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease(MClicenseparameters . license_token); MClicenseparameters . license_token = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("name"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease(MClicenseparameters . license_name); MClicenseparameters . license_name = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("organization"), t_value) && ctxt . ConvertToString(t_value, t_string)) { MCValueRelease( MClicenseparameters . license_organization); MClicenseparameters . license_organization = t_string; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("class"), t_value)) { MCAutoStringRef t_class; MCLicenseClass t_license_class; if (ctxt . ConvertToString(t_value, &t_class) && MCStringToLicenseClass(*t_class, t_license_class)) { MClicenseparameters . license_class = t_license_class; } else MClicenseparameters . license_class = kMCLicenseClassNone; } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("multiplicity"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { MClicenseparameters . license_multiplicity = MCNumberFetchAsUnsignedInteger(*t_number); } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("scriptlimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . script_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("dolimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . do_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("usinglimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . using_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("insertlimit"), t_value)) { MCAutoNumberRef t_number; if (ctxt.ConvertToNumber(t_value, &t_number)) { integer_t t_limit; t_limit = MCNumberFetchAsInteger(*t_number); MClicenseparameters . insert_limit = t_limit <= 0 ? 0 : t_limit; } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("deploy"), t_value)) { static struct { const char *tag; uint32_t value; } s_deploy_map[] = { { "windows", kMCLicenseDeployToWindows }, { "macosx", kMCLicenseDeployToMacOSX }, { "linux", kMCLicenseDeployToLinux }, { "ios", kMCLicenseDeployToIOS }, { "android", kMCLicenseDeployToAndroid }, { "winmobile", kMCLicenseDeployToWinMobile }, { "meego", kMCLicenseDeployToLinuxMobile }, { "server", kMCLicenseDeployToServer }, { "ios-embedded", kMCLicenseDeployToIOSEmbedded }, { "android-embedded", kMCLicenseDeployToIOSEmbedded }, { "html5", kMCLicenseDeployToHTML5 }, { "filemaker", kMCLicenseDeployToFileMaker }, }; MClicenseparameters . deploy_targets = 0; MCAutoStringRef t_params; if (ctxt . ConvertToString(t_value, &t_params)) { MCAutoArrayRef t_split_strings; MCValueRef t_fetched_string; if (MCStringSplit(*t_params, MCSTR(","), nil, kMCCompareExact, &t_split_strings)) { for(uint32_t i = 0; i < MCArrayGetCount(*t_split_strings); i++) { // Fetch the string value created with MCStringSplit MCArrayFetchValueAtIndex(*t_split_strings, i+1, t_fetched_string); for(uint32_t j = 0; j < sizeof(s_deploy_map) / sizeof(s_deploy_map[0]); j++) if (MCStringIsEqualToCString((MCStringRef)t_fetched_string, s_deploy_map[j] . tag, kMCStringOptionCompareCaseless)) { MClicenseparameters . deploy_targets |= s_deploy_map[j] . value; break; } } } } } if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("addons"), t_value) && MCValueIsArray(t_value)) { MCValueRelease(MClicenseparameters . addons); MCArrayCopy((MCArrayRef)t_value, MClicenseparameters . addons); } }
void MCArraysExecSplitByColumn(MCExecContext& ctxt, MCStringRef p_string, MCArrayRef& r_array) { MCStringRef t_row_delim, t_column_delim; t_row_delim = ctxt . GetRowDelimiter(); t_column_delim = ctxt . GetColumnDelimiter(); // Output array MCAutoArrayRef t_array; if (!MCArrayCreateMutable(&t_array)) { ctxt . Throw(); return; } // Temporary array for storing columns MCAutoArray<MCStringRef> t_temp_array; // Iterate over the rows of the input string uindex_t t_offset, t_length; t_offset = 0; t_length = MCStringGetLength(p_string); bool t_success; t_success = true; uindex_t t_row_index; t_row_index = 0; while (t_success && t_offset < t_length) { // Find the end of this row MCRange t_row_found; if (!MCStringFind(p_string, MCRangeMake(t_offset, UINDEX_MAX), t_row_delim, ctxt . GetStringComparisonType(), &t_row_found)) { t_row_found . offset = t_length; t_row_found . length = 0; } // Iterate over the cells of this row uindex_t t_cell_offset, t_column_index; t_cell_offset = t_offset; t_column_index = 0; while (t_success && t_cell_offset <= t_row_found . offset) { // Find the end of this cell MCRange t_cell_found; if (!MCStringFind(p_string, MCRangeMake(t_cell_offset, UINDEX_MAX), t_column_delim, ctxt . GetStringComparisonType(), &t_cell_found) || t_cell_found . offset > t_row_found . offset) { t_cell_found . offset = t_row_found . offset; // AL-2014-08-04: [[ Bug 13090 ]] Make sure cell offset is incremented eventually when the delimiter is not found t_cell_found . length = 1; } // Check that the output array has a slot for this column if (t_temp_array.Size() <= t_column_index) t_temp_array.Extend(t_column_index + 1); // Check that a string has been created to store this column MCRange t_range; t_range = MCRangeMake(t_cell_offset, t_cell_found . offset - t_cell_offset); if (t_temp_array[t_column_index] == nil) { t_success = MCStringCreateMutable(0, t_temp_array[t_column_index]); // AL-2014-08-04: [[ Bug 13090 ]] If we are creating a new column, make sure we pad with empty cells 'above' this one uindex_t t_rows = t_row_index; while (t_success && t_rows--) t_success = MCStringAppend(t_temp_array[t_column_index], t_row_delim); if (t_success) t_success = MCStringAppendFormat(t_temp_array[t_column_index], "%*@", &t_range, p_string); } else { // AL-2014-06-12: [[ Bug 12610 ]] Range parameter to MCStringFormat must be a pointer to an MCRange t_success = MCStringAppendFormat(t_temp_array[t_column_index], "%@%*@", t_row_delim, &t_range, p_string); } // Next cell t_column_index++; t_cell_offset = t_cell_found . offset + t_cell_found . length; } // AL-2014-08-04: [[ Bug 13090 ]] Pad the rest of this row with empty cells index_t t_pad_number; t_pad_number = t_temp_array . Size() - t_column_index; if (t_success && t_pad_number > 0) { while (t_success && t_pad_number--) t_success = MCStringAppend(t_temp_array[t_column_index++], t_row_delim); } // Next row t_row_index++; t_offset = t_row_found . offset + t_row_found . length; } // Convert the temporary array into a "proper" array for (uindex_t i = 0; i < t_temp_array.Size() && t_success; i++) { t_success = MCArrayStoreValueAtIndex(*t_array, i + 1, t_temp_array[i]); MCValueRelease(t_temp_array[i]); } if (t_success) t_success = MCArrayCopy(*t_array, r_array); if (!t_success) ctxt . Throw(); }
IO_stat MCImage::import(MCStringRef newname, IO_handle stream, IO_handle mstream) { bool t_success = true; MCImageCompressedBitmap *t_compressed = nil; MCImageBitmap *t_bitmap = nil; MCStringRef t_name = nil; MCPoint t_hotspot = {1, 1}; t_success = MCImageImport(stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap); if (t_success) { if (t_compressed == nil) t_success = setbitmap(t_bitmap, 1.0); else t_success = setcompressedbitmap(t_compressed); } MCImageFreeCompressedBitmap(t_compressed); MCImageFreeBitmap(t_bitmap); uindex_t t_width, t_height; if (t_success) t_success = getsourcegeometry(t_width, t_height); if (t_success) { xhot = t_hotspot.x; yhot = t_hotspot.y; bool t_resize = true; t_resize = !(flags & F_LOCK_LOCATION); if (t_resize) { rect.width = t_width; rect.height = t_height; } if (m_rep->GetFrameCount() > 1) { if ((flags & F_REPEAT_COUNT) == 0) repeatcount = -1; irepeatcount = repeatcount; state |= CS_DO_START; } if (isunnamed() && t_name != nil) { MCNewAutoNameRef t_name_nameref; /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref); setname(*t_name_nameref); } if (isunnamed() && newname != nil) { MCNewAutoNameRef t_name_nameref; uindex_t t_offset; if (MCStringLastIndexOfChar(newname, PATH_SEPARATOR, UINDEX_MAX, kMCCompareExact, t_offset)) { /* UNCHECKED */ MCStringCopySubstring(newname, MCRangeMakeMinMax(t_offset + 1, MCStringGetLength(newname)), t_name); /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref); } else /* UNCHECKED */ MCNameCreate(newname, &t_name_nameref); setname(*t_name_nameref); } } MCValueRelease(t_name); return t_success ? IO_NORMAL : IO_ERROR; }
~MCWidgetPopup(void) { MCValueRelease(m_result); m_result = nil; }
RTFStatus RTFReader::Flush(bool p_force) { RTFStatus t_status; t_status = kRTFStatusSuccess; if (!m_attributes_changed && !p_force) return t_status; MCTextBlock t_block; bool t_changed; t_changed = false; if (m_attributes_changed) { t_block . foreground_color = m_state . GetForegroundColor(); t_block . background_color = m_state . GetBackgroundColor(); t_block . font_name = m_state . GetFontName(); if (m_state . GetFontSize() != 0) t_block . font_size = half_points_to_pixels(m_state . GetFontSize()); else t_block . font_size = 0; t_block . font_style = FA_DEFAULT_STYLE; if ((m_state . GetFontStyle() & kRTFFontStyleItalic) != 0) t_block . font_style |= FA_ITALIC; if ((m_state . GetFontStyle() & kRTFFontStyleBold) != 0) t_block . font_style |= FA_BOLD; if ((m_state . GetFontStyle() & kRTFFontStyleUnderline) != 0) t_block . font_style |= FA_UNDERLINE; if ((m_state . GetFontStyle() & kRTFFontStyleStrikethrough) != 0) t_block . font_style |= FA_STRIKEOUT; if ((m_state . GetFontStyle() & kRTFFontStyleLink) != 0) t_block . font_style |= FA_LINK; if ((m_state . GetFontStyle() & kRTFFontStyleSuperscript) != 0) t_block . text_shift = -4; else if ((m_state . GetFontStyle() & kRTFFontStyleSubscript) != 0) t_block . text_shift = 4; else t_block . text_shift = 0; if (m_state . GetHyperlink() != kMCEmptyName) MCNameClone(m_state . GetHyperlink(), t_block . text_link); else t_block . text_link = nil; if (m_state . GetMetadata() != kMCEmptyString) /* UNCHECKED */ MCStringCopy(m_state . GetMetadata(), t_block . text_metadata); else t_block . text_metadata = MCValueRetain(kMCEmptyString); t_block . string_native = false; t_block . string_buffer = NULL; t_block . string_length = 0; if (t_block . foreground_color != m_attributes . foreground_color || t_block . background_color != m_attributes . background_color || t_block . font_size != m_attributes . font_size || t_block . font_style != m_attributes . font_style || t_block . text_shift != m_attributes . text_shift || CStringCompare(t_block . font_name, m_attributes . font_name) != 0 || t_block . text_link != m_attributes . text_link || t_block . text_metadata != m_attributes . text_metadata) t_changed = true; } const uint2 *t_string_buffer; uint4 t_string_length; if (t_status == kRTFStatusSuccess) t_status = m_text . Borrow(t_string_buffer, t_string_length); if (t_status == kRTFStatusSuccess && t_string_length > 0 && (t_changed || p_force)) { if (m_needs_paragraph) { m_needs_paragraph = false; // MW-2012-03-14: [[ RtfParaStyles ]] Use the 'Paragraph()' method to ensure // paragraph styles get applied. Paragraph(); } m_attributes . string_native = false; m_attributes . string_buffer = t_string_buffer; m_attributes . string_length = t_string_length / 2; m_converter(m_converter_context, NULL, &m_attributes); m_text . Clear(); } if (t_changed) { MCValueRelease(m_attributes . text_metadata); MCNameDelete(m_attributes . text_link); memcpy(&m_attributes, &t_block, sizeof(MCTextBlock)); m_attributes_changed = false; } return t_status; }
void MCStoreProductRequestResponseEvent::Destroy() { MCValueRelease(m_product_id); delete this; }
Exec_stat MCF_unparsetextatts(Properties which, uint4 flags, MCStringRef name, uint2 height, uint2 size, uint2 style, MCValueRef &r_result) { switch (which) { case P_TEXT_ALIGN: switch (flags & F_ALIGNMENT) { case F_ALIGN_LEFT: r_result = MCSTR(MCleftstring); break; case F_ALIGN_CENTER: r_result = MCSTR(MCcenterstring); break; case F_ALIGN_RIGHT: r_result = MCSTR(MCrightstring); break; case F_ALIGN_JUSTIFY: r_result = MCSTR(MCjustifystring); break; } break; case P_TEXT_FONT: r_result = MCValueRetain(name); break; case P_TEXT_HEIGHT: { MCAutoNumberRef t_height; /* UNCHECKED */ MCNumberCreateWithUnsignedInteger(height, &t_height); r_result = MCValueRetain(*t_height); break; } case P_TEXT_SIZE: { MCAutoNumberRef t_size; /* UNCHECKED */ MCNumberCreateWithUnsignedInteger(size, &t_size); r_result = MCValueRetain(*t_size); break; } case P_TEXT_STYLE: { if (style == FA_DEFAULT_STYLE) { r_result = MCSTR(MCplainstring); return ES_NORMAL; } if (r_result != nil) MCValueRelease(r_result); MCAutoListRef t_list; /* UNCHECKED */ MCListCreateMutable(',', &t_list); if (MCF_getweightint(style) != MCFW_MEDIUM) MCListAppendCString(*t_list, MCF_getweightstring(style)); if (style & FA_ITALIC || style & FA_OBLIQUE) MCListAppendCString(*t_list, MCF_getslantlongstring(style)); if (style & FA_BOX) MCListAppendCString(*t_list, MCboxstring); if (style & FA_3D_BOX) MCListAppendCString(*t_list, MCthreedboxstring); if (style & FA_UNDERLINE) MCListAppendCString(*t_list, MCunderlinestring); if (style & FA_STRIKEOUT) MCListAppendCString(*t_list, MCstrikeoutstring); if (style & FA_LINK) MCListAppendCString(*t_list, MClinkstring); if (MCF_getexpandint(style) != FE_NORMAL) MCListAppendCString(*t_list, MCF_getexpandstring(style)); MCAutoStringRef t_string; /* UNCHECKED */ MCListCopyAsString(*t_list, &t_string); r_result = MCValueRetain(*t_string); } break; default: break; } return ES_NORMAL; }
void MCStoreProductRequestErrorEvent::Destroy() { MCValueRelease(m_product); MCValueRelease(m_error); delete this; }
void MCArraysEvalArrayDecode(MCExecContext& ctxt, MCDataRef p_encoding, MCArrayRef& r_array) { bool t_success; t_success = true; IO_handle t_stream_handle; t_stream_handle = nil; if (t_success) { t_stream_handle = MCS_fakeopen(MCDataGetBytePtr(p_encoding), MCDataGetLength(p_encoding)); if (t_stream_handle == nil) t_success = false; } uint8_t t_type; if (t_success) if (IO_read_uint1(&t_type, t_stream_handle) != IO_NORMAL) t_success = false; // AL-2014-05-01: [[ Bug 11989 ]] If the type is 'empty' then just return the empty array. if (t_success && t_type == kMCEncodedValueTypeEmpty) { r_array = MCValueRetain(kMCEmptyArray); return; } // AL-2014-05-15: [[ Bug 12203 ]] Check initial byte for version 7.0 encoded array. bool t_legacy; t_legacy = t_type < kMCEncodedValueTypeArray; MCArrayRef t_array; t_array = nil; if (t_success) t_success = MCArrayCreateMutable(t_array); if (t_legacy) { if (t_success) if (MCS_putback(t_type, t_stream_handle) != IO_NORMAL) t_success = false; MCObjectInputStream *t_stream; t_stream = nil; if (t_success) { t_stream = new MCObjectInputStream(t_stream_handle, MCDataGetLength(p_encoding), false); if (t_stream == nil) t_success = false; } if (t_success) if (t_stream -> ReadU8(t_type) != IO_NORMAL) t_success = false; if (t_success) if (MCArrayLoadFromStreamLegacy(t_array, *t_stream) != IO_NORMAL) t_success = false; delete t_stream; } else { if (t_success) if (IO_read_valueref_new((MCValueRef &)t_array, t_stream_handle) != IO_NORMAL) t_success = false; } MCS_close(t_stream_handle); if (t_success) { r_array = t_array; return; } MCValueRelease(t_array); ctxt . Throw(); }
static MCStringRef windows_convert_date_format(MCStringRef p_format) { MCStringRef t_output; MCStringCreateMutable(0, t_output); uindex_t t_offset = 0; while (t_offset < MCStringGetLength(p_format)) { unichar_t t_char; t_char = MCStringGetCharAtIndex(p_format, t_offset++); if (t_char == '\'') { // Copy quoted strings to the output with no conversion while ((t_char = MCStringGetCharAtIndex(p_format, t_offset++)) != '\'') MCStringAppendChar(t_output, t_char); } else { // Is this a day/month/year specifier? if (t_char == 'd' || t_char == 'M' || t_char == 'y') { // Count the number of consecutive identical characters unichar_t t_want = t_char; int t_count = 1; while (MCStringGetCharAtIndex(p_format, t_offset) == t_want) { t_count++; t_offset++; } // Append the correct formatting instruction switch (t_char) { case 'd': if (t_count == 1) MCStringAppendFormat(t_output, "%%#d"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%d"); else if (t_count == 3) MCStringAppendFormat(t_output, "%%a"); else if (t_count == 4) MCStringAppendFormat(t_output, "%%A"); break; case 'M': if (t_count == 1) MCStringAppendFormat(t_output, "%%#m"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%m"); else if (t_count == 3) MCStringAppendFormat(t_output, "%%b"); else if (t_count == 4) MCStringAppendFormat(t_output, "%%B"); break; case 'y': if (t_count == 1) MCStringAppendFormat(t_output, "%%#y"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%y"); else if (t_count == 4) MCStringAppendFormat(t_output, "%%Y"); break; } } else { // Unknown character, copy it to the output MCStringAppendChar(t_output, t_char); } } } MCValueRelease(p_format); return t_output; }
Boolean MCScreenDC::close(Boolean force) { if (m_dst_profile != nil) { CMCloseProfile(m_dst_profile); m_dst_profile = nil; } if (m_srgb_profile != nil) { CMCloseProfile(m_srgb_profile); m_srgb_profile = nil; } SetApplicationDockTileMenu(NULL); ReleaseMenu(f_icon_menu); DisposeEventHandlerUPP(s_icon_menu_event_handler_upp); f_icon_menu = NULL; s_icon_menu_event_handler_upp = NULL; showmenu(); //if the menu is hidden, show it. finalisebackdrop(); DisposeRgn(mouseMoveRgn); //dispose the region crated in open() uint2 i; if (ncolors != 0) { int2 i; for (i = 0 ; i < ncolors ; i++) { if (colornames[i] != NULL) MCValueRelease(colornames[i]); } delete colors; delete colornames; delete allocs; } DisposeWindow((WindowPtr)invisibleWin); delete vis; delete mousewindow; delete activewindow; delete lastactivewindow; //TSM - closes down TSM for this app and removes appleevents AERemoveEventHandler(kTextServiceClass, kPos2Offset, TSMPositionToOffsetUPP, False); AERemoveEventHandler(kTextServiceClass, kOffset2Pos, TSMOffsetToPositionUPP, False); AERemoveEventHandler(kTextServiceClass, kUpdateActiveInputArea, TSMUpdateHandlerUPP, False); AERemoveEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod, TSMUnicodeNotFromInputUPP, False); DisposeAEEventHandlerUPP(TSMPositionToOffsetUPP); DisposeAEEventHandlerUPP(TSMOffsetToPositionUPP); DisposeAEEventHandlerUPP(TSMUpdateHandlerUPP); DisposeAEEventHandlerUPP(TSMUnicodeNotFromInputUPP); closeIME(); RemoveReceiveHandler(dragdropUPP, NULL); RemoveTrackingHandler(dragmoveUPP, NULL); DisposeDragTrackingHandlerUPP(dragmoveUPP); DisposeDragReceiveHandlerUPP(dragdropUPP); opened = False; return True; }
static MCStringRef windows_convert_time_format(MCStringRef p_format) { MCStringRef t_output; MCStringCreateMutable(0, t_output); uindex_t t_offset = 0; while (t_offset < MCStringGetLength(p_format)) { unichar_t t_char; t_char = MCStringGetCharAtIndex(p_format, t_offset++); if (t_char == '\'') { // Copy quoted strings to the output with no conversion while ((t_char = MCStringGetCharAtIndex(p_format, t_offset++)) != '\'') MCStringAppendChar(t_output, t_char); } else { // Is this a day/month/year specifier? if (t_char == 'h' || t_char == 'H' || t_char == 'm' || t_char == 's' || t_char == 't') { // Count the number of consecutive identical characters unichar_t t_want = t_char; int t_count = 1; while ((t_char = MCStringGetCharAtIndex(p_format, t_offset)) == t_want) { t_count++; t_offset++; } // Append the correct formatting instruction switch (t_want) { case 'h': if (t_count == 1) MCStringAppendFormat(t_output, "%%#I"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%I"); break; case 'H': if (t_count == 1) MCStringAppendFormat(t_output, "%%#H"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%H"); break; case 'm': if (t_count == 1) MCStringAppendFormat(t_output, "%%#M"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%M"); break; case 's': if (t_count == 1) MCStringAppendFormat(t_output, "%%#S"); else if (t_count == 2) MCStringAppendFormat(t_output, "%%S"); break; case 't': MCStringAppendFormat(t_output, "%%p"); } } else { // Unknown character, copy it to the output MCStringAppendChar(t_output, t_char); } } } MCValueRelease(p_format); return t_output; }