diff options
author | Andrew Ferguson | 2008-02-22 17:39:24 +0000 |
---|---|---|
committer | Andrew Ferguson | 2008-02-22 17:39:24 +0000 |
commit | d3630393474642125ee0c5628fb9c8c82c43eb9f (patch) | |
tree | 816fa3dcb3e549f69d45400535c8777dafce1c93 | |
parent | 7a98d26913fa7506aec2a487f55d76e0cf85ada6 (diff) | |
download | org.eclipse.cdt-d3630393474642125ee0c5628fb9c8c82c43eb9f.tar.gz org.eclipse.cdt-d3630393474642125ee0c5628fb9c8c82c43eb9f.tar.xz org.eclipse.cdt-d3630393474642125ee0c5628fb9c8c82c43eb9f.zip |
201087: apply contributions on behalf of James Blackburn
3 files changed, 327 insertions, 26 deletions
diff --git a/core/org.eclipse.cdt.core/schema/templateProcessTypes.exsd b/core/org.eclipse.cdt.core/schema/templateProcessTypes.exsd index 6dcd8a8b554..7914b5a3eba 100644 --- a/core/org.eclipse.cdt.core/schema/templateProcessTypes.exsd +++ b/core/org.eclipse.cdt.core/schema/templateProcessTypes.exsd @@ -62,7 +62,7 @@ <attribute name="processRunner" type="string" use="required"> <annotation> <documentation> - A class that extends org.eclipse.cdt.templateengine.process.ProcessRunner abstract class and implements all its abstract methods. This is the code that actually processes. + A class that extends org.eclipse.cdt.core.templateengine.process.ProcessRunner abstract class and implements all its abstract methods. This is the code that actually processes. </documentation> <appInfo> <meta.attribute kind="java" basedOn="org.eclipse.cdt.templateengine.process.ProcessRunner"/> diff --git a/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/Howtodeveloptemplates.html b/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/Howtodeveloptemplates.html index 44692ba8d34..1efadb18ea6 100644 --- a/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/Howtodeveloptemplates.html +++ b/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/Howtodeveloptemplates.html @@ -60,7 +60,7 @@ pages based on whether the template needs user input or not. This document details the schema for writing project templates. The schema file <code class="filename">TemplateDescriptorSchema.xsd</code>, which defines the structure for the project templates, is part of -<code class="filename">org.eclipse.cdt.templateengine</code> plug-in. +<code class="filename">org.eclipse.cdt.core</code> plug-in. </p> <p> The structure or schema for a project template is as follows: @@ -369,7 +369,7 @@ The <code>process</code> element within the root element of a project template defines the processes to be followed to create a project, based on the inputs taken. Here is the syntax for this element: </p> -<p class="CodeBlock"><code><process type="org.eclipse.cdt.templateengine.<process type>"><br> <simple name="name" value=""/> <br><br> <complex name="name"> <br> ...<br> </complex> <br><br> <simple-array name="values"><br> ...<br> </simple-array><br><br> <complex-array name="name"><br> ...<br> </complex-array> <br><br></process></code></p> +<p class="CodeBlock"><code><process type="org.eclipse.cdt.{core|managedbuilder.core}.<process type>"><br> <simple name="name" value=""/> <br><br> <complex name="name"> <br> ...<br> </complex> <br><br> <simple-array name="values"><br> ...<br> </simple-array><br><br> <complex-array name="name"><br> ...<br> </complex-array> <br><br></process></code></p> <p> A <code>process</code> element defines a single process. A process is like a procedure with a set of parameters. In similar terms, the @@ -380,7 +380,7 @@ arguments for the process matching their types and in the order specified. <p> You can specify the process type using the <code>type</code> attribute. For example, to add files to a project you can use -<code>org.eclipse.cdt.templateengine.AddFiles</code> as the process type. +<code>org.eclipse.cdt.core.AddFiles</code> as the process type. </p> <p> A <code>process</code> element may include the following child elements: @@ -448,7 +448,7 @@ for the copy process. </p> <p> The Template Engine plug-in provides a set of process types using the -extension-point <code class="filename">org.eclipse.cdt.templateengine.processType</code>. Using +extension-point <code class="filename">org.eclipse.cdt.core.templateProcessTypes</code>. Using these process types you can describe a process in your template. For example, you can describe the copy process by providing the source and destination folder names. @@ -456,7 +456,7 @@ folder names. <p> The following is a list of process types provided by the Template Engine: </p> -<ul> +<!--<ul> <li> <p> <b>NewProject</b>: It defines all the parameters required for a @@ -493,10 +493,10 @@ type of the target binary. It is of type <code>simple</code>. configurations for the project. It is of type <code>simple</code>. </p> </li> -</ul> +</ul> --> <li> <p> -<b>NewManagedProject</b>: It defines all the parameters +<i>org.eclipse.cdt.managedbuilder.core.</i><b>NewManagedProject</b>: It defines all the parameters required for a new managed project and provides the fully qualified name of the class, which processes these parameters. </p> @@ -533,7 +533,7 @@ configurations for the managed project. It is of type <code>simple</code>. </ul> <li> <p> -<b>Copy</b>: It defines all the parameters required to copy +<i>org.eclipse.cdt.core.</i><b>Copy</b>: It defines all the parameters required to copy files and provides the fully qualified name of the class, which processes these parameters. </p> @@ -571,14 +571,14 @@ location. </ul> <li> <p> -<b>Append</b>: It defines all the parameters required to append +<i>org.eclipse.cdt.core.</i><b>Append</b>: It defines all the parameters required to append files to a project and provides the fully qualified name of the class, which processes these parameters. For more information about the parameters, refer to the <code>Copy</code> process type described above. </p> <li> <p> -<b>AddFile</b>: It defines all the parameters required to add a +<i>org.eclipse.cdt.core.</i><b>AddFile</b>: It defines all the parameters required to add a file to the project and provides the fully qualified name of the class, which processes these parameters. </p> @@ -603,7 +603,7 @@ process type described above. </ul> <li> <p> -<b>AddFiles</b>: It defines all the parameters required to add +<i>org.eclipse.cdt.core.</i><b>AddFiles</b>: It defines all the parameters required to add files to a project and provides the fully qualified name of the class, which processes these parameters. </p> @@ -628,7 +628,7 @@ process type described above. </ul> <li> <p> -<b>CreateSourceFolder</b>: It defines all the parameters +<i>org.eclipse.cdt.core.</i><b>CreateSourceFolder</b>: It defines all the parameters required to create a folder for the source files in a project and provides the fully qualified name of the class, which processes these parameters. </p> @@ -652,7 +652,7 @@ created. It is of <code>simple</code> type. </ul> <li> <p> -<b>AddLink</b>: It defines all the parameters required to +<i>org.eclipse.cdt.core.</i><b>AddLink</b>: It defines all the parameters required to create a linked file and provides the fully qualified name of the class, which processes these parameters. </p> @@ -682,7 +682,7 @@ file should be created. It is of <code>simple</code> type. </ul> <li> <p> -<b>CreateIncludeFolder</b>: It defines all the parameters +<i>org.eclipse.cdt.managedbuilder.core.</i><b>CreateIncludeFolder</b>: It defines all the parameters required to create a folder for the header files in a project and provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the <code>CreateSourceFolder</code> @@ -690,7 +690,48 @@ process type described above. </p> <li> <p> -<b>SetMBSStringOptionValue</b>: It defines all the parameters +<i>org.eclipse.cdt.managedbuilder.core.</i><b>ExcludeResources</b>: It defines all the parameters +required to exclude resources from a CDT project and provides the +fully qualified name of the class, which processes these parameters. +</p> +<p> +Here is a list of parameters defined by this process type: +</p> +<ul> +<li> +<p> +<em>projectName</em>: Use this parameter to specify the name +of the project for which resources will be excluded. It is of <code>simple</code> +type. +</p> +<li> +<p> +<em>configIdPattern</em>: Use this parameter to specify a regular expression of +<code>java.util.regex.Pattern</code> syntax for matching against project configuration ids. +The resources that match any of the regular expressions given in the <i>filePatterns</i> argument +will be excluded from all matching project configurations. It is of <code>simple</code> type. +</p> +<li> +<p> +<em>filePatterns</em>: Use this parameter to specify a <code>simple-array</code> of +<code>java.util.regex.Pattern</code> for matching against project resources to be excluded. The paths that +will be matched against are workspace relative (include the project folder) and use forward slash as the file separator. +That this argument is an array is purely to allow logically separate patterns to be given separately rather than as one big string. +If any of the regular expressions matches then the resource in question will be excluded for the matching configuration(s). +The resources that match any of the regular expressions given in the <i>filePatterns</i> argument +will be excluded for all matching project configurations. It is of <code>simple-array</code> type. +<li> +<p> +<em>invertedConfigMatching</em>: If this is set to "true" then the set of configurations for which resources +matching any of the specified file patterns will be inverted. This enables you to specify which configurations the +files should not be excluded for without having to know what other configurations may exist. It is of <code>simple</code> type. +</p> +</li> +</ul> +</p> +<li> +<p> +<i>org.eclipse.cdt.managedbuilder.core.</i><b>SetMBSStringOptionValue</b>: It defines all the parameters required to create a string option value and provides the fully qualified name of the class, which processes these parameters. </p> @@ -733,7 +774,7 @@ the resource. It is of <code>simple</code> type. </ul> <li> <p> -<b>SetMBSStringListOptionValues</b>: It defines all the +<i>org.eclipse.cdt.managedbuilder.core.</i><b>SetMBSStringListOptionValues</b>: It defines all the parameters required to create a string list of option values and provides the fully qualified name of the class, which processes these parameters. The parameters required are similar to that of <code>SetMBSStringOptionValue</code> @@ -743,7 +784,7 @@ option values. For information about the parameters, refer to the </p> <li> <p> -<b>SetMBSBooleanOptionValue</b>: It defines all the parameters +<i>org.eclipse.cdt.managedbuilder.core.</i><b>SetMBSBooleanOptionValue</b>: It defines all the parameters required to create a boolean option value and provides the fully qualified name of the class, which processes these parameters. The parameters required are similar to that of <code>SetMBSStringOptionValue</code> process type, only @@ -753,7 +794,7 @@ For information about the parameters, refer to the </p> <li> <p> -<b>AppendMBSStringOptionValue</b>: It defines all the +<i>org.eclipse.cdt.managedbuilder.core.</i><b>AppendToMBSStringOptionValue</b>: It defines all the parameters required to append a string option value to an existing string option. It also provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the @@ -761,14 +802,21 @@ these parameters. For information about the parameters, refer to the </p> <li> <p> -<b>AppendCreate</b>: It defines all the parameters required to +<i>org.eclipse.cdt.managedbuilder.core.</i><b>AppendToMBSStringListOptionValues</b>: It defines all the +parameters required to append a string list of option values to an existing string list of option value. +It also provides the fully qualified name of the class, which processes these parameters. For information +about the parameters, refer to the <code>SetMBSStringListOptionValues</code> process type described above. +</p> +<li> +<p> +<i>org.eclipse.cdt.core.</i><b>AppendCreate</b>: It defines all the parameters required to append or create a file in a project. It also provides the fully qualified name of the class, which processes these parameters. For information about the parameters, refer to the <code>AddFiles</code> process type described above. </p> <li> <p> -<b>CreateResourceIdentifier</b>: It defines all the parameters +<i>org.eclipse.cdt.core.</i><b>CreateResourceIdentifier</b>: It defines all the parameters required to append or create a resource identifier. It also provides the fully qualified name of the class, which processes these parameters. </p> @@ -789,9 +837,19 @@ type. </p> </li> </ul> +<li> +<p> +<i>org.eclipse.cdt.managedbuilder.core.</i><b>GenerateMakefileWithBuildDescription</b>: +</p> +<ul> +<li> +<p><em>projectName: </em>Use this parameter to specify the name +of the project for which a makefile will be generated from the current project build info. It is of <code>simple</code> +type. +</p> </li> </ul> -<p> +<p><br> Once the project template has been written, register it with Eclipse to make it available for use. For more information on this, refer to <A href="Howtoregistertemplates.html#Howto%2eregister%2etemplates">How to register a template with Eclipse</a>. diff --git a/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/exampletemplate.html b/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/exampletemplate.html index 0f916442609..dd644908d85 100644 --- a/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/exampletemplate.html +++ b/doc/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/exampletemplate.html @@ -35,16 +35,259 @@ The following is an example template to create a simple Symbian OS <code class="filename">EXE</code> project: </p> -<p class="CodeBlock"><code><?xml version="1.0" encoding="ISO-8859-1"?><br><template type="ProjTempl" version="1.0" supplier="Symbian" revision="1.0" author="Bala Torati"<br> id="EXE" label="Simple EXE" description="A skeletal Symbian OS EXE project. Creates a folder for sources and another for include."<br> help="help.html"><br><br> <property-group id="basics" label="Basic Settings" description="Basic properties of a project" type="PAGES-ONLY" help="help.html"><br> <br><property id="uid2"<br> label="UID 2"<br> description="UID 2"<br> default="0x00000000"<br> type="input"<br> pattern="0x[0-9a-fA-F]{8}"<br> hidden="false"<br> mandatory="true"<br> persist="true"/><br> <br><property id="uid3"<br> label="UID 3"<br> description="UID 3"<br> default="0x00000000"<br> type="input"<br> pattern="0x[0-9a-fA-F]{8}"<br> hidden="false"<br> mandatory="false"<br> persist="true"/><br><br><property id="vid"<br> label="Vendor ID"<br> description="Vendor ID"<br> default="0x00000000"<br> type="input"<br> pattern="0x[0-9a-fA-F]{8}"<br> hidden="false"<br> mandatory="true"<br> persist="true"/><br><br><property id="author"<br> label="Author"<br> description="Name of the author"<br> type="input"<br> pattern=".*"<br> default=""<br> hidden="false"<br> persist="true"/><br><br><property id="copyright"<br> label="Copyright notice"<br> description="Your copyright notice"<br> type="input"<br> pattern=".*"<br> default="Your copyright notice"<br> hidden="false"<br> persist="true"/><br><br><property id="targetType"<br> label="Target Type"<br> description="Select the target type"<br> type="select"<br> hidden="false"<br> mandatory="true"<br> persist="true"><br> <item label="APP" selected="true" name="app"/><br> <item label="LIB" selected="false" name="lib"/><br> <item label="DLL" selected="false" name="dll"/><br> <item label="EXE" selected="false" name="exe"/><br> <item label="EXEDLL" selected="false" name="exedll"/><br> </property><br> </property-group><br><br> <property-group id="directories" label="Project Directories" description="Generated files will be copied to the specified directories under the project root directory" type="PAGES-ONLY" help="help.html"><br> <property id="incDir"<br> label="Include"<br> description="Directory for C++ header files"<br> type="input"<br> default="inc"<br> pattern="[a-zA-Z0-9]+"<br> mandatory="true"<br> persist="true"/><br><br> <property id="sourceDir"<br> label="Source"<br> description="Directory for C++ source files"<br> type="input"<br> default="src"<br> pattern="[a-zA-Z0-9]+"<br> mandatory="true"<br> persist="true"/><br> </property-group><br> <br> <process type="org.eclipse.cdt.templates.NewSymbianProject"><br> <simple name="name" value="$(projectName)"/><br> <simple name="targetType" value="$(targetType)"/><br> <simple name="uid2" value="$(uid2)"/><br> <simple name="uid3" value="$(uid3)"/><br> <simple name="vid" value="$(vid)"/><br> </process><br><br> <process type="org.eclipse.cdt.core.templateengine.process.processes.CreateSourceFolder"><br> <simple name="projectName" value="$(projectName)"/><br> <simple name="path" value="$(sourceDir)"/><br> </process><br><br> <process type="org.eclipse.cdt.managedbuilder.templateengine.processes.CreateIncludeFolder"><br> <simple name="projectName" value="$(projectName)"/><br> <simple name="path" value="$(incDir)"/><br> </process><br><br> <process type="org.eclipse.cdt.core.templateengine.process.processes.AddFiles"><br> <simple name="projectName" value="$(projectName)"/><br> <complex-array name="files"><br> <element><br> <simple name="source" value="inc/Basename.h"/><br> <simple name="target" value="$(incDir)/$(baseName).h"/><br> <simple name="replaceable" value="true"/><br> </element><br> <element><br> <simple name="source" value="src/Basename.cpp"/><br> <simple name="target" value="$(sourceDir)/$(baseName).cpp"/><br> <simple name="replaceable" value="true"/><br> </element><br> </complex-array><br> </process><br><br> <process type="org.eclipse.cdt.managedbuilder.templateengine.processes.AppendToMBSStringListOptionValues"><br> <simple -name="projectName" value= "$(projectName)"/> <br> <complex-array name="resourcePaths"><br> <element><br> <simple name="id" value=".*linker\.libraries\.libraries.*" /><br> <simple-array name="values"><br> <element value="euser.lib" /><br> </simple-array><br> <simple name="path" value="" /><br> </element><br> </complex-array><br> </process><br></template></code></p> +<p class="CodeBlock"><code><?xml version="1.0" encoding="ISO-8859-1"?><br> +<template type="ProjTempl" version="1.0" supplier="Symbian" revision="1.0" author="Bala Torati"<br> + id="EXE" label="Simple EXE" description="A skeletal Symbian OS EXE project. Creates a folder for sources and another for include."<br> + help="help.html"><br> +<br> + <property-group id="basics" label="Basic Settings" description="Basic properties of a project" type="PAGES-ONLY" help="help.html"><br> + <br> +<property id="uid2"<br> + label="UID 2"<br> + description="UID 2"<br> + default="0x00000000"<br> + type="input"<br> + pattern="0x[0-9a-fA-F]{8}"<br> + hidden="false"<br> + mandatory="true"<br> + persist="true"/><br> + <br> +<property id="uid3"<br> + label="UID 3"<br> + description="UID 3"<br> + default="0x00000000"<br> + type="input"<br> + pattern="0x[0-9a-fA-F]{8}"<br> + hidden="false"<br> + mandatory="false"<br> + persist="true"/><br> +<br> +<property id="vid"<br> + label="Vendor ID"<br> + description="Vendor ID"<br> + default="0x00000000"<br> + type="input"<br> + pattern="0x[0-9a-fA-F]{8}"<br> + hidden="false"<br> + mandatory="true"<br> + persist="true"/><br> +<br> +<property id="author"<br> + label="Author"<br> + description="Name of the author"<br> + type="input"<br> + pattern=".*"<br> + default=""<br> + hidden="false"<br> + persist="true"/><br> +<br> +<property id="copyright"<br> + label="Copyright notice"<br> + description="Your copyright notice"<br> + type="input"<br> + pattern=".*"<br> + default="Your copyright notice"<br> + hidden="false"<br> + persist="true"/><br> +<br> +<property id="targetType"<br> + label="Target Type"<br> + description="Select the target type"<br> + type="select"<br> + hidden="false"<br> + mandatory="true"<br> + persist="true"><br> + <item label="APP" selected="true" name="app"/><br> + <item label="LIB" selected="false" name="lib"/><br> + <item label="DLL" selected="false" name="dll"/><br> + <item label="EXE" selected="false" name="exe"/><br> + <item label="EXEDLL" selected="false" name="exedll"/><br> + </property><br> + </property-group><br> +<br> + <property-group id="directories" label="Project Directories" description="Generated files will be copied to the specified directories under the project root directory" type="PAGES-ONLY" help="help.html"><br> + <property id="incDir"<br> + label="Include"<br> + description="Directory for C++ header files"<br> + type="input"<br> + default="inc"<br> + pattern="[a-zA-Z0-9]+"<br> + mandatory="true"<br> + persist="true"/><br> +<br> + <property id="sourceDir"<br> + label="Source"<br> + description="Directory for C++ source files"<br> + type="input"<br> + default="src"<br> + pattern="[a-zA-Z0-9]+"<br> + mandatory="true"<br> + persist="true"/><br> + </property-group><br> + <br> + <process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject"><br> + <simple name="name" value="$(projectName)"/><br> + <simple name="targetType" value="$(targetType)"/><br> + <simple name="uid2" value="$(uid2)"/><br> + <simple name="uid3" value="$(uid3)"/><br> + <simple name="vid" value="$(vid)"/><br> + </process><br> +<br> + <process type="org.eclipse.cdt.core.CreateSourceFolder"><br> + <simple name="projectName" value="$(projectName)"/><br> + <simple name="path" value="$(sourceDir)"/><br> + </process><br> +<br> + <process type="org.eclipse.cdt.managedbuilder.core.CreateIncludeFolder"><br> + <simple name="projectName" value="$(projectName)"/><br> + <simple name="path" value="$(incDir)"/><br> + </process><br> +<br> + <process type="org.eclipse.cdt.core.AddFiles"><br> + <simple name="projectName" value="$(projectName)"/><br> + <complex-array name="files"><br> + <element><br> + <simple name="source" value="inc/Basename.h"/><br> + <simple name="target" value="$(incDir)/$(baseName).h"/><br> + <simple name="replaceable" value="true"/><br> + </element><br> + <element><br> + <simple name="source" value="src/Basename.cpp"/><br> + <simple name="target" value="$(sourceDir)/$(baseName).cpp"/><br> + <simple name="replaceable" value="true"/><br> + </element><br> + </complex-array><br> + </process><br> +<br> + <process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues"><br> + <simple +name="projectName" value= "$(projectName)"/> <br> + <complex-array name="resourcePaths"><br> + <element><br> + <simple name="id" value=".*linker\.libraries\.libraries.*" /><br> + <simple-array name="values"><br> + <element value="euser.lib" /><br> + </simple-array><br> + <simple name="path" value="" /><br> + </element><br> + </complex-array><br> + </process><br> +</template></code></p> <p> The above given template copies the following source (<code class="filename">.cpp</code>) and header (<code class="filename">.h</code>) files in the <code>src</code> and <code>inc</code> folders respectively. These files uses a set of macros to get the values specified by the developer for file name, author name, copyright etc. </p> -<p class="CodeBlock"><code>/*<br>============================================================================<br> Name : $(baseName).cpp<br> Author : $(author)<br> Version :<br> Copyright : $(copyright)<br> Description : Exe source file<br>============================================================================<br>*/<br><br>// Include Files <br><br>#include "$(baseName).h"<br>#include <e32base.h><br>#include <e32std.h><br>#include <e32cons.h> // Console<br><br><br>// Constants<br><br>_LIT(KTextConsoleTitle, "Console");<br>_LIT(KTextFailed, " failed, leave code = %d");<br>_LIT(KTextPressAnyKey, " [press any key]\n");<br><br><br>// Global Variables<br><br>LOCAL_D CConsoleBase* console; // write all messages to this<br><br><br>// Local Functions<br><br>LOCAL_C void MainL(const TDesC& aArgs)<br> {<br> //<br> // add your program code here, example code below<br> //<br> console->Write(_L("Hello, world!\n"));<br> console->Printf(_L("Command line args: \"%S\"\n"), &aArgs);<br> }<br><br><br>LOCAL_C void DoStartL()<br> {<br> // Create active scheduler (to run active objects)<br> CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();<br> CleanupStack::PushL(scheduler);<br> CActiveScheduler::Install(scheduler);<br><br> // Call main function with command line<br> TBuf<256> cmdLine;<br> RProcess().CommandLine(cmdLine);<br> MainL(cmdLine);<br><br> // Delete active scheduler<br> CleanupStack::PopAndDestroy(scheduler);<br> }<br><br><br>// Global Functions<br><br>GLDEF_C TInt E32Main()<br> {<br> // Create cleanup stack<br> __UHEAP_MARK;<br> CTrapCleanup* cleanup = CTrapCleanup::New();<br><br> // Create output console<br> TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));<br> if (createError)<br> return createError;<br><br> // Run application code inside TRAP harness, wait keypress when terminated<br> TRAPD(mainError, DoStartL());<br> if (mainError)<br> console->Printf(KTextFailed, mainError);<br> console->Printf(KTextPressAnyKey);<br> console->Getch();<br> <br> delete console;<br> delete cleanup;<br> __UHEAP_MARKEND;<br> return KErrNone;<br> }</code></p> -<p class="CodeBlock"><code>/*<br>============================================================================<br> Name : $(baseName).h<br> Author : $(author)<br> Version :<br> Copyright : $(copyright)<br> Description : Exe header file<br>============================================================================<br>*/<br><br>#ifndef __$(baseName)_H__<br>#define __$(baseName)_H__<br><br><br>// Include Files<br><br>#include <e32base.h><br><br><br>// Function Prototypes<br><br>GLDEF_C TInt E32Main();<br><br><br>#endif // __$(baseName)_H__</code></p> +<p class="CodeBlock"><code>/*<br> +============================================================================<br> + Name : $(baseName).cpp<br> + Author : $(author)<br> + Version :<br> + Copyright : $(copyright)<br> + Description : Exe source file<br> +============================================================================<br> +*/<br> +<br> +// Include Files <br> +<br> +#include "$(baseName).h"<br> +#include <e32base.h><br> +#include <e32std.h><br> +#include <e32cons.h> // Console<br> +<br> +<br> +// Constants<br> +<br> +_LIT(KTextConsoleTitle, "Console");<br> +_LIT(KTextFailed, " failed, leave code = %d");<br> +_LIT(KTextPressAnyKey, " [press any key]\n");<br> +<br> +<br> +// Global Variables<br> +<br> +LOCAL_D CConsoleBase* console; // write all messages to this<br> +<br> +<br> +// Local Functions<br> +<br> +LOCAL_C void MainL(const TDesC& aArgs)<br> + {<br> + //<br> + // add your program code here, example code below<br> + //<br> + console->Write(_L("Hello, world!\n"));<br> + console->Printf(_L("Command line args: \"%S\"\n"), &aArgs);<br> + }<br> +<br> +<br> +LOCAL_C void DoStartL()<br> + {<br> + // Create active scheduler (to run active objects)<br> + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();<br> + CleanupStack::PushL(scheduler);<br> + CActiveScheduler::Install(scheduler);<br> +<br> + // Call main function with command line<br> + TBuf<256> cmdLine;<br> + RProcess().CommandLine(cmdLine);<br> + MainL(cmdLine);<br> +<br> + // Delete active scheduler<br> + CleanupStack::PopAndDestroy(scheduler);<br> + }<br> +<br> +<br> +// Global Functions<br> +<br> +GLDEF_C TInt E32Main()<br> + {<br> + // Create cleanup stack<br> + __UHEAP_MARK;<br> + CTrapCleanup* cleanup = CTrapCleanup::New();<br> +<br> + // Create output console<br> + TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));<br> + if (createError)<br> + return createError;<br> +<br> + // Run application code inside TRAP harness, wait keypress when terminated<br> + TRAPD(mainError, DoStartL());<br> + if (mainError)<br> + console->Printf(KTextFailed, mainError);<br> + console->Printf(KTextPressAnyKey);<br> + console->Getch();<br> + <br> + delete console;<br> + delete cleanup;<br> + __UHEAP_MARKEND;<br> + return KErrNone;<br> + }</code></p> +<p class="CodeBlock"><code>/*<br> +============================================================================<br> + Name : $(baseName).h<br> + Author : $(author)<br> + Version :<br> + Copyright : $(copyright)<br> + Description : Exe header file<br> +============================================================================<br> +*/<br> +<br> +#ifndef __$(baseName)_H__<br> +#define __$(baseName)_H__<br> +<br> +<br> +// Include Files<br> +<br> +#include <e32base.h><br> +<br> +<br> +// Function Prototypes<br> +<br> +GLDEF_C TInt E32Main();<br> +<br> +<br> +#endif // __$(baseName)_H__</code></p> <p> When the developer chooses the above template in the New Project wizard, the following wizard pages are generated: |