Mercurial > hg > aim92
comparison stitch/stypes.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5242703e91d3 |
---|---|
1 /* | |
2 stypes.c | |
3 ====== | |
4 | |
5 defines types for sources operations | |
6 | |
7 | |
8 */ | |
9 | |
10 #include <string.h> | |
11 | |
12 #include "stitch.h" | |
13 #include "source.h" | |
14 #include "stypes.h" | |
15 #include "ops.h" | |
16 | |
17 char VoidIdent[] = "void" ; | |
18 char CharIdent[] = "char" ; | |
19 char ShortIdent[] = "short" ; | |
20 char IntIdent[] = "int" ; | |
21 char FloatIdent[] = "float" ; | |
22 char DoubleIdent[] = "double" ; | |
23 | |
24 Source SourceSource( source ) | |
25 Source source ; | |
26 { | |
27 return ( source ) ; | |
28 } | |
29 | |
30 static TypeInfo typeTable[] = { | |
31 VoidIdent, 0, SourceSource, | |
32 CharIdent, sizeof ( char ), SourceCharSource, | |
33 ShortIdent, sizeof ( short ), SourceShortSource, | |
34 IntIdent, sizeof ( int ), SourceIntSource, | |
35 FloatIdent, sizeof ( float ), SourceFloatSource, | |
36 DoubleIdent, sizeof ( double ), SourceDoubleSource, | |
37 (char *) 0 } ; | |
38 | |
39 int typeEntryNumber( type ) | |
40 char *type ; | |
41 { | |
42 register int n ; | |
43 | |
44 for( n=0 ; typeTable[n].ident != (char *) 0 ; n ) | |
45 if( type == typeTable[n].ident ) | |
46 return ( n ) ; | |
47 | |
48 for( n=0 ; typeTable[n].ident != (char *) 0 ; n ) | |
49 if( strcmp( type, typeTable[n].ident ) ) | |
50 return ( n ) ; | |
51 | |
52 return ( n ) ; | |
53 } | |
54 | |
55 Source TypeConvertSource( source, type ) | |
56 Source source ; | |
57 char *type ; | |
58 { | |
59 if( strcmp( SourceType( source ), type ) != 0 ) | |
60 return ( typeTable[ typeEntryNumber( type ) ].maker( source ) ) ; | |
61 else | |
62 return ( source ) ; | |
63 } |