/  Utilities

CKDoc

Type

StringTokenizer

ConsoleInput

Additional Utiilities

CKDoc

inherits : Object

A ChucK documentation generator. Based on Spencer Salazar's ckdoc utility.

constructors

CKDoc()

Default constructor for CKDoc.

member functions

void addGroup(Type[] types, string name, string shortName, string description)

Add a group of types to be documented, including group 'name', a 'shortName' to be used for any files, and a group 'description'.

void addGroup(string[] typeNames, string name, string shortName, string description)

Add a group of types (by type name) to be documented, including group 'name', a 'shortName' to be used for any files, and a group 'description'.

void addGroupExternal(string name, string URL, string description, string longDesc)

Add a group documention at an external URL location.

void clear()

Clear all added groups.

string examplesRoot(string path)

Set the examples directory root path; returns what was set.

string examplesRoot()

Get the current examples directory root path.

string genCSS()

Generate CSS; return as string.

void genGroups(string[] results)

Generate documentation for all added groups, return each in a separate entry.

string genIndex(string indexTitle)

Generate top-level index; return as string.

string genType(Type type)

Generate documentation for a single Type.

string genType(string typeName)

Generate documentation for a single Type (by name).

int numGroups()

Get the number of groups added.

int outputFormat(int which)

Set which output format to use; see CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON.

int outputFormat()

Set which output format is selected; see CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON.

int outputToDir(string path, string indexTitle)

Generate everything as files into the output directory.

int sort(int toggle)

Enable or disable alphabetical sorting of functions and variables.

int sort()

Get the current status of alphabetical sorting.

static member variables

int HTML

Output HTML format.

int JSON

Output JSON format (not implemented).

int MARKDOWN

Output MARKDOWN format (not implemented).

int NONE

No output format.

int TEXT

Output TEXT format (not implemented).


Type

inherits : Object

A representation of a ChucK type.

examples

constructors

Type()

Default constructor for Type.

member functions

int arrayDepth()

Return the number of array dimensions associated with this Type (e.g., 'int[][]' has 2; 'int' has 0).

string baseName()

Return the base name of this Type. The base of name of an array Type is the type without the array dimensions (e.g., base name of 'int[][]' is 'int')

Type[] children()

Retrieve this Type's children Types.

int equals(Type another)

Return whether this Type is same as 'another'.

int isArray()

Return whether this Type is some kind of an array.

int isPrimitive()

Return whether this is a primitive Type (e.g., 'int' and 'dur' are primitives types; 'Object' and its children Types are not).

int isa(Type another)

Return whether this Type is a kind of 'another'.

int isa(string another)

Return whether this Type is a kind of 'another'.

string name()

Return the name of this Type.

string origin()

Return a string describing where this Type was defined (e.g., "builtin", "chugin", "cklib", "user").

Type parent()

Return this Type's parent Type; returns null if this Type is 'Object'.

static member functions

Type find(string typeName)

Find and return the Type associated with 'typeName'; returns null if no Types currently in the VM with that name.

Type[] getTypes(int attributes, int origins)

Retrieve all top-level Types in the ChucK runtime type system that fit the attributes and origins flags. Flags that can bitwise-OR'ed for attributes: Type.ATTRIB_OBJECT, Type.ATTRIB_PRIMITIVE, TYPE_SPECIAL -- and for origins: Type.ORIGIN_BUILTIN, Type.ORIGIN_CHUGIN, Type.ORIGIN_CKLIB, Type.ORIGIN_USER.

Type[] getTypes()

Retrieves all top-level Types currently in the type system.

Type of(Object obj)

Return the Type of 'obj'

Type of(int val)

Return the Type associated with 'int'.

Type of(float val)

Return the Type associated with 'float'.

Type of(time val)

Return the Type associated with 'time'.

Type of(dur val)

Return the Type associated with 'dur'.

Type of(complex val)

Return the Type associated with 'complex'.

Type of(polar val)

Return the Type associated with 'polar'.

Type of(vec2 val)

Return the Type associated with 'vec2'.

Type of(vec3 val)

Return the Type associated with 'vec3'.

Type of(vec4 val)

Return the Type associated with 'vec4'.

static member variables

int BUILTIN

Origin bit for "builtin".

int CHUGIN

Origin bit for "chugin".

int CKLIB

Origin bit for "cklib".

int OBJECT

Attribute bit for non-primitive Object types.

int PRIMITIVE

Attribute bit for primitive types.

int SPECIAL

Attribute bit for special types (e.g., @array and @function).

int USER

Origin bit for "user".


StringTokenizer

inherits : Object

Break a string into tokens. This uses whitespace as the delimiter.

examples

constructors

StringTokenizer()

Default constructor for StringTokenizer.

member functions

string get(int index)

Return the i-th token in the set string.

string get(int index, string out)

Return the i-th token in the set string. Additionally, write the token string to the `out` string variable.

int more()

Return true (1) if there are still more tokens, false (0) if no more tokens.

string next()

Return the next token string.

string next(string out)

Return the next token string. Additionally, write the token string to the 'out' string variable.

void reset()

Reset token iteration back to the beginning of the set string.

void set(string line)

Set the string to be tokenized.

int size()

Returns the number of token strings that the set string can be broken into.


ConsoleInput

inherits : Event : Object

(Terminal only) a utility for prompting user input on the command line.

examples

constructors

ConsoleInput()

Default constructor for ConsoleInput.

member functions

int can_wait()

(internal) used by virtual machine for synthronization.

string getLine()

Return the next line of input as a string.

int more()

Return whether there is more input to read.

Event prompt()

Return an Event to wait on.

Event prompt(string what)

Print a prompt text and return an Event to wait on.