📄 ctocpp.html
字号:
<p>- The step -class is the more complex ones. If the conversion doesn't work, then perform it manually instead, it is also the less fastidious ones. The following -prop should work without problem, and luckily, what it does is also the more annoying part!<br><br><p><hr>Node:<a name="Make%20list">Make list</a>,Next:<a rel=next href="#Make%20header">Make header</a>,Previous:<a rel=previous href="#General%20restrictions">General restrictions</a>,Up:<a rel=up href="#Limitations">Limitations</a><br><h2>Make list</h2><p>Limitations for the -list command.<br><br><p>- If your project uses a list of files as the ones of Turbo C,you don't need for mklist.<br>The program is able to build this list providing that all functionshave a prototype in header file and this header file is includedin each source using the function. Otherwise you have to completethe list.<br>- The #include statements should use the "" enclosures for yourheader files and the <> ones, for external libraries.<br> For example: #include <stdlib.h><br> #include "myheader.h"<br><p><hr>Node:<a name="Make%20header">Make header</a>,Next:<a rel=next href="#Make%20class">Make class</a>,Previous:<a rel=previous href="#Make%20list">Make list</a>,Up:<a rel=up href="#Limitations">Limitations</a><br><h2>Make header</h2><p>Limitations for the -include command.<br><br><p>- The script doesn't manage conditional compilation.<br> Statements as #if or #ifdef are not managed when building the header file.<br><br><p>- Functions may take macro arguments as the FILE one.<br> This can be a problem inside an header file. Such problem is already solved if each function has a prototype in the original source, but this is no always the case, as old compiler allows to omit them.<br> When such problems are encoutered in producing the header file, change manually the file.<br><p><hr>Node:<a name="Make%20class">Make class</a>,Next:<a rel=next href="#Step%20by%20step">Step by step</a>,Previous:<a rel=previous href="#Make%20header">Make header</a>,Up:<a rel=up href="#Limitations">Limitations</a><br><h2>Make class</h2><p>Limitations for the -class command.<br><br><p>- The name automatically choosen, that of the file, may conflict.<br> A function with the same name that the file will has same name that a class and will be considered as a constructor.<p><hr>Node:<a name="Step%20by%20step">Step by step</a>,Next:<a rel=next href="#Moving%20the%20files">Moving the files</a>,Previous:<a rel=previous href="#Make%20class">Make class</a>,Up:<a rel=up href="#Top">Top</a><br><h1>Step by step</h1><p>To convert a whole project, a single command is used repetively, with different options and arguments:<br><p>COMMAND: ctocpp <br><br><p>The arguments may be:<br><br> - the full path of the main file, (the one that holds the "main" function).<br> - the name of a filename that holds the list of sources.<br> - the name of a filename that holds the list of headers.<br> - a couple of paths separated by the @ symbol, for the move command only.<br><p>When the scripts are used directly and not from the ctocpp command, the filename of a list of file must be prefixed by the @ symbol, when it must be read, not when it must be created. <br><br><ul><li><a href="#Moving%20the%20files">Moving the files</a>: This is optional. <li><a href="#Making%20a%20list">Making a list</a>: Build the project (automatical). <li><a href="#Verify%20headers">Verify headers</a>: This is performed by --include. <li><a href="#Generating%20classes">Generating classes</a>: Generated by --class. <li><a href="#List%20of%20headers">List of headers</a>: --all does the job. <li><a href="#Propagating%20changes">Propagating changes</a>: --prop achieves the work. </ul><p><hr>Node:<a name="Moving%20the%20files">Moving the files</a>,Next:<a rel=next href="#Making%20a%20list">Making a list</a>,Previous:<a rel=previous href="#Step%20by%20step">Step by step</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>Moving the files</h2><p>Step 1: Move the files. This is optional.<br><br><p>COMMAND: ctocpp -m mainfile.c olddir@newdir [olddir@newdir]<br><br><p>- mainfile.c is the file that holds the main() function.<br>- olddir is a directories where the files are stored.<br>- newdir is the new location.<br>- several old@new couples are required if the project staysinside several directories. <br> You can move all directories into a single one.<br>N.B.: If you move the files with a file manager, the #includestatements will not be updated.<br><p><hr>Node:<a name="Making%20a%20list">Making a list</a>,Next:<a rel=next href="#Verify%20headers">Verify headers</a>,Previous:<a rel=previous href="#Moving%20the%20files">Moving the files</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>Making a list</h2><p>Step 2: Make the project list with mklist.py<br><br><p>COMMAND: ctocpp -l mainfile.c prjlist<br><br><p>- mainfile.c is the file that holds the main() function.<br>- prjlist is the name of the file that will contains the list ofall .c sources of the project (you choose a name for it).<br> It will be overwritten without prompting.<br><p><hr>Node:<a name="Verify%20headers">Verify headers</a>,Next:<a rel=next href="#List%20of%20headers">List of headers</a>,Previous:<a rel=previous href="#Making%20a%20list">Making a list</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>Verify headers</h2><p>Step 3: Make declarations inside headers, matching thedefinitions inside sources.<br><br><p>C compiler are less restrictive than C++ one, a functioncan be used without prototypes.<br> To update your sources to C++ rules, use mkheader.py<br><br><p>COMMAND: ctocpp -i mainfile.c projectlist<br><br><p>- do not forget the @ before the project's filename.<p><hr>Node:<a name="List%20of%20headers">List of headers</a>,Next:<a rel=next href="#Generating%20classes">Generating classes</a>,Previous:<a rel=previous href="#Verify%20headers">Verify headers</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>List of headers</h2><p>Step 4:<br> Now you need the list of all header files.<br> This is not the same that the list of sources, as the projectmay use header to include with no corresponding source.<br><br><p>COMMAND: ctocpp -a mainfile.c projectlist<br><br><p>- Headlist if the name of the file to create, that will holdall header filenames. No symbol at this stage (It is usedto differentiate a source from a list of files).<br>- The file is overwritten without prompting.<br><p><hr>Node:<a name="Generating%20classes">Generating classes</a>,Next:<a rel=next href="#Propagating%20changes">Propagating changes</a>,Previous:<a rel=previous href="#List%20of%20headers">List of headers</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>Generating classes</h2><p>Step 5:<br> If you want to define you own classes, skip this step.<br>-class or mkclass allows to make a class from variables and prototypesfrom an header file. If produces a new .hpp file and doesn'tchange the previous header.<br><br><p>COMMAND: ctocpp -c mainfile.c projectlist<br><br><p>- Do not forget the symbol before the project's filename.<br>- If a function has name that is that of the file, it will be considered as a constructor. The class name must be changed.<br><br><p>When all C++ headers are created you may change the defaultclasses names or move their members from class to class ifyou want.<br> If a method has the same name that the class, you must torename the class, as the name is reserved to a constructor.<p><hr>Node:<a name="Propagating%20changes">Propagating changes</a>,Next:<a rel=next href="#Example">Example</a>,Previous:<a rel=previous href="#Generating%20classes">Generating classes</a>,Up:<a rel=up href="#Step%20by%20step">Step by step</a><br><h2>Propagating changes</h2><p>Step 6:<br> The last step produces a full set of C++ files with .cppextensions, from .c and .hpp files.<br>- Function are transformed in methods.<br>- Global variables are made static and integrated into class declarations.<br>- Call of functions are replaced by call of methods.<br>- Global variables references are replaced by references to members.<br><br><p>COMMAND: ctocpp -p mainfile.c projectlist<br><br><p>- Prjlist is the name of the file that hold all .c sourcesin the project. The symbol prefixes the name.<br>- Headlist is a file that holds all .h headers. Symbol before it.<br><p><hr>Node:<a name="Example">Example</a>,Next:<a rel=next href="#Index">Index</a>,Previous:<a rel=previous href="#Propagating%20changes">Propagating changes</a>,Up:<a rel=up href="#Top">Top</a><br><h1>Example</h1><p>Now you are ready to compile your C++ project.<br><br><p>N.B.: When you use a sub-program directly, if you omit the "@" symbolin front of a filename when required, the script will process the fileitself, not a list of files. This allows to convert a single file.<br><br><p>Example: cdlist (available at http://www.scriptet.com) <br><br><p>The / symbol is inverted for Windows.<br>The scripts are installed into the /ctocpp directory.<br>The cdlist files are in the /cdwin directory.<br>The program use a personal GUI library, in the /gui directory.<br>The main function is inside the listit.c file.<br>I choose to move all necessary file into the /cdnew directoryand give the new project file the "cdlist" name:<br><p>You can type simply: ctocpp \cdnew\listit.c \cdnew\cdlistBut this is not recommend, as you may have to rename classesautomatically created.<br>Or you can perform detailed steps:<br><br><p>From the /ctocpp directory, using the scripts directly:<br> Step 1: mover /cdwin/listit.c /gui:/cdnew /cdwin:/cdnew<br> Step 2: mklist /cdnew/listit.c /cdnew/cdlist.prj<br> Step 3: mkheader @/cdnew/cdlist.prj<br> Step 4: allhead /cdnew/listit.c /cdnew/cdlist.hpj<br> Step 5: mkclass @/cdnew/cdlist.prj<br> Step 6: mkcpp @/cdnew/cdlist.prj @/cdnew/cdlist.hpj<br><p>N.B.:<br>- the @ symbol is used when the file is a list of files andwhen it is read, not when it is created.<br><p>Delete the .c files and type: make -fcdcpp.mak<br>(makefile for Turbo C++)<p><hr>Node:<a name="Index">Index</a>,Previous:<a rel=previous href="#Example">Example</a>,Up:<a rel=up href="#Top">Top</a><br><h1>Index</h1><ul compact><li>Attribute: <a href="#Propagating%20changes">Propagating changes</a>, <a href="#Generating%20classes">Generating classes</a><li>CDList: <a href="#Example">Example</a><li>Class: <a href="#Generating%20classes">Generating classes</a>, <a href="#Propagating%20changes">Propagating changes</a><li>Command line: <a href="#Overview">Overview</a><li>Date: <a href="#Top">Top</a><li>Description: <a href="#Overview">Overview</a><li>Example: <a href="#Example">Example</a><li>Files: <a href="#Requirements%20&%20conventions">Requirements & conventions</a><li>Function: <a href="#Propagating%20changes">Propagating changes</a><li>Header: <a href="#List%20of%20headers">List of headers</a><li>Headers: <a href="#Verify%20headers">Verify headers</a><li>How to: <a href="#How%20it%20works">How it works</a>, <a href="#Step%20by%20step">Step by step</a><li>Learning: <a href="#Step%20by%20step">Step by step</a><li>Limitations: <a href="#Make%20header">Make header</a>, <a href="#Make%20list">Make list</a>, <a href="#Make%20class">Make class</a>, <a href="#General%20restrictions">General restrictions</a><li>List: <a href="#List%20of%20headers">List of headers</a>, <a href="#Making%20a%20list">Making a list</a><li>Method: <a href="#Generating%20classes">Generating classes</a>, <a href="#Propagating%20changes">Propagating changes</a><li>Move: <a href="#Tools">Tools</a>, <a href="#Moving%20the%20files">Moving the files</a>, <a href="#Mover">Mover</a><li>Principle: <a href="#How%20it%20works">How it works</a><li>Project: <a href="#Making%20a%20list">Making a list</a>, <a href="#Mover">Mover</a>, <a href="#Tools">Tools</a>, <a href="#Moving%20the%20files">Moving the files</a><li>Purpose: <a href="#Overview">Overview</a><li>replace: <a href="#Search">Search</a><li>Replace: <a href="#Tools">Tools</a><li>Requirement: <a href="#Requirements%20&%20conventions">Requirements & conventions</a><li>Restrictions: <a href="#Make%20class">Make class</a>, <a href="#Make%20list">Make list</a>, <a href="#General%20restrictions">General restrictions</a>, <a href="#Make%20header">Make header</a><li>Search: <a href="#Tools">Tools</a><li>search: <a href="#Search">Search</a><li>Step: <a href="#Step%20by%20step">Step by step</a><li>Target: <a href="#Requirements%20&%20conventions">Requirements & conventions</a><li>Variable: <a href="#Propagating%20changes">Propagating changes</a></ul>Copyright 2001-2005 © Denis Sureau <a href="http://www.scriptol.org/">http://www.scriptol.org/</a><br></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -