lib/accessor.h
author laurent
Tue, 01 Dec 2009 09:03:33 +0100
changeset 220 f332b62cd2c1
parent 219 9bb38736f126
child 221 c6aed7e5f070
permissions -rwxr-xr-x
Bug with ULINT correction fixed
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     1
#ifndef __ACCESSOR_H
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     2
#define __ACCESSOR_H
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     3
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     4
// variable declaration macros
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     5
#define __DECLARE_VAR(type, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     6
	type name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     7
#define __DECLARE_GLOBAL(type, resource, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     8
	type resource##__##name;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     9
	static type *GLOBAL__##name = &resource##__##name;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    10
	type __GET_GLOBAL_##name(void) {return *GLOBAL__##name;}\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    11
	void __SET_GLOBAL_##name(type value) {*GLOBAL__##name = value;}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    12
#define __DECLARE_GLOBAL_LOCATION(type, location)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    13
	extern type *location;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    14
#define __DECLARE_GLOBAL_LOCATED(type, resource, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    15
	type *resource##__##name;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    16
	static type *GLOBAL__##name;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    17
	type __GET_GLOBAL_##name(void) {return *GLOBAL__##name;}\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    18
	void __SET_GLOBAL_##name(type value) {*GLOBAL__##name = value;}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    19
#define __DECLARE_EXTERNAL(type, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    20
	type *name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    21
#define __DECLARE_LOCATED(type, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    22
	type *name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    23
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    24
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    25
// variable initialization macros
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    26
#define __INIT_VAR(name, initial)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    27
	name = initial;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    28
#define __INIT_GLOBAL(name, initial)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    29
	*GLOBAL__##name = initial;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    30
#define __INIT_GLOBAL_LOCATED(resource, name, location)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    31
	resource##__##name = location;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    32
    GLOBAL__##name = location;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    33
#define __INIT_EXTERNAL(type, global, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    34
	{extern type *GLOBAL__##global;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    35
	 name = GLOBAL__##global;}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    36
#define __INIT_LOCATED(type, location, name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    37
	{extern type *location;\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    38
	 name = location;}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    39
#define __INIT_LOCATED_VALUE(name, initial)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    40
	*name = initial;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    41
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    42
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    43
// variable getting macros
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    44
#define __GET_VAR(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    45
	name
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    46
#define __GET_EXTERNAL(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    47
	__GET_GLOBAL_##name()
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    48
#define __GET_LOCATED(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    49
	*(name)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    50
#define __GET_VAR_BY_REF(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    51
	&(name)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    52
#define __GET_EXTERNAL_BY_REF(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    53
	GLOBAL__##name
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    54
#define __GET_LOCATED_BY_REF(name)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    55
	name
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    56
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    57
// variable setting macros
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    58
#define __SET_VAR(name, new_value)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    59
	name = new_value
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    60
#define __SET_EXTERNAL(name, new_value)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    61
	__SET_GLOBAL_##name(value)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    62
#define __SET_LOCATED(name, new_value)\
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    63
	*(name) = value
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    64
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    65
#endif //__ACCESSOR_H