UE1:UE1PreProcessor: Difference between revisions

From Unreal Wiki, The Unreal Engine Documentation Site
Raven (talk | contribs)
m New page: __TOC__ ==About== This is simple preprocessor for UnrealEngine 1. It was inspired by UnrealEngine 3 build-in preprocessor. ==Install== Copy files in the archive to your <Udir>/system fold...
 
Raven (talk | contribs)
mNo edit summary
Line 10: Line 10:


==Usage==
==Usage==
It's copy of UT3 preprocessor. Currently supported directives are:
 
===Directives===
Currently supported directives are:


<uscript>`process - should be in the first line of .uc file. Tells preprocessor to parse file
<uscript>`process - should be in the first line of .uc file. Tells preprocessor to parse file
Line 26: Line 28:
`check definition>value - evaluates to true if defined variable (definition) is greater then value. Used in floats, integers.
`check definition>value - evaluates to true if defined variable (definition) is greater then value. Used in floats, integers.
`check definition<value - evaluates to true if defined variable (definition) is less then value. Used in floats, integers.</uscript>
`check definition<value - evaluates to true if defined variable (definition) is less then value. Used in floats, integers.</uscript>
===Macros===
Macros are in fact hardcoded constants. Each macro will write something in currently parsed .uc file. Currently supported macros are:
<uscript>__FILE__ - will write name of currently parsed file
__CLASS__ - will write name of currently parsed class
__DATE__ - will write time</uscript>


===Commandline parameters===
===Commandline parameters===
You can use '''uenginepp''' by typing in console following command:


<uscript>utpreprocessor <project_dir>/<project_file> <modifiers></uscript>
<uscript>uenginepp <project_dir>/<project_file> <modifiers></uscript>


where:
where:
Line 46: Line 56:


===Project file===
===Project file===
Project file must have upc extension, and 'path' must be relative to uenginepp.exe location. Default location to files with preprocessor headers is:
<uscript><project_folder>/classes_ucp</uscript>
parsed .uc files will be stored in:
<uscript><project_folder>/classes</uscript>
Here's all commands for project file.


<uscript>[project]                - project informations
<uscript>[project]                - project informations
Line 55: Line 74:
output=folder            - override default output folder where parsed .uc files are written
output=folder            - override default output folder where parsed .uc files are written
input=folder              - override default input folder where parsed .uc files are stored
input=folder              - override default input folder where parsed .uc files are stored
dateformat=m.d.y          - date format (look below for all examples)


[globals]                - group contatin global variables for whole project
[globals]                - group contatin global variables for whole project
Line 70: Line 90:
output=classes
output=classes
input=classes_ucp
input=classes_ucp
dateformat=m.d.y


[globals]
[globals]
Line 75: Line 96:
global_value2=test2</uscript>
global_value2=test2</uscript>


Note that project file must have upc extension, and 'path' must be relative to uenginepp.exe location. Default location to files with preprocessor headers is:
====Date====
You can use following date formats:


<uscript><project_folder>/classes_ucp</uscript>
<uscript>// Assuming today is: February 12th, 2008, 19:16:18
F j, Y, g:i a                  - February 12th, 2008, 7:16 pm
m.d.y                          - 01.12.08
m-d-y, H:i:s                    - 01-12-08, 17:16:17
j, n, Y                        - 12, 1, 2008
D M j G:i:s T Y                - Sat Feb 12 19:16:08 MST 2008
H:i:s                          - 17:16:17</uscript>


parsed .uc files will be stored in:
===Example===
 
<uscript><project_folder>/classes</uscript>


Let's say you have project file in <UDir>/system called RUI.upc with content:
Let's say you have project file in <UDir>/system called RUI.upc with content:
Line 112: Line 138:
You run preprocessor and:
You run preprocessor and:


1. directive `process  is found, so preprocessor knows that this class has to be parsed.
#directive `process  is found, so preprocessor knows that this class has to be parsed.
2. directive `define is found. Preprocessor assign to const int1 value 120
#directive `define is found. Preprocessor assign to const int1 value 120
3. directive `define is found. Preprocessor assign to const int1 value 123
#directive `define is found. Preprocessor assign to const int1 value 123
4. directive `define is found. Preprocessor assign to const nc value var() class<actor> NewActor;
#directive `define is found. Preprocessor assign to const nc value var() class<actor> NewActor;
5. it detects `check directive and compare int1 and int2. because int1 is smaller then int2, expression evaluates to false and all next lines are skipped and deleted
#it detects `check directive and compare int1 and int2. because int1 is smaller then int2, expression evaluates to false and all next lines are skipped and deleted
6. it detects `else directive. preprocessor stops deleting lines and searches for next directives
#it detects `else directive. preprocessor stops deleting lines and searches for next directives
7. var() int test2; is not detected as directive so it's left alone
#var() int test2; is not detected as directive so it's left alone
8. directive `write is detected. preprocessor searches for variable named nc and (if found) writes it in .uc file
#directive `write is detected. preprocessor searches for variable named nc and (if found) writes it in .uc file
9. directive `endif stops conditional expression
#directive `endif stops conditional expression


output .uc file in classes will look like:
output .uc file in classes will look like:
Line 145: Line 171:


Of course input file can look different, but most important thing is to write '''`process''' in first line.
Of course input file can look different, but most important thing is to write '''`process''' in first line.
==Changelog==
*'''v 0.1.2'''
**added new macros
*'''v 0.1.1'''
**fixed parser
*'''v 0.1.2'''
**initial release

Revision as of 02:49, 27 August 2008

