Example #1
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;
}
Example #2
0
/*
 * Get the operation.
 */
static int
get_operation(FILE * inFile, ABObj action)
{
    int                 return_value = 0;
    int                 rc = 0; /* r turn code */
    ISTRING             string = NULL;
    ISTRING             name = NULL;
    int                 intval;

    if (!abio_get_list_begin(inFile))
    {
        return (abil_print_load_err(ERR_WANT_LIST), -1);
    }

    switch (obj_get_func_type(action))
    {
    case AB_FUNC_CODE_FRAG:     /* code fragment */
        if (!abio_get_string(inFile, &string))
        {
            rc = abil_print_load_err(ERR_WANT_STRING);
            goto abort;
        }
        obj_set_func_code(action, istr_string(string));
        break;

    case AB_FUNC_USER_DEF:      /* function name (user defined) */
        if (!abio_gil_get_name(inFile, &name))
        {
            rc = abil_print_load_err(ERR_WANT_NAME);
            goto abort;
        }
        obj_set_func_name(action, istr_string(name));
        break;

    case AB_FUNC_BUILTIN:       /* predefined function */
        if (!abio_gil_get_name(inFile, &name))
        {
            return (abil_print_load_err(ERR_WANT_NAME), -1);
        }
        obj_set_func_builtin(action,
                          gilP_string_to_builtin_action(istr_string(name)));

        if (obj_get_func_builtin(action) != AB_STDACT_UNDEF)
        {
            if (abio_get_list_end(inFile))
                return return_value;

            switch (obj_get_arg_type(action))
            {
            case AB_ARG_STRING:
                if (!abio_get_string(inFile, &string))
                    return (abil_print_load_err(ERR_WANT_STRING), -1);
                obj_set_arg_string(action, istr_string(string));
                break;
            case AB_ARG_INT:
                if (!abio_get_integer(inFile, &intval))
                    return (abil_print_load_err(ERR_WANT_INTEGER), -1);
                obj_set_arg_int(action, intval);
                break;
            case AB_ARG_FLOAT:
                rc = abil_print_load_err(ERR_UNKNOWN);
                break;
            default:
                rc = abil_print_load_err(ERR_WANT_ARG);
                break;
            }
        }

        break;

    default:
        break;
    }

    if (rc < 0)
    {
        return_value = rc;
    }
    else
    {
        if (!abio_get_list_end(inFile))
        {
            return (abil_print_load_err(ERR_WANT_LIST), -1);
        }
    }

abort:
    istr_destroy(string);
    istr_destroy(name);
    return return_value;
}