Пример #1
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;
	}
Пример #2
0
void MCArraysEvalIsAnArray(MCExecContext& ctxt, MCValueRef p_value, bool& r_result)
{
    // FG-2014-10-21: [[ Bugfix 13737 ]] An array is only an array if it has at
    // least one key (i.e the empty array is not an array...)
    r_result = MCValueGetTypeCode(p_value) == kMCValueTypeCodeArray
        && MCArrayGetCount((MCArrayRef)p_value) > 0;
}
Пример #3
0
void MCPlatformHandleApplicationStartup(int p_argc, MCStringRef *p_argv, MCStringRef *p_envp, int& r_error_code, MCStringRef & r_error_message)
{
    struct X_init_options t_options;
    t_options.argc = p_argc;
    t_options.argv = p_argv;
    t_options.envp = p_envp;
    t_options.app_code_path = nullptr;

	if (X_init(t_options))
	{
		r_error_code = 0;
		r_error_message = nil;
		return;
	}

    r_error_code = -1;

    if (MCresult == nullptr)
    {
        /* TODO[2017-04-05] X_init() failed before initialising global
         * variables.  This could be because something horrible happened, or it
         * could be because it found "-h" in the arguments.  It's better to
         * quit without an error message than to crash, but it the future it
         * would be good to distinguish between the two. */
        r_error_message = MCValueRetain(kMCEmptyString);
    }
    else if (MCValueGetTypeCode(MCresult -> getvalueref()) == kMCValueTypeCodeString)
    {
        r_error_message = (MCStringRef)MCValueRetain(MCresult->getvalueref());
    }
    else
    {
        r_error_message = MCValueRetain(MCSTR("Unknown error occurred"));
    }
}
Пример #4
0
// In standalone mode, we try to work out what went wrong...
void MCModeGetStartupErrorMessage(MCStringRef& r_caption, MCStringRef& r_text)
{
	r_caption = MCSTR("Initialization Error");
	if (MCValueGetTypeCode(MCresult -> getvalueref()) == kMCValueTypeCodeString)
		r_text = MCValueRetain((MCStringRef)MCresult -> getvalueref());
	else
		r_text = MCSTR("unknown reason");
}