Skip to content

Commit

Permalink
update plooc
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Oct 23, 2019
1 parent c5f1fd4 commit a06aafb
Show file tree
Hide file tree
Showing 15 changed files with 772 additions and 117 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ sources/gmsi/service/gui/tgui/grid/example.lib
*.dep
*.gabwan01
*.dep
sources/gmsi/utilities/3rd-party/PLOOC/example/project/mdk/plooc_example.uvguix.gabwan01
73 changes: 59 additions & 14 deletions sources/gmsi/utilities/3rd-party/PLOOC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ The Protected Low-overhead Object Oriented Programming with ANSI-C, a.k.a PLOOC
- Support interface implementation
- Support strict type checking/validation in certain compilers, such as IAR with multi-file compilation enabled.
- Compliant with __ANSI-C99__
- ANSI-C90 is also supported but the protection for private feature is disabled.
- Support **Overload**
- Require C11 or _Generic
- Low-overhead
> NOTE: Almost ZERO OVERHEAD. The template fully utilises the ANSI-C enforced compilation rules to deliver desired OO features with the the least necessary cost.
Expand Down Expand Up @@ -74,11 +77,16 @@ If you have any questions or suggestions, please feel free to let us know.
## Update Log
---

- \[08/15/2019] Update plooc_class_strict.h to use more soften syntax
- [09/06/2019] Add support for C89/90, version 4.50
- Add full support for overload \(require C11\)
- \[09/05/2019] Add support for C89/90, version 4.40
- When C89/90 is enforced, \_\_OOC_DEBUG\_\_ should always be defined.
- The protection for private and protected members is turned off.
- \[08/15/2019] Update plooc_class_strict.h to use more soften syntax, version 4.31
- Users now can use arbitrary order for public_member, private_member and protected_member.
- The separator "," can be ignored.
- Simplified the plooc_class_strict.h template. Some common macros are moved to plooc_class.h, which will be shared by other template later.
- \[08/14/2019\] Introduce support for limited support for polymorphism
- \[08/14/2019\] Introduce support for limited support for overload, version 4.30
- Use can use macro \_\_PLOOC_EVAL() to select the right API which has the corresponding number of parameters.
- \[07/26/2019\] Syntax update, version 4.21
- Modify plooc_class_black_box.h to use unified syntax as other templates.
Expand Down Expand Up @@ -139,18 +147,20 @@ The full license text follows:
### Template
| module | Contrinutor |
| ------ | ------ |
| plooc.h | GorgonMeducer ||
| plooc.h | GorgonMeducer |
| plooc_class.h | GorgonMeducer, Simon Qian |
| plooc_class_strict.h | GorgonMeducer |
| plooc_class_back_box.h | GorgonMeducer |
| plooc_class_simple.h | Simon Qian |
| plooc_class_simple_c90.h | GorgonMeducer |


### Examples
| module | Contrinutor |
| ------ | ------ |
| byte_queue | GorgonMeducer |
| Advanced_byte_queue | GorgonMeducer |
| How to define a class | GorgonMeducer |
| How to access protected members | GorgonMeducer |
| How to implement Polymorphism | GorgonMeducer |

## Applications / Projects which claim to use PLOOC
---
Expand All @@ -169,18 +179,53 @@ In order to show how PLOOC is easy and simple to use, examples are provided to d

More examples will be added later...

#### [Example 1: byte_queue](https://github.com/GorgonMeducer/PLOOC/tree/master/example/byte_queue)
This example shows
- How to define a class
- ### [Example 1: How to define a class](https://github.com/GorgonMeducer/PLOOC/tree/master/example/byte_queue)

This example shows

- How to define a class
- How to add private member
- How to add protected member
- How to access class members
- How to define user friendly interface
- How to access class members
- How to define user friendly interface

