UIEvolutin Inc.
UJML Language Reference
Compiling

Compiling is the process of turning UJML source code into UJML byte code.

A compiler is a program that reads in UJML source code files and outputs UJML byte code files. See Types of UJML Files. Compilers for UJML are available in a number of different contexts, from visual debuggers to Web-based compiler servlets. To learn more about using a compiler, you can refer to the appropriate documentation for the compiler you are using.

Compiler settings

Compiler settings are values which change how the compiler goes about converting the UJML source into byte code. There are a variety of compiler settings, many of which vary from compiler to compiler. The two most important settings, which are available everywhere, are 'Trace' and 'Debug'. 

The 'Trace' setting may be either true or false (on or off). If it is true, then the UJML compiler will output code when a _trace() function is encountered. See Debugging, _trace() function. Otherwise the _trace() function is ignored. 

The 'Debug' setting determines if the compiler produces special symbols in the byte code which are used by the debugger. This should never be on when compiling to run on a device.

Conditional compilation

You can compile only certain parts of your UJML file by using conditional compilation. Conditional compilation uses special UJML tags called 'processing directives' which define and/or undefine names and then test to see if those names exist. See Compilation Tags. The tests create code blocks which are compiled or not as indicated by the processing instruction used for the test. 

Note: Unlike C-language style preprocessor directives, UJML processing directives use string names which are either defined or not defined, rather than being defined as equal to some value. 

Some UJML compilers support defining conditional compilation names in the compiler directives.

The following example shows how to define the conditional compilation name 'MARSLANDER' only if the conditional compilation name 'LUNARLANDER' is not defined. It is part of the lunarlander.ujml sample.

<?ujml-ifndef LUNARLANDER?>
<?ujml-define MARSLANDER?>
<?ujml-endif?>

 

The following example shows how to nested conditional compilation blocks. It is part of the lunarlander.ujml sample.

<?ujml-ifdef MARSLANDER?>
// Environment.
mAppName = "&APP_NAME_MARS;" ;
mFrameMsec = 100;
mGravity = 2;
mFloorHeight = 6;
<?ujml-ifdef EASYPLAY?>
mSafeLandingVelocity = 16;
mThrust = 6;
mMaxFuel = 72;
<?ujml-else?>
mSafeLandingVelocity = 10;
mThrust = 5;
mMaxFuel = 60;
<?ujml-endif?>
// Images.
mLanderImageURL = _image_url("img/landerstrip");
mLanderWidth = 44;
mLanderHeight = 32;
mBackGroundTileImageURL = _image_url("img/skytile");
mSurfaceTileWidth = 96;
mSurfaceTileHeight = 28;
mSurfaceTileImageURL = _image_url("img/marssurfacetile");
mBackGroundTileWidth = 96;
mBackGroundTileHeight = 96;
<?ujml-else?>
// Environment.
mAppName = "&APP_NAME;" ;
mFrameMsec = 100;
mGravity = 1;
mFloorHeight = 6;
<?ujml-ifdef EASYPLAY?>
mSafeLandingVelocity = 9;
mThrust = 6;
mMaxFuel = 60;
<?ujml-else?>
mSafeLandingVelocity = 7;
mThrust = 4;
mMaxFuel = 36;
<?ujml-endif?>
// Images.
mLanderImageURL = _image_url("img/landerstrip");
mLanderWidth = 44;
mLanderHeight = 32;
mBackGroundTileImageURL = _image_url("img/spacetile");
mSurfaceTileWidth = 96;
mSurfaceTileHeight = 28;
mSurfaceTileImageURL = _image_url("img/surfacetile");
mBackGroundTileWidth = 96;
mBackGroundTileHeight = 96;
<?ujml-endif?>
Copyright (c) 2000-2007 UIEvolution, Inc. All rights reserved.
What do you think about this topic? Send feedback!