cxCedaScript.h
@import "Ceda/cxObject/Object.h"
@import "Ceda/cxObject/ReflectionByteCode.h"
#include "Ceda/cxMacroExpander/ExpressionParser.h"
#include "Ceda/cxMacroExpander/LSSourceFile.h"
CEDA_DEFINE_PROJECT_API_MACRO
namespace ceda
{
/*
The textual encoding/decoding makes use of the CDM schema, so there is no need to
decorate the data with type information except where required for variant types.
The following table illustrates how the basic types are encoded as text
Type and value text encoding
-----------------------------------------------------------------------
char8 : 'x' 'x' or "x"
string8 : "Hello world" "Hello world" or 'hello world'
float64 : 3.14159 3.14159
Also need hex version to avoid data loss
int32 : 27 27 or 0x1D
bool : false false
Consider the tuple definition
$tuple Point { int32 x; int32 y; };
A Point value with x=10, y=20 can be encoded as
(10,-20)
where the order of the attribute values must match the order provided in the tuple
definition. Alternatively we can use the form
{x=10 y=20}
where the name value pairs can appear in any order.
A variant value is encoded using the tag name following by its value if any. For
example, given the following closed variant definition
$variant Shape
{
Circle circle;
Triangle triangle;
Rectangle rectangle;
};
and a value equal to the unit circle centred at the origin, we could represent this
as
circle { centre=(0,0) radius=1 }
An open variant is encoded similarly except that the type name is used in place of
the tag name.
A vector<T> value is encoded using a comma separated list of values enclosed in
square brackets. For example, a vector<int32> value could be [1,2,-7,8]. A
more complicated example is a vector<Shape> value which may be encoded as
[ rectangle(0, 0,10,10),
circle ((0,0) ,1),
circle((10,-5), 2),
triangle( (0,0), (10,0), (0,10) )
]
A bag<T> is encoded using a comma separated list of values in square brackets. The
order is not significant. For example a bag<int32> could be [1,1,1,2,2,7].
A set<T> is encoded using a comma separated list of values enclosed in braces. For
example, a set<char> value could be { 'x', 'a', 'A' }
A map<K,V> is encoded as though it were a set<pair<K,V>>.
An mvector is encoded in the same way as a vector, and an mbag is encoded in the
same way as a bag.
Example
-------
Controls.Folder
{
Name = "F1"
Children =
[
Controls.Folder
{
Name = "F2"
Children =
[
Text.Text
{
Name = "my text doc"
Text = "This is some text, OK?"
Font =
{
Height = 70
Italic = 1
FaceName = "Times New Roman"
}
Colour = (200,200,0,0)
},
Image.Bitmap {},
Controls.Slider {},
Controls.Board
{
Name = "My Board"
Size = (800,600)
},
Misc.MandelbrotSet
{
Name = "ms"
Size = (640,480)
Window = (-0.58,0.55,-0.43,0.65)
RPalette = { C = 2 }
}
]
},
Statistics.PieChart
{
Name = "My pie chart"
NumSections = 10
Size = (300,400)
}
]
}
*/
@api void ParseVariable(ExpressionParser& parser, ReflectionByteCode rbc, void* data);
@api void ParseArrayVariable(ExpressionParser& parser, ReflectionByteCode rbc, ssize_t size, void* data);
@api void ParseVectorVariable(ExpressionParser& parser, ReflectionByteCode rbc, void* data);
@api void ParseMapVariable(ExpressionParser& parser, ReflectionByteCode rbc, void* data);
@api void ParseClassVariable(ExpressionParser& parser, const ReflectedClass& rc, void* data);
@api void ParseVariantVariable(ExpressionParser& parser, const ReflectedVariant& rv, void* data);
////// Parse data source
@api ptr<IObject> ParseDataSource(ExpressionParser& parser, ConstStringZ className);
@api ptr<IObject> ParseDataSource(ExpressionParser& parser);
@api ptr<IObject> ParseDataSource(const xstring& s, LexScannerException& error);
$function+ ptr<IObject> ParseDataSourceFromString(const xstring& pds, xstring& errorMsg);
$function+ ptr<IObject> ParseDataSourceFromString2(const xstring& pds);
////// Navigate a path
// Navigate the given path through obj. Returns address of field and sets rbc to
// the type of the field.
@api void* NavigatePathToField(ptr<IObject> obj, ExpressionParser& parser, ReflectionByteCode& rbc, bool writeAccess);
$function+ void* NavigatePathToField(ptr<IObject> obj, const xstring& path, ReflectionByteCode& rbc, bool writeAccess, xstring& errorMsg);
} // namespace ceda