Фрагмент конфигуратора DWE

Jul 19, 2008 17:23

С купюрами.



## Генерация исходного кода документа из html-шаблона

group = {
  ## Теги
  tags : group = {

## Код
    code : group = {
      type : string = section
      closed : boolean = true
      open : string = <-code
      close : string = code->
      param : boolean = false
      section : string = text
      set_mode : string = code
      mode : string = text
      begin_line : boolean = true
    }

## Инициализация
    init : group = {
      type : string = section
      closed : boolean = true
      open : string = <-init
      close : string = init->
      param : boolean = false
      section : string = init
      set_mode : string = code
      mode : string = text
      begin_line : boolean = true
    }

## Инициализация контекста
    init_context : group = {
      type : string = section
      closed : boolean = true
      open : string = <-context
      close : string = context->
      param : boolean = false
      section : string = init-context
      set_mode : string = code
      mode : string = text
      begin_line : boolean = true
    }

## Переменные
    var : group = {
      type : string = list
      open : string = <-var "
      param_close : string = " var->
      closed : boolean = false
      list_section : group = {
        text : string = var_text
        init : string = var_init
        init-context : string = var_init_context
        done : string = var_done
        update : string = var_update
        access : string = var_access
      }
      param : boolean = true
      begin_line : boolean = true
      param_type : string = trim
    }

## Вызов
    call : group = {
      type : string = script
      open : string = <-call "
      param_close : string = "
      close : string = call->
      closed : boolean = true
      param : boolean = true
      begin_line : boolean = true
      param_type : string = split
      open_script : text = {
        check_section text
        set_mode code
        out_text {eol}{sp}{sp}_CallDocument:=_GetCallDocument(WebContext, Context, '{param2}', '{param1}');{eol}
        out_text {sp}{sp}_CallContext:=_GetCallContext(Context, '{param2}', '{param1}');{eol}
        set_section update
        out_text {eol}{sp}{sp}_CallDocument:=_GetCallDocument(WebContext, Context, '{param2}', '{param1}');{eol}
        out_text {sp}{sp}_CallContext:=_GetCallContext(Context, '{param2}', '{param1}');{eol}
        clear_section
      }
      close_script : text = {
        out_Text {sp}{sp}Content.AddStrings(_CallDocument.Generate(WebContext, _CallContext, '{param1}'));{eol}
        set_section update
        out_Text {sp}{sp}_CallDocument.Put(WebContext, _CallContext, '{param1}');{eol}
        clear_section
        clear_mode
      }
    }

## Загрузка документа
    document : group = {
      type : string = script
      open : string = <-document "
      param_close : string = " document->
      closed : boolean = false
      param : boolean = true
      begin_line : boolean = true
      param_type : string = trim
      open_script : text = {
        check_section text
        check_mode text
        list dependancies {param}
      }
    }
  }

modes : group = {
    text : string = #$20#$20Writeln('{text}');
    code_group : string = #$20#$20#$20#$20'{text}'{pas_eol}+
  }

lists : group = {
    uses : group = {
      template : string = , {text}
      separator : string =
      terminator : string =
      begin : string =
    }
    var_text : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    var_init : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    var_init_context : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    var_done : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    var_update : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    var_access : group = {
      template : string = #$20#$20{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    members : group = {
      template : string = {sp}{sp}{sp}{sp}{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    fields : group = {
      template : string = {sp}{sp}{sp}{sp}{text}
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    save_context : group = {
      template : string = {sp}{sp}SaveContextValue('{text}');
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
    dependancies : group = {
      template : string = {sp}{sp}Engine.LoadDocument('{text}');
      separator : string = {eol}
      terminator : string =
      begin : string =
    }
  }

generator : text = {
// Generated by DWE module web_engine.dcu
library {library_name};
uses
  ShareMem, SysUtils, Classes, HTTPApp, IniFiles, Math, DateUtils, StrUtils,
  web_interface, web_engine, web_templates{list:uses};

// Interface
{interface}

// Module class
type
  {class_name} = class(TDWEDocument)
  private
    // fields
{list:fields}
    procedure _CheckDependancies;
    function _GetCallDocument(WebContext : IDWEWebContext; Context : IDWEClass; RefName : String; AName : String) : IDWEDocument;
    function _GetCallContext(Context : IDWEClass; RefName, AName : String) : IDWEClass;
  protected
    procedure DoInitContext(WebContext : IDWEWebContext; Context : IDWEClass; RefName : String);override;
  public
    constructor Create(AParent : IDWEValue = nil; AName : String = '');override;
    destructor Destroy;override;
    function Generate(WebContext : IDWEWebContext; Context : IDWEClass; RefName : String) : IDWEStringList;override;
    procedure Put(WebContext : IDWEWebContext; Context : IDWEClass; RefName : String);override;
    function GetHasAccess(WebContext : IDWEWebContext; Context : IDWEClass; RefName : String) : Boolean;override;
    // custom members
{list:members}
  end;

const
  ModuleClassName = '{class_name}';
  ModuleName = '{module_name}';
  ModuleFileName = '{file_name}';

// Implementation
{implementation}

...

exports
  ModuleFunc name 'ModuleFunc';

begin
  Randomize;
end.
 }
}

dwe

Previous post Next post
Up