1
#(# Qsomebase q example SomeBaseType)
2
#(# Qsomeunit q example SomeUnitType)
3
#(# Qsomederived q example SomeDerivedType)
5
#(#type $Qsomebase) // Opaque derivation defined in C, presumed a non-unit type
6
// Used to define an alias for some type from raw C.
7
// The defining typedef must happen at the C level, e.g.
8
typedef whatever_t (t $Qsomebase);
10
#(#type $Qsomeunit () ) // Derive from #(t () ), which we treat as a special unit type
12
#(#type $Qsomederived $Qsomenormal ) // Derive from SomeNormalType from before
14
// Opaque derivations:
16
// Alternatively, we might do something dumb like supply an inline typedef and
17
// allow the preprocessor to "autogenerate" it as needed. That might look like:
18
#(#type $Qsomebase (typedef "whatever_t" "") )
19
// -> typedef whatever_t (t $Qsomebase) ;
21
#(#type $Qsomebase (typedef "char" "[16]") )
22
// -> typedef char #(t $Qsomebase) [16] ;
24
#(#type $Qsomebase (typedef "int (*" ")(const void*,const void*)") )
25
// -> typedef int (*#(t $Qsomebase))(const void*,const void*) ;
26
// I believe, however, that there are strong arguments against doing it that
27
// way--it's too flexible to be simple and not flexible enough to be useful. It
28
// could be stretched a bit using treenames to complete the concept:
29
#(#type $Qsomebase (ctype whatever_t) )
30
#(#type $Qsomebase (carray char 16) )
31
#(#type $Qsomebase (cfuncp int (cptr void (const) ) (cptr void (const) ) ) )
32
// We also might simply indicate what header we'll need to define the type;
34
#(#type $Qsomebase (include "somelib/example.SomeBaseType.h") )
35
// All subject to future discussion.