Sorpetaler Fensterbau GmbH

only search Hybrie.net
Hybrie - Delphi .NET Interoplogo

Reference

Delphi Import File  [back to documentation]

These files can import data type definitions from delphi. They are run by the frontend,
which analyzes the files specified within and generates a corresponding User Type Definition
You have to be careful to edit a file with the ending .g.yml,
This is the convention for automatic generated types, which will be overwritten by every converter run.

The format itself is a simple but sufficient DSL, as the example from the Demo will show you:

guid F3BB89AE-F2D0-494C-87CF-3F7822544FA9
from ..\..\Delphi
   in HybrieDemoInclude.pas
   import *
end

Important: you can specifiy mulitple in/import/using pairs within a from ... end block,
This will import several types at once (useful for dependent files)

Keywords:
from

This keyword loads a directory for input processing

in

Specifies a delphi source file from which to import data types. (wildcards not supported yet)

import

This can either be a concrete type name or a wildcard *,
Which imports all files, which is the preferred option.

using

This is an optional keyword and is required if you don't want to import the file into the output folder,
But rather you want to use one of your packages this file is contained in.
This helps avoiding import conflicts within your Delphi project, as one unit can only be imported once in certain cases.

end

Ends the script, conversion now begins

Common file specification  [back to documentation]

The input to the program is mostly defined in a human-editable markup format, based on the YAML specification.
Listed is a certain set of rules which have to be followed:

  • Every YAML document starts with a version and a document separator.
    %YAML 1.2
    ---
     
  • The fully qualified name of the document is the root of all nodes, i.e. it serves as a common namespace.
    When using a language which support namespaces, all elements will be defined in that namespace.
    Following the Java package convention, the file name should match the namespace, this keeps things in order.
     Demo.Hybrie.IForm:
     
  • Both the Interface Specification and User Type Definition support import statements.
    The type namepsace is taken from the Common Type System in .NET,
    so far only the types in the core module and types defined in the User Type Definition are supported.
    There are two kinds of import statements:
    • Namespace imports (e.g. System)
    • Import of other YAML documents, this is used by the User Type Definition engine to reference other types.
      It also imports the namespace as above
  • Tthe order of the keys in the hashmap does matter (i.e.)
    In a future version, this requirement might be dropped, when there is a dependency resolution mechanism to resolve the order of statements.
    Nonetheless, the implementation used does keep the input order intact, so it won't create any problems.

Interface Specification  [back to documentation]

For defining remote callable modules in your programs, you need an interface specification
For now, these need to be manually edited, but do not fear, it follows a Common file specification based on YAML, so Here you can define methods and their parameters, using .NET primitive types, arrays and the User Type Definition.
To get a broader overview, here is a listing of the Demo Project source file:

%YAML 1.2
---
# This document is a mapping of key/value pairs...

Demo.Hybrie.IForm:
 guid: 369193A4-9659-41BE-ACD5-CEF4A8FE176B
 sender-guid: 120F3408-D33A-432C-A8CA-579092B56C99

 import-from:
  - System
  - System.Collections
  - System.Collections.Generic
  - Demo.Hybrie.Data

 define-method:
  SynchronizeBoolean:
   guid: D83E02EF-B12C-4E52-A24D-E50AFDF3D6EE
   in:
    - value: Boolean
    - sent: DateTime

  SynchronizeDirection:
   guid: 4282555B-34D4-4E52-A06E-4CC5667D4708
   return: DateTime
   in:
    - value: Direction
    - sent: DateTime

  SynchronizeSimpleText:
   guid: 7987060B-421A-4406-B10B-41079DF36EAA
   return: DateTime
   in:
    - value: String
    - sent: DateTime

  SynchronizeMemo:
   guid: 25BBB333-DAE5-418D-96AD-EE990FA0AA2B
   return: DateTime
   in:
    - value: String
    - sent: DateTime

  SynchronizeCurrentTime:
   guid: ED800FC7-5395-48F7-B2AB-C9A5BEE80C4D
   return: DateTime
   in:
    - value: DateTime

  SynchronizeBoolArray:
   guid: BDB63919-6374-400C-A33C-086FEA1E00C1
   return: DateTime
   in:
    - value: Boolean[1..6]
    - sent: DateTime
  
  SynchronizeMyRecord:
   guid: 0D71FDE0-E66C-4438-817F-1B6A171DCF4C
   return: DateTime
   in:
    - value: MyRecord
    - sent: DateTime

  SynchronizeGrid:
   guid: CC6D4D71-0BA8-4716-9E1F-A1D018AA9EB4
   return: DateTime
   in:
    - value: MyArray
    - sent: DateTime


 
And here is a listing of the YAML Types, for comparison:
To sum up:
  • A root node contains a map of define elements, usually maps themselves
  • All elements have a guid attribute, this eases recognition

User Type Definition  [back to documentation]

The data type specification is the core of the interoperability between different computer languages.
Here is the data definition file from the Demo Project:

%YAML 1.2
---
# automatically generated YAML file: 2012-02-06 10:38:38 UTC
# Copyright 2010 - 2012 Sorpetaler Fensterbau GmbH

Demo.Hybrie.Data:
 guid: F3BB89AE-F2D0-494C-87CF-3F7822544FA9

 import-from:
  - System
  - System.Collections
  - System.Collections.Generic
  - System.Linq

 define-enum:
  Direction:
   - Alias Delphi:
      Unit: HybrieDemoInclude
      Name: TDirection
      File: HybrieDemoInclude.pas
      Assembly: 
      Directory: C:\Users\sebastian\Documents\Hybrie.NET\Delphi
   - Undef
   - Left
   - Right
   - Up
   - Down

 define-record:
  MyRecord:
   - Alias Delphi:
      Unit: HybrieDemoInclude
      Name: TMyRecord
      File: HybrieDemoInclude.pas
      Assembly: 
      Directory: C:\Users\sebastian\Documents\Hybrie.NET\Delphi
   - BooleanValue: System.Boolean
   - Direction: Direction
   - SimpleText: System.String
   - Memo: System.String
   - BoolArray: System.Boolean[1 .. 6]
   - CurrentTime: System.DateTime

 define-record:
  MyGrid:
   - Alias Delphi:
      Unit: HybrieDemoInclude
      Name: TMyGrid
      File: HybrieDemoInclude.pas
      Assembly: 
      Directory: C:\Users\sebastian\Documents\Hybrie.NET\Delphi
   - BooleanValue: System.Boolean
   - IntegerValue: System.Int32
   - DoubleValue: System.Double
   - SomeText: System.String
   - Direction: Direction

 define-typealias:
  - MyArray: MyGrid[* .. *]


 
Again, for better understanding a type analysis of the document:
A document can use any number of elements, using these kinds of definitions:
Enum

A sequence of enum constant names to values, values can be defined or automatically valued:

  • Normal value: scalar (- NameOfConstant)
  • Explicit value: map  (- NameOfConstant: Value)

Record

A sequence of maps name to types

Class

From the syntax point of view, the same as record.
Once properly supported, will have class specific features.

Alias

This is induced by the frontend, if an alias is specified, no code will be generated for that language,
instead the given type will be referenced (works for delphi so far)