UP font generate
This commit is contained in:
59
demo/plooc/test_class.c
Normal file
59
demo/plooc/test_class.c
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
#define __TEST_CLASS_CLASS_IMPLEMENT__
|
||||
|
||||
#include "test_class.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(...) assert(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#undef this
|
||||
#define this (*ptThis)
|
||||
|
||||
const i_test_class_t TEST_CLASS = {
|
||||
.Init = &test_class_init,
|
||||
.Depose = &test_class_depose,
|
||||
|
||||
/* other methods */
|
||||
};
|
||||
|
||||
|
||||
/*! \brief the constructor of the class: test_class */
|
||||
test_class_t *test_class_init(test_class_t *ptObj, test_class_cfg_t *ptCFG) {
|
||||
/* initialise "this" (i.e. ptThis) to access class members */
|
||||
class_internal(ptObj, ptThis, test_class_t);
|
||||
|
||||
ASSERT(NULL != ptObj && NULL != ptCFG);
|
||||
|
||||
return ptObj;
|
||||
}
|
||||
|
||||
/*! \brief the destructor of the class: test_class */
|
||||
void test_class_depose(test_class_t *ptObj) {
|
||||
/* initialise "this" (i.e. ptThis) to access class members */
|
||||
class_internal(ptObj, ptThis, test_class_t);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*! \brief a method only visible for current class and derived class */
|
||||
void test_class_protected_method_example1(test_class_t *ptObj) {
|
||||
/* initialise "this" (i.e. ptThis) to access class members */
|
||||
class_internal(ptObj, ptThis, test_class_t);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*! \brief a method only visible for current class and derived class */
|
||||
void test_class_protected_method_example2(test_class_t *ptObj) {
|
||||
/* initialise "this" (i.e. ptThis) to access class members */
|
||||
class_internal(ptObj, ptThis, test_class_t);
|
||||
|
||||
|
||||
}
|
71
demo/plooc/test_class.h
Normal file
71
demo/plooc/test_class.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef __TEST_CLASS_H__
|
||||
#define __TEST_CLASS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*! \NOTE: Make sure #include "plooc_class.h" is close to the class definition
|
||||
*/
|
||||
#if defined(__TEST_CLASS_CLASS_IMPLEMENT__)
|
||||
#define __PLOOC_CLASS_IMPLEMENT__
|
||||
#elif defined(__TEST_CLASS_CLASS_INHERIT__)
|
||||
#define __PLOOC_CLASS_INHERIT__
|
||||
#endif
|
||||
|
||||
#include "plooc_class.h"
|
||||
|
||||
|
||||
//! \name class test_class_t
|
||||
//! @{
|
||||
declare_class(test_class_t)
|
||||
def_class(test_class_t,
|
||||
public_member(
|
||||
//!< place your public members here
|
||||
)
|
||||
private_member(
|
||||
//!< place your private members here
|
||||
)
|
||||
protected_member(
|
||||
//!< place your protected members here
|
||||
)
|
||||
)
|
||||
end_def_class(test_class_t) /* do not remove this for forward compatibility */
|
||||
//! @}
|
||||
|
||||
typedef struct test_class_cfg_t {
|
||||
|
||||
//! put your configuration members here
|
||||
|
||||
} test_class_cfg_t;
|
||||
|
||||
//! \name interface i_test_class_t
|
||||
//! @{
|
||||
def_interface(i_test_class_t)
|
||||
test_class_t *(*Init)(test_class_t *ptObj, test_class_cfg_t *ptCFG);
|
||||
|
||||
void (*Depose)(test_class_t *ptObj);
|
||||
/* other methods */
|
||||
|
||||
end_def_interface(i_test_class_t) /*do not remove this for forward compatibility */
|
||||
//! @}
|
||||
|
||||
extern const i_test_class_t TEST_CLASS;
|
||||
|
||||
/*! \brief the constructor of the class: test_class */
|
||||
extern test_class_t *test_class_init(test_class_t *ptObj, test_class_cfg_t *ptCFG);
|
||||
|
||||
/*! \brief the destructor of the class: test_class */
|
||||
extern void test_class_depose(test_class_t *ptObj);
|
||||
|
||||
protected_method(
|
||||
/*! \brief a method only visible for current class and derived class */
|
||||
extern void test_class_protected_method_example1(test_class_t *ptObj);
|
||||
/*! \brief a method only visible for current class and derived class */
|
||||
extern void test_class_protected_method_example2(test_class_t *ptObj);
|
||||
)
|
||||
|
||||
/*! \note it is very important to undef those macros */
|
||||
#undef __TEST_CLASS_CLASS_INHERIT__
|
||||
#undef __TEST_CLASS_CLASS_IMPLEMENT__
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user