mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-21 23:34:44 -08:00
Updates to readme, small fixes to code and organizational refactors
This commit is contained in:
parent
4e61fefc55
commit
30381648b2
@ -311,6 +311,7 @@ Interface :``
|
||||
|
||||
Bodies:
|
||||
|
||||
* def_body
|
||||
* def_class_body
|
||||
* def_enum_body
|
||||
* def_export_body
|
||||
@ -322,8 +323,6 @@ Bodies:
|
||||
* def_struct_body
|
||||
* def_union_body
|
||||
|
||||
* def_body
|
||||
|
||||
Usage:
|
||||
|
||||
```cpp
|
||||
|
@ -1,18 +1,10 @@
|
||||
# Documentation
|
||||
|
||||
This library is currently in a bootstrapping phase.
|
||||
|
||||
Eventually it will have zero dependencies and have its code size severely constricted.
|
||||
|
||||
All dependencies are currently held within `Bloat.hpp` and `Bloat.cpp`
|
||||
|
||||
All the library code is contained in two files: `gen.hpp` and `gen.cpp`
|
||||
|
||||
## gen.hpp
|
||||
|
||||
While getting fleshed out, all feature macros are defined on the top of the header.
|
||||
|
||||
These macros are:
|
||||
Feature Macros:
|
||||
|
||||
* `GENCPP_ROLL_OWN_DEPENDENCIES` : Optional override so that user may define the dependencies themselves.
|
||||
* `GEN_DEFINE_LIBRARY_CORE_CONSTANTS` : Optional typename codes as they are non-standard to C/C++ and not necessary to library usage
|
||||
|
@ -6,7 +6,7 @@
|
||||
#pragma region GENCPP DEPENDENCIES
|
||||
//! If its desired to roll your own dependencies, define GENCPP_PROVIDE_DEPENDENCIES before including this file.
|
||||
//! Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||
#ifndef GENCPP_PROVIDE_DEPENDENCIES
|
||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||
|
||||
// NOTE: Ensure we use standard methods for these calls if we use GEN_PICO
|
||||
#pragma region Macros
|
||||
|
111
project/gen.hpp
111
project/gen.hpp
@ -12,7 +12,7 @@
|
||||
#pragma region GENCPP DEPENDENCIES
|
||||
//! If its desired to roll your own dependencies, define GENCPP_PROVIDE_DEPENDENCIES before including this file.
|
||||
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||
#ifndef GENCPP_ROLL_OWN_DEPENDENCIES
|
||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||
|
||||
#if __clang__
|
||||
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||
@ -23,14 +23,8 @@
|
||||
# pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#if defined( GEN_HAS_ATTRIBUTE )
|
||||
# undef GEN_HAS_ATTRIBUTE
|
||||
#endif
|
||||
#if defined( __has_attribute )
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
||||
#else
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||
#endif
|
||||
|
||||
#pragma region Platform Detection
|
||||
|
||||
/* Platform architecture */
|
||||
|
||||
@ -117,6 +111,15 @@
|
||||
# error Unknown compiler
|
||||
#endif
|
||||
|
||||
#if defined( GEN_HAS_ATTRIBUTE )
|
||||
# undef GEN_HAS_ATTRIBUTE
|
||||
#endif
|
||||
#if defined( __has_attribute )
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
||||
#else
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||
#endif
|
||||
|
||||
#ifndef GEN_DEF_INLINE
|
||||
# if defined( GEN_STATIC )
|
||||
# define GEN_DEF_INLINE
|
||||
@ -159,48 +162,13 @@
|
||||
# define forceinline inline
|
||||
#endif
|
||||
|
||||
#ifndef count_of
|
||||
# define count_of( x ) ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) )
|
||||
#endif
|
||||
|
||||
#ifndef is_between
|
||||
# define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) )
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
# define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
||||
#endif
|
||||
|
||||
#ifndef size_of
|
||||
# define size_of( x ) ( sw )( sizeof( x ) )
|
||||
#endif
|
||||
|
||||
#ifndef swap
|
||||
# define swap( Type, a, b ) \
|
||||
do \
|
||||
{ \
|
||||
Type tmp = ( a ); \
|
||||
( a ) = ( b ); \
|
||||
( b ) = tmp; \
|
||||
} while ( 0 )
|
||||
#endif
|
||||
#pragma endregion Platform Detection
|
||||
|
||||
#ifndef zpl_cast
|
||||
# define zpl_cast( Type ) ( Type )
|
||||
#endif
|
||||
|
||||
#ifndef global
|
||||
# define global static // Global variables
|
||||
#endif
|
||||
|
||||
#ifndef internal
|
||||
# define internal static // Internal linkage
|
||||
#endif
|
||||
|
||||
#ifndef local_persist
|
||||
# define local_persist static // Local Persisting variables
|
||||
#endif
|
||||
|
||||
// num_args macro
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
// Supports 0-10 arguments
|
||||
#define macro_num_args_impl( _0, \
|
||||
@ -237,14 +205,27 @@
|
||||
)
|
||||
#endif
|
||||
|
||||
// Bits
|
||||
|
||||
#define bit( Value_ ) ( 1 << Value_ )
|
||||
#define bitfield_is_equal( Type_, Field_, Mask_ ) ( (Type_(Mask_) & Type_(Field_)) == Type_(Mask_) )
|
||||
|
||||
// Casting
|
||||
#define ccast( Type_, Value_ ) * const_cast< Type_* >( & (Value_) )
|
||||
#define scast( Type_, Value_ ) static_cast< Type_ >( Value_ )
|
||||
|
||||
#define rcast( Type_, Value_ ) reinterpret_cast< Type_ >( Value_ )
|
||||
#define scast( Type_, Value_ ) static_cast< Type_ >( Value_ )
|
||||
#define pcast( Type_, Value_ ) ( * (Type_*)( & (Value_) ) )
|
||||
|
||||
// Keywords
|
||||
|
||||
#define global static // Global variables
|
||||
#define internal static // Internal linkage
|
||||
#define local_persist static // Local Persisting variables
|
||||
|
||||
#define stringize_va( ... ) #__VA_ARGS__
|
||||
#define stringize( ... ) stringize_va( __VA_ARGS__ )
|
||||
|
||||
#define do_once() \
|
||||
do \
|
||||
{ \
|
||||
@ -280,8 +261,31 @@ while(0);
|
||||
|
||||
namespace gen
|
||||
{
|
||||
constexpr
|
||||
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
#ifndef count_of
|
||||
# define count_of( x ) ( ( size_of( x ) / size_of( 0 [ x ] ) ) / ( ( sw )( ! ( size_of( x ) % size_of( 0 [ x ] ) ) ) ) )
|
||||
#endif
|
||||
|
||||
#ifndef is_between
|
||||
# define is_between( x, lower, upper ) ( ( ( lower ) <= ( x ) ) && ( ( x ) <= ( upper ) ) )
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
# define min( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
||||
#endif
|
||||
|
||||
#ifndef size_of
|
||||
# define size_of( x ) ( sw )( sizeof( x ) )
|
||||
#endif
|
||||
|
||||
#ifndef swap
|
||||
# define swap( Type, a, b ) \
|
||||
do \
|
||||
{ \
|
||||
Type tmp = ( a ); \
|
||||
( a ) = ( b ); \
|
||||
( b ) = tmp; \
|
||||
} while ( 0 )
|
||||
#endif
|
||||
|
||||
#pragma region Basic Types
|
||||
#ifndef GEN_U8_MIN
|
||||
@ -406,6 +410,9 @@ namespace gen
|
||||
#pragma endregion Basic Types
|
||||
|
||||
#pragma region Debug
|
||||
constexpr
|
||||
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
|
||||
#ifndef GEN_DEBUG_TRAP
|
||||
# if defined( _MSC_VER )
|
||||
# if _MSC_VER < 1300
|
||||
@ -3012,6 +3019,9 @@ namespace gen
|
||||
, Code specifiers = NoCode, Code attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag::None );
|
||||
|
||||
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
|
||||
Code def_body( CodeT type );
|
||||
|
||||
// There are two options for defining a struct body, either varadically provided with the args macro to auto-deduce the arg num,
|
||||
/// or provide as an array of Code objects.
|
||||
|
||||
@ -3037,9 +3047,6 @@ namespace gen
|
||||
Code def_struct_body ( s32 num, Code* codes );
|
||||
Code def_union_body ( s32 num, ... );
|
||||
Code def_union_body ( s32 num, Code* codes );
|
||||
|
||||
// Constructs an empty body. Use AST::validate_body() to check if the body is was has valid entries.
|
||||
Code def_body( CodeT type );
|
||||
# pragma endregion Upfront
|
||||
|
||||
# pragma region Parsing
|
||||
|
Loading…
Reference in New Issue
Block a user