diff --git a/engine/src/coretextfonts.mm b/engine/src/coretextfonts.mm
index 2e2b1828be4..11803569aba 100644
--- a/engine/src/coretextfonts.mm
+++ b/engine/src/coretextfonts.mm
@@ -462,7 +462,7 @@ void coretext_get_font_name(void *p_font, MCNameRef& r_name)
t_font_name = CTFontCopyDisplayName((CTFontRef)p_font);
MCAutoStringRef t_font_name_string;
- MCStringCreateWithCFString(t_font_name, &t_font_name_string);
+ MCStringCreateWithCFStringRef(t_font_name, &t_font_name_string);
MCNameCreate(*t_font_name_string, r_name);
}
diff --git a/engine/src/dskmac.cpp b/engine/src/dskmac.cpp
index ca3a7f0be10..e066275639a 100644
--- a/engine/src/dskmac.cpp
+++ b/engine/src/dskmac.cpp
@@ -2871,7 +2871,7 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
// Change the current folder
MCAutoStringRef t_path;
- if (MCStringCreateWithCFString(t_fs_path, &t_path))
+ if (MCStringCreateWithCFStringRef(t_fs_path, &t_path))
/* UNCHECKED */ SetCurrentFolder(*t_path);
CFRelease(t_bundle_url);
@@ -5944,7 +5944,7 @@ bool MCS_get_browsers(MCStringRef &r_browsers)
MCAutoStringRef t_browser_string;
if (t_success)
- t_success = MCStringCreateWithCFString(t_browser_title, &t_browser_string);
+ t_success = MCStringCreateWithCFStringRef(t_browser_title, &t_browser_string);
if (t_success)
t_success = MCListAppend(*t_browser_list, *t_browser_string);
diff --git a/engine/src/externalv1.cpp b/engine/src/externalv1.cpp
index ccebf961f42..4ec71f5a258 100755
--- a/engine/src/externalv1.cpp
+++ b/engine/src/externalv1.cpp
@@ -1993,7 +1993,7 @@ static MCExternalError MCExternalVariableAppend(MCExternalVariableRef var, MCExt
{
MCAutoStringRef t_string;
- if (!MCStringCreateWithCFString(*(CFStringRef*)p_value, &t_string))
+ if (!MCStringCreateWithCFStringRef(*(CFStringRef*)p_value, &t_string))
return kMCExternalErrorNotAString;
return var -> AppendString(p_options, *t_string);
diff --git a/engine/src/externalv1.mm b/engine/src/externalv1.mm
index 0e802373d4f..97817387de1 100644
--- a/engine/src/externalv1.mm
+++ b/engine/src/externalv1.mm
@@ -92,7 +92,7 @@
{
MCAutoStringRef t_string;
- if (!MCStringCreateWithCFString((CFStringRef)src, &t_string))
+ if (!MCStringCreateWithCFStringRef((CFStringRef)src, &t_string))
return kMCExternalErrorNotAString;
var = MCValueRetain(*t_string);
@@ -118,7 +118,7 @@
MCAutoStringRef t_string;
NSString *t_as_string;
t_as_string = [src description];
- if (!MCStringCreateWithCFString((CFStringRef)t_as_string, &t_string))
+ if (!MCStringCreateWithCFStringRef((CFStringRef)t_as_string, &t_string))
return kMCExternalErrorOutOfMemory;
var = MCValueRetain(*t_string);
@@ -337,7 +337,7 @@
if (t_error == kMCExternalErrorNone)
{
- if (!MCStringCreateWithCFString((CFStringRef)t_key, &t_key_stringref) ||
+ if (!MCStringCreateWithCFStringRef((CFStringRef)t_key, &t_key_stringref) ||
!MCNameCreate(*t_key_stringref, &t_key_nameref))
t_error = kMCExternalErrorOutOfMemory;
}
diff --git a/engine/src/mac-av-player.mm b/engine/src/mac-av-player.mm
index b033ee33108..025ad06519d 100644
--- a/engine/src/mac-av-player.mm
+++ b/engine/src/mac-av-player.mm
@@ -1364,7 +1364,7 @@ static Boolean AVAssetHasType(AVAsset *p_asset, NSString *p_type)
{
NSString *t_mediaType;
t_mediaType = [t_asset_track mediaType];
- MCStringCreateWithCFString((CFStringRef)t_mediaType, *(MCStringRef*)r_value);
+ MCStringCreateWithCFStringRef((CFStringRef)t_mediaType, *(MCStringRef*)r_value);
}
break;
case kMCPlatformPlayerTrackPropertyOffset:
diff --git a/engine/src/mac-clipboard.mm b/engine/src/mac-clipboard.mm
index e410a97dbb9..53010fccb2c 100644
--- a/engine/src/mac-clipboard.mm
+++ b/engine/src/mac-clipboard.mm
@@ -315,7 +315,7 @@
// Convert the UTI to a StringRef
MCStringRef t_return = NULL;
- MCStringCreateWithCFString(t_uti, t_return);
+ MCStringCreateWithCFStringRef(t_uti, t_return);
CFRelease(t_uti);
return t_return;
}
@@ -574,7 +574,7 @@
// Convert the NSString into a StringRef
MCStringRef t_type_string;
- if (!MCStringCreateWithCFString((CFStringRef)t_type, t_type_string))
+ if (!MCStringCreateWithCFStringRef((CFStringRef)t_type, t_type_string))
return NULL;
m_type = t_type_string;
@@ -612,7 +612,7 @@
// Turn this path into a LiveCode string
MCAutoStringRef t_path_string;
- if (!MCStringCreateWithCFString((CFStringRef)t_path, &t_path_string))
+ if (!MCStringCreateWithCFStringRef((CFStringRef)t_path, &t_path_string))
return NULL;
// Because this needs to return data, UTF-8 encode the result
diff --git a/engine/src/mac-dialog.mm b/engine/src/mac-dialog.mm
index 72d292a8535..0d809b8e88c 100644
--- a/engine/src/mac-dialog.mm
+++ b/engine/src/mac-dialog.mm
@@ -213,7 +213,7 @@ MCPlatformDialogResult MCPlatformEndFolderDialog(MCStringRef& r_selected_folder)
{
NSString *t_alias;
resolve_alias([s_dialog_nesting -> panel filename], t_alias);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_alias, r_selected_folder);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_alias, r_selected_folder);
[t_alias release];
}
else
@@ -509,7 +509,7 @@ - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
if (!t_should_show && m_filter->extension_count > 0)
{
MCAutoStringRef t_filename;
- if (MCStringCreateWithCFString((CFStringRef)t_filename_resolved, &t_filename) && *t_filename != nil)
+ if (MCStringCreateWithCFStringRef((CFStringRef)t_filename_resolved, &t_filename) && *t_filename != nil)
{
uindex_t t_dot;
// AL-2014-04-01: [[ Bug 12081 ]] Find last occurrence of '.' rather than first, for file extension detection.
@@ -649,7 +649,7 @@ MCPlatformDialogResult MCPlatformEndFileDialog(MCPlatformFileDialogKind p_kind,
if (p_kind == kMCPlatformFileDialogKindSave)
{
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[s_dialog_nesting -> panel filename], r_paths);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[s_dialog_nesting -> panel filename], r_paths);
if (t_accessory != nil && [t_accessory currentType] != nil)
r_type = MCValueRetain([t_accessory currentType]);
else
@@ -666,7 +666,7 @@ MCPlatformDialogResult MCPlatformEndFileDialog(MCPlatformFileDialogKind p_kind,
resolve_alias([[(NSOpenPanel *)s_dialog_nesting -> panel filenames] objectAtIndex: i], t_alias);
MCAutoStringRef t_conv_filename;
- if (MCStringCreateWithCFString((CFStringRef)t_alias, &t_conv_filename))
+ if (MCStringCreateWithCFStringRef((CFStringRef)t_alias, &t_conv_filename))
/* UNCHECKED */ MCStringAppendFormat(r_paths, "%s%@", i > 0 ? "\n" : "", *t_conv_filename);
[t_alias release];
diff --git a/engine/src/mac-menu.mm b/engine/src/mac-menu.mm
index 1a4c2d5727e..4d4e02ee071 100644
--- a/engine/src/mac-menu.mm
+++ b/engine/src/mac-menu.mm
@@ -913,10 +913,10 @@ void MCPlatformGetMenuItemProperty(MCPlatformMenuRef p_menu, uindex_t p_index, M
switch(p_property)
{
case kMCPlatformMenuItemPropertyTitle:
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_item title], *(MCStringRef*)r_value);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[t_item title], *(MCStringRef*)r_value);
break;
case kMCPlatformMenuItemPropertyTag:
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_item representedObject], *(MCStringRef*)r_value);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[t_item representedObject], *(MCStringRef*)r_value);
break;
case kMCPlatformMenuItemPropertySubmenu:
{
diff --git a/engine/src/mbliphone.mm b/engine/src/mbliphone.mm
index 2a05f3a5f22..e0a63d3ec5d 100644
--- a/engine/src/mbliphone.mm
+++ b/engine/src/mbliphone.mm
@@ -378,7 +378,7 @@ virtual uint64_t GetFileSize(void)
bool MCIPhoneSystem::GetVersion(MCStringRef& r_string)
{
- return MCStringCreateWithCFString((CFStringRef)[[UIDevice currentDevice] systemVersion], r_string);
+ return MCStringCreateWithCFStringRef((CFStringRef)[[UIDevice currentDevice] systemVersion], r_string);
}
bool MCIPhoneSystem::GetMachine(MCStringRef& r_string)
@@ -388,7 +388,7 @@ virtual uint64_t GetFileSize(void)
t_machine = [t_machine stringByAppendingString:@" Simulator"];
#endif
- return MCStringCreateWithCFString((CFStringRef)t_machine, r_string);
+ return MCStringCreateWithCFStringRef((CFStringRef)t_machine, r_string);
}
MCNameRef MCIPhoneSystem::GetProcessor(void)
@@ -679,7 +679,7 @@ virtual uint64_t GetFileSize(void)
if (MCNameIsEqualToCaseless(p_type, MCN_temporary))
{
MCAutoStringRef t_temp;
- MCStringCreateWithCFString((CFStringRef)NSTemporaryDirectory() , &t_temp);
+ MCStringCreateWithCFStringRef((CFStringRef)NSTemporaryDirectory() , &t_temp);
// MW-2012-09-18: [[ Bug 10279 ]] Remove trailing slash, if any.
// MW-2012-10-04: [[ Bug 10435 ]] Actually use a NUL character, rather than a '0'!
@@ -692,17 +692,17 @@ virtual uint64_t GetFileSize(void)
{
NSArray *t_paths;
t_paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- MCStringCreateWithCFString((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
+ MCStringCreateWithCFStringRef((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
}
else if (MCNameIsEqualToCaseless(p_type, MCN_home))
{
- MCStringCreateWithCFString((CFStringRef)NSHomeDirectory() , &t_path);
+ MCStringCreateWithCFStringRef((CFStringRef)NSHomeDirectory() , &t_path);
}
else if (MCStringIsEqualToCString(MCNameGetString(p_type), "cache", kMCCompareCaseless))
{
NSArray *t_paths;
t_paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- MCStringCreateWithCFString((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
+ MCStringCreateWithCFStringRef((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
}
// SN-2015-04-16: [[ Bug 14295 ]] The resources folder on Mobile is the same
// as the engine folder.
@@ -720,7 +720,7 @@ virtual uint64_t GetFileSize(void)
{
NSArray *t_paths;
t_paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
- MCStringCreateWithCFString((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
+ MCStringCreateWithCFStringRef((CFStringRef)[t_paths objectAtIndex: 0] , &t_path);
}
diff --git a/engine/src/mbliphoneapp.mm b/engine/src/mbliphoneapp.mm
index 80779abbe66..dacf75a703a 100644
--- a/engine/src/mbliphoneapp.mm
+++ b/engine/src/mbliphoneapp.mm
@@ -90,7 +90,7 @@ static void dispatch_notification_events(void)
MCAutoStringRef t_text;
// PM-2015-10-27: [[ Bug 16279 ]] Prevent crash when the payload is empty
if (t_event -> text != nil)
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_event -> text, &t_text);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_event -> text, &t_text);
else
t_text = MCValueRetain(kMCEmptyString);
@@ -388,7 +388,7 @@ - (BOOL)application:(UIApplication *)p_application didFinishLaunchingWithOptions
if (t_launch_url)
{
MCAutoStringRef t_url_text;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_launch_url absoluteString], &t_url_text);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[t_launch_url absoluteString], &t_url_text);
MCValueAssign(m_launch_url, *t_url_text);
// HSC-2012-03-13 [[ Bug 10076 ]] Prevent Push Notification crashing when applicationDidBecomeActive is called multiple times
@@ -529,7 +529,7 @@ - (void)application:(UIApplication*)p_application didRegisterForRemoteNotificati
if (t_registration_text != nil)
{
MCAutoStringRef t_device_token;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_registration_text, &t_device_token);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_registration_text, &t_device_token);
MCValueAssign(m_device_token, *t_device_token);
// MW-2014-09-22: [[ Bug 13446 ]] Queue the event.
@@ -579,7 +579,7 @@ - (BOOL)application:(UIApplication *)p_application openURL:(NSURL*)p_url sourceA
if (p_url != nil)
{
MCAutoStringRef t_url_text;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[p_url absoluteString], &t_url_text);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[p_url absoluteString], &t_url_text);
MCValueAssign(m_launch_url, *t_url_text);
if (m_did_become_active)
MCNotificationPostUrlWakeUp(m_launch_url);
@@ -662,7 +662,7 @@ - (void)startPreparing
if (m_pending_local_notification != nil)
{
MCAutoStringRef t_mc_reminder_text;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)m_pending_local_notification, &t_mc_reminder_text);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)m_pending_local_notification, &t_mc_reminder_text);
MCNotificationPostLocalNotificationEvent(*t_mc_reminder_text);
// HSC-2012-03-13 [[ Bug 10076 ]] Prevent Push Notification crashing when applicationDidBecomeActive is called multiple times
@@ -672,7 +672,7 @@ - (void)startPreparing
if (m_pending_push_notification != nil)
{
MCAutoStringRef t_mc_reminder_text;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)m_pending_push_notification, &t_mc_reminder_text);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)m_pending_push_notification, &t_mc_reminder_text);
MCNotificationPostPushNotificationEvent(*t_mc_reminder_text);
// HSC-2012-03-13 [[ Bug 10076 ]] Prevent Push Notification crashing when applicationDidBecomeActive is called multiple times
diff --git a/engine/src/mbliphonebrowser.mm b/engine/src/mbliphonebrowser.mm
index a406a4b5c8d..b27273f003e 100644
--- a/engine/src/mbliphonebrowser.mm
+++ b/engine/src/mbliphonebrowser.mm
@@ -280,7 +280,7 @@ - (void)setPendingRequest: (bool)newValue;
t_view = (UIWebView *)GetView();
if (t_view != nil && [[t_view request] URL] != nil)
{
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[[[t_view request] URL] absoluteString], r_url);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[[[t_view request] URL] absoluteString], r_url);
return;
}
@@ -443,7 +443,7 @@ - (void)setPendingRequest: (bool)newValue;
return;
}
MCAutoStringRef t_result_string;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_result, &t_result_string);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_result, &t_result_string);
ctxt.SetTheResultToValue(*t_result_string);
}
@@ -631,7 +631,7 @@ bool datadetectortypes_to_string(UIDataDetectorTypes p_types, char *&r_list)
// Whether we send loadRequest or loadRequested depends on 'notify'.
Exec_stat t_stat;
MCAutoStringRef t_url, t_type;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[[p_request URL] absoluteString], &t_url);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[[p_request URL] absoluteString], &t_url);
/* UNCHECKED */ MCStringCreateWithCString(s_types[p_type], &t_type);
t_stat = t_target -> message_with_valueref_args(p_notify ? MCM_browser_load_requested : MCM_browser_load_request, *t_url, *t_type);
@@ -662,7 +662,7 @@ bool datadetectortypes_to_string(UIDataDetectorTypes p_types, char *&r_list)
MCAutoStringRef t_url, t_description;
MCExecContext ctxt(nil, nil, nil);
GetUrl(ctxt, &t_url);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[p_error localizedDescription], &t_description);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[p_error localizedDescription], &t_description);
MCNativeControl *t_old_target;
t_old_target = ChangeTarget(this);
t_target -> message_with_valueref_args(MCM_browser_load_failed, *t_url, *t_description);
diff --git a/engine/src/mbliphonecalendar.mm b/engine/src/mbliphonecalendar.mm
index fded0c46106..6c6ab2670cc 100644
--- a/engine/src/mbliphonecalendar.mm
+++ b/engine/src/mbliphonecalendar.mm
@@ -540,7 +540,7 @@ bool MCSystemShowEvent(MCStringRef p_event_id, MCStringRef& r_result)
t_show_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_show_event showViewEvent:t_ns_event withResult: t_ns_result];
if (t_ns_result != nil)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
[t_ns_result release];
[t_show_event release];
return t_result;
@@ -554,7 +554,7 @@ bool MCSystemCreateEvent(MCStringRef& r_result)
t_create_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_create_event showCreateEvent: t_ns_result];
if (t_ns_result.length > 0)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
[t_ns_result release];
return t_result;
}
@@ -572,7 +572,7 @@ bool MCSystemUpdateEvent(MCStringRef p_event_id, MCStringRef& r_result)
// Allow the user to update the event data
[t_update_event showUpdateEvent: t_ns_event withResult:t_ns_result];
if (t_ns_result != nil)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
}
[t_ns_result release];
@@ -604,7 +604,7 @@ bool MCSystemRemoveEvent(MCStringRef p_event_id, bool p_reocurring, MCStringRef&
t_delete_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_delete_event deleteEvent: t_ns_event withInstances:p_reocurring withResult: t_ns_result];
if (t_ns_result != NULL)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_event_id_deleted);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_event_id_deleted);
[t_ns_result release];
[t_ns_event release];
return t_result;
@@ -618,7 +618,7 @@ bool MCSystemAddEvent(MCCalendar p_new_calendar_data, MCStringRef& r_result)
t_add_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_add_event addEvent: p_new_calendar_data withResult: t_ns_result];
if (t_ns_result != NULL)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
[t_ns_result release];
return t_result;
}
@@ -631,7 +631,7 @@ bool MCSystemGetCalendarsEvent(MCStringRef& r_result)
t_get_calendars_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_get_calendars_event getCalendarsEvent: t_ns_result];
if (t_ns_result != NULL)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
[t_ns_result release];
return t_result;
}
@@ -663,7 +663,7 @@ bool MCSystemFindEvent(MCDateTime p_start_date, MCDateTime p_end_date, MCStringR
t_find_event = [[com_runrev_livecode_MCIPhonePickEventDelegate alloc] init];
[t_find_event findEvent:t_start_date andEnd: t_end_date withResult: t_ns_result];
if (t_ns_result != NULL)
- t_result = MCStringCreateWithCFString((CFStringRef)t_ns_result, r_result);
+ t_result = MCStringCreateWithCFStringRef((CFStringRef)t_ns_result, r_result);
}
[t_ns_result release];
diff --git a/engine/src/mbliphonecontact.mm b/engine/src/mbliphonecontact.mm
index de1cd41aa60..d1e409f2f11 100644
--- a/engine/src/mbliphonecontact.mm
+++ b/engine/src/mbliphonecontact.mm
@@ -179,7 +179,7 @@ bool MCCFDictionaryToArray(CFDictionaryRef p_dict, MCArrayRef &r_array)
if (key_to_name(t_dict_keys[i], &t_key_name))
{
MCAutoStringRef t_string;
- MCStringCreateWithCFString((CFStringRef)t_dict_values[i], &t_string);
+ MCStringCreateWithCFStringRef((CFStringRef)t_dict_values[i], &t_string);
t_success = MCArrayStoreValue(*t_prop_array, false, *t_key_name, *t_string);
}
}
@@ -245,7 +245,7 @@ bool MCCreatePersonData(ABRecordRef p_person, MCArrayRef& r_contact)
if (!s_property_map[i].has_labels)
{
MCAutoStringRef t_value;
- MCStringCreateWithCFString((CFStringRef)t_prop_value, &t_value);
+ MCStringCreateWithCFStringRef((CFStringRef)t_prop_value, &t_value);
t_success = MCContactAddProperty(*t_contact, *s_property_map[i].name, *t_value);
}
else
@@ -271,7 +271,7 @@ bool MCCreatePersonData(ABRecordRef p_person, MCArrayRef& r_contact)
if (t_proptype == kABStringPropertyType)
{
MCAutoStringRef t_value;
- MCStringCreateWithCFString((CFStringRef)t_multi_value, &t_value);
+ MCStringCreateWithCFStringRef((CFStringRef)t_multi_value, &t_value);
t_success = MCContactAddPropertyWithLabel(*t_contact, *s_property_map[i].name, *t_label_name, *t_value);
}
else if (t_proptype == kABDictionaryPropertyType)
@@ -545,7 +545,7 @@ bool MCContactFindContact(MCStringRef p_person_name, MCStringRef &r_chosen)
// AL-2015-05-14: [[ Bug 15370 ]] Crash when matching contact not found
if (t_success && t_chosen != nil)
- t_success = MCStringCreateWithCFString((CFStringRef)t_chosen, r_chosen);
+ t_success = MCStringCreateWithCFStringRef((CFStringRef)t_chosen, r_chosen);
if (t_people != nil)
[t_people release];
diff --git a/engine/src/mbliphonedc.mm b/engine/src/mbliphonedc.mm
index 935cf32fb6c..7cc60aac113 100644
--- a/engine/src/mbliphonedc.mm
+++ b/engine/src/mbliphonedc.mm
@@ -1222,7 +1222,7 @@ static void MCIPhoneDoDidBecomeActive(void *)
// Convert the arguments into stringrefs
MCStringRef args[1];
- MCStringCreateWithCFString((CFStringRef)[[[NSProcessInfo processInfo] arguments] objectAtIndex: 0], args[0]);
+ MCStringCreateWithCFStringRef((CFStringRef)[[[NSProcessInfo processInfo] arguments] objectAtIndex: 0], args[0]);
// SN-2015-09-22: [[ Bug 15987 ]] Use NSProcessInfo to get the env variables
// Convert the environment variables into stringrefs
@@ -1255,8 +1255,8 @@ static void MCIPhoneDoDidBecomeActive(void *)
// We convert the CFStringRef that we got from the dictionary into
// StringRefs, and create a Bash-like environment variable
- if (MCStringCreateWithCFString((CFStringRef)t_value, &t_value_str)
- && MCStringCreateWithCFString((CFStringRef)t_key, &t_variable_str)
+ if (MCStringCreateWithCFStringRef((CFStringRef)t_value, &t_value_str)
+ && MCStringCreateWithCFStringRef((CFStringRef)t_key, &t_variable_str)
&& MCStringFormat(t_env_var, "%@=%@", *t_variable_str, *t_value_str))
t_envp[t_index] = t_env_var;
diff --git a/engine/src/mbliphonedialog.mm b/engine/src/mbliphonedialog.mm
index c2a4acc88be..5e7b30199ef 100644
--- a/engine/src/mbliphonedialog.mm
+++ b/engine/src/mbliphonedialog.mm
@@ -532,7 +532,7 @@ static void dopopupaskdialog_prewait(void *p_context)
UITextField *t_text_field;
t_text_field = [[t_alert_controller textFields] firstObject];
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_text_field text], ctxt -> result);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[t_text_field text], ctxt -> result);
}];
[t_alert_controller addAction: t_ok_action];
@@ -554,7 +554,7 @@ static void dopopupaskdialog_postwait(void *p_context)
t_result = [ctxt -> alert getText];
if (t_result != nil)
- MCStringCreateWithCFString(t_result, &t_message_text);
+ MCStringCreateWithCFStringRef(t_result, &t_message_text);
// MW-2012-10-24: [[ Bug 10491 ]] The delegate now holds the button index, not the alert view.
if ([ctxt -> delegate index] == 0 || *t_message_text == nil)
@@ -571,7 +571,7 @@ static void dopopupaskdialog_postwait(void *p_context)
t_result = (CFStringRef)[ctxt -> text_field text];
if (t_result != nil)
- MCStringCreateWithCFString(t_result, &t_message_text);
+ MCStringCreateWithCFStringRef(t_result, &t_message_text);
if ([ctxt -> delegate index] == 0 || *t_message_text == nil)
ctxt -> result = nil;
diff --git a/engine/src/mbliphoneextra.mm b/engine/src/mbliphoneextra.mm
index e3c834f9aec..1c98e33f37a 100644
--- a/engine/src/mbliphoneextra.mm
+++ b/engine/src/mbliphoneextra.mm
@@ -680,7 +680,7 @@ bool MCSystemGetPreferredLanguages(MCStringRef& r_preferred_languages)
for (NSString *t_lang in t_preferred_langs)
{
MCAutoStringRef t_language;
- if (t_success && MCStringCreateWithCFString((CFStringRef)t_lang, &t_language))
+ if (t_success && MCStringCreateWithCFStringRef((CFStringRef)t_lang, &t_language))
t_success = MCListAppend(*t_languages, *t_language);
}
}
@@ -696,7 +696,7 @@ bool MCSystemGetCurrentLocale(MCStringRef& r_current_locale)
NSString *t_current_locale_id = nil;
t_current_locale_id = [[NSLocale currentLocale] objectForKey: NSLocaleIdentifier];
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_current_locale_id, r_current_locale);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_current_locale_id, r_current_locale);
return true;
}
@@ -711,7 +711,7 @@ bool MCSystemGetSystemIdentifier(MCStringRef& r_identifier)
NSString *t_identifier;
t_identifier = objc_msgSend([UIDevice currentDevice], sel_getUid("uniqueIdentifier"));
- return MCStringCreateWithCFString((CFStringRef)t_identifier, r_identifier);
+ return MCStringCreateWithCFStringRef((CFStringRef)t_identifier, r_identifier);
}
bool MCSystemGetIdentifierForVendor(MCStringRef& r_identifier)
@@ -723,7 +723,7 @@ bool MCSystemGetIdentifierForVendor(MCStringRef& r_identifier)
{
NSString *t_identifier;
t_identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
- return MCStringCreateWithCFString((CFStringRef)t_identifier, r_identifier);
+ return MCStringCreateWithCFStringRef((CFStringRef)t_identifier, r_identifier);
}
r_identifier = MCValueRetain(kMCEmptyString);
@@ -740,7 +740,7 @@ bool MCSystemGetApplicationIdentifier(MCStringRef& r_identifier)
NSString *t_identifier;
t_identifier = [t_plist objectForKey: @"CFBundleIdentifier"];
- return MCStringCreateWithCFString((CFStringRef)t_identifier, r_identifier);
+ return MCStringCreateWithCFStringRef((CFStringRef)t_identifier, r_identifier);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/engine/src/mbliphoneinput.mm b/engine/src/mbliphoneinput.mm
index 6005ee773b7..684c015cd7c 100644
--- a/engine/src/mbliphoneinput.mm
+++ b/engine/src/mbliphoneinput.mm
@@ -847,7 +847,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
if (t_field)
{
- if (MCStringCreateWithCFString((CFStringRef)[t_field text], r_string))
+ if (MCStringCreateWithCFStringRef((CFStringRef)[t_field text], r_string))
return;
}
else
@@ -872,7 +872,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
if (t_field)
{
- if (MCStringCreateWithCFString((CFStringRef)[[t_field font] fontName], r_font))
+ if (MCStringCreateWithCFStringRef((CFStringRef)[[t_field font] fontName], r_font))
return;
}
else
diff --git a/engine/src/mbliphonemediapick.mm b/engine/src/mbliphonemediapick.mm
index a9414ec8cbe..98111cedbd9 100644
--- a/engine/src/mbliphonemediapick.mm
+++ b/engine/src/mbliphonemediapick.mm
@@ -181,7 +181,7 @@ bool MCSystemPickMedia(MCMediaType p_media_type, bool p_multiple, MCStringRef& r
}
// Call MCIPhonePickMedia to process the media pick selection.
if (MCIPhonePickMedia(p_multiple, t_media_types, r_return_media_types) && r_return_media_types != nil)
- return MCStringCreateWithCFString((CFStringRef)r_return_media_types, r_result);
+ return MCStringCreateWithCFStringRef((CFStringRef)r_return_media_types, r_result);
return false;
}
diff --git a/engine/src/mbliphonenotification.mm b/engine/src/mbliphonenotification.mm
index ee38a6ee0a3..57bfa62d257 100644
--- a/engine/src/mbliphonenotification.mm
+++ b/engine/src/mbliphonenotification.mm
@@ -107,7 +107,7 @@ bool MCSystemGetRegisteredNotifications (MCStringRef& r_registered_alerts)
if (t_result == nil)
r_registered_alerts = MCValueRetain(kMCEmptyString);
else
- return MCStringCreateWithCFString((CFStringRef)t_result, r_registered_alerts);
+ return MCStringCreateWithCFStringRef((CFStringRef)t_result, r_registered_alerts);
return true;
}
@@ -122,17 +122,17 @@ bool MCSystemGetNotificationDetails(int32_t p_id, MCNotification &r_notification
if ([t_local_notification alertBody] == nil)
r_notification.body = MCValueRetain(kMCEmptyString);
else
- MCStringCreateWithCFString ((CFStringRef)[t_local_notification alertBody], r_notification.body); // or ""
+ MCStringCreateWithCFStringRef ((CFStringRef)[t_local_notification alertBody], r_notification.body); // or ""
if ([t_local_notification alertAction] == nil)
r_notification.action = MCValueRetain(kMCEmptyString);
else
- MCStringCreateWithCFString ((CFStringRef)[t_local_notification alertAction], r_notification.action); // or ""
+ MCStringCreateWithCFStringRef ((CFStringRef)[t_local_notification alertAction], r_notification.action); // or ""
if ([t_local_notification.userInfo objectForKey:@"payload"] == nil)
r_notification.user_info = MCValueRetain(kMCEmptyString);
else
- MCStringCreateWithCFString ((CFStringRef)[t_local_notification.userInfo objectForKey:@"payload"], r_notification.user_info);
+ MCStringCreateWithCFStringRef ((CFStringRef)[t_local_notification.userInfo objectForKey:@"payload"], r_notification.user_info);
r_notification.time = [[t_local_notification fireDate] timeIntervalSince1970];
r_notification.badge_value = t_local_notification.applicationIconBadgeNumber;
r_notification.play_sound = t_local_notification.soundName != nil ? true : false;
diff --git a/engine/src/mbliphonepick.mm b/engine/src/mbliphonepick.mm
index 0b732471690..e9731fb99fd 100644
--- a/engine/src/mbliphonepick.mm
+++ b/engine/src/mbliphonepick.mm
@@ -904,7 +904,7 @@ bool MCSystemPick(MCStringRef p_options, bool p_use_checkmark, uint32_t p_initia
t_success = MCSystemPickN(t_option_list_array, p_use_checkmark, false, false, false, t_initial_index_array, t_return_index, p_button_rect);
MCAutoStringRef t_result;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_return_index, &t_result);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_return_index, &t_result);
if (t_success)
MCresult -> setvalueref (*t_result);
r_chosen_index = atoi ([t_return_index cStringUsingEncoding:NSMacOSRomanStringEncoding]);
diff --git a/engine/src/mbliphoneplayer.mm b/engine/src/mbliphoneplayer.mm
index 16845249e15..1b59ca2da39 100644
--- a/engine/src/mbliphoneplayer.mm
+++ b/engine/src/mbliphoneplayer.mm
@@ -366,7 +366,7 @@ static void content_to_url(MCStringRef p_file, NSURL*& r_url)
}
if (t_string != nil)
{
- if (MCStringCreateWithCFString((CFStringRef)t_string, r_content))
+ if (MCStringCreateWithCFStringRef((CFStringRef)t_string, r_content))
return;
}
else
diff --git a/engine/src/mbliphonesensor.mm b/engine/src/mbliphonesensor.mm
index 773f027c286..9e824dc35ee 100644
--- a/engine/src/mbliphonesensor.mm
+++ b/engine/src/mbliphonesensor.mm
@@ -148,13 +148,13 @@ - (void)locationManager: (CLLocationManager *)manager didFailWithError: (NSError
if (s_location_enabled)
{
MCAutoStringRef t_error;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[error localizedDescription], &t_error);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[error localizedDescription], &t_error);
MCSensorPostErrorMessage(kMCSensorTypeLocation, *t_error);
}
else if (s_heading_enabled)
{
MCAutoStringRef t_error;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[error localizedDescription], &t_error);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[error localizedDescription], &t_error);
MCSensorPostErrorMessage(kMCSensorTypeHeading, *t_error);
}
}
@@ -538,7 +538,7 @@ static void (^acceleration_update)(CMAccelerometerData *, NSError *) = ^(CMAccel
else
{
MCAutoStringRef t_error;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[error localizedDescription], &t_error);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[error localizedDescription], &t_error);
MCSensorPostErrorMessage(kMCSensorTypeAcceleration, *t_error);
}
}
@@ -604,7 +604,7 @@ static void (^rotation_rate_update)(CMGyroData *, NSError *) = ^(CMGyroData *gyr
else
{
MCAutoStringRef t_error;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[error localizedDescription], &t_error);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[error localizedDescription], &t_error);
MCSensorPostErrorMessage(kMCSensorTypeRotationRate, *t_error);
}
}
diff --git a/engine/src/mbliphonestore.mm b/engine/src/mbliphonestore.mm
index a3cf08993b7..162b7d8948a 100644
--- a/engine/src/mbliphonestore.mm
+++ b/engine/src/mbliphonestore.mm
@@ -224,7 +224,7 @@ void MCPurchaseGetProductIdentifier(MCExecContext& ctxt, MCPurchase *p_purchase,
else
t_payment = t_ios_data->payment;
- if (t_payment != nil && MCStringCreateWithCFString((CFStringRef)[t_payment productIdentifier], r_productIdentifier))
+ if (t_payment != nil && MCStringCreateWithCFStringRef((CFStringRef)[t_payment productIdentifier], r_productIdentifier))
return;
ctxt . Throw();
@@ -293,7 +293,7 @@ void MCPurchaseGetTransactionIdentifier(MCExecContext& ctxt, MCPurchase *p_purch
// PM-2015-03-10: [[ Bug 14858 ]] transactionIdentifier can be nil if the purchase is still in progress (i.e when purchaseStateUpdate msg is sent with state=sendingRequest)
if (t_transaction != nil
&& [t_transaction transactionIdentifier] != nil
- && MCStringCreateWithCFString((CFStringRef)[t_transaction transactionIdentifier], r_identifier))
+ && MCStringCreateWithCFStringRef((CFStringRef)[t_transaction transactionIdentifier], r_identifier))
return;
ctxt . Throw();
@@ -511,7 +511,7 @@ void update_purchase_state(MCPurchase *p_purchase)
{
p_purchase->state = kMCPurchaseStateError;
MCValueRelease(t_ios_data->error);
- MCStringCreateWithCFString((CFStringRef)[t_error localizedDescription], t_ios_data->error);
+ MCStringCreateWithCFStringRef((CFStringRef)[t_error localizedDescription], t_ios_data->error);
}
break;
}
@@ -557,7 +557,7 @@ - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)tran
t_success = MCMemoryNew(t_ios_data);
if (t_success)
- t_success = MCStringCreateWithCFString((CFStringRef)[[t_transaction payment] productIdentifier], t_ios_data->product_id);
+ t_success = MCStringCreateWithCFStringRef((CFStringRef)[[t_transaction payment] productIdentifier], t_ios_data->product_id);
if (t_success)
t_success = MCPurchaseCreate(t_ios_data->product_id, t_ios_data, t_purchase);
@@ -700,7 +700,7 @@ - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProdu
for (NSString *t_invalid_id in response.invalidProductIdentifiers)
{
MCAutoStringRef t_string;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_invalid_id, &t_string);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_invalid_id, &t_string);
MCStorePostProductRequestError(*t_string, MCSTR("invalid product identifier"));
}
}
@@ -723,8 +723,8 @@ - (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
MCAutoStringRef t_product, t_error;
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[(com_runrev_livecode_MCProductsRequest*)request getProductId], &t_product);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[error description], &t_error);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[(com_runrev_livecode_MCProductsRequest*)request getProductId], &t_product);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[error description], &t_error);
MCStorePostProductRequestError(*t_product, *t_error);
[request release];
@@ -871,11 +871,11 @@ bool MCNSStringToUnicode(NSString *p_ns_string, unichar_t *&r_uni_string, uint32
t_locale_currency_code = [[m_product priceLocale] objectForKey: NSLocaleCurrencyCode];
t_locale_currency_symbol = [[m_product priceLocale] objectForKey: NSLocaleCurrencySymbol];
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[m_product productIdentifier], &t_product_id);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[m_product localizedDescription], &t_description);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[m_product localizedTitle], &t_title);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_locale_currency_code, &t_currency_code);
- /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_locale_currency_symbol, &t_currency_symbol);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[m_product productIdentifier], &t_product_id);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[m_product localizedDescription], &t_description);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)[m_product localizedTitle], &t_title);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_locale_currency_code, &t_currency_code);
+ /* UNCHECKED */ MCStringCreateWithCFStringRef((CFStringRef)t_locale_currency_symbol, &t_currency_symbol);
unichar_t *t_unicode_description = nil;
uint32_t t_unicode_description_length = 0;
diff --git a/engine/src/mbliphoneurl.mm b/engine/src/mbliphoneurl.mm
index ffe4ea75297..5f5395a6f46 100644
--- a/engine/src/mbliphoneurl.mm
+++ b/engine/src/mbliphoneurl.mm
@@ -219,7 +219,7 @@ - (void)connection: (NSURLConnection *)connection didFailWithError: (NSError *)e
// AL-2014-07-15: [[ Bug 12478 ]] Pass a StringRef to url callbacks for error.
MCAutoStringRef t_error;
- MCStringCreateWithCFString((CFStringRef)[error localizedDescription], &t_error);
+ MCStringCreateWithCFStringRef((CFStringRef)[error localizedDescription], &t_error);
m_callback(m_context, kMCSystemUrlStatusError, *t_error);
[connection release];
}
@@ -233,7 +233,7 @@ - (void)connectionDidFinishLoading: (NSURLConnection *)connection
// AL-2014-07-15: [[ Bug 12478 ]] Pass a StringRef to url callbacks for error.
MCAutoStringRef t_error;
- MCStringCreateWithCFString((CFStringRef)t_err_string, &t_error);
+ MCStringCreateWithCFStringRef((CFStringRef)t_err_string, &t_error);
m_callback(m_context, kMCSystemUrlStatusError, *t_error);
}
else
@@ -592,7 +592,7 @@ void PutFTPUrlClientCallback(CFWriteStreamRef p_stream, CFStreamEventType p_even
{
CFStringRef t_description = CFErrorCopyDescription(t_err);
MCAutoStringRef t_error;
- MCStringCreateWithCFString(t_description, &t_error);
+ MCStringCreateWithCFStringRef(t_description, &t_error);
t_context->callback(t_context->context, kMCSystemUrlStatusError, *t_error);
CFRelease(t_description);
}
diff --git a/engine/src/osxprinter.cpp b/engine/src/osxprinter.cpp
index be2dc267590..cdd6d8d7f77 100644
--- a/engine/src/osxprinter.cpp
+++ b/engine/src/osxprinter.cpp
@@ -2410,7 +2410,7 @@ bool MCListSystemPrinters(MCStringRef &r_names)
for(CFIndex i = 0; i < CFArrayGetCount(t_printers) && t_success; ++i)
{
MCAutoStringRef t_name;
- t_success = MCStringCreateWithCFString(PMPrinterGetName((PMPrinter)CFArrayGetValueAtIndex(t_printers, i)), &t_name)
+ t_success = MCStringCreateWithCFStringRef(PMPrinterGetName((PMPrinter)CFArrayGetValueAtIndex(t_printers, i)), &t_name)
&& MCListAppend(*t_names, *t_name);
}
diff --git a/engine/src/syscfdate.cpp b/engine/src/syscfdate.cpp
index 08fcdddc722..ad6d7bd7cd5 100644
--- a/engine/src/syscfdate.cpp
+++ b/engine/src/syscfdate.cpp
@@ -92,7 +92,7 @@ MCLocaleRef MCS_getsystemlocale()
// And turn this into a StringRef
MCAutoStringRef t_locale_id;
- if (!MCStringCreateWithCFString(t_cf_locale_id, &t_locale_id))
+ if (!MCStringCreateWithCFStringRef(t_cf_locale_id, &t_locale_id))
return nil;
// Finally, construct a Locale object using this name
@@ -195,7 +195,7 @@ static bool osx_cf_format_time(CFLocaleRef p_locale, CFStringRef p_format, CFAbs
{
CFDateFormatterSetFormat(t_formatter, p_format);
CFStringRef cfstr = CFDateFormatterCreateStringWithAbsoluteTime(NULL, t_formatter, p_time);
- if (!MCStringCreateWithCFString(cfstr, t_formatted_time))
+ if (!MCStringCreateWithCFStringRef(cfstr, t_formatted_time))
t_success = false;
CFRelease(cfstr);
}
@@ -236,7 +236,7 @@ static bool osx_cf_fetch_format(CFLocaleRef p_locale, CFDateFormatterStyle p_dat
MCAutoStringRef t_icu_format;
if (t_success)
- t_success = MCStringCreateWithCFString(CFDateFormatterGetFormat(t_formatter), &t_icu_format);
+ t_success = MCStringCreateWithCFStringRef(CFDateFormatterGetFormat(t_formatter), &t_icu_format);
MCStringRef t_format;
t_format = nil;
diff --git a/libfoundation/include/foundation.h b/libfoundation/include/foundation.h
index f49ea4d1e38..05643b68450 100644
--- a/libfoundation/include/foundation.h
+++ b/libfoundation/include/foundation.h
@@ -620,10 +620,14 @@ typedef uint16_t unichar_t;
typedef wchar_t *BSTR;
#endif
-#if defined(__MAC__) || defined(__IOS__)
+#if defined(__HAS_CORE_FOUNDATION__)
+typedef const void *CFTypeRef;
+typedef const struct __CFBoolean *CFBooleanRef;
typedef const struct __CFNumber *CFNumberRef;
typedef const struct __CFString *CFStringRef;
typedef const struct __CFData *CFDataRef;
+typedef const struct __CFArray *CFArrayRef;
+typedef const struct __CFDictionary *CFDictionaryRef;
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -1512,7 +1516,12 @@ inline void *MCValueGetExtraBytesPtr(MCValueRef value) { return ((uint8_t *)valu
// Emit a debug log message containing the description of the value
MC_DLLEXPORT void MCValueLog(MCValueRef);
#endif
-
+
+#if defined(__HAS_CORE_FOUNDATION__)
+MC_DLLEXPORT bool MCValueCreateWithCFTypeRef(CFTypeRef p_cf_value, bool p_use_lists, MCValueRef& r_cf_value);
+MC_DLLEXPORT bool MCValueConvertToCFTypeRef(MCValueRef p_value, bool p_use_lists, CFTypeRef& r_cf_value);
+#endif
+
//////////
}
@@ -1993,7 +2002,12 @@ MC_DLLEXPORT extern MCBooleanRef kMCFalse;
MC_DLLEXPORT extern MCBooleanRef kMCTrue;
MC_DLLEXPORT bool MCBooleanCreateWithBool(bool value, MCBooleanRef& r_boolean);
-
+
+#if defined(__HAS_CORE_FOUNDATION__)
+MC_DLLEXPORT bool MCBooleanCreateWithCFBooleanRef(CFBooleanRef p_cf_number, MCBooleanRef& r_number);
+MC_DLLEXPORT bool MCBooleanConvertToCFBooleanRef(MCBooleanRef p_number, CFBooleanRef& r_cf_number);
+#endif
+
////////////////////////////////////////////////////////////////////////////////
//
// NUMBER DEFINITIONS
@@ -2016,9 +2030,9 @@ MC_DLLEXPORT bool MCNumberParseOffset(MCStringRef p_string, uindex_t offset, uin
MC_DLLEXPORT bool MCNumberParse(MCStringRef string, MCNumberRef& r_number);
MC_DLLEXPORT bool MCNumberParseUnicodeChars(const unichar_t *chars, uindex_t char_count, MCNumberRef& r_number);
-#if defined(__MAC__) || defined (__IOS__)
-// Convert the given array to a CFArrayRef if it is a sequence.
-MC_DLLEXPORT bool MCNumberConvertToCFNumberRef(MCArrayRef self, CFNumberRef& r_array);
+#if defined(__HAS_CORE_FOUNDATION__)
+MC_DLLEXPORT bool MCNumberCreateWithCFNumberRef(CFNumberRef p_cf_number, MCNumberRef& r_number);
+MC_DLLEXPORT bool MCNumberConvertToCFNumberRef(MCNumberRef p_number, CFNumberRef& r_cf_number);
#endif
MC_DLLEXPORT extern MCNumberRef kMCZero;
@@ -2152,8 +2166,7 @@ MC_DLLEXPORT bool MCStringCreateWithCStringAndRelease(char *cstring /*delete[]*/
#ifdef __HAS_CORE_FOUNDATION__
// Create a string from a CoreFoundation string object.
-MC_DLLEXPORT bool MCStringCreateWithCFString(CFStringRef cf_string, MCStringRef& r_string);
-MC_DLLEXPORT bool MCStringCreateWithCFStringAndRelease(CFStringRef cf_string, MCStringRef& r_string);
+MC_DLLEXPORT bool MCStringCreateWithCFStringRef(CFStringRef cf_string, MCStringRef& r_string);
#endif
// Create a string from a Pascal-style (counted) string. This always uses the MacRoman encoding.
@@ -2410,7 +2423,7 @@ MC_DLLEXPORT bool MCStringConvertToWString(MCStringRef string, unichar_t*& r_wst
// Converts the content to unicode_t*
MC_DLLEXPORT bool MCStringConvertToUTF8String(MCStringRef string, char*& r_utf8string);
-#if defined(__MAC__) || defined (__IOS__)
+#ifdef __HAS_CORE_FOUNDATION__
// Converts the content to CFStringRef
MC_DLLEXPORT bool MCStringConvertToCFStringRef(MCStringRef string, CFStringRef& r_cfstring);
#endif
@@ -2837,9 +2850,9 @@ MC_DLLEXPORT bool MCDataEndsWith(MCDataRef p_data, MCDataRef p_needle);
MC_DLLEXPORT bool MCDataFirstIndexOf(MCDataRef p_data, MCDataRef p_chunk, MCRange t_range, uindex_t& r_index);
MC_DLLEXPORT bool MCDataLastIndexOf(MCDataRef p_data, MCDataRef p_chunk, MCRange t_range, uindex_t& r_index);
-// convert the given data to CFDataRef
-#if defined(__MAC__) || defined (__IOS__)
-MC_DLLEXPORT bool MCDataConvertToCFDataRef(MCDataRef p_data, CFDataRef& r_cfdata);
+#if defined(__HAS_CORE_FOUNDATION__)
+MC_DLLEXPORT bool MCDataCreateWithCFDataRef(CFDataRef p_cf_data, MCDataRef& r_data);
+MC_DLLEXPORT bool MCDataConvertToCFDataRef(MCDataRef p_data, CFDataRef& r_cf_data);
#endif
////////////////////////////////////////////////////////////////////////////////
@@ -2917,6 +2930,22 @@ MC_DLLEXPORT bool MCArrayIterate(MCArrayRef array, uintptr_t& iterator, MCNameRe
// Returns true if the given array is the empty array.
MC_DLLEXPORT bool MCArrayIsEmpty(MCArrayRef self);
+#if defined(__HAS_CORE_FOUNDATION__)
+// If p_use_lists is true, then any arrays which look like sequences will be
+// converted to MCProperListRef / CFArrayRef (depending on direction).
+
+MC_DLLEXPORT bool MCArrayCreateWithCFDictionaryRef(CFDictionaryRef p_cf_dictionary, bool p_use_lists, MCArrayRef& r_array);
+MC_DLLEXPORT bool MCArrayConvertToCFDictionaryRef(MCArrayRef p_value, bool p_use_lists, CFDictionaryRef& r_cf_value);
+MC_DLLEXPORT bool MCArrayCreateWithCFArrayRef(CFArrayRef p_cf_array, bool p_use_lists, MCArrayRef& r_array);
+// Attempt to convert the array to a CFArrayRef. If the array cannot be
+// converted, r_cf_value is set to nullptr and true is returned.
+MC_DLLEXPORT bool MCArrayConvertToCFArrayRef(MCArrayRef p_value, bool p_use_lists, CFArrayRef& r_cf_value);
+#endif
+
+// Attempt to convert the array to a properlist. If the array cannot be
+// converted to a list, r_list is set to nullptr and true is returned.
+MC_DLLEXPORT bool MCArrayConvertToProperList(MCArrayRef p_array, MCProperListRef& r_list);
+
////////////////////////////////////////////////////////////////////////////////
//
// LIST DEFINITIONS
@@ -3457,6 +3486,13 @@ MC_DLLEXPORT bool MCProperListEndsWithList(MCProperListRef list, MCProperListRef
MC_DLLEXPORT bool MCProperListIsListOfType(MCProperListRef list, MCValueTypeCode p_type);
MC_DLLEXPORT bool MCProperListIsHomogeneous(MCProperListRef list, MCValueTypeCode& r_type);
+#if defined(__HAS_CORE_FOUNDATION__)
+MC_DLLEXPORT bool MCProperListCreateWithCFArrayRef(CFArrayRef p_cf_dictionary, bool p_use_lists, MCProperListRef& r_list);
+MC_DLLEXPORT bool MCProperListConvertToCFArrayRef(MCProperListRef p_list, bool p_use_lists, CFArrayRef& r_list);
+#endif
+
+MC_DLLEXPORT bool MCProperListConvertToArray(MCProperListRef p_list, MCArrayRef& r_array);
+
////////////////////////////////////////////////////////////////////////////////
//
// OBJC DEFINITIONS
diff --git a/libfoundation/libfoundation.gyp b/libfoundation/libfoundation.gyp
index fff4fe5a2ae..fc30f1f1f90 100644
--- a/libfoundation/libfoundation.gyp
+++ b/libfoundation/libfoundation.gyp
@@ -79,7 +79,8 @@
'src/foundation-array.cpp',
'src/foundation-bidi.cpp',
- 'src/foundation-chunk.cpp',
+ 'src/foundation-chunk.cpp',
+ 'src/foundation-cf.cpp',
'src/foundation-core.cpp',
'src/foundation-custom.cpp',
'src/foundation-data.cpp',
@@ -102,7 +103,6 @@
'src/foundation-set.cpp',
'src/foundation-stream.cpp',
'src/foundation-string.cpp',
- 'src/foundation-string-cf.cpp',
'src/foundation-string-native.cpp.h',
'src/foundation-text.cpp',
'src/foundation-typeconvert.cpp',
@@ -169,7 +169,7 @@
'sources!':
[
- 'src/foundation-string-cf.cpp',
+ 'src/foundation-cf.cpp',
'src/foundation-objc.mm',
],
},
diff --git a/libfoundation/src/foundation-array.cpp b/libfoundation/src/foundation-array.cpp
index e235547f84b..3089cdd188b 100644
--- a/libfoundation/src/foundation-array.cpp
+++ b/libfoundation/src/foundation-array.cpp
@@ -619,6 +619,42 @@ bool MCArrayIsEmpty(MCArrayRef self)
////////////////////////////////////////////////////////////////////////////////
+MC_DLLEXPORT_DEF
+bool MCArrayConvertToProperList(MCArrayRef p_array, MCProperListRef& r_list)
+{
+ MCAutoProperListRef t_list;
+ if (!MCProperListCreateMutable(&t_list))
+ {
+ return false;
+ }
+
+ for(uindex_t t_index = 1; t_index <= MCArrayGetCount(p_array); t_index++)
+ {
+ MCValueRef t_value;
+ if (!MCArrayFetchValueAtIndex(p_array, t_index, t_value))
+ {
+ r_list = nullptr;
+ return true;
+ }
+
+ if (!MCProperListPushElementOntoBack(*t_list, t_value))
+ {
+ return false;
+ }
+ }
+
+ if (!t_list.MakeImmutable())
+ {
+ return false;
+ }
+
+ r_list = t_list.Take();
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
void __MCArrayDestroy(__MCArray *self)
{
if (__MCArrayIsIndirect(self))
diff --git a/libfoundation/src/foundation-cf.cpp b/libfoundation/src/foundation-cf.cpp
new file mode 100644
index 00000000000..fbf4b380e31
--- /dev/null
+++ b/libfoundation/src/foundation-cf.cpp
@@ -0,0 +1,525 @@
+/* Copyright (C) 2003-2015 LiveCode Ltd.
+
+This file is part of LiveCode.
+
+LiveCode is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License v3 as published by the Free
+Software Foundation.
+
+LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with LiveCode. If not see . */
+
+#include
+#include
+
+#include "foundation-private.h"
+
+#define integer_t cf_integer_t
+#include
+#undef integer_t
+
+////////////////////////////////////////////////////////////////////////////////
+
+template
+static inline void CFDeleter(T type)
+{
+ if (type == nullptr)
+ return;
+ CFRelease(type);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCBooleanCreateWithCFBooleanRef(CFBooleanRef p_cf_boolean, MCBooleanRef& r_boolean)
+{
+ if (p_cf_boolean == kCFBooleanTrue)
+ {
+ r_boolean = MCValueRetain(kMCTrue);
+ }
+ else
+ {
+ r_boolean = MCValueRetain(kMCFalse);
+ }
+
+ return true;
+}
+
+MC_DLLEXPORT_DEF
+bool MCBooleanConvertToCFBooleanRef(MCBooleanRef p_boolean, CFBooleanRef& r_boolean_ref)
+{
+ if (p_boolean == kMCTrue)
+ {
+ r_boolean_ref = (CFBooleanRef)CFRetain(kCFBooleanTrue);
+ }
+ else
+ {
+ r_boolean_ref = (CFBooleanRef)CFRetain(kCFBooleanFalse);
+ }
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCNumberCreateWithCFNumberRef(CFNumberRef p_cf_number, MCNumberRef& r_number)
+{
+ if (!CFNumberIsFloatType(p_cf_number))
+ {
+ int64_t t_integer;
+ CFNumberGetValue(p_cf_number, kCFNumberSInt64Type, &t_integer);
+ if (t_integer >= INTEGER_MIN && t_integer <= INTEGER_MAX)
+ {
+ return MCNumberCreateWithInteger((integer_t)t_integer, r_number);
+ }
+ else if (t_integer >= UINTEGER_MIN && t_integer <= UINTEGER_MAX)
+ {
+ return MCNumberCreateWithUnsignedInteger((uinteger_t)t_integer, r_number);
+ }
+ }
+
+ double t_real;
+ CFNumberGetValue(p_cf_number, kCFNumberDoubleType, &t_real);
+ return MCNumberCreateWithReal(t_real, r_number);
+}
+
+MC_DLLEXPORT_DEF
+bool MCNumberConvertToCFNumberRef(MCNumberRef p_number, CFNumberRef& r_number_ref)
+{
+ CFNumberRef t_number_ref;
+ if (MCNumberIsInteger(p_number))
+ {
+ t_number_ref = CFNumberCreate(nullptr, kCFNumberSInt32Type, &p_number->integer);
+ }
+ else
+ {
+ t_number_ref = CFNumberCreate(nullptr, kCFNumberDoubleType, &p_number->real);
+ }
+
+ if (t_number_ref == nullptr)
+ {
+ return false;
+ }
+
+ r_number_ref = t_number_ref;
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCStringCreateWithCFStringRef(CFStringRef p_cf_string, MCStringRef& r_string)
+{
+ bool t_success;
+ t_success = true;
+
+ CFIndex t_string_length;
+ t_string_length = CFStringGetLength(p_cf_string);
+
+ CFIndex t_buffer_size;
+ t_buffer_size = CFStringGetMaximumSizeForEncoding(t_string_length, kCFStringEncodingUnicode) + 1;
+
+ MCAutoPointer t_buffer;
+ t_success = MCMemoryNewArray(t_buffer_size, &t_buffer);
+
+ CFIndex t_used_size;
+ if (t_success)
+ CFStringGetBytes(p_cf_string, CFRangeMake(0, t_string_length), kCFStringEncodingUnicode, '?', false, (UInt8*)*t_buffer, t_buffer_size, &t_used_size);
+
+ if (t_success)
+ t_success = MCStringCreateWithChars((unichar_t *)*t_buffer, t_used_size / 2, r_string);
+
+ return t_success;
+}
+
+MC_DLLEXPORT_DEF
+bool MCStringConvertToCFStringRef(MCStringRef p_string, CFStringRef& r_cfstring)
+{
+ __MCAssertIsString(p_string);
+
+ uindex_t t_length;
+ unichar_t* t_chars;
+
+ t_length = MCStringGetLength(p_string);
+ if (!MCMemoryNewArray(t_length + 1, t_chars))
+ return false;
+
+ MCStringGetChars(p_string, MCRangeMake(0, t_length), t_chars);
+ r_cfstring = CFStringCreateWithCharacters(nil, t_chars, t_length);
+
+ MCMemoryDeleteArray(t_chars);
+ return r_cfstring != nil;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCDataCreateWithCFDataRef(CFDataRef p_cf_data, MCDataRef& r_data)
+{
+ return MCDataCreateWithBytes(CFDataGetBytePtr(p_cf_data), CFDataGetLength(p_cf_data), r_data);
+}
+
+MC_DLLEXPORT_DEF
+bool MCDataConvertToCFDataRef(MCDataRef p_data, CFDataRef& r_cf_data)
+{
+ CFDataRef t_cf_data = CFDataCreate(nil, MCDataGetBytePtr(p_data), MCDataGetLength(p_data));
+ if (t_cf_data == nullptr)
+ {
+ return false;
+ }
+ r_cf_data = t_cf_data;
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCProperListCreateWithCFArrayRef(CFArrayRef p_cf_array, bool p_use_lists, MCProperListRef& r_list)
+{
+ MCAutoProperListRef t_list;
+ if (!MCProperListCreateMutable(&t_list))
+ {
+ return false;
+ }
+
+ for(CFIndex t_index = 0; t_index < CFArrayGetCount(p_cf_array); t_index++)
+ {
+ MCAutoValueRef t_value;
+ if (!MCValueCreateWithCFTypeRef(CFArrayGetValueAtIndex(p_cf_array, t_index), p_use_lists, &t_value) ||
+ !MCProperListPushElementOntoBack(*t_list, *t_value))
+ {
+ return false;
+ }
+ }
+
+ if (!t_list.MakeImmutable())
+ {
+ return false;
+ }
+
+ r_list = t_list.Take();
+
+ return true;
+}
+
+MC_DLLEXPORT_DEF
+bool MCProperListConvertToCFArrayRef(MCProperListRef p_list, bool p_use_lists, CFArrayRef& r_cf_array)
+{
+ MCAutoCustomPointer t_cf_array =
+ CFArrayCreateMutable(nullptr, MCProperListGetLength(p_list), &kCFTypeArrayCallBacks);
+
+ if (!t_cf_array)
+ {
+ return MCErrorThrowOutOfMemory();
+ }
+
+ for(uindex_t t_index = 0; t_index < MCProperListGetLength(p_list); t_index++)
+ {
+ MCAutoCustomPointer t_cf_value;
+ if (!MCValueConvertToCFTypeRef(MCProperListFetchElementAtIndex(p_list, t_index), p_use_lists, &t_cf_value))
+ {
+ return false;
+ }
+ CFArraySetValueAtIndex((CFMutableArrayRef)*t_cf_value, t_index, *t_cf_value);
+ }
+
+ r_cf_array = (CFArrayRef)t_cf_array.Release();
+
+ return true;
+}
+
+MC_DLLEXPORT_DEF
+bool MCProperListCreateWithCFDictionaryRef(CFDictionaryRef p_cf_dictionary, bool p_use_lists, MCProperListRef& r_proper_list)
+{
+ MCAutoArrayRef t_array;
+ if (!MCArrayCreateWithCFDictionaryRef(p_cf_dictionary, p_use_lists, &t_array))
+ {
+ return false;
+ }
+
+ return MCArrayConvertToProperList(*t_array, r_proper_list);
+}
+
+MC_DLLEXPORT_DEF
+bool MCProperListConvertToCFDictionaryRef(MCProperListRef p_list, bool p_use_lists, CFDictionaryRef& r_cf_dictionary)
+{
+ MCAutoArrayRef t_array;
+ if (!MCProperListConvertToArray(p_list, &t_array))
+ {
+ return false;
+ }
+
+ return MCArrayConvertToCFDictionaryRef(*t_array, p_use_lists, r_cf_dictionary);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+struct MCArrayCreateWithCFDictionaryRefContext
+{
+ bool use_lists;
+ MCArrayRef array;
+ bool result;
+};
+
+static void MCArrayCreateWithCFDictionaryRefApplier(const void *p_key, const void *p_value, void *p_context)
+{
+ MCArrayCreateWithCFDictionaryRefContext *context =
+ static_cast(p_context);
+
+ CFTypeRef t_cf_key = (CFTypeRef)p_key;
+ CFTypeRef t_cf_value = (CFTypeRef)p_value;
+
+ if (p_value == nullptr)
+ {
+ return;
+ }
+
+ if (CFGetTypeID(p_key) != CFStringGetTypeID())
+ {
+ context->result = false;
+ return;
+ }
+
+ MCAutoStringRef t_key_string;
+ MCNewAutoNameRef t_key;
+ MCAutoValueRef t_value;
+ if (!MCStringCreateWithCFStringRef((CFStringRef)t_cf_key, &t_key_string) ||
+ !MCNameCreate(*t_key_string, &t_key) ||
+ !MCValueCreateWithCFTypeRef(t_cf_value, context->use_lists, &t_value) ||
+ !MCArrayStoreValue(context->array, true, *t_key, *t_value))
+ {
+ context->result = false;
+ return;
+ }
+}
+
+MC_DLLEXPORT_DEF
+bool MCArrayCreateWithCFDictionaryRef(CFDictionaryRef p_cf_dict, bool p_use_lists, MCArrayRef& r_array)
+{
+ MCAutoArrayRef t_array;
+ if (!MCArrayCreateMutable(&t_array))
+ {
+ return false;
+ }
+
+ MCArrayCreateWithCFDictionaryRefContext t_context;
+ t_context.use_lists = p_use_lists;
+ t_context.array = *t_array;
+ t_context.result = true;
+ CFDictionaryApplyFunction(p_cf_dict, MCArrayCreateWithCFDictionaryRefApplier, &t_context);
+
+ if (!t_context.result)
+ {
+ return false;
+ }
+
+ if (!t_array.MakeImmutable())
+ {
+ return false;
+ }
+
+ r_array = t_array.Take();
+
+ return true;
+}
+
+MC_DLLEXPORT_DEF
+bool MCArrayConvertToCFDictionaryRef(MCArrayRef p_array, bool p_use_lists, CFDictionaryRef& r_cf_dict)
+{
+ MCAutoCustomPointer t_cf_dict =
+ CFDictionaryCreateMutable(nullptr, MCArrayGetCount(p_array),
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+
+ uintptr_t t_iterator = 0;
+ MCNameRef t_key = nullptr;
+ MCValueRef t_value = nullptr;
+ while(MCArrayIterate(p_array, t_iterator, t_key, t_value))
+ {
+ MCAutoCustomPointer t_cf_key;
+ if (!MCStringConvertToCFStringRef(MCNameGetString(t_key), (CFStringRef&)t_cf_key))
+ {
+ return false;
+ }
+
+ MCAutoCustomPointer t_cf_value;
+ if (!MCValueConvertToCFTypeRef(t_value, p_use_lists, &t_cf_value))
+ {
+ return false;
+ }
+
+ CFDictionarySetValue((CFMutableDictionaryRef)*t_cf_dict, *t_cf_key, *t_cf_value);
+ }
+
+ r_cf_dict = (CFDictionaryRef)t_cf_dict.Release();
+
+ return true;
+}
+
+MC_DLLEXPORT_DEF
+bool MCArrayCreateWithCFArrayRef(CFArrayRef p_cf_array, bool p_use_lists, MCArrayRef& r_array)
+{
+ MCAutoProperListRef t_list;
+ if (!MCProperListCreateWithCFArrayRef(p_cf_array, p_use_lists, &t_list))
+ {
+ return false;
+ }
+
+ return MCProperListConvertToArray(*t_list, r_array);
+}
+
+MC_DLLEXPORT_DEF
+bool MCArrayConvertToCFArrayRef(MCArrayRef p_array, bool p_use_lists, CFArrayRef& r_cf_array)
+{
+ MCAutoProperListRef t_list;
+ if (!MCArrayConvertToProperList(p_array, &t_list))
+ {
+ return false;
+ }
+
+ if (*t_list == nullptr)
+ {
+ r_cf_array = nullptr;
+ return true;
+ }
+
+ return MCProperListConvertToCFArrayRef(*t_list, p_use_lists, r_cf_array);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+MC_DLLEXPORT_DEF
+bool MCValueCreateWithCFTypeRef(CFTypeRef p_cf_type, bool p_use_lists, MCValueRef& r_value)
+{
+ CFTypeID t_type_id = CFGetTypeID(p_cf_type);
+ if ((CFNullRef)p_cf_type == kCFNull)
+ {
+ r_value = MCValueRetain(kMCNull);
+ return true;
+ }
+ else if ((CFBooleanRef)p_cf_type == kCFBooleanTrue)
+ {
+ r_value = MCValueRetain(kMCTrue);
+ return true;
+ }
+ else if ((CFBooleanRef)p_cf_type == kCFBooleanFalse)
+ {
+ r_value = MCValueRetain(kMCFalse);
+ return true;
+ }
+ else if (t_type_id == CFNumberGetTypeID())
+ {
+ return MCNumberCreateWithCFNumberRef((CFNumberRef)p_cf_type, (MCNumberRef&)r_value);
+ }
+ else if (t_type_id == CFDataGetTypeID())
+ {
+ return MCDataCreateWithCFDataRef((CFDataRef)p_cf_type, (MCDataRef&)r_value);
+ }
+ else if (t_type_id == CFStringGetTypeID())
+ {
+ return MCStringCreateWithCFStringRef((CFStringRef)p_cf_type, (MCStringRef&)r_value);
+ }
+ else if (t_type_id == CFArrayGetTypeID())
+ {
+ if (p_use_lists)
+ {
+ return MCProperListCreateWithCFArrayRef((CFArrayRef)p_cf_type, p_use_lists, (MCProperListRef&)r_value);
+ }
+ return MCArrayCreateWithCFArrayRef((CFArrayRef)p_cf_type, p_use_lists, (MCArrayRef&)r_value);
+ }
+ else if (t_type_id == CFDictionaryGetTypeID())
+ {
+ MCAutoArrayRef t_array;
+ if (!MCArrayCreateWithCFDictionaryRef((CFDictionaryRef)p_cf_type, p_use_lists, &t_array))
+ {
+ return false;
+ }
+
+ MCValueRef t_value;
+ if (p_use_lists &&
+ MCArrayFetchValueAtIndex(*t_array, 1, t_value))
+ {
+ MCAutoProperListRef t_maybe_list;
+ if (!MCArrayConvertToProperList(*t_array, &t_maybe_list))
+ {
+ return false;
+ }
+ if (*t_maybe_list != nullptr)
+ {
+ r_value = t_maybe_list.Take();
+ return true;
+ }
+ }
+
+ r_value = t_array.Take();
+
+ return true;
+ }
+
+ return MCObjcObjectCreateWithId((void *)p_cf_type, (MCObjcObjectRef&)r_value);
+}
+
+MC_DLLEXPORT_DEF
+bool MCValueConvertToCFTypeRef(MCValueRef p_value, bool p_use_lists, CFTypeRef& r_cf_type)
+{
+ switch(MCValueGetTypeCode(p_value))
+ {
+ case kMCValueTypeCodeNull:
+ r_cf_type = CFRetain(kCFNull);
+ return true;
+
+ case kMCValueTypeCodeBoolean:
+ return MCBooleanConvertToCFBooleanRef((MCBooleanRef)p_value, (CFBooleanRef&)r_cf_type);
+
+ case kMCValueTypeCodeNumber:
+ return MCNumberConvertToCFNumberRef((MCNumberRef)p_value, (CFNumberRef&)r_cf_type);
+
+ case kMCValueTypeCodeData:
+ return MCDataConvertToCFDataRef((MCDataRef)p_value, (CFDataRef&)r_cf_type);
+
+ case kMCValueTypeCodeString:
+ return MCStringConvertToCFStringRef((MCStringRef)p_value, (CFStringRef&)r_cf_type);
+
+ case kMCValueTypeCodeName:
+ return MCStringConvertToCFStringRef(MCNameGetString((MCNameRef)p_value), (CFStringRef&)r_cf_type);
+
+ case kMCValueTypeCodeArray:
+ MCValueRef t_value;
+ if (p_use_lists &&
+ MCArrayFetchValueAtIndex((MCArrayRef)p_value, 1, t_value))
+ {
+ CFTypeRef t_cf_type;
+ if (!MCArrayConvertToCFArrayRef((MCArrayRef)p_value, p_use_lists, (CFArrayRef&)t_cf_type))
+ {
+ return false;
+ }
+ if (t_cf_type != nullptr)
+ {
+ r_cf_type = t_cf_type;
+ return true;
+ }
+ }
+ return MCArrayConvertToCFDictionaryRef((MCArrayRef)p_value, p_use_lists, (CFDictionaryRef&)r_cf_type);
+
+ case kMCValueTypeCodeProperList:
+ return MCProperListConvertToCFArrayRef((MCProperListRef)p_value, p_use_lists, (CFArrayRef&)r_cf_type);
+
+ default:
+ if (MCValueGetTypeInfo(p_value) == kMCObjcObjectTypeInfo)
+ {
+ r_cf_type = MCObjcObjectGetId((MCObjcObjectRef)p_value);
+ return true;
+ }
+ break;
+ }
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
diff --git a/libfoundation/src/foundation-data.cpp b/libfoundation/src/foundation-data.cpp
index 755bbfd4a14..c89a3d2d997 100644
--- a/libfoundation/src/foundation-data.cpp
+++ b/libfoundation/src/foundation-data.cpp
@@ -867,20 +867,6 @@ MCDataLastIndexOf (MCDataRef self,
return false;
}
-#if defined(__MAC__) || defined (__IOS__)
-MC_DLLEXPORT_DEF
-bool MCDataConvertToCFDataRef(MCDataRef p_data, CFDataRef& r_cfdata)
-{
- __MCAssertIsData(p_data);
-
- if (__MCDataIsIndirect(p_data))
- p_data = p_data -> contents;
-
- r_cfdata = CFDataCreate(nil, MCDataGetBytePtr(p_data), MCDataGetLength(p_data));
- return r_cfdata != nil;
-}
-#endif
-
static void __MCDataClampRange(MCDataRef p_data, MCRange& x_range)
{
uindex_t t_left, t_right;
diff --git a/libfoundation/src/foundation-number.cpp b/libfoundation/src/foundation-number.cpp
index f375f17c77b..65ceb1b8d39 100644
--- a/libfoundation/src/foundation-number.cpp
+++ b/libfoundation/src/foundation-number.cpp
@@ -283,29 +283,6 @@ bool MCNumberParseOffsetPartial(MCStringRef p_string, uindex_t offset, uindex_t
return t_success;
}
-#if defined(__MAC__) || defined (__IOS__)
-#include
-MC_DLLEXPORT_DEF
-bool MCNumberConvertToCFNumberRef(MCNumberRef self, CFNumberRef& r_number)
-{
- CFNumberRef t_number;
- if (MCNumberIsInteger(self))
- t_number = CFNumberCreate(NULL,
- kCFNumberIntType,
- &self -> integer);
- else
- t_number = CFNumberCreate(NULL,
- kCFNumberFloat64Type,
- &self -> real);
-
- if (t_number == NULL)
- return false;
-
- r_number = t_number;
- return true;
-}
-#endif
-
////////////////////////////////////////////////////////////////////////////////
bool __MCNumberCopyDescription(__MCNumber *self, MCStringRef& r_string)
diff --git a/libfoundation/src/foundation-proper-list.cpp b/libfoundation/src/foundation-proper-list.cpp
index 004ec705567..5912fdb3cfc 100644
--- a/libfoundation/src/foundation-proper-list.cpp
+++ b/libfoundation/src/foundation-proper-list.cpp
@@ -972,6 +972,35 @@ bool MCProperListReverse(MCProperListRef self)
////////////////////////////////////////////////////////////////////////////////
+MC_DLLEXPORT_DEF
+bool MCProperListConvertToArray(MCProperListRef p_list, MCArrayRef& r_array)
+{
+ MCAutoArrayRef t_array;
+ if (!MCArrayCreateMutable(&t_array))
+ {
+ return false;
+ }
+
+ for(uindex_t t_index = 0; t_index < MCProperListGetLength(p_list); t_index++)
+ {
+ if (!MCArrayStoreValueAtIndex(*t_array, t_index + 1, MCProperListFetchElementAtIndex(p_list, t_index)))
+ {
+ return false;
+ }
+ }
+
+ if (!t_array.MakeImmutable())
+ {
+ return false;
+ }
+
+ r_array = t_array.Take();
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
void __MCProperListDestroy(__MCProperList *self)
{
if (__MCProperListIsIndirect(self))
diff --git a/libfoundation/src/foundation-string-cf.cpp b/libfoundation/src/foundation-string-cf.cpp
deleted file mode 100644
index 873309f1a26..00000000000
--- a/libfoundation/src/foundation-string-cf.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2003-2015 LiveCode Ltd.
-
-This file is part of LiveCode.
-
-LiveCode is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License v3 as published by the Free
-Software Foundation.
-
-LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with LiveCode. If not see . */
-
-#include
-#include
-
-#include "foundation-private.h"
-
-#define integer_t cf_integer_t
-#include
-#undef integer_t
-
-////////////////////////////////////////////////////////////////////////////////
-
-MC_DLLEXPORT_DEF
-bool MCStringCreateWithCFString(CFStringRef p_cf_string, MCStringRef& r_string)
-{
- bool t_success;
- t_success = true;
-
- CFIndex t_string_length;
- t_string_length = CFStringGetLength(p_cf_string);
-
- CFIndex t_buffer_size;
- t_buffer_size = CFStringGetMaximumSizeForEncoding(t_string_length, kCFStringEncodingUnicode) + 1;
-
- MCAutoPointer t_buffer;
- t_success = MCMemoryNewArray(t_buffer_size, &t_buffer);
-
- CFIndex t_used_size;
- if (t_success)
- CFStringGetBytes(p_cf_string, CFRangeMake(0, t_string_length), kCFStringEncodingUnicode, '?', false, (UInt8*)*t_buffer, t_buffer_size, &t_used_size);
-
- if (t_success)
- t_success = MCStringCreateWithChars((unichar_t *)*t_buffer, t_used_size / 2, r_string);
-
- return t_success;
-}
-
-////////////////////////////////////////////////////////////////////////////////
diff --git a/libfoundation/src/foundation-string.cpp b/libfoundation/src/foundation-string.cpp
index 504a8eeadfb..6421c47615c 100755
--- a/libfoundation/src/foundation-string.cpp
+++ b/libfoundation/src/foundation-string.cpp
@@ -2863,27 +2863,6 @@ bool MCStringConvertToUTF32(MCStringRef self, uint32_t *&r_codepoints, uinteger_
return false;
}
-#if defined(__MAC__) || defined (__IOS__)
-MC_DLLEXPORT_DEF
-bool MCStringConvertToCFStringRef(MCStringRef p_string, CFStringRef& r_cfstring)
-{
- __MCAssertIsString(p_string);
-
- uindex_t t_length;
- unichar_t* t_chars;
-
- t_length = MCStringGetLength(p_string);
- if (!MCMemoryNewArray(t_length + 1, t_chars))
- return false;
-
- MCStringGetChars(p_string, MCRangeMake(0, t_length), t_chars);
- r_cfstring = CFStringCreateWithCharacters(nil, t_chars, t_length);
-
- MCMemoryDeleteArray(t_chars);
- return r_cfstring != nil;
-}
-#endif
-
#ifdef __WINDOWS__
MC_DLLEXPORT_DEF
bool MCStringConvertToBSTR(MCStringRef p_string, BSTR& r_bstr)
diff --git a/libscript/src/objc.lcb b/libscript/src/objc.lcb
index 90ad46111a6..bbfa22bbab5 100644
--- a/libscript/src/objc.lcb
+++ b/libscript/src/objc.lcb
@@ -31,7 +31,7 @@ public foreign type ObjcAutoreleasedId binds to "MCObjcAutoreleasedIdTypeInfo"
/****/
-private foreign handler MCStringCreateWithCFString(in pNSString as ObjcId, out rString as String) returns CBool binds to "MCStringCreateWithCFString"
+private foreign handler MCStringCreateWithCFStringRef(in pNSString as ObjcId, out rString as String) returns CBool binds to "MCStringCreateWithCFStringRef"
private foreign handler MCStringConvertToCFStringRef(in pString as String, out rNSString as ObjcRetainedId) returns CBool binds to "MCStringConvertToCFStringRef"
/**/
@@ -75,15 +75,15 @@ a variable of type String.
public handler StringFromNSString(in pObjcString as ObjcObject) returns String
variable tString as String
unsafe
- MCStringCreateWithCFString(pObjcString, tString)
+ MCStringCreateWithCFStringRef(pObjcString, tString)
end unsafe
return tString
end handler
/****/
-private foreign handler MCDataCreateWithCFData(in pNSData as ObjcId, out rString as Data) returns CBool binds to "MCDataCreateWithCFData"
-private foreign handler MCDataConvertToCFDataRef(in pNSData as Data, out rNSData as ObjcRetainedId) returns CBool binds to "MCDataConvertToCFDataRef"
+private foreign handler MCDataCreateWithCFDataRef(in pNSData as ObjcId, out rData as Data) returns CBool binds to "MCDataCreateWithCFDataRef"
+private foreign handler MCDataConvertToCFDataRef(in pData as Data, out rNSData as ObjcRetainedId) returns CBool binds to "MCDataConvertToCFDataRef"
/**/
@@ -98,7 +98,7 @@ A Objective-C object of type NSData
Description
Use to convert a variable of type Data to an Objective-C
-string object (NSData).
+data object (NSData).
*/
public handler DataToNSData(in pData as Data) returns ObjcObject
@@ -116,23 +116,174 @@ Parameters:
pObjcData: The NSData to convert
Returns:
-A String value
+A Data value
Description
Use to convert an Objective-C data object (NSData) to
a variable of type Data.
*/
-public handler DataFromNSData(in pObjcData as ObjcObject) returns String
+public handler DataFromNSData(in pObjcData as ObjcObject) returns Data
variable tData as Data
unsafe
- MCDataCreateWithCFData(pObjcData, tData)
+ MCDataCreateWithCFDataRef(pObjcData, tData)
end unsafe
return tData
end handler
/****/
+private foreign handler MCNumberCreateWithCFNumberRef(in pNSNumber as ObjcId, out rNumber as Number) returns CBool binds to "MCNumberCreateWithCFNumberRef"
+private foreign handler MCNumberConvertToCFNumberRef(in pNumber as Number, out rNSNumber as ObjcRetainedId) returns CBool binds to "MCNumberConvertToCFNumberRef"
+
+/**/
+
+/**
+Summary: Convert a Number into an Objective-C number
+
+Parameters:
+pNumber: The Number to convert
+
+Returns:
+A Objective-C object of type NSNumber
+
+Description
+Use to convert a variable of type Number to an Objective-C
+number object (NSNumber).
+
+*/
+public handler NumberToNSNumber(in pNumber as Number) returns ObjcObject
+ variable tNSNumber as ObjcRetainedId
+ unsafe
+ MCNumberConvertToCFNumberRef(pNumber, tNSNumber)
+ end unsafe
+ return tNSNumber
+end handler
+
+/**
+Summary: Convert a Objective-C number into a Number
+
+Parameters:
+pObjcNumber: The NSNumber to convert
+
+Returns:
+A Number value
+
+Description
+Use to convert an Objective-C number object (NSNumber) to
+a variable of type Number.
+
+*/
+public handler NumberFromNSNumber(in pObjcNumber as ObjcObject) returns Number
+ variable tNumber as Number
+ unsafe
+ MCNumberCreateWithCFNumberRef(pObjcNumber, tNumber)
+ end unsafe
+ return tNumber
+end handler
+
+/****/
+
+private foreign handler MCProperListCreateWithCFArrayRef(in pNSArray as ObjcId, in pUseLists as CBool, out rList as List) returns CBool binds to "MCProperListCreateWithCFArrayRef"
+private foreign handler MCProperListConvertToCFArrayRef(in pList as List, in pUseLists as CBool, out rNSArray as ObjcRetainedId) returns CBool binds to "MCProperListConvertToCFArrayRef"
+
+/**/
+
+/**
+Summary: Convert a List into an Objective-C array
+
+Parameters:
+pNumber: The List to convert
+
+Returns:
+A Objective-C object of type NSArray
+
+Description
+Use to convert a variable of type List to an Objective-C
+array object (NSArray).
+
+*/
+public handler ListToNSArray(in pList as List) returns ObjcObject
+ variable tNSArray as ObjcRetainedId
+ unsafe
+ MCProperListConvertToCFArrayRef(pList, true, tNSArray)
+ end unsafe
+ return tNSArray
+end handler
+
+/**
+Summary: Convert a Objective-C array into a List
+
+Parameters:
+pObjcNumber: The NSArray to convert
+
+Returns:
+A Number value
+
+Description
+Use to convert an Objective-C array object (NSArray) to
+a variable of type List.
+
+*/
+public handler ListFromNSArray(in pObjcArray as ObjcObject) returns List
+ variable tList as List
+ unsafe
+ MCProperListCreateWithCFArrayRef(pObjcArray, true, tList)
+ end unsafe
+ return tList
+end handler
+
+/****/
+
+private foreign handler MCArrayCreateWithCFDictionaryRef(in pNSDictionary as ObjcId, in pUseLists as CBool, out rArray as Array) returns CBool binds to "MCArrayCreateWithCFDictionaryRef"
+private foreign handler MCArrayConvertToCFDictionaryRef(in pArray as Array, in pUseLists as CBool, out rNSDictionary as ObjcRetainedId) returns CBool binds to "MCArrayConvertToCFDictionaryRef"
+
+/**
+Summary: Convert an Array into an Objective-C dictionary
+
+Parameters:
+pNumber: The Array to convert
+
+Returns:
+A Objective-C object of type NSDictionary
+
+Description
+Use to convert a variable of type Array to an Objective-C
+dictionary object (NSDictionary).
+
+*/
+public handler ArrayToNSDictionary(in pArray as Array) returns ObjcObject
+ variable tNSArray as ObjcRetainedId
+ unsafe
+ MCArrayConvertToCFDictionaryRef(pArray, true, tNSArray)
+ end unsafe
+ return tNSArray
+end handler
+
+/**
+Summary: Convert a Objective-C dictionary into a Array
+
+Parameters:
+pObjcNumber: The NSDictionary to convert
+
+Returns:
+An Array value
+
+Description
+Use to convert an Objective-C dictionary object (NSDictionary) to
+a variable of type Array.
+
+*/
+public handler ArrayFromNSDictionary(in pObjcArray as ObjcObject) returns List
+ variable tArray as Array
+ unsafe
+ MCArrayCreateWithCFDictionaryRef(pObjcArray, true, tArray)
+ end unsafe
+ return tArray
+end handler
+
+/****/
+
public handler type ObjcActionProxyHandler(in pSender as ObjcObject, in pContext as optional any) returns nothing
private foreign handler MCObjcObjectCreateActionProxy(in pHandler as optional any, in pValue as optional any) returns ObjcObject binds to "MCObjcObjectCreateActionProxy"
diff --git a/libscript/src/script-execute-objc.mm b/libscript/src/script-execute-objc.mm
index 3f9bf7e472c..fd1abe5fd12 100644
--- a/libscript/src/script-execute-objc.mm
+++ b/libscript/src/script-execute-objc.mm
@@ -35,7 +35,7 @@ bool MCScriptCallObjCCatchingErrors(ffi_cif *p_cif, void (*p_function)(), void *
@catch (NSException *exception)
{
MCAutoStringRef t_reason;
- if (!MCStringCreateWithCFString((CFStringRef)[exception reason], &t_reason))
+ if (!MCStringCreateWithCFStringRef((CFStringRef)[exception reason], &t_reason))
{
return false;
}