~psmay/+junk/prasky.dev

« back to all changes in this revision

Viewing changes to sample2.c

  • Committer: Peter S. May
  • Date: 2012-10-25 02:04:41 UTC
  • Revision ID: peter_s._may_httppsmay.com-20121025020441-qqz9r3idkhk2jsih
Initial. Doesn't parse () correctly yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#(# Qsomebase q example SomeBaseType)
 
2
#(# Qsomeunit q example SomeUnitType)
 
3
#(# Qsomederived q example SomeDerivedType)
 
4
 
 
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);
 
9
 
 
10
#(#type $Qsomeunit () ) // Derive from #(t () ), which we treat as a special unit type
 
11
 
 
12
#(#type $Qsomederived $Qsomenormal ) // Derive from SomeNormalType from before
 
13
 
 
14
// Opaque derivations:
 
15
 
 
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) ;
 
20
// or
 
21
#(#type $Qsomebase (typedef "char" "[16]") )
 
22
        // -> typedef char #(t $Qsomebase) [16] ;
 
23
// or even
 
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;
 
33
// e.g.
 
34
#(#type $Qsomebase (include "somelib/example.SomeBaseType.h") )
 
35
// All subject to future discussion.