About

This is simple preprocessor for UnrealEngine 1. It was inspired by UnrealEngine 3 build-in preprocessor.

Install

Copy files in the archive to your <Udir>/system folder.

Download

link: http://turniej.unreal.pl/files/uenginepp.zip (~570 kb)

Usage

Directives

Currently supported directives are:

<uscript>`process - should be in the first line of .uc file. Tells preprocessor to parse file `include file - embade file in the currently opened .uc `inc_process file - embade file in the currently opened .uc and parses it `define variable - defines empty variable (used in `ifdef and `ifndef directives) `define variable=value - defines variable with specified value `write variable - writes defined variable `ifdef variable - evaluates to true if variable is defined `ifndef variable - evaluates to true if variable is not defined `else - part of conditional statement `endif - ends conditional statement `check definition==value - evaluates to true if defined variable (definition) equals value. Used in strings, floats, integers. `check definition<>value - evaluates to true if defined variable (definition) does not match value. Used in strings, floats, integers. `check definition>value - evaluates to true if defined variable (definition) is greater then value. Used in floats, integers. `check definition<value - evaluates to true if defined variable (definition) is less then value. Used in floats, integers.</uscript>

Macros

Macros are in fact hardcoded constants. Each macro will write something in currently parsed .uc file. Currently supported macros are:

<uscript>__FILE__ - will write name of currently parsed file __CLASS__ - will write name of currently parsed class __DATE__ - will write time</uscript>

Commandline parameters

You can use uenginepp by typing in console following command:

<uscript>uenginepp <project_dir>/<project_file> <modifiers></uscript>

where:

<uscript><project_dir> - relative project directory. <project_file> - file (.upc extension) conaining all options. If file is detected, no fuhrer modifiers are checked.</uscript>


modifiers:

<uscript>-clean - deletes preprocessor directives from .uc file -debug - turns on debug mode (prints every operation on parsed .uc file) -make <ini file> - runs ucc.exe with specified ini -h - prints help -global someglobal=somevalue - defines global variable</uscript>

Project file

Project file must have upc extension, and 'path' must be relative to uenginepp.exe location. Default location to files with preprocessor headers is:

<uscript><project_folder>/classes_ucp</uscript>

parsed .uc files will be stored in:

<uscript><project_folder>/classes</uscript>

Here's all commands for project file.

<uscript>[project] - project informations path=path - path to project debug=true - turns on debug mode (prints every operation on parsed .uc) make=true - if true, ucc will be executed make_ini=ini_file.ini - if present runs ucc.exe with specified ini clean=true - if true will delete preprocessor directives output=folder - override default output folder where parsed .uc files are written input=folder - override default input folder where parsed .uc files are stored dateformat=m.d.y - date format (look below for all examples)

[globals] - group contatin global variables for whole project someglobal=somevalue - global variable (sample)</uscript>

example:

<uscript> [project] path=../MyProject/ debug=true make=true make_ini=make.ini clean=true output=classes input=classes_ucp dateformat=m.d.y

[globals] global_value1=test1 global_value2=test2</uscript>

Date

You can use following date formats:

<uscript>// Assuming today is: February 12th, 2008, 19:16:18 F j, Y, g:i a - February 12th, 2008, 7:16 pm m.d.y - 01.12.08 m-d-y, H:i:s - 01-12-08, 17:16:17 j, n, Y - 12, 1, 2008 D M j G:i:s T Y - Sat Feb 12 19:16:08 MST 2008 H:i:s - 17:16:17</uscript>

Example

Let's say you have project file in <UDir>/system called RUI.upc with content:

<uscript>[project] path=../RComputerUI/ debug=true make=true make_ini=make.ini clean=true output=classes input=classes_ucp</uscript>

whe you'll call uenginepp.exe RUI.upc parser will process all files in classes_ucp, and generates output code in classes, which will be striped out (or not) from preprocessor directives. Let's say you have class:


<uscript>`process `define int1=120 `define int2=123 `define nc=var() class<actor> NewActor; class PreProcessorTest extends Actor;

`check int1>int2 var() int test1; `else var() int test2; `write nc `endif</uscript>

You run preprocessor and:

  1. directive `process is found, so preprocessor knows that this class has to be parsed.
  2. directive `define is found. Preprocessor assign to const int1 value 120
  3. directive `define is found. Preprocessor assign to const int1 value 123
  4. directive `define is found. Preprocessor assign to const nc value var() class<actor> NewActor;
  5. it detects `check directive and compare int1 and int2. because int1 is smaller then int2, expression evaluates to false and all next lines are skipped and deleted
  6. it detects `else directive. preprocessor stops deleting lines and searches for next directives
  7. var() int test2; is not detected as directive so it's left alone
  8. directive `write is detected. preprocessor searches for variable named nc and (if found) writes it in .uc file
  9. directive `endif stops conditional expression

output .uc file in classes will look like:

<uscript>class PreProcessorTest extends Actor;

var() int test2; var() class<actor> NewActor;</uscript>

Same output code with clean turned off:

<uscript>//`#process //`#define int1=120 //`#define int2=123 //`#define nc=var() class<actor> NewActor; class PreProcessorTest extends Actor;

//`#check int1>int2 //`#var() int test1; //`#else var() int test2; var() class<actor> NewActor; //`#write nc //`#endif</uscript>

Of course input file can look different, but most important thing is to write `process in first line.

Changelog

  • v 0.1.2
    • added new macros
  • v 0.1.1
    • fixed parser
  • v 0.1.2
    • initial release