File: type_query.ck

package info (click to toggle)
chuck 1.5.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 41,260 kB
  • sloc: cpp: 124,539; ansic: 35,893; javascript: 2,111; yacc: 609; makefile: 457; python: 174; perl: 86
file content (51 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (3)
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();
}