Skip to content

Scaffolds syntax

Konstantin Tomashevich edited this page Jun 8, 2017 · 2 revisions

Configuration

Each scaffold should starts with configuration block. Currently, all configuration is tab size and class name. Example configuration block:

tab: "    "
className: MyObject

Vars

Vars block contains information about your class vars, which will be used in code generation. Each non-empty line is new var declaration. Vars declaration syntax: <type> <name> = <default>$<attribute name>. Example vars block:

vars:
Urho3D::PODVector <Urho3D::StringHash> myArray_ =$My Array
float myFloat_ =500.0f$My float
Urho3D::String myString_ ="StringValue"$My String

Header

Header block is output header template. It contains your header and command comments. There are supported header command-comments:

//@Insert var list
//@Insert vars getters and setters

Example header block:

#pragma once
#include <Urho3D/Scene/Component.h>

class MyObject : public Urho3D::Component
{
URHO3D_OBJECT (MyObject, Component)
protected:
    //@Insert var list

public:
    MyObject (Urho3D::Context *context);
    virtual ~MyObject ();
    static void RegisterObject (Urho3D::Context *context);

    //@Insert vars getters and setters
};

Object

Object block is output c++ object template. It contains your c++ object code and command comments. There are supported object command-comments:

//@Insert vars initialization
//@Insert attributes registration
//@Insert vars getters and setters

Example object block:

object:
#include "MyObject.hpp"
#include <Urho3D/Core/Context.h>

MyObject::MyObject (Urho3D::Context *context) : Urho3D::Component (context),
    //@Insert vars initialization
{

}

MyObject::~MyObject ()
{

}

void MyObject::RegisterObject (Urho3D::Context *context)
{
    context->RegisterFactory <MyObject> ();
    //@Insert attributes registration
}

//@Insert vars getters and setters

Bindings (optional)

Bindings block is Angel Script bindings template. It contains your bindings and command comments. There are supported bindings command-comments:

//@Insert arrays getters and setters
//@Insert getters and setters bindings

Example bindings block:

bindings:
#include <Urho3D/ThirdParty/AngelScript/angelscript.h>
#include <Urho3D/AngelScript/APITemplates.h>

//@Insert arrays getters and setters

void BindMyObject (asIScriptEngine *engine)
{
    Urho3D::RegisterObject <MyObject> (engine, "MyObject");
    //@Insert getters and setters bindings
}