Beispiel #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;
		}
	}
}
Beispiel #2
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;
}
Beispiel #3
0
// MW-2015-03-09: [[ Bug 14139 ]] Fixed licensing issue with thirdparties
void MCLicenseGetRevLicenseInfoByKey(MCExecContext& ctxt, MCNameRef p_key, MCArrayRef& r_info)
{
    MCValueRef t_value;
    if (MClicenseparameters . addons == nil ||
        !MCArrayFetchValue(MClicenseparameters . addons, ctxt . GetCaseSensitive(), p_key, t_value))
        {
            r_info = MCValueRetain(kMCEmptyArray);
            return;
        }
    
    if (ctxt . ConvertToArray(t_value, r_info))
        return;
    
    ctxt . Throw();
}
Beispiel #4
0
bool MCArraysCopyTransposed(MCArrayRef self, MCArrayRef& r_transposed)
{
	MCAutoArray<array_extent_t> t_extents;
	if (!MCArraysCopyExtents(self, t_extents.PtrRef(), t_extents.SizeRef()) ||
		t_extents.Size() != 2)
		return false;

	integer_t t_rows = extent_size(t_extents[0]);
	integer_t t_cols = extent_size(t_extents[1]);

	integer_t t_row_end = t_extents[0].min + t_rows;
	integer_t t_col_end = t_extents[1].min + t_cols;

	if (MCArrayGetCount(self) != t_rows * t_cols)
		return false;

	MCAutoArrayRef t_transposed;
	if (!MCArrayCreateMutable(&t_transposed))
		return false;

	for (integer_t r = t_extents[0].min; r < t_row_end; r++)
	{
		for (integer_t c = t_extents[1].min; c < t_col_end; c++)
		{
			MCAutoStringRef t_src_string, t_dst_string;
			MCNewAutoNameRef t_src_name, t_dst_name;
			MCValueRef t_value;
			if (!MCStringFormat(&t_src_string, "%d,%d", r, c) ||
				!MCStringFormat(&t_dst_string, "%d,%d", c, r))
				return false;
			if (!MCNameCreate(*t_src_string, &t_src_name) ||
				!MCNameCreate(*t_dst_string, &t_dst_name))
				return false;
			if (!MCArrayFetchValue(self, true, *t_src_name, t_value) ||
				!MCArrayStoreValue(*t_transposed, true, *t_dst_name, t_value))
				return false;
		}
	}

	return MCArrayCopy(*t_transposed, r_transposed);
}
Beispiel #5
0
bool MCArraysCopyMatrix(MCExecContext& ctxt, MCArrayRef self, matrix_t*& r_matrix)
{
	MCAutoArray<array_extent_t> t_extents;
	if (!MCArraysCopyExtents(self, t_extents.PtrRef(), t_extents.SizeRef()) ||
		t_extents.Size() != 2)
		return false;

	integer_t t_rows = extent_size(t_extents[0]);
	integer_t t_cols = extent_size(t_extents[1]);

	integer_t t_row_offset = t_extents[0].min;
	integer_t t_col_offset = t_extents[1].min;

	if (MCArrayGetCount(self) != t_rows * t_cols)
		return false;

	MCAutoPointer<matrix_t> t_matrix;
	if (!MCMatrixNew(t_rows, t_cols, t_row_offset, t_col_offset, &t_matrix))
		return false;

	for (integer_t row = 0; row < t_rows; row++)
	{
		for (integer_t col = 0; col < t_cols; col++)
		{
			MCAutoStringRef t_string;
			MCNewAutoNameRef t_name;
			MCValueRef t_value;
			if (!MCStringFormat(&t_string, "%d,%d", row + t_row_offset, col + t_col_offset) ||
				!MCNameCreate(*t_string, &t_name) ||
				!MCArrayFetchValue(self, true, *t_name, t_value) ||
				!ctxt.ConvertToReal(t_value, MCMatrixEntry(*t_matrix, row, col)))
				return false;
		}
	}

	t_matrix.Take(r_matrix);
	return true;
}
Beispiel #6
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);
}
Beispiel #7
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);
    }
}
Beispiel #8
0
void MCArraysEvalIsAmongTheKeysOf(MCExecContext& ctxt, MCNameRef p_key, MCArrayRef p_array, bool& r_result)
{
	MCValueRef t_value;
	r_result = MCArrayFetchValue(p_array, ctxt.GetCaseSensitive(), p_key, t_value);
}