#### [Example 2: enhanced_byte_queue](https://github.com/GorgonMeducer/PLOOC/tree/master/example/enhanced_byte_queue)
- How to inherit from a base class
### [Example 2: How to access protected members](https://github.com/GorgonMeducer/PLOOC/tree/master/example/enhanced_byte_queue)

- How to inherit from a base class
- How to access protected members which are inherited from base
- How to inherit a interface
- How to override base methods
- How to inherit a interface
- How to override base methods

### [Example 3: How to implement Overload ](https://github.com/GorgonMeducer/PLOOC/tree/master/example/trace)

- How to implement overload using PLOOC

- Require C11 support

```
LOG_OUT("\r\n-[Demo of overload]------------------------------\r\n");
LOG_OUT((uint32_t) 0x12345678);
LOG_OUT("\r\n");
LOG_OUT(0x12345678);
LOG_OUT("\r\n");
LOG_OUT("PI is ");
LOG_OUT(3.1415926f);
LOG_OUT("\r\n");
LOG_OUT("\r\nShow BYTE Array:\r\n");
LOG_OUT((uint8_t *)main, 100);
LOG_OUT("\r\nShow Half-WORD Array:\r\n");
LOG_OUT((uint16_t *)main, 100/sizeof(uint16_t));
LOG_OUT("\r\nShow WORD Array:\r\n");
LOG_OUT((uint32_t *)main, 100/sizeof(uint32_t));
```



