projects.practivist.org

sendero_base.Core

This module provides the core for the sendero_base dynamic type system. Available types are enumerated by the VarT enum. The Var struct represents a basic value in the type system.

It is recommended that the convenience function set() in sendero_base.Set and the SenderoObject.add() function (in sendero_base.Object) be used instead of manipulating the Var struct directly. This will help adjust to API changes. If you must manipulate the Var struct directly, then try writing a helper function of your own.

JSON source can be compiled into Var types using the parseJson() function in sendero_base.json.ObjectParser.

License:
GNU Lesser General Public License v3

Authors:
Aaron Craelius





enum VarT ;
Specifies available variable types in the sendero_base dynamic type system.

Null
Null value

Number
Number of type real

String
String of type char[]

Bool
Value of type bool

Array
Array of type IArray

Object
Object of type IObject

Function
Function delegate of type Function

Time
Time value of type tango.time. Time

Void
Used user/binary data of type void*

alias Number ;
The basic number type in sendero_base dynamic type system (set to real).

alias String ;
The basic string type in sendero_base dynamic type system (set to char[]).

interface IObject ;
The interface for an object in the sendero_base dynamic type system.

abstract int opApply (int delegate(ref char[] key, ref Var val) dg);


abstract Var opIndex (char[] key);
Retrieves a variable in an object through dictionary lookup.

abstract void opIndexAssign (Var val, char[] key);
Sets the value for the member of an object

abstract Var opCall (Var[] params, IObject ctxt);
Called when an object is called like a function.

Params:
Var[] params an array of the parameters to the function
IObject ctxt the context in which the function is called

Returns:
The return value of the function

abstract void toString (char[] flags, IObject ctxt, void delegate(char[]) write);
Converts the object to an end-user string representation. Allows objects to have complex formatting options - useful for any object that needs a more complex string representation than the basic number/datetime formatting such as local times, currency, measurements, etc.

Params:
char[] flags flags for string formatting
IObject ctxt the current execution context
void delegate(char[]) write a consumer delegate

interface IArray ;
The interface for an array in the sendero_base dynamic type system.

abstract int opApply (int delegate(ref Var val) dg);


abstract Var opIndex (uint i);
Params:
uint i array index

Returns:
the ith element in the array (if it exists) or a Var of type VarT.Null

abstract uint length ();
Returns:
the length of the array

alias Function ;
The basic function type in sendero_base dynamic type system.

struct Var ;
A variable in the sendero_base dynamic type system.

IArray array_ ;
The IArray value of the variable for when type = VarT.Array

IObject obj_ ;
The IObject value of the variable for when type = VarT.Object

Function function_ ;
The Function value of the variable for when type = VarT.Function

bool bool_ ;
The boolean value of the variable for when type = VarT.Bool

Number number_ ;
The Number value of the variable for when type = VarT.Number

String string_ ;
The String value of the variable for when type = VarT.String

Time time_ ;
The Time value of the variable for when type = VarT.Time

void* void_ ;
The void* value of the variable for when type = VarT.Void. Used for user/binary data.

VarT type ;
The type of the variable

Documentation last updated Thu May 29 17:23:14 2008