示例#1
0
void MCArraysDoIntersect(MCExecContext& ctxt, MCArrayRef p_dst_array, MCArrayRef p_src_array, bool p_recursive)
{
	MCNameRef t_key;
	MCValueRef t_src_value;
    MCValueRef t_dst_value;
	uintptr_t t_iterator;
	t_iterator = 0;
    
    bool t_is_array;
    
	while(MCArrayIterate(p_dst_array, t_iterator, t_key, t_dst_value))
	{
		if (MCArrayFetchValue(p_src_array, ctxt . GetCaseSensitive(), t_key, t_src_value))
        {
            if (p_recursive && MCValueIsArray(t_dst_value) && MCValueIsArray(t_src_value))
            {
                MCArraysExecIntersectRecursive(ctxt, (MCArrayRef)t_dst_value, (MCArrayRef)t_src_value);
                if (ctxt . HasError())
                    return;
            }
			continue;
        }
        
		if (!MCArrayRemoveValue(p_dst_array, ctxt . GetCaseSensitive(), t_key))
		{
			ctxt . Throw();
			return;
		}
	}
}
示例#2
0
	static bool WidgetGeometryFromLCBList(MCValueRef p_list, uint32_t &r_width, uint32_t &r_height)
	{
		// MCProperList gets converted to a sequence array
		if (!MCValueIsArray(p_list))
			return false;
		
		MCArrayRef t_array;
		t_array = (MCArrayRef)p_list;
		
		if (!MCArrayIsSequence(t_array) || MCArrayGetCount(t_array) != 2)
			return false;
		
		uint32_t t_width, t_height;
		MCValueRef t_value;
		if (!MCArrayFetchValueAtIndex(t_array, 1, t_value) || MCValueGetTypeCode(t_value) != kMCValueTypeCodeNumber)
			return false;
		
		t_width = MCNumberFetchAsUnsignedInteger((MCNumberRef)t_value);
		
		if (!MCArrayFetchValueAtIndex(t_array, 2, t_value) || MCValueGetTypeCode(t_value) != kMCValueTypeCodeNumber)
			return false;
		
		t_height = MCNumberFetchAsUnsignedInteger((MCNumberRef)t_value);
		
		r_width = t_width;
		r_height = t_height;
		
		return true;
	}
示例#3
0
bool MCContactAddPropertyWithLabel(MCArrayRef p_contact, MCNameRef p_property, MCNameRef p_label, MCValueRef p_value)
{   
	MCValueRef t_element;
	MCValueRef t_array;
	if (!MCArrayFetchValue(p_contact, false, p_property, t_array) ||
		!MCValueIsArray(t_array) ||
		!MCArrayFetchValue((MCArrayRef)t_array, false, p_label, t_array))
		return false;
	
	uindex_t t_index = 1;
	if (!MCValueIsArray(t_array))
		t_index = 1;
	else
		t_index = MCArrayGetCount((MCArrayRef)t_array) + 1;
	
    MCAutoArrayRef t_copied_array;
    if (MCArrayCopy((MCArrayRef) t_array, &t_copied_array))
        return MCArrayStoreValueAtIndex(*t_copied_array, t_index, p_value);
    
    return false;
}
示例#4
0
void MCMailDoComposeMail(MCExecContext& ctxt, MCStringRef p_to, MCStringRef p_cc, MCStringRef p_bcc, MCStringRef p_subject, MCStringRef p_body, MCArrayRef p_attachments, MCMailType p_type)
{	
	bool t_can_send;
	MCMailGetCanSendMail(ctxt, t_can_send);

	if (!t_can_send)
		return;

	MCAutoArray<MCAttachmentData> t_attachments;

	if (p_attachments != nil && !MCArrayIsEmpty(p_attachments))
	{
		MCValueRef t_data;
		MCValueRef t_file;
		MCValueRef t_type;
		MCValueRef t_name;
		MCAttachmentData t_attachment;
		
		if (MCArrayIsSequence(p_attachments))
		{
			for(uindex_t i = 0; i < MCArrayGetCount(p_attachments); i++)
			{
				MCValueRef t_value;
				MCArrayFetchValueAtIndex(p_attachments, i + 1, t_value);
				if (!MCValueIsArray(t_value))
					continue;

                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("data"), t_data) ||
                    !ctxt . ConvertToData(t_data, t_attachment . data))
                    t_attachment . data = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("file"), t_file) ||
                    !ctxt . ConvertToString(t_file, t_attachment . file))
                    t_attachment . file = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("type"), t_type) ||
                    !ctxt . ConvertToString(t_type, t_attachment . type))
                    t_attachment . type = nil;
                
                if (!MCArrayFetchValue((MCArrayRef)t_value, false, MCNAME("name"), t_name) ||
                    !ctxt . ConvertToString(t_name, t_attachment . name))
                    t_attachment . name = nil;

				t_attachments . Push(t_attachment);
			}	
		}
		else
		{
			if (!MCArrayFetchValue(p_attachments, false, MCNAME("data"), t_data) ||
                !ctxt . ConvertToData(t_data, t_attachment . data))
                t_attachment . data = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("file"), t_file) ||
                !ctxt . ConvertToString(t_file, t_attachment . file))
                t_attachment . file = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("type"), t_type) ||
                !ctxt . ConvertToString(t_type, t_attachment . type))
                t_attachment . type = nil;
            
            if (!MCArrayFetchValue(p_attachments, false, MCNAME("name"), t_name) ||
                !ctxt . ConvertToString(t_name, t_attachment . name))
                t_attachment . name = nil;
		
			t_attachments . Push(t_attachment);
		}
	}

	MCAutoStringRef t_result;

	MCSystemSendMailWithAttachments(p_to, p_cc, p_bcc, p_subject, p_body, p_type, t_attachments . Ptr(), t_attachments . Size(), &t_result);

	ctxt . SetTheResultToValue(*t_result);
}
示例#5
0
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);
    }
}