![example3](https://github.com/GorgonMeducer/PLOOC/blob/master/example/picture/example3.png?raw=true)




11 changes: 8 additions & 3 deletions sources/gmsi/utilities/3rd-party/PLOOC/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ In order to show how PLOOC is easy and simple to use, examples are provided to d

More examples will be added later...

## [Example 1: byte_queue](https://github.com/GorgonMeducer/PLOOC/tree/master/example/byte_queue)
## [Example 1: How to define a class](https://github.com/GorgonMeducer/PLOOC/tree/master/example/byte_queue)
This example shows
- How to define a class
- How to add private member
- How to add protected member
- How to access class members
- How to define user friendly interface

## [Example 2: enhanced_byte_queue](https://github.com/GorgonMeducer/PLOOC/tree/master/example/enhanced_byte_queue)
## [Example 2: How to access protected members](https://github.com/GorgonMeducer/PLOOC/tree/master/example/enhanced_byte_queue)
- How to inherit from a base class
- How to access protected members which are inherited from base
- How to inherit a interface
- How to override base methods

## [Example 3: How to implement Overload ](https://github.com/GorgonMeducer/PLOOC/tree/master/example/trace)

Author: GorgonMeducer<[email protected]>, under Apache 2.0
- How to implement overload using PLOOC

![example3](https://github.com/GorgonMeducer/PLOOC/blob/master/example/picture/example3.png?raw=true)


Author: GorgonMeducer<[email protected]>, under Apache 2.0
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ byte_queue_t * byte_queue_init(byte_queue_t *ptObj, byte_queue_cfg_t *ptCFG)
class_internal(ptObj, ptThis, byte_queue_t);

ASSERT(NULL != ptObj && NULL != ptCFG);

/* access inherited member of mem_t directly */
if ( (NULL == ptCFG->pchBuffer)
|| (0 == ptCFG->hwSize)) {
if ( (NULL == ptCFG->use_as__mem_t.pchBuffer)
|| (0 == ptCFG->use_as__mem_t.hwSize)) {

return NULL;
}


memset(ptObj, 0, sizeof(byte_queue_t)); //! clear object
/*
Expand Down Expand Up @@ -88,10 +90,9 @@ bool byte_queue_enqueue(byte_queue_t *ptObj, uint8_t chByte)
//! queue is full
return false;
}

this.pchBuffer[this.hwHead++] = chByte;
this.use_as__mem_t.pchBuffer[this.hwHead++] = chByte;
this.hwCount++;
if (this.hwHead >= this.hwSize) {
if (this.hwHead >= this.use_as__mem_t.hwSize) {
this.hwHead = 0;
}
/* ------------------atomicity sensitive end---------------- */
Expand All @@ -113,9 +114,9 @@ bool byte_queue_dequeue(byte_queue_t *ptObj, uint8_t *pchByte)
return false;
}

chByte = this.pchBuffer[this.hwTail++];
chByte = this.use_as__mem_t.pchBuffer[this.hwTail++];
this.hwCount--;
if (this.hwTail >= this.hwSize) {
if (this.hwTail >= this.use_as__mem_t.hwSize) {
this.hwTail = 0;
}
/* ------------------atomicity sensitive end---------------- */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion sources/gmsi/utilities/3rd-party/PLOOC/example/project/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@

#include "byte_queue/byte_queue.h"
#include "enhanced_byte_queue/enhanced_byte_queue.h"
#include "trace/trace.h"
/*============================ MACROS ========================================*/

#ifndef QUEUE_BUFFER_SIZE
# define QUEUE_BUFFER_SIZE 256
#endif

#define LOG_OUT(...) TRACE_TOSTR(__VA_ARGS__)

/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
Expand Down Expand Up @@ -87,6 +90,23 @@ int main(void)
ENHANCED_BYTE_QUEUE.Count(&s_tQueue));
} while(0);

LOG_OUT("\r\n-[Demo of overload]------------------------------\r\n");
LOG_OUT((uint32_t) 0x12345678);
LOG_OUT("\r\n");
LOG_OUT(0x12345678);
LOG_OUT("\r\n");
LOG_OUT("PI is ");
LOG_OUT(3.1415926f);
LOG_OUT("\r\n");

LOG_OUT("\r\nShow BYTE Array:\r\n");
LOG_OUT((uint8_t *)main, 100);

LOG_OUT("\r\nShow Half-WORD Array:\r\n");
LOG_OUT((uint16_t *)main, 100/sizeof(uint16_t));

LOG_OUT("\r\nShow WORD Array:\r\n");
LOG_OUT((uint32_t *)main, 100/sizeof(uint32_t));

while(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer1>1</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
Expand All @@ -172,7 +172,7 @@
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<aSer4>1</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
Expand Down Expand Up @@ -377,6 +377,38 @@
</File>
</Group>

<Group>
<GroupName>trace</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>13</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\trace\trace.h</PathWithFileName>
<FilenameWithoutPath>trace.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>14</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\trace\trace.c</PathWithFileName>
<FilenameWithoutPath>trace.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>

<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<TargetName>arm_compiler_6_example</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6130000::V6.13.0.1 (dev drop 1) for Armv8.1-M and MVE::..\..\Program Files\ARMCompiler6.13DevdropforArmv8.1-MandMVE</pCCUsed>
<pCCUsed>6130000::V6.13::.\ARMCompiler6.13</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
Expand Down Expand Up @@ -327,7 +327,7 @@
<uC99>1</uC99>
<uGnu>1</uGnu>
<useXO>0</useXO>
<v6Lang>3</v6Lang>
<v6Lang>6</v6Lang>
<v6LangP>3</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
Expand All @@ -336,7 +336,7 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>-fms-extensions -Wno-microsoft-anon-tag -Wno-empty-body</MiscControls>
<Define>_MSC_VER</Define>
<Define>_MSC_VER __OOC_DEBUG__</Define>
<Undefine></Undefine>
<IncludePath>..\mdk;..\..\..\example;..\..\..\..\PLOOC</IncludePath>
</VariousControls>
Expand Down Expand Up @@ -459,6 +459,21 @@
</File>
</Files>
</Group>
<Group>
<GroupName>trace</GroupName>
<Files>
<File>
<FileName>trace.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\trace\trace.h</FilePath>
</File>
<File>
<FileName>trace.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\trace\trace.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
Expand Down
Loading

0 comments on commit a06aafb

Please sign in to comment.