Debian Codegraph @

examples/type/type_query.ck

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