UP font generate
This commit is contained in:
370
lib/utils/inc/plooc.h
Normal file
370
lib/utils/inc/plooc.h
Normal file
@@ -0,0 +1,370 @@
|
||||
#ifndef HW_LIB_PLOOC_H
|
||||
#define HW_LIB_PLOOC_H
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
|
||||
//! you have to define this by yourselves
|
||||
#else
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#endif
|
||||
|
||||
/*! \NOTE the uint_fast8_t used in this header file is defined in stdint.h
|
||||
if you don't have stdint.h supported in your toolchain, you should
|
||||
define uint_fast8_t all by yourself with following rule:
|
||||
a. if the target processor is 8 bits, define it as uint8_t
|
||||
b. if the target processor is 16 bits, define it as uint16_t
|
||||
c. if the target processor is 32 bits, define it as uint32_t
|
||||
d. if the target processor is 64 bits, define it as either uint32_t or
|
||||
uint64_t
|
||||
*/
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
# pragma clang diagnostic ignored "-Wreserved-identifier"
|
||||
# pragma clang diagnostic ignored "-Wtypedef-redefinition"
|
||||
# pragma clang diagnostic ignored "-Wmissing-declarations"
|
||||
# pragma clang diagnostic ignored "-Wempty-body"
|
||||
# pragma clang diagnostic ignored "-Wmicrosoft-anon-tag"
|
||||
#elif ((__ARMCC_VERSION >= 5000000) && (__ARMCC_VERSION < 6000000))
|
||||
/*! arm compiler 5 */
|
||||
# pragma push
|
||||
# pragma diag_suppress 1,64,174,177,188,68,513,144,2525
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
/*! IAR */
|
||||
#elif defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# pragma GCC diagnostic ignored "-Wempty-body"
|
||||
# pragma GCC diagnostic ignored "-Wpragmas"
|
||||
# pragma GCC diagnostic ignored "-Wformat="
|
||||
# pragma GCC diagnostic ignored "-Wmissing-braces"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*============================ MACROS ========================================*/
|
||||
#ifndef __cplusplus
|
||||
# ifndef plooc_private
|
||||
# define plooc_private static
|
||||
# endif
|
||||
|
||||
# ifndef plooc_public
|
||||
# define plooc_public
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef plooc_malloc_align
|
||||
# define plooc_malloc_align(__size, __align) malloc(__size)
|
||||
#endif
|
||||
|
||||
#ifndef plooc_free
|
||||
# define plooc_free free
|
||||
#endif
|
||||
|
||||
|
||||
/*============================ MACROFIED FUNCTIONS ===========================*/
|
||||
|
||||
|
||||
/*! \note add which macro to support multiple inheriting and implementations
|
||||
*!
|
||||
*! declare_interface( i_lv0_abc_t )
|
||||
*! declare_interface( i_lv0_efg_t )
|
||||
*! def_interface( i_lv0_abc_t )
|
||||
*! ...
|
||||
*! end_def_interface( i_lv0_abc_t )
|
||||
*!
|
||||
*! def_interface( i_lv0_efg_t )
|
||||
*! ...
|
||||
*! end_def_interface( i_lv0_efg_t )
|
||||
*!
|
||||
*! declare_interface( i_lv1_t )
|
||||
*! def_interface( i_lv1_t, which( inherit( i_lv0_abc_t )
|
||||
*! inherit( i_lv0_efg_t ) ) )
|
||||
*! ...
|
||||
*! end_def_interface( i_lv1_t )
|
||||
*/
|
||||
|
||||
#define __declare_interface(__name) typedef struct __name __name;
|
||||
#define __declare_structure(__name) typedef struct __name __name;
|
||||
|
||||
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
|
||||
|
||||
//! \name interface definition
|
||||
//! @{
|
||||
#define __def_interface(__name) \
|
||||
/*typedef struct __name __name;*/ \
|
||||
struct __name {
|
||||
|
||||
#define __end_def_interface(__name) \
|
||||
};
|
||||
//! @}
|
||||
|
||||
//! \name structure definition
|
||||
//! @{
|
||||
#define __def_structure(__name) \
|
||||
/*typedef struct __name __name; */ \
|
||||
struct __name {
|
||||
|
||||
#define __end_def_structure(__name) \
|
||||
};
|
||||
//! @}
|
||||
|
||||
#else
|
||||
//! \name interface definition
|
||||
//! @{
|
||||
#define __def_interface(__name, ...) \
|
||||
typedef struct __name __name; \
|
||||
__VA_ARGS__ \
|
||||
struct __name {
|
||||
|
||||
#define __end_def_interface(__name) \
|
||||
};
|
||||
//! @}
|
||||
|
||||
//! \name structure definition
|
||||
//! @{
|
||||
#define __def_structure(__name, ...) \
|
||||
typedef struct __name __name; \
|
||||
__VA_ARGS__ \
|
||||
struct __name {
|
||||
|
||||
#define __end_def_structure(__name) \
|
||||
};
|
||||
//! @}
|
||||
#endif
|
||||
|
||||
//! \brief macro for inheritance
|
||||
|
||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
||||
#define __IMPLEMENT_EX(__TYPE, __NAME) \
|
||||
__TYPE __NAME;
|
||||
#else
|
||||
#define __IMPLEMENT_EX(__TYPE, __NAME) \
|
||||
union { \
|
||||
__TYPE __NAME; \
|
||||
__TYPE; \
|
||||
};
|
||||
#endif
|
||||
|
||||
#define __INHERIT_EX(__TYPE, __NAME) __TYPE __NAME;
|
||||
#define INHERIT_EX(__TYPE, __NAME) __INHERIT_EX(__TYPE, __NAME)
|
||||
|
||||
#define __INHERIT(__TYPE) INHERIT_EX(__TYPE, use_as__##__TYPE)
|
||||
#define INHERIT(__TYPE) __INHERIT(__TYPE)
|
||||
|
||||
|
||||
|
||||
/*! \note You can only use IMPLEMENT when defining INTERFACE. For Implement
|
||||
* interface when defining class, you should use DEF_CLASS_IMPLEMENT
|
||||
* instead.
|
||||
*/
|
||||
#define __IMPLEMENT(__INTERFACE) __IMPLEMENT_EX( __INTERFACE, \
|
||||
use_as__##__INTERFACE)
|
||||
#define IMPLEMENT(__INTERFACE) __IMPLEMENT(__INTERFACE)
|
||||
|
||||
/*! \note if you have used INHERIT or IMPLEMENT to define a class / INTERFACE,
|
||||
you can use OBJ_CONVERT_AS to extract the reference to the inherited
|
||||
object.
|
||||
\*/
|
||||
#define __OBJ_CONVERT_AS(__OBJ, __INTERFACE) (__OBJ.use_as__##__INTERFACE)
|
||||
#define OBJ_CONVERT_AS(__OBJ, __INTERFACE) __OBJ_CONVERT_AS( (__OBJ), \
|
||||
__INTERFACE)
|
||||
|
||||
#define __REF_OBJ_AS(__OBJ, __TYPE) (&(__OBJ.use_as__##__TYPE))
|
||||
#define REF_OBJ_AS(__OBJ, __TYPE) __REF_OBJ_AS((__OBJ), __TYPE)
|
||||
|
||||
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
|
||||
/*! \brief You can use __PLOOC_EVAL() to dynamically select the right API which
|
||||
*! has the right number of parameters (no more than 8).
|
||||
*/
|
||||
//! @{
|
||||
#define __PLOOC_VA_NUM_ARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, \
|
||||
_13, _14, _15, _16, __N, ...) __N
|
||||
#define __PLOOC_VA_NUM_ARGS(...) \
|
||||
__PLOOC_VA_NUM_ARGS_IMPL( 0,##__VA_ARGS__,16,15,14,13,12,11,10,9, \
|
||||
8,7,6,5,4,3,2,1,0)
|
||||
|
||||
#define __16_PLOOC_EVAL(__FUNC, __NO_ARGS) __FUNC##__NO_ARGS
|
||||
#define __15_PLOOC_EVAL(__FUNC, __NO_ARGS) __16_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __14_PLOOC_EVAL(__FUNC, __NO_ARGS) __15_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __13_PLOOC_EVAL(__FUNC, __NO_ARGS) __14_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
|
||||
#define __12_PLOOC_EVAL(__FUNC, __NO_ARGS) __13_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __11_PLOOC_EVAL(__FUNC, __NO_ARGS) __12_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __10_PLOOC_EVAL(__FUNC, __NO_ARGS) __11_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __9_PLOOC_EVAL(__FUNC, __NO_ARGS) __10_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __8_PLOOC_EVAL(__FUNC, __NO_ARGS) __9_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
|
||||
#define __7_PLOOC_EVAL(__FUNC, __NO_ARGS) __8_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __6_PLOOC_EVAL(__FUNC, __NO_ARGS) __7_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __5_PLOOC_EVAL(__FUNC, __NO_ARGS) __6_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __4_PLOOC_EVAL(__FUNC, __NO_ARGS) __5_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __3_PLOOC_EVAL(__FUNC, __NO_ARGS) __4_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __2_PLOOC_EVAL(__FUNC, __NO_ARGS) __3_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __1_PLOOC_EVAL(__FUNC, __NO_ARGS) __2_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
#define __0_PLOOC_EVAL(__FUNC, __NO_ARGS) __1_PLOOC_EVAL(__FUNC, __NO_ARGS)
|
||||
|
||||
#define __PLOOC_EVAL(__FUNC, ...) __0_PLOOC_EVAL( \
|
||||
__FUNC, \
|
||||
__PLOOC_VA_NUM_ARGS(__VA_ARGS__))
|
||||
//! @}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* new standard (lower case) *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
||||
# define def_interface(__name) __def_interface(__name)
|
||||
# define define_interface(__name) __def_interface(__name)
|
||||
# define def_structure(__name) __def_structure(__name)
|
||||
# define define_structure(__name) __def_structure(__name)
|
||||
# define def_params(__code) __code
|
||||
# define define_params(__code) __code
|
||||
# define end_def_params()
|
||||
# define end_define_params()
|
||||
# define def_members(__code) __code
|
||||
# define define_members(__code) __code
|
||||
# define end_def_members()
|
||||
# define end_define_members()
|
||||
#else
|
||||
# define def_interface(__name, ...) __def_interface(__name, __VA_ARGS__)
|
||||
# define define_interface(__name, ...) __def_interface(__name, __VA_ARGS__)
|
||||
# define def_structure(__name, ...) __def_structure(__name, __VA_ARGS__)
|
||||
# define define_structure(__name, ...) __def_structure(__name, __VA_ARGS__)
|
||||
# define def_params(...) __VA_ARGS__
|
||||
# define define_params(...) __VA_ARGS__
|
||||
# define end_def_params(...)
|
||||
# define end_define_params(...)
|
||||
# define def_members(...) __VA_ARGS__
|
||||
# define define_members(...) __VA_ARGS__
|
||||
# define end_def_members(...)
|
||||
# define end_define_members(...)
|
||||
#endif
|
||||
|
||||
#define implement(__type) IMPLEMENT(__type)
|
||||
#define implement_ex(__type, __name) __IMPLEMENT_EX(__type, __name)
|
||||
#define inherit_ex(__type, __name) INHERIT_EX(__type, __name)
|
||||
#define inherit(__type) INHERIT(__type)
|
||||
#define ref_interface(__INTERFACE) const __INTERFACE *ptMethod;
|
||||
#define convert_obj_as(__obj, __type) OBJ_CONVERT_AS(__obj, __type)
|
||||
#define obj_convert_as(__obj, __type) OBJ_CONVERT_AS(__obj, __type) /* obsolete */
|
||||
#define ref_obj_as(__obj, __type) REF_OBJ_AS(__obj, __type)
|
||||
|
||||
#define end_def_interface(__name) __end_def_interface(__name)
|
||||
#define end_define_interface(__name) __end_def_interface(__name)
|
||||
#define dcl_interface(__name) __declare_interface(__name)
|
||||
#define declare_interface(__name) __declare_interface(__name)
|
||||
#define end_def_structure(__name) __end_def_structure(__name)
|
||||
#define end_define_structure(__name) __end_def_structure(__name)
|
||||
#define dcl_structure(__name) __declare_structure(__name)
|
||||
#define declare_structure(__name) __declare_structure(__name)
|
||||
|
||||
#define this_interface(__INTERFACE) convert_obj_as(this, __INTERFACE)
|
||||
#define base_obj(__type) convert_obj_as(this, __type)
|
||||
|
||||
|
||||
|
||||
/*============================ TYPES =========================================*/
|
||||
|
||||
//! \name interface: u32_property_t
|
||||
//! @{
|
||||
dcl_interface(u32_property_t)
|
||||
def_interface(u32_property_t)
|
||||
bool (*Set)(uint32_t wValue);
|
||||
|
||||
uint32_t (*Get)(void);
|
||||
end_def_interface(u32_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: u16_property_t
|
||||
//! @{
|
||||
dcl_interface(u16_property_t)
|
||||
def_interface(u16_property_t)
|
||||
bool (*Set)(uint_fast16_t wValue);
|
||||
|
||||
uint_fast16_t (*Get)(void);
|
||||
end_def_interface(u16_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: u8_property_t
|
||||
//! @{
|
||||
dcl_interface(u8_property_t)
|
||||
def_interface(u8_property_t)
|
||||
bool (*Set)(uint_fast8_t wValue);
|
||||
|
||||
uint_fast8_t (*Get)(void);
|
||||
end_def_interface(u8_property_t)
|
||||
//! @}
|
||||
|
||||
|
||||
//! \name interface: i32_property_t
|
||||
//! @{
|
||||
dcl_interface(i32_property_t)
|
||||
def_interface(i32_property_t)
|
||||
bool (*Set)(int32_t wValue);
|
||||
|
||||
int32_t (*Get)(void);
|
||||
end_def_interface(i32_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: i16_property_t
|
||||
//! @{
|
||||
dcl_interface(i16_property_t)
|
||||
def_interface(i16_property_t)
|
||||
bool (*Set)(int_fast16_t wValue);
|
||||
|
||||
int_fast16_t (*Get)(void);
|
||||
end_def_interface(i16_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: u8_property_t
|
||||
//! @{
|
||||
dcl_interface(i8_property_t)
|
||||
def_interface(i8_property_t)
|
||||
bool (*Set)(int_fast8_t wValue);
|
||||
|
||||
int_fast8_t (*Get)(void);
|
||||
end_def_interface(i8_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: bool_property_t
|
||||
//! @{
|
||||
dcl_interface(bool_property_t)
|
||||
def_interface(bool_property_t)
|
||||
bool (*Set)(bool bValue);
|
||||
|
||||
bool (*Get)(void);
|
||||
end_def_interface(bool_property_t)
|
||||
//! @}
|
||||
|
||||
//! \name interface: bool_property_t
|
||||
//! @{
|
||||
dcl_interface(en_property_t)
|
||||
def_interface(en_property_t)
|
||||
bool (*Enable)(void);
|
||||
|
||||
bool (*Disable)(void);
|
||||
end_def_interface(en_property_t)
|
||||
//! @}
|
||||
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ LOCAL VARIABLES ===============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//#if defined(__clang__)
|
||||
//# pragma clang diagnostic pop
|
||||
//#endif
|
||||
|
||||
#endif //HW_LIB_PLOOC_H
|
386
lib/utils/inc/plooc_class.h
Normal file
386
lib/utils/inc/plooc_class.h
Normal file
@@ -0,0 +1,386 @@
|
||||
#ifndef HW_LIB_PLOOC_CLASS_H
|
||||
#define HW_LIB_PLOOC_CLASS_H
|
||||
|
||||
#if defined(__cplusplus) || defined(__OOC_CPP__)
|
||||
# undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__
|
||||
# undef PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___
|
||||
# define PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__OOC_RELEASE__) || defined(__OOC_CPP__)
|
||||
# undef __OOC_DEBUG__
|
||||
# define __OOC_DEBUG__ 1
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(__PLOOC_CLASS_USE_STRICT_TEMPLATE__) \
|
||||
&& !defined(__PLOOC_CLASS_USE_SIMPLE_TEMPLATE__) \
|
||||
&& !defined(__PLOOC_CLASS_USE_BLACK_BOX_TEMPLATE__)
|
||||
# define __PLOOC_CLASS_USE_SIMPLE_TEMPLATE__ 1
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
|
||||
|
||||
#ifndef __OOC_DEBUG__
|
||||
# define __OOC_DEBUG__
|
||||
# warning For C89/90, __OOC_DEBUG__ is enforced.
|
||||
#endif
|
||||
|
||||
#if defined(__PLOOC_CLASS_USE_STRICT_TEMPLATE__)
|
||||
# undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__
|
||||
# define __PLOOC_CLASS_USE_SIMPLE_TEMPLATE__
|
||||
#endif
|
||||
|
||||
#if defined(__PLOOC_CLASS_USE_BLACK_BOX_TEMPLATE__)
|
||||
# undef __PLOOC_CLASS_USE_BLACK_BOX_TEMPLATE__
|
||||
# define __PLOOC_CLASS_USE_SIMPLE_TEMPLATE__
|
||||
#endif
|
||||
|
||||
# if !defined(__OOC_DEBUG__) || !defined(__PLOOC_CLASS_USE_SIMPLE_TEMPLATE__)
|
||||
# error \
|
||||
You must use __OOC_DEBUG__ (or __OOC_RELEASE__) together with the\
|
||||
__PLOOC_CLASS_USE_SIMPLE_TEMPLATE__ in ANSI-C89/90.
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __PLOOC_CLASS_H__
|
||||
#define __PLOOC_CLASS_H__
|
||||
|
||||
/******************************************************************************
|
||||
* HOW TO USE *
|
||||
******************************************************************************/
|
||||
//! TODO: Add How to use
|
||||
|
||||
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
//#include <stdint.h>
|
||||
/*! \NOTE the uint_fast8_t used in this header file is defined in stdint.h
|
||||
if you don't have stdint.h supported in your toolchain, you should
|
||||
define uint_fast8_t all by yourself with following rule:
|
||||
a. if the target processor is 8 bits, define it as uint8_t
|
||||
b. if the target processor is 16 bits, define it as uint16_t
|
||||
c. if the target processor is 32 bits, define it as uint32_t
|
||||
d. if the target processor is 64 bits, define it as either uint32_t or
|
||||
uint64_t
|
||||
*/
|
||||
|
||||
#include "plooc.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*============================ MACROS ========================================*/
|
||||
/*!\ node if you want your code more "elegent", say you want to use "this" with
|
||||
* "." rather than a pointer with "->", you can add following macros to
|
||||
* your code, assuming the variable name of the object pointer is "ptThis".
|
||||
* If your object pointer has a different name, please feel free to change
|
||||
* the macro by yourself
|
||||
|
||||
#undef this
|
||||
#define this (*ptThis)
|
||||
|
||||
*/
|
||||
|
||||
/*============================ MACROFIED FUNCTIONS ===========================*/
|
||||
|
||||
//! @{
|
||||
#ifndef __PLOOC_CONNECT2
|
||||
# define __PLOOC_CONNECT2( __A, __B) __A##__B
|
||||
#endif
|
||||
#ifndef __PLOOC_CONNECT3
|
||||
# define __PLOOC_CONNECT3( __A, __B, __C) __A##__B##__C
|
||||
#endif
|
||||
#ifndef __PLOOC_CONNECT4
|
||||
# define __PLOOC_CONNECT4( __A, __B, __C, __D) __A##__B##__C##__D
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
#ifndef __PLOOC_ALIGN
|
||||
# define __PLOOC_ALIGN(__N) __attribute__((aligned(__N)))
|
||||
#endif
|
||||
#ifndef PLOOC_ALIGN
|
||||
# define PLOOC_ALIGN(__N) __PLOOC_ALIGN(__N)
|
||||
#endif
|
||||
/*
|
||||
#ifndef PLOOC_DEFAULT_OBJ_ALIGN
|
||||
# define PLOOC_DEFAULT_OBJ_ALIGN sizeof(uint_fast8_t)
|
||||
#endif
|
||||
*/
|
||||
#ifndef PLOOC_PACKED
|
||||
# define PLOOC_PACKED __attribute__((packed))
|
||||
#endif
|
||||
|
||||
//! @{
|
||||
#ifndef PLOOC_CONNECT2
|
||||
# define PLOOC_CONNECT2( __A, __B) __PLOOC_CONNECT2( __A, __B)
|
||||
#endif
|
||||
#ifndef PLOOC_CONNECT3
|
||||
# define PLOOC_CONNECT3( __A, __B, __C) __PLOOC_CONNECT3( __A, __B, __C)
|
||||
#endif
|
||||
#ifndef PLOOC_CONNECT4
|
||||
# define PLOOC_CONNECT4( __A, __B, __C, __D) __PLOOC_CONNECT4( __A, __B, __C, __D)
|
||||
#endif
|
||||
//! @}
|
||||
|
||||
#ifndef PLOOC_UNUSED_PARAM
|
||||
# define PLOOC_UNUSED_PARAM(__N) do {(__N) = (__N);}while(0)
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
|
||||
|
||||
# ifndef PLOOC_ALIGNOF
|
||||
# define PLOOC_ALIGNOF(__TYPE) __alignof__(__TYPE)
|
||||
# endif
|
||||
|
||||
# define PLOOC_ALIGNOF_STRUCT(__TYPE) PLOOC_ALIGNOF(struct {__TYPE})
|
||||
# define PLOOC_SIZEOF_STRUCT(__TYPE) sizeof(struct {__TYPE})
|
||||
|
||||
#else
|
||||
|
||||
# ifndef PLOOC_ALIGNOF
|
||||
# define PLOOC_ALIGNOF(...) __alignof__(__VA_ARGS__)
|
||||
# endif
|
||||
|
||||
# define PLOOC_ALIGNOF_STRUCT(...) PLOOC_ALIGNOF(struct {__VA_ARGS__})
|
||||
# define PLOOC_SIZEOF_STRUCT(...) sizeof(struct {__VA_ARGS__})
|
||||
|
||||
/*! \note When both __OOC_DEBUG__ and
|
||||
*! PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___ are
|
||||
*! defined, memory layout boundary, i.e. struct wrapper inside PLOOC
|
||||
*! VISIBLE will be removed. This enables some platform to use the gaps
|
||||
*! between members with different memory aligments to add members with
|
||||
*! correct size and aligment for saving space.
|
||||
*!
|
||||
*! You can do this when you have all the source code and compile all
|
||||
*! the source code with the same presence of "__OOC_DEBUG__".
|
||||
*! If some of the code is compiled with different presence of
|
||||
*! "__OOC_DEBUG__", i.e. using Lib + source, removing the memory
|
||||
*! layout boundaries will cause different view of the structure and hence
|
||||
*! cause undefined behaviours.
|
||||
*/
|
||||
# if defined(PLOOC_CFG_REMOVE_MEMORY_LAYOUT_BOUNDARY___USE_WITH_CAUTION___)
|
||||
# define PLOOC_VISIBLE(...) __VA_ARGS__
|
||||
# else
|
||||
# define PLOOC_VISIBLE(...) \
|
||||
struct { \
|
||||
__VA_ARGS__ \
|
||||
}PLOOC_ALIGN(PLOOC_ALIGNOF_STRUCT(__VA_ARGS__));
|
||||
# endif
|
||||
|
||||
# if !defined (__PLOOC_CLASS_USE_NO_STRUCT_MASK__)
|
||||
|
||||
# define PLOOC_INVISIBLE(...) \
|
||||
uint8_t PLOOC_CONNECT3(chMask_,__LINE__,__COUNTER__) \
|
||||
[PLOOC_SIZEOF_STRUCT(__VA_ARGS__)] \
|
||||
PLOOC_ALIGN(PLOOC_ALIGNOF_STRUCT(__VA_ARGS__));
|
||||
|
||||
# else
|
||||
# define PLOOC_INVISIBLE(...) \
|
||||
struct { \
|
||||
__VA_ARGS__ \
|
||||
} PLOOC_CONNECT3(zzz_, __LINE__,__COUNTER__) \
|
||||
PLOOC_ALIGN(PLOOC_ALIGNOF_STRUCT(__VA_ARGS__));
|
||||
# endif /* __PLOOC_CLASS_USE_NO_STRUCT_MASK__ */
|
||||
|
||||
# define __PLOOC_PRO_struct struct
|
||||
# define __PLOOC_PRI_struct struct
|
||||
# define __PLOOC_EXT_struct struct
|
||||
# define __PLOOC_PRO_union union
|
||||
# define __PLOOC_PRI_union union
|
||||
# define __PLOOC_EXT_union union
|
||||
# define __PLOOC_EXT_uint8_t uint8_t
|
||||
# define __PLOOC_PRI_uint8_t uint8_t
|
||||
# define __PLOOC_PRO_uint8_t uint8_t
|
||||
# define __PLOOC_EXT_
|
||||
# define __PLOOC_PRI_
|
||||
# define __PLOOC_PRO_
|
||||
|
||||
|
||||
|
||||
# ifdef __OOC_DEBUG__
|
||||
|
||||
//! \brief wrapper for shell type
|
||||
# define __PLOOC_EXT__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
//! \brief wrapper for internal private type
|
||||
# define __PLOOC_PRI__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
//! \brief wrapper for internal protected type
|
||||
# define __PLOOC_PRO__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# else
|
||||
|
||||
//! \brief wrapper for shell type
|
||||
# define __PLOOC_EXT__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__private_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__protected_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_EXT__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
//! \brief wrapper for internal private type
|
||||
# define __PLOOC_PRI__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRI__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
//! \brief wrapper for internal protected type
|
||||
# define __PLOOC_PRO__public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__private_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define __PLOOC_PRO__which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
||||
&& !defined(__cplusplus)
|
||||
# undef which
|
||||
# define which(__declare) ,_which(__declare)
|
||||
#else
|
||||
# undef which
|
||||
# define which(...) ,_which(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#undef private_member
|
||||
#define private_member ,_private_member
|
||||
|
||||
#undef protected_member
|
||||
#define protected_member ,_protected_member
|
||||
|
||||
#undef public_member
|
||||
#define public_member ,_public_member
|
||||
|
||||
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
|
||||
|| defined(__cplusplus)
|
||||
|
||||
/*! \brief helper macros for heap managed objects. They use malloc() and free()
|
||||
*! internally.
|
||||
*!
|
||||
*! \note Make sure your constractor is named as <class_name>_init and it takes
|
||||
*! an configuration structure with a type named as <class_name>_cfg_t.
|
||||
*!
|
||||
*! \note Make sure your destructor is named as <class_name>_depose.
|
||||
*/
|
||||
# undef __new_class
|
||||
# define __new_class(__name, ...) \
|
||||
__name##_init( \
|
||||
(__name##_t *)plooc_malloc_align( sizeof(__name##_t), \
|
||||
PLOOC_ALIGNOF(__name##_t)), \
|
||||
(__name##_cfg_t []) {{__VA_ARGS__}} \
|
||||
)
|
||||
|
||||
# undef __free_class
|
||||
# define __free_class(__name, __obj) \
|
||||
do { \
|
||||
__name##_depose((__name##_t *)(__obj)); \
|
||||
plooc_free(__obj); \
|
||||
} while(0)
|
||||
|
||||
|
||||
# undef private_method
|
||||
# undef protected_method
|
||||
# undef public_method
|
||||
|
||||
# if defined(__PLOOC_CLASS_IMPLEMENT) || defined(__PLOOC_CLASS_IMPLEMENT__)
|
||||
|
||||
# define private_method(...) __VA_ARGS__
|
||||
# define protected_method(...) __VA_ARGS__
|
||||
# define public_method(...) __VA_ARGS__
|
||||
|
||||
# elif defined(__PLOOC_CLASS_INHERIT) || defined(__PLOOC_CLASS_INHERIT__)
|
||||
|
||||
# define private_method(...)
|
||||
# define protected_method(...) __VA_ARGS__
|
||||
# define public_method(...) __VA_ARGS__
|
||||
|
||||
# else
|
||||
|
||||
# define private_method(...)
|
||||
# define protected_method(...)
|
||||
# define public_method(...) __VA_ARGS__
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/*============================ TYPES =========================================*/
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
/*============================ INCLUDES ======================================*/
|
||||
|
||||
|
||||
|
||||
#if defined(__PLOOC_CLASS_USE_STRICT_TEMPLATE__)
|
||||
# include "plooc_class_strict.h"
|
||||
#elif defined(__PLOOC_CLASS_USE_SIMPLE_TEMPLATE__)
|
||||
# if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
|
||||
# include "plooc_class_simple_c90.h"
|
||||
# else
|
||||
# include "plooc_class_simple.h"
|
||||
# endif
|
||||
#elif defined(__PLOOC_CLASS_USE_BLACK_BOX_TEMPLATE__)
|
||||
# ifndef __PLOOC_I_KNOW_BLACK_BOX_IS_INCOMPATIBLE_WITH_OTHER_TEMPLATES__
|
||||
# warning The black box template is incompatible with other templates. When\
|
||||
header files which contains different templates mixing together, the one contains\
|
||||
black box template will cause conflicts in other header files. To avoid such\
|
||||
conflicts, you can either use black box alone in a project or in the source code of\
|
||||
the target module avoid including header files which directly or indirectly \
|
||||
including the header file of the very same module. To suppress this warning, please\
|
||||
find the macro __PLOOC_I_KNOW_BLACK_BOX_IS_INCOMPATIBLE_WITH_OTHER_TEMPLATES__ in your\
|
||||
project to acknowledge that you understand the facts and consequences.
|
||||
# endif
|
||||
# include "plooc_class_black_box.h"
|
||||
#else
|
||||
# include "plooc_class_simple.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef __PLOOC_CLASS_USE_STRICT_TEMPLATE__
|
||||
#undef __PLOOC_CLASS_USE_SIMPLE_TEMPLATE__
|
||||
#undef __PLOOC_CLASS_USE_BLACK_BOX_TEMPLATE__
|
||||
#undef __PLOOC_CLASS_IMPLEMENT
|
||||
#undef __PLOOC_CLASS_IMPLEMENT__
|
||||
#undef __PLOOC_CLASS_INHERIT__
|
||||
#undef __PLOOC_CLASS_INHERIT
|
||||
|
||||
#if defined(__cplusplus)
|
||||
# undef class
|
||||
# undef this
|
||||
# undef private
|
||||
# undef public
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif //HW_LIB_PLOOC_CLASS_H
|
231
lib/utils/inc/plooc_class_black_box.h
Normal file
231
lib/utils/inc/plooc_class_black_box.h
Normal file
@@ -0,0 +1,231 @@
|
||||
#ifndef HW_LIB_PLOOC_CLASS_BLACK_BOX_H
|
||||
#define HW_LIB_PLOOC_CLASS_BLACK_BOX_H
|
||||
/*============================ INCLUDES ======================================*/
|
||||
//#include <stdint.h>
|
||||
//#include <stdbool.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*============================ MACROS ========================================*/
|
||||
#undef declare_class
|
||||
#undef dcl_class
|
||||
#undef def_class
|
||||
#undef define_class
|
||||
#undef __def_class
|
||||
#undef end_def_class
|
||||
#undef end_define_class
|
||||
#undef __end_def_class
|
||||
#undef extern_class
|
||||
#undef __extern_class
|
||||
#undef end_extern_class
|
||||
#undef __end_extern_class
|
||||
#undef class
|
||||
#undef __class
|
||||
/*============================ MACROFIED FUNCTIONS ===========================*/
|
||||
|
||||
#if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
|
||||
|
||||
# ifdef __OOC_DEBUG__
|
||||
# define __def_class(__name, __public ,...) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
# else
|
||||
# define __def_class(__name, __public, ...) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__public \
|
||||
PLOOC_INVISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
# define __end_def_class(__name, ...)
|
||||
|
||||
# undef private_member
|
||||
# define private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
# undef public_member
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
# undef __class
|
||||
# define __class(__name) __##__name
|
||||
|
||||
# define class(__name) __class(__name)
|
||||
|
||||
#define __extern_class(__name,...)
|
||||
#define __end_extern_class(__name, ...)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef __OOC_DEBUG__
|
||||
|
||||
# define __def_class(__name, __public, ...) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
|
||||
#define __extern_class(__name, __public, ...) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__public \
|
||||
PLOOC_INVISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
|
||||
|
||||
#define __end_extern_class(__name, ...)
|
||||
|
||||
# undef private_member
|
||||
# define private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
# undef public_member
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
# define __def_class(__name, __public, ...) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
|
||||
#define __extern_class(__name,__public, ...) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__public \
|
||||
PLOOC_VISIBLE(__VA_ARGS__) \
|
||||
};
|
||||
|
||||
|
||||
#define __end_extern_class(__name, ...)
|
||||
|
||||
# undef private_member
|
||||
# define private_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
|
||||
# undef public_member
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
# define __end_def_class(__name, ...)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
# undef __class
|
||||
# define __class(__name) __##__name
|
||||
|
||||
# undef class
|
||||
# define class(__name) __class(__name)
|
||||
|
||||
|
||||
#define declare_class(__name) typedef struct __name __name;
|
||||
#define dcl_class(__name) declare_class(__name)
|
||||
|
||||
#define end_def_class(__name, ...) __end_def_class(__name, __VA_ARGS__)
|
||||
#define end_define_class(__name, ...) end_def_class(__name, ...)
|
||||
|
||||
#define def_class(__name, __public, ...) \
|
||||
__def_class(__name, __public, __VA_ARGS__)
|
||||
#define define_class(__name, __public, ...) \
|
||||
def_class(__name,__public, __VA_ARGS__)
|
||||
|
||||
#define class(__name) __class(__name)
|
||||
|
||||
#define extern_class(__name, __public, ...) \
|
||||
__extern_class(__name, __public,__VA_ARGS__)
|
||||
#define end_extern_class(__name, ...) __end_extern_class(__name, __VA_ARGS__)
|
||||
|
||||
#ifndef __PLOOC_CLASS_BLACK_BOX_H__
|
||||
#define __PLOOC_CLASS_BLACK_BOX_H__
|
||||
|
||||
/*! \brief macro for initializing class in compiler-time
|
||||
*! \param __type class name
|
||||
*! \param __obj target object
|
||||
*! \param ... initialization list
|
||||
*/
|
||||
#define __INIT_CLASS_OBJ(__type, __obj, ...) \
|
||||
union { \
|
||||
class(__type) __##__obj; \
|
||||
__type; \
|
||||
} __obj = { \
|
||||
.__##__obj = __VA_ARGS__ \
|
||||
}
|
||||
#define init_class_obj(__type, __obj, ...) \
|
||||
__INIT_CLASS_OBJ(__type, __obj, __VA_ARGS__)
|
||||
|
||||
#define __EXTERN_CLASS_OBJ(__type, __obj) \
|
||||
extern union { \
|
||||
class(__type) __##__obj; \
|
||||
__type; \
|
||||
}__obj;
|
||||
#define extern_class_obj(__type, __obj) \
|
||||
__EXTERN_CLASS_OBJ( __type, __obj )
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* new standard (lower case) *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
# undef __class_internal
|
||||
# define __class_internal(__src, __des, __type, ...) \
|
||||
class(__type) *(__des) = (class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(__des); \
|
||||
__with_class(__type, (__src), __VA_ARGS__)
|
||||
|
||||
# undef class_internal
|
||||
# define class_internal(__src, __des, __type, ...) \
|
||||
__class_internal(__src, __des, __type, __VA_ARGS__)
|
||||
|
||||
# undef __with_class
|
||||
# define __with_class(__type, __src, ...) \
|
||||
{ \
|
||||
class(__type)*_ =(class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(_); \
|
||||
__VA_ARGS__; \
|
||||
} \
|
||||
for (class(__type)*_ =(class(__type) *)(__src); NULL != _; _ = NULL)
|
||||
|
||||
# undef with_class
|
||||
# define with_class(__type, __src, ...) \
|
||||
__with_class(__type, __src, __VA_ARGS__)
|
||||
|
||||
#undef which
|
||||
#define which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
/*============================ TYPES =========================================*/
|
||||
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ LOCAL VARIABLES ===============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
|
||||
#undef __PLOOC_CLASS_IMPLEMENT__
|
||||
#undef __PLOOC_CLASS_INHERIT__
|
||||
#undef __PLOOC_CLASS_IMPLEMENT
|
||||
#undef __PLOOC_CLASS_INHERIT
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //HW_LIB_PLOOC_CLASS_BLACK_BOX_H
|
200
lib/utils/inc/plooc_class_simple.h
Normal file
200
lib/utils/inc/plooc_class_simple.h
Normal file
@@ -0,0 +1,200 @@
|
||||
#ifndef HW_LIB_PLOOC_CLASS_SIMPLE_H
|
||||
#define HW_LIB_PLOOC_CLASS_SIMPLE_H
|
||||
|
||||
//#include "plooc_class.h"
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
//#include <stdint.h>
|
||||
|
||||
/*! \NOTE the uint_fast8_t used in this header file is defined in stdint.h
|
||||
if you don't have stdint.h supported in your toolchain, you should
|
||||
define uint_fast8_t all by yourself with following rule:
|
||||
a. if the target processor is 8 bits, define it as uint8_t
|
||||
b. if the target processor is 16 bits, define it as uint16_t
|
||||
c. if the target processor is 32 bits, define it as uint32_t
|
||||
d. if the target processor is 64 bits, define it as either uint32_t or
|
||||
uint64_t
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*============================ MACROS ========================================*/
|
||||
#undef private_member
|
||||
#undef protected_member
|
||||
#undef public_member
|
||||
|
||||
|
||||
/*============================ MACROFIED FUNCTIONS ===========================*/
|
||||
|
||||
#ifndef __PLOOC_CLASS_SIMPLE_H__
|
||||
#define __PLOOC_CLASS_SIMPLE_H__
|
||||
|
||||
# define __def_simple_class(__name) struct __name
|
||||
# define def_simple_class(__name) __def_simple_class(__name)
|
||||
# define define_simple_class(__name) def_simple_class(__name)
|
||||
# define declare_simple_class(__name) typedef struct __name __name;
|
||||
# define dcl_simple_class(__name) declare_simple_class(__name)
|
||||
|
||||
#endif /* __PLOOC_CLASS_SIMPLE_H__ */
|
||||
|
||||
#if defined(__OOC_DEBUG__)
|
||||
|
||||
# define private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#elif defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
|
||||
|
||||
# define private_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#elif defined(__PLOOC_CLASS_INHERIT__) || defined(__PLOOC_CLASS_INHERIT)
|
||||
|
||||
# define private_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define protected_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#else /* __PLOOC_CLASS_EXTERN */
|
||||
|
||||
# define private_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define protected_member(...) PLOOC_INVISIBLE(__VA_ARGS__)
|
||||
# define public_member(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
// code below is just try to be compatible with plooc_class_strict
|
||||
#undef declare_class
|
||||
#undef dcl_class
|
||||
#undef def_class
|
||||
#undef define_class
|
||||
#undef __def_class
|
||||
#undef end_def_class
|
||||
#undef end_define_class
|
||||
#undef __end_def_class
|
||||
#undef extern_class
|
||||
#undef __extern_class
|
||||
#undef end_extern_class
|
||||
#undef __end_extern_class
|
||||
|
||||
|
||||
#define __end_def_class(...)
|
||||
|
||||
#define __def_class(__name, ...) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__VA_ARGS__ \
|
||||
};
|
||||
|
||||
|
||||
#if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
|
||||
|
||||
# undef __class
|
||||
# define __class(__name) __name
|
||||
|
||||
# undef class
|
||||
# define class(__name) __class(__name)
|
||||
|
||||
# undef __with_class
|
||||
# define __with_class(__type, __src, ...) \
|
||||
{ \
|
||||
class(__type)*_ =(class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(_); \
|
||||
__VA_ARGS__; \
|
||||
} \
|
||||
for (class(__type)*_ =(class(__type) *)(__src); NULL != _; _ = NULL)
|
||||
|
||||
# undef with_class
|
||||
# define with_class(__type, __src, ...) \
|
||||
__with_class(__type, __src, __VA_ARGS__)
|
||||
|
||||
# undef __class_internal
|
||||
# define __class_internal(__src, __des, __type, ...) \
|
||||
class(__type) *(__des) = (class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(__des); \
|
||||
__with_class(__type, (__src), __VA_ARGS__)
|
||||
|
||||
# undef class_internal
|
||||
# define class_internal(__src, __des, __type, ...) \
|
||||
__class_internal(__src, __des, __type, __VA_ARGS__)
|
||||
|
||||
#define __extern_class(...)
|
||||
|
||||
#define __end_extern_class(...)
|
||||
|
||||
#elif defined(__PLOOC_CLASS_INHERIT__) || defined(__PLOOC_CLASS_INHERIT)
|
||||
|
||||
# undef __class_protected
|
||||
# define __class_protected(__name) __name
|
||||
|
||||
# undef class_protected
|
||||
# define class_protected(__name) __class_protected(__name)
|
||||
|
||||
|
||||
|
||||
# undef __with_protected
|
||||
# define __with_protected(__type, __src, ...) \
|
||||
{ \
|
||||
class_protected(__type)*_ =(class_protected(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(_); \
|
||||
__VA_ARGS__; \
|
||||
}
|
||||
|
||||
# undef with_protected
|
||||
# define with_protected(__type, __src, ...) \
|
||||
__with_protected(__type, __src, __VA_ARGS__)
|
||||
|
||||
|
||||
# undef __protected_internal
|
||||
# define __protected_internal(__src, __des, __type, ...) \
|
||||
class_protected(__type) *(__des)=(class_protected(__type) *)(__src);\
|
||||
PLOOC_UNUSED_PARAM(__des); \
|
||||
__with_protected(__type, __src, __VA_ARGS__)
|
||||
|
||||
# undef protected_internal
|
||||
# define protected_internal(__src, __des, __type, ...) \
|
||||
__protected_internal(__src, __des, __type, __VA_ARGS__)
|
||||
|
||||
#define __extern_class(...)
|
||||
|
||||
#define __end_extern_class(...)
|
||||
|
||||
#else /* __PLOOC_CLASS_EXTERN */
|
||||
|
||||
#define __extern_class(...) __def_class(__VA_ARGS__)
|
||||
|
||||
#define __end_extern_class(...)
|
||||
|
||||
#endif
|
||||
|
||||
#undef which
|
||||
#define which(...) PLOOC_VISIBLE(__VA_ARGS__)
|
||||
|
||||
#define def_class(__name, ...) __def_class(__name, __VA_ARGS__)
|
||||
#define define_class(__name, ...) def_class(__name, __VA_ARGS__)
|
||||
|
||||
#define end_def_class(...) __end_def_class(__VA_ARGS__)
|
||||
#define end_define_class(...) end_def_class(__VA_ARGS__)
|
||||
|
||||
#define dcl_class(__name) typedef struct __name __name;
|
||||
#define declare_class(__name) typedef struct __name __name;
|
||||
|
||||
#define extern_class(__name, ...) __extern_class(__name, __VA_ARGS__)
|
||||
|
||||
#define end_extern_class(__name, ...) __end_extern_class(__name, __VA_ARGS__)
|
||||
|
||||
#undef __PLOOC_CLASS_IMPLEMENT__
|
||||
#undef __PLOOC_CLASS_INHERIT__
|
||||
#undef __PLOOC_CLASS_IMPLEMENT
|
||||
#undef __PLOOC_CLASS_INHERIT
|
||||
/*============================ TYPES =========================================*/
|
||||
/*============================ GLOBAL VARIABLES ==============================*/
|
||||
/*============================ LOCAL VARIABLES ===============================*/
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //HW_LIB_PLOOC_CLASS_SIMPLE_H
|
444
lib/utils/inc/plooc_class_strict.h
Normal file
444
lib/utils/inc/plooc_class_strict.h
Normal file
@@ -0,0 +1,444 @@
|
||||
#ifndef HW_LIB_PLOOC_CLASS_STRICT_H
|
||||
#define HW_LIB_PLOOC_CLASS_STRICT_H
|
||||
|
||||
|
||||
//#include "plooc_class.h"
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
//#include <stdint.h>
|
||||
|
||||
/*! \NOTE the uint_fast8_t used in this header file is defined in stdint.h
|
||||
if you don't have stdint.h supported in your toolchain, you should
|
||||
define uint_fast8_t all by yourself with following rule:
|
||||
a. if the target processor is 8 bits, define it as uint8_t
|
||||
b. if the target processor is 16 bits, define it as uint16_t
|
||||
c. if the target processor is 32 bits, define it as uint32_t
|
||||
d. if the target processor is 64 bits, define it as either uint32_t or
|
||||
uint64_t
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*============================ MACROS ========================================*/
|
||||
#undef dcl_class
|
||||
#undef declare_class
|
||||
#undef def_class
|
||||
#undef define_class
|
||||
#undef __def_class2
|
||||
#undef __def_class3
|
||||
#undef __def_class4
|
||||
#undef __def_class5
|
||||
#undef __def_class6
|
||||
#undef __def_class7
|
||||
#undef __def_class8
|
||||
#undef __def_class
|
||||
#undef end_def_class
|
||||
#undef end_define_class
|
||||
#undef __end_def_class
|
||||
#undef extern_class
|
||||
#undef __extern_class
|
||||
#undef end_extern_class
|
||||
#undef __end_extern_class
|
||||
|
||||
/*============================ MACROFIED FUNCTIONS ===========================*/
|
||||
|
||||
|
||||
#if defined(__PLOOC_CLASS_IMPLEMENT__) || defined(__PLOOC_CLASS_IMPLEMENT)
|
||||
|
||||
# define __def_class2(__name, _1) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
};
|
||||
|
||||
# define __def_class3(__name, _1, _2) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
};
|
||||
|
||||
# define __def_class4(__name, _1, _2, _3) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_3) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
};
|
||||
|
||||
# define __def_class5(__name, _1, _2, _3, _4) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_4) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
};
|
||||
|
||||
# define __def_class6(__name, _1, _2, _3, _4, _5) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_5) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
};
|
||||
|
||||
# define __def_class7(__name, _1, _2, _3, _4, _5, _6) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_6) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
};
|
||||
|
||||
# define __def_class8(__name, _1, _2, _3, _4, _5, _6, _7) \
|
||||
typedef struct __name __name; \
|
||||
typedef struct __##__name __##__name; \
|
||||
struct __##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_6) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRI_,_7) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_7) \
|
||||
};
|
||||
|
||||
# define __end_def_class(...)
|
||||
|
||||
# define __extern_class(...)
|
||||
# define __end_extern_class(...)
|
||||
|
||||
|
||||
# undef __class
|
||||
# define __class(__name) __##__name
|
||||
|
||||
# undef class
|
||||
# define class(__name) __class(__name)
|
||||
|
||||
|
||||
# undef __with_class
|
||||
# define __with_class(__type, __src, ...) \
|
||||
{ \
|
||||
class(__type)*_ =(class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(_); \
|
||||
__VA_ARGS__; \
|
||||
} \
|
||||
for (class(__type)*_ =(class(__type) *)(__src);NULL != _; _ = NULL)
|
||||
|
||||
# undef with_class
|
||||
# define with_class(__type, __src, ...) \
|
||||
__with_class(__type, __src, __VA_ARGS__)
|
||||
|
||||
# undef __class_internal
|
||||
# define __class_internal(__src, __des, __type, ...) \
|
||||
class(__type) *(__des) = (class(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(__des); \
|
||||
__with_class(__type, (__src), __VA_ARGS__)
|
||||
|
||||
|
||||
# undef class_internal
|
||||
# define class_internal(__src, __des, __type,...) \
|
||||
__class_internal(__src, __des, __type, __VA_ARGS__)
|
||||
|
||||
|
||||
#elif defined(__PLOOC_CLASS_INHERIT__) || defined(__PLOOC_CLASS_INHERIT)
|
||||
|
||||
# define __def_class2(__name, _1) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
};
|
||||
|
||||
# define __def_class3(__name, _1, _2) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
};
|
||||
|
||||
# define __def_class4(__name, _1, _2, _3) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_3) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
};
|
||||
|
||||
# define __def_class5(__name, _1, _2, _3, _4) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_4) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
};
|
||||
|
||||
# define __def_class6(__name, _1, _2, _3, _4, _5) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_5) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
};
|
||||
|
||||
# define __def_class7(__name, _1, _2, _3, _4, _5, _6) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_6) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
};
|
||||
|
||||
# define __def_class8(__name, _1, _2, _3, _4, _5, _6, _7) \
|
||||
typedef struct __name __name; \
|
||||
struct __protected_##__name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_6) \
|
||||
__PLOOC_CONNECT2(__PLOOC_PRO_,_7) \
|
||||
}; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_7) \
|
||||
};
|
||||
|
||||
|
||||
|
||||
# define __end_def_class(...)
|
||||
|
||||
# define __extern_class(...)
|
||||
|
||||
# define __end_extern_class(...)
|
||||
|
||||
# undef __class_protected
|
||||
# define __class_protected(__name) struct __protected_##__name
|
||||
|
||||
# undef class_protected
|
||||
# define class_protected(__name) __class_protected(__name)
|
||||
|
||||
|
||||
# undef __with_protected
|
||||
# define __with_protected(__type, __src, ...) \
|
||||
{ \
|
||||
class_protected(__type)*_ =(class_protected(__type) *)(__src); \
|
||||
PLOOC_UNUSED_PARAM(_); \
|
||||
__VA_ARGS__; \
|
||||
} \
|
||||
for ( class_protected(__type)*_ =(class_protected(__type) *)(__src); \
|
||||
NULL != _; \
|
||||
_ = NULL)
|
||||
|
||||
# undef with_protected
|
||||
# define with_protected(__type, __src, ...) \
|
||||
__with_protected(__type, __src, __VA_ARGS__)
|
||||
|
||||
# undef __protected_internal
|
||||
# define __protected_internal(__src, __des, __type, ...) \
|
||||
class_protected(__type) *(__des)=(class_protected(__type) *)(__src);\
|
||||
PLOOC_UNUSED_PARAM(__des); \
|
||||
__with_protected(__type, __src, __VA_ARGS__)
|
||||
|
||||
# undef protected_internal
|
||||
# define protected_internal(__src, __des, __type, ...) \
|
||||
__protected_internal(__src, __des, __type, __VA_ARGS__)
|
||||
|
||||
|
||||
#else /* __PLOOC_CLASS_EXTERN */
|
||||
|
||||
# define __def_class2(__name, _1) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
};
|
||||
|
||||
# define __def_class3(__name, _1, _2) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
};
|
||||
|
||||
# define __def_class4(__name, _1, _2, _3) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
};
|
||||
|
||||
# define __def_class5(__name, _1, _2, _3, _4) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
};
|
||||
|
||||
# define __def_class6(__name, _1, _2, _3, _4, _5) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
};
|
||||
|
||||
# define __def_class7(__name, _1, _2, _3, _4, _5, _6) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
};
|
||||
|
||||
# define __def_class8(__name, _1, _2, _3, _4, _5, _6, _7) \
|
||||
typedef struct __name __name; \
|
||||
struct __name { \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_1) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_2) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_3) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_4) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_5) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_6) \
|
||||
__PLOOC_CONNECT2(__PLOOC_EXT_,_7) \
|
||||
};
|
||||
|
||||
# define __end_def_class(...)
|
||||
|
||||
#define __extern_class(...) __PLOOC_EVAL(__def_class, __VA_ARGS__) \
|
||||
(__VA_ARGS__)
|
||||
|
||||
#define __end_extern_class(...)
|
||||
|
||||
#endif
|
||||
|
||||
#define def_class(...) __PLOOC_EVAL(__def_class, __VA_ARGS__) \
|
||||
(__VA_ARGS__)
|
||||
#define define_class(...) def_class(__VA_ARGS__)
|
||||
|
||||
#define end_def_class(...) __end_def_class(__VA_ARGS__)
|
||||
#define end_define_class(...) end_def_class(__VA_ARGS__)
|
||||
|
||||
#define declare_class(__name) typedef struct __name __name;
|
||||
#define dcl_class(__name) declare_class(__name)
|
||||
|
||||
#define extern_class(...) __extern_class(__VA_ARGS__)
|
||||
#define end_extern_class(...) __end_extern_class(__VA_ARGS__)
|
||||
|
||||
|
||||
#undef __PLOOC_CLASS_IMPLEMENT__
|
||||
#undef __PLOOC_CLASS_INHERIT__
|
||||
#undef __PLOOC_CLASS_IMPLEMENT
|
||||
#undef __PLOOC_CLASS_INHERIT
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif //HW_LIB_PLOOC_CLASS_STRICT_H
|
Reference in New Issue
Block a user