⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ansi_c.txt

📁 c#设计模式WithCla
💻 TXT
字号:
                   Generating ANSI C Code

The purpose of this paper is to describe how to generate ANSI C code from class diagrams, state diagrams, and object interaction diagrams.  These scripts are "getting started" scripts that must be updated for your development environment.
These scripts are "getting started" scripts that must be updated for your development environment.

1. ANSI C - Getting Started ANSI C Code Generation from Class Diagrams

Class Diagram: ansiccar.omt
Script Files: chead1.sct and cfunc1.sct 
Main File: cmain.c

Quick Start - Generating ANSI C code:
- open ansicar.omt
- generate .h files with chead1.sct
- generate .c files with cfunc1.sct
- compile, link, and run in your ANSI C environment

The steps to generate ANSI C++ and to compile the generated files are as follows:
>> Launch With Class from Windows
>> Open ansicar.omt
>> Select "Utilities - Generate Code File per Class"
>> Select h as the file extension
>> Select chead1.sct to generate the header files (.h)
>> Select "Utilities - Generate Code File per Class"
>> Select cpp as the file extension
>> Select cfunc1.sct to generate the source code files (.c)
>> Select "File - Edit File" to examine the generated files, e.g. car.h
>> Run your C environment
>> Create the Car Project, e.g. carproj.mak
>> Add the .c files to the project. e.g. cmain.c, car.c etc
>> Compile all .c files
>> Compile cmain.c
>> Execute the project

2. ANSI C - Getting Started ANSI C Code Generation from State Diagrams
State Diagram: ST1STATE.OMT
Script Files: STAANSC1.SCT - Creates C function; test with ST1STATE.OMT and CSTAMAIN.C.
              STAANSC2.SCT - Creates C function; test with ST1STATE.OMT and CSTAMAIN.C.
Main File: CSTAMAIN.C.

The following are the general steps to test out the ANSI C code generation scripts:

- Create a directory for the state .omt files, script files, and C++ files, e.g. WCSTATE.

- Copy the appropriate files into each directory, e.g. copy st*.*.

- In With Class open a state diagram, e.g. ST1STATE.OMT.

- Select "Utilities - Generate State Code/Report" to generate a text report.  Enter a report file name, e.g. RPTSTATE.TXT.  Select a state report script, e.g. RPTSTATE.SCT, DDSTATE.SCT, or TABSTATE.SCT.  After report generation, select "File - Edit File" to examine the generated report.

- Enter the file name, e.g. CONTROL.C

- Select the code generation script, e.g. STAANSC1.SCT or STAANSC2.SCT.

- Select "Edit - Edit File" and open CONTROL.C for review.

- In your ANSI C environment, create a project, e.g. STATE1.MAK and add the CONTROL.C and CSTAMAIN.C.

- Compile and run the program.

- Go back to With Class and update the state diagram with new states, events, conditions, and actions and repeat the entire process.

3.  ANSI C - Creating Message Sequence Tables from Object Interaction Diagrams
Object Interaction Diagram: CAROBJ.OMT
Script File: TABOBMSG.SCT

The following are the general steps to generate the message sequence table and then update ANSI C code with messages.
- Open the object interaction diagram, e.g. CAROBJ.OMT.
- Select "Utilities - Generate Object Code/Report".
- Enter a report name, e.g. TABMSG.TXT.
- Browse and select the message sequence table script, e.g. TABOBMSG.SCT to generate the message sequence table.
- Cut and paste messages from the message sequence table into your ANSI C code.
- As required update the object interaction diagram and the message sequence script (TABOBMSG.SCT) and repeat the process.

4. I request your recommended changes to these ANSI C code generation scripts. The generated code compiles in Borland C++ with the ANSI option on.  The generated code does not compile with the K&R option on because of void return.  Request comments and improvements: Richard Felsinger, RCF Associates, 960 Scottland Dr, Mt Pleasant, SC 29464   71162.755@compuserve.com telephone 803-881-3648

5. Many thanks, Richard Felsinger 803-881-3648

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -