Пример #1
0
/*
 * Get the function_type for an action holder
 */
static int
get_function_type(FILE * inFile, ABObj action)
{
    int                 return_value = 0;
    ISTRING             type_name = NULL;

    if (!abio_gil_get_name(inFile, &type_name))
    {
        return (abil_print_load_err(ERR_WANT_KEYWORD), -1);
    }

    if (istr_equalstr(type_name, "ExecuteCode"))
    {
        obj_set_func_type(action, AB_FUNC_CODE_FRAG);
    }
    else if (istr_equalstr(type_name, ":user_defined"))
    {
	/* yes, :user_defined in GIL means a builtin action */
        obj_set_func_type(action, AB_FUNC_BUILTIN);
    }
    else if (istr_equalstr(type_name, "CallFunction"))
    {
        obj_set_func_type(action, AB_FUNC_USER_DEF);
    }
    else
    {
        return (abil_print_load_err(ERR_WANT_KEYWORD), -1);
    }

    istr_destroy(type_name);
    return return_value;
}
Пример #2
0
static int
add_user_handler(ABObj obj, ABObj module,
                 ISTRING handler, AB_WHEN when)
{
    int                 retval = 0;
    ABObj               project = NULL;
    ABObj               action = NULL;

    if (handler == NULL)
    {
        return 0;
    }
    project = obj_get_project(module);

    /*
     * With "callbacks," the to field is irrelevant.  The target is generally
     * whatever widget calls the callback, so we set the "to" field to NULL,
     * so that this action may be used by multiple widgets.  I.e., if the
     * function type, name and to fields match, an action will be shared.
     */
    action = obj_create(AB_TYPE_ACTION, NULL);
    obj_set_func_type(action, AB_FUNC_USER_DEF);
    obj_set_func_name(action, istr_string(handler));
    obj_set_arg_type(action, AB_ARG_VOID_PTR);
    action->info.action.to = NULL;

    obj_set_from(action, obj);
    obj_set_when(action, when);

    install_action(obj, module, action);
    return 0;
}
Пример #3
0
static int
write_map_window(
			GenCodeInfo	genCodeInfo, 
			ABObj 		window,
			BOOL		show
)
{
    File	codeFile = genCodeInfo->code_file;
    ABObj	project = obj_get_project(window);
    ABObj	proj_root_window = abmfP_get_root_window(project);
    ABObjRec	showActionRec;
    ABObj	showAction = &showActionRec;
    ABObj	winParent = NULL;
    char	winParentName[1024];
    obj_construct(showAction, AB_TYPE_ACTION, NULL);
    *winParentName = 0;

    obj_set_from(showAction, NULL);
    obj_set_to(showAction, window);
    obj_set_func_type(showAction, AB_FUNC_BUILTIN);
    obj_set_func_builtin(showAction, AB_STDACT_SHOW);

    winParent = obj_get_win_parent(window);
    if (winParent == NULL)
    {
	sprintf(winParentName, "%s()", abmfP_lib_get_toplevel_widget->name);
    }
    else
    {
        strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent));
    }
    abio_printf(codeFile, "%s(%s, %s);\n",
	abmfP_get_init_proc_name(window),
	abmfP_get_c_struct_ptr_name(genCodeInfo, window),
	winParentName);

    if (show)
    	abmfP_write_builtin_action(genCodeInfo, showAction, FALSE);

    obj_destruct(showAction);
    return 0;
}