/vhost/mculabs/snippet_db/class/class.h
1 /*
2 file: class.h
3 version: 1.01
4 description: Enables use of [pseudo] classes. (type of C++ / OOP)
5 compiler: CCS C
6 written by : Michael Bradley
7
8 Usage:
9 You must define 'class' as the name of your instance,
10 and undefine it after the include
11
12 #define class clsInstance1
13 #include "some_file.c"
14 #undef class
15
16 #define class clsInstance2
17 #include "some_file.c"
18 #undef class
19
20
21 To access a function or variable in the above class;
22
23 clsInstance1_coolFunction(); // call a function in the class
24 clsInstance1_flagOK = 1; // set a variable in the class
25
26
27 In each included class file, all functions must be prefaced
28 with clsFN(), and all global variables with clsVAR()
29
30
31 Example of included file:
32
33 int8 clsVAR(flagOK);
34 int8 clsVAR(flagRunning);
35
36 void clsFN(coolFunction)(void)
37 {
38 clsVAR(flagOK) = 1;
39 }
40
41 void clsFN(setRunFlag)(int8 status)
42 {
43 int8 localVar; // since local, no class preface needed
44 localVar = 1;
45 clsVAR(flagRunning) = status;
46 }
47
48 */
49
50 #ifndef __CLASS
51 #define __CLASS
52
53 #define mDEFCLASS(cls,def) ##cls##_##def
54 #define clsFN(f) mDEFCLASS(class,f)
55 #define clsVAR(v) mDEFCLASS(class,v)
56
57 #endif
|