1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
//---------------------------------------------------------------------
// name: type-query.ck
// desc: this example shows working with the Type type in ChucK
// to query Types currently in the ChucK type system
//
// version: needs 1.5.0.0 or higher
//
// author: Ge Wang (https://ccrma.stanford.edu/~ge/)
// date: Winter 2023
//---------------------------------------------------------------------
// get types currently in ChucK type system
Type.getTypes(
Type.PRIMITIVE, Type.BUILTIN
) @=> Type types[];
// print results of query
for( int i; i < types.size(); i++ )
{
cherr <= "(builtin primitive types): " <= types[i].name() <= " (" <= types[i].origin() <= ")" <= IO.newline();
}
// get types currently in ChucK type system
Type.getTypes(
Type.OBJECT, Type.BUILTIN
) @=> types;
// print results of query
for( int i; i < types.size(); i++ )
{
cherr <= "(builtin object types): " <= types[i].name() <= " (" <= types[i].origin() <= ")" <= IO.newline();
}
// get types currently in ChucK type system
Type.getTypes(
Type.OBJECT, Type.CHUGIN
) @=> types;
// print results of query
for( int i; i < types.size(); i++ )
{
cherr <= "(chugin types): " <= types[i].name() <= " (" <= types[i].origin() <= ")" <= IO.newline();
}
// get all subclasses of UGen
UGen.typeOf().children() @=> types;
// print results
for( int i; i < types.size(); i++ )
{
cherr <= "(UGens): " <= types[i].name() <= " (" <= types[i].origin() <= ")" <= IO.newline();
}
|