Last modified 4 years ago Last modified on 07/02/08 22:23:19

See Sql Stats Meta Language Test Stuff for an example of the current script stuff.

/*
 * Special types in the metalanguage:
 *
 * count:       positive integer representing a count of something
 *
 * string:      just a text string
 *
 * enum:        enumerant of several values; within the generated C code the
 *              actual ``member-values'' of an enumerant will be prefixed with
 *              the name of the enumerant followed by an undesquore. Thus:
 *              code_value_name = $enum_name + "_" + $value_name.
 *
 * real:        a numeric value capable of holding numeric values that are part
 *              of the "real" set of numbers (try Wikipedia for "real number"
 *              if you don't understand this).
 *
 * bool:        boolean type that can be either true or false
 *
 * Some special keywords:
 *
 * abstract:    qualifier keyword that declares that the declared struct/table
 *              type will be inherited from and *will* need a unique ID column
 *              to link the tables together.
 *
 *              abstract types cannot be instantiated, only types derived from
 *              abstract types can be.
 *
 * prefix:      qualifier keyword that will declare that the given type or
 *              field will have to be prefixed with the string following the
 *              keyword in all but the generated SQL code. NOTE: for types that
 *              get inherited from, this will also affect all "subclasses".
 *
 * set          qualifier keyword for enum(-like?) types which declares that it
 *              is possible for the given field to have multiple values of the
 *              enum enabled at the same time. Thus this turns the given field
 *              in a bit field-like type (it might be implemented as an array
 *              of boolean values as well, that hasn't been decided upon yet).
 *
 * unique:      qualifier keyword that declarese that the value of the declared
 *              variable needs to be unique across all instances of the
 *              surrounding type.
 */
abstract struct BASE prefix "STATS_"
{
    unique string   id;             /**< unique language independenant name
                                         that can be used in code to identify a
                                         specific stats instance */
    string          name;           /**< short name, describing the component, must be
                                         translateable */
};

enum TECH_LEVEL
{
    ONE,
    TWO,
    THREE,
};

struct COMPONENT : BASE
{
    set TECH_LEVEL  level;          /**< technology level(s) of this component
                                         */
    real            buildPower;     /**< power required to build this component
                                         */
    real            buildPoints;    /**< build points (which are rate-limited
                                         in the construction units) required to
                                         build this component. */
    real            weight;          /**< weight of this component */
    bool            designable;      /**< indicates whether this component is
                                          "designable" and can thus be used in
                                          the design screen. */
    /** @TODO devise some kind of type to refer to IMD models; perhaps just
     *        filenames will suffice?
     *
     *        We'll name it IMD_model for now. */
    IMD_model       baseModel;      /**< The "base" IMD model representing this
                                         component in 3D space. */
};

struct BODY : COMPONENT
{
    count           weaponSlots;    /**< The number of available weapon slots
                                         on the body */
    real            powerOutput;    /**< Engine output of this body's engine */
};
/*
 * Generated type definitions for C:
 */

typedef struct
{
    const char*     id;             /**< unique language independenant name
                                         that can be used in code to identify a
                                         specific stats instance */
    const char*     name;           /**< short name, describing the component, must be
                                         translateable */
} STATS_BASE;

typedef enum
{
    TECH_LEVEL_ONE,
    TECH_LEVEL_TWO,
    TECH_LEVEL_THREE,
} TECH_LEVEL;

typedef struct
{
    /* BEGIN of inherited "STATS_BASE" definition */
    const char*     id;             /**< unique language independenant name
                                         that can be used in code to identify a
                                         specific stats instance */
    const char*     name;           /**< short name, describing the component, must be
                                         translateable */
    /* END of inherited "STATS_BASE" definition */

    TECH_LEVEL      level[3];       /**< technology level(s) of this component
                                         */
    float           buildPower;     /**< power required to build this component
                                         */
    float           buildPoints;    /**< build points (which are rate-limited
                                         in the construction units) required to
                                         build this component. */
    float           weight;          /**< weight of this component */
    bool            designable;      /**< indicates whether this component is
                                          "designable" and can thus be used in
                                          the design screen. */
    /** @TODO devise some kind of type to refer to IMD models; perhaps just
     *        filenames will suffice?
     *
     *        We'll name it IMD_model for now. */
    iIMDShape*      baseModel;      /**< The "base" IMD model representing this
                                         component in 3D space. */
} STATS_COMPONENT;

typedef struct
{
    /* BEGIN of inherited "STATS_COMPONENT" definition */
    /* BEGIN of inherited "STATS_BASE" definition */
    const char*     id;             /**< unique language independenant name
                                         that can be used in code to identify a
                                         specific stats instance */
    const char*     name;           /**< short name, describing the component, must be
                                         translateable */
    /* END of inherited "STATS_BASE" definition */

    TECH_LEVEL      level[3];       /**< technology level(s) of this component
                                         */
    float           buildPower;     /**< power required to build this component
                                         */
    float           buildPoints;    /**< build points (which are rate-limited
                                         in the construction units) required to
                                         build this component. */
    float           weight;          /**< weight of this component */
    bool            designable;      /**< indicates whether this component is
                                          "designable" and can thus be used in
                                          the design screen. */
    /** @TODO devise some kind of type to refer to IMD models; perhaps just
     *        filenames will suffice?
     *
     *        We'll name it IMD_model for now. */
    iIMDShape*      baseModel;      /**< The "base" IMD model representing this
                                         component in 3D space. */
    /* END of inherited "STATS_COMPONENT" definition */

    unsigned int    weaponSlots;    /**< The number of available weapon slots
                                         on the body */
    float           powerOutput;    /**< Engine output of this body's engine */
} STATS_BODY;
--
-- Generated SQL statements for table construction
--

CREATE TABLE `BASE` (
    unique_inheritance_id   INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, -- Automatically generated ID to link the inheritance hierarchy
    id                      TEXT UNIQUE NOT NULL,                       -- unique language independenant name
                                                                        -- that can be used in code to identify a
                                                                        -- specific stats instance
    name                    TEXT NOT NULL                               -- short name, describing the component, must be
                                                                        -- translateable
);

CREATE TABLE `COMPONENT` (
    unique_inheritance_id   INTEGER PRIMARY KEY NOT NULL,               -- Automatically generated ID to link the inheritance hierarchy
    level_1                 INTEGER NOT NULL,                           -- technology level(s) of this component
    level_2                 INTEGER NOT NULL,
    level_3                 INTEGER NOT NULL,
    buildPower              NUMERIC NOT NULL,                           -- power required to build this component
    buildPoints             NUMERIC NOT NULL,                           -- build points (which are rate-limited
                                                                        -- in the construction units) required to
                                                                        -- build this component.
    weight                  NUMERIC NOT NULL,                           -- weight of this component
    designable              INTEGER NOT NULL,                           -- indicates whether this component is
                                                                        -- "designable" and can thus be used in
                                                                        -- the design screen.
     -- @TODO devise some kind of type to refer to IMD models; perhaps just
     --       filenames will suffice?
     -- 
     --       We'll name it IMD_model for now.
    baseModel               TEXT NOT NULL                               -- The "base" IMD model representing this
                                                                        -- component in 3D space.
);

CREATE TABLE `BODY` (
    unique_inheritance_id   INTEGER PRIMARY KEY NOT NULL,               -- Automatically generated ID to link the inheritance hierarchy
    weaponSlots             INTEGER NOT NULL,                           -- The number of available weapon slots
                                                                        -- on the body
    powerOutput             NUMERIC NOT NULL                            -- Engine output of this body's engine
);