Metaprogramming Text Processor

Using the MTP Tool

The MTP tool is a Java applet-application hybrid. This means it can be activated directly as an application in a conventional environment or it can be activated via an HTML file to a web browser. Alternatively, the MTP tool can be linked directly with other Java code to create integrated product generators. There also exists a supporting implementation of a plugin for the Metrowerks CodeWarrior integrated development environment that enables the use of MTP files for streamlined generation of executable code. The form of the MTP input is the same (with minor differences) regardless of the form of tool activation used.

For purposes of exploring the concepts of MTP and adaptable components, only the applet form of activation is directly available to everyone. Other forms are available only by special arrangement with PHS, usually as part of a DsE adoption initiative.


Activation of MTP using HTML

To use MTP, first create an MTP-annotated input file. At a minimum, this file will contain one metaprogram definition and an instantiation of that metaprogram.

To apply the MTP tool through an applet to your input file, create an HTML file with contents similar to the following:

<html>
<head> <title>Generated Component</title> </head>
<body>
<applet archive="http://www.domain-specific.com/MTP/metapLib.zip"
	code="component.class"  width=420 height=315>
<param name="file" value="sample.mtp">
</applet>
</body>
</html>

changing the value of the "file" parameter from "sample.mtp" to the name of your input file. You then open your HTML file with your favorite browser that supports Java 1.1 programs. Your browser will then display the output of MTP processing.

Select the file ELT.java.mtp to see an example of an MTP annotated Adaptable Component. This component contains a definition and instantiation of a metaprogram named "setTracker". It generates compilable Java source code that implements a simple expense ledger capability. Activate the file ELT.html to display the generated Java code that results.

Note that this means of using MTP over the Internet, due to security conventions, imposes two constraints inherent to Java applets. First, use of "file inclusion" statements will cause most browsers to produce a security violation and terminate the applet without producing a result. Second, although MTP is capable of generating its output into a file, the applet form must generate all output into a window; you can then either print the window's contents or select, copy, and save the text to a file using browser commands.




PHS