/* * Write the project.h file. */ int abmfP_write_project_header_file( GenCodeInfo genCodeInfo, ABObj project, STRING codeFileName ) { File codeFile = genCodeInfo->code_file; char projectName[1024]; /* * Write file header. */ abmfP_write_user_header_seg(genCodeInfo); abio_puts(codeFile, nlstr); sprintf(projectName, "project %s", obj_get_name(project)); abmfP_write_file_header( genCodeInfo, codeFileName, TRUE, projectName, util_get_program_name(), ABMF_MODIFY_USER_SEGS, " * Contains: object data structures and callback declarations" ); write_includes(genCodeInfo); /* * Write declarations for i18n. * These are needed only if i18n is enabled. */ if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) write_i18n_declarations(genCodeInfo, project); write_app_resource_struct(genCodeInfo, project); write_connection_decls(genCodeInfo, project); write_callback_decls(genCodeInfo, project); write_app_resource_var_extern(genCodeInfo, project); abmfP_write_user_long_seg(genCodeInfo, "Add types, macros, and externs here"); abmfP_write_file_footer(genCodeInfo, codeFileName, TRUE); return OK; }
/* * Write the project.c file. */ int abmfP_write_project_c_file( GenCodeInfo genCodeInfo, STRING codeFileName, BOOL prepareForMerge, ABObj project ) { File codeFile = genCodeInfo->code_file; STRING errmsg = NULL; STRING *p = NULL; ABObj win_obj = NULL; ABObj obj = NULL; ABObj action = NULL; AB_ACTION_INFO *action_info = NULL; AB_TRAVERSAL trav; ABObj module = NULL; int numFuncsWritten = 0; char projectName[1024]; *projectName = 0; /* * Write file header. */ abmfP_write_user_header_seg(genCodeInfo); abio_puts(codeFile, nlstr); sprintf(projectName, "project %s", obj_get_name(project)); abmfP_write_file_header( genCodeInfo, codeFileName, FALSE, projectName, util_get_program_name(), ABMF_MODIFY_USER_SEGS, " * Contains: main() and cross-module connections" ); /* * Write includes. */ write_includes(genCodeInfo, project); /* * Write user segment */ abmfP_write_user_file_top_seg(genCodeInfo); /* i18n variable declarations */ if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) write_i18n_var_declrs(genCodeInfo, project); write_option_desc_list(genCodeInfo, project); write_app_resources(genCodeInfo, project); write_app_resource_var(genCodeInfo, project); /* * Write main(). */ write_main(genCodeInfo, project); /* * Write callback funcs. */ numFuncsWritten = 0; for (trav_open(&trav, project, AB_TRAV_ACTIONS); (action = trav_next(&trav)) != NULL;) { action_info = &(action->info.action); /* If the function name for the action is not NULL AND * the action is a cross-module connection OR the action * is a shared connection, then write it out. */ if ( (abmfP_get_action_name(action) != NULL) && ( obj_is_cross_module(action) || ( (!mfobj_has_flags(action, CGenFlagIsDuplicateDef)) && (mfobj_has_flags(action, CGenFlagWriteDefToProjFile)) && (obj_get_func_type(action) == AB_FUNC_USER_DEF) ) ) ) { ++numFuncsWritten; abmfP_write_action_function(genCodeInfo, action); } } trav_close(&trav); if (numFuncsWritten > 0) { abio_puts(codeFile, nlstr); } abmfP_write_user_file_bottom_seg(genCodeInfo); return OK; }
/* * Write the callback proc stub file. */ int abmfP_write_stubs_c_file( GenCodeInfo genCodeInfo, STRING codeFileName, ABObj module ) { File codeFile = genCodeInfo->code_file; STRING errmsg = NULL; ABObj win_obj = NULL; ABObj project = obj_get_project(module); char moduleHeaderFileName[MAX_PATH_SIZE]; char moduleName[MAX_PATH_SIZE]; /* * Write file header. */ abmfP_write_user_header_seg(genCodeInfo); abio_puts(codeFile, nlstr); sprintf(moduleName, "module %s", obj_get_name(module)); abmfP_write_file_header( genCodeInfo, codeFileName, FALSE, moduleName, util_get_program_name(), ABMF_MODIFY_USER_SEGS, " * Contains: Module callbacks and connection functions" ); /* * Write includes. */ strcpy(moduleHeaderFileName, abmfP_get_ui_header_file_name(module)); abmfP_write_c_system_include(genCodeInfo, "stdio.h"); abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h"); abmfP_write_c_local_include(genCodeInfo, abmfP_get_utils_header_file_name(module)); /* * Include project file if i18n is enabled. This file * is needed for the message catalog stuff */ if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) abmfP_write_c_local_include(genCodeInfo, abmfP_get_project_header_file_name(project)); abmfP_write_c_local_include(genCodeInfo, moduleHeaderFileName); /* * Write out includes for modules with connection targets */ { StringListRec connIncludes; int i = 0; int num_strings = 0; strlist_construct(&connIncludes); strlist_add_str(&connIncludes, moduleHeaderFileName, NULL); abmfP_get_connect_includes(&connIncludes, module); num_strings = strlist_get_num_strs(&connIncludes); if (num_strings > 1) /* start at 1 - skip this_ui.h */ { abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Header files for cross-module connections"); } for (i = 1; i < num_strings; ++i) { abio_printf(codeFile, "#include %s\n", strlist_get_str(&connIncludes, i, NULL)); } strlist_destruct(&connIncludes); } abio_puts(codeFile, nlstr); abmfP_write_user_file_top_seg(genCodeInfo); abio_puts(codeFile, nlstr); if (write_action_functions(genCodeInfo, module) != OK) return ERROR; abmfP_write_user_file_bottom_seg(genCodeInfo); return OK; }