/* * 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; }
static int write_includes(GenCodeInfo genCodeInfo, ABObj project) { File codeFile = genCodeInfo->code_file; STRING *p = NULL; AB_TRAVERSAL trav; ABObj module = NULL; StringList includes = strlist_create(); char buf[MAXPATHLEN+1]; int i; strlist_set_is_unique(includes, TRUE); *buf = 0; /* standard system includes */ for (p = Includes; *p; p++) { strlist_add_str(includes, *p, NULL); } /* * Includes for sessioning. * These include files are needed only if sessioning * is used. */ if (abmfP_proj_needs_session_save(project) || abmfP_proj_needs_session_restore(project)) { for (p = Session_Includes; *p; p++) { strlist_add_str(includes, *p, NULL); } } /* * Includes for i18n. * These include files are needed only if i18n * is enabled. */ if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) { for (p = I18n_Includes; *p; p++) { strlist_add_str(includes, *p, NULL); } } /* module includes */ for (trav_open(&trav, project, AB_TRAV_MODULES); (module = trav_next(&trav)) != NULL; ) { if (!obj_is_defined(module)) { continue; } sprintf(buf, "\"%s\"", abmfP_get_ui_header_file_name(module)); strlist_add_str(includes, buf, NULL); } trav_close(&trav); /* project include */ sprintf(buf, "\"%s\"", abmfP_get_project_header_file_name(project)); strlist_add_str(includes, buf, NULL); sprintf(buf, "\"%s\"", abmfP_get_utils_header_file_name(project)); strlist_add_str(includes, buf, NULL); abmfP_get_connect_includes(includes, project); /* Write the includes */ for (i = 0; i < strlist_get_num_strs(includes); ++i) { abio_printf(codeFile, "#include %s\n", strlist_get_str(includes, i, NULL)); } abio_puts(codeFile, nlstr); strlist_destroy(includes); return 0; }
int abmfP_get_connect_includes(StringList includeFiles, ABObj projOrModule) { AB_TRAVERSAL trav; BOOL actionIsCrossModule = FALSE; ABObj project = obj_get_project(projOrModule); ABObj action = NULL; ABObj toObj = NULL; ABObj compRoot = NULL; ABObj toModule = NULL; ABObj win_parent = NULL; ABObj popup_win = NULL; char headerFilename[MAXPATHLEN+1]; *headerFilename = 0; strlist_set_is_unique(includeFiles, TRUE); assert(project != NULL); if (project == NULL) { return 0; } for (trav_open(&trav, projOrModule, AB_TRAV_ACTIONS_FOR_OBJ); (action = trav_next(&trav)) != NULL; ) { actionIsCrossModule = obj_is_cross_module(action); toObj = obj_get_to(action); if (toObj == NULL) { continue; } toModule = obj_get_module(toObj); if (actionIsCrossModule) { sprintf(headerFilename, "\"%s\"", abmfP_get_ui_header_file_name(toModule)); strlist_add_str(includeFiles, headerFilename, NULL); } /* * Check to see if the popup's window parent is in another module */ compRoot = obj_get_root(toObj); popup_win = NULL; if (obj_is_popup_win(compRoot)) { popup_win = compRoot; } if (popup_win == NULL) { popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_DIALOG); } if (popup_win == NULL) { popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_BASE_WINDOW); } if (popup_win != NULL) { win_parent= obj_get_win_parent(popup_win); if (win_parent != NULL) { toModule = obj_get_module(win_parent); if (toModule != NULL) { sprintf(headerFilename, "\"%s\"", abmfP_get_ui_header_file_name(toModule)); strlist_add_str(includeFiles, headerFilename, NULL); } } } /* * For some actions, we need widget-specific convenience * functions and resource strings that exist in the header files. */ if (obj_get_func_type(action) == AB_FUNC_BUILTIN) { switch (obj_get_func_builtin(action)) { case AB_STDACT_SET_LABEL: case AB_STDACT_SET_TEXT: case AB_STDACT_SET_VALUE: abmfP_comp_get_widget_specific_includes( includeFiles, obj_get_root(toObj)); break; } } } trav_close(&trav); return 0; }