mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
Moved the indentation for the library over
The entire project uses the namespace and it felt redundant. There is a fix for array append_at. Finally got csv parsing working with it.
This commit is contained in:
parent
d1c061769c
commit
8bb0db8145
@ -1,6 +1,9 @@
|
||||
# Documentation
|
||||
|
||||
All the library code is contained in two files: `gen.hpp` and `gen.cpp`
|
||||
The core library is contained within `gen.hpp` and `gen.cpp`.
|
||||
Things related to the editor and scanner are in their own respective files. (Ex: `gen.scanner.<hpp/cpp>` )
|
||||
|
||||
|
||||
|
||||
## gen.hpp
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
#include "gen.hpp"
|
||||
|
||||
namespace gen
|
||||
{
|
||||
namespace gen {
|
||||
|
||||
#pragma region StaticData
|
||||
// TODO : Convert global allocation strategy to use the dual-scratch allocator for a contextual scope.
|
||||
global AllocatorInfo GlobalAllocator;
|
||||
@ -1235,9 +1235,9 @@ namespace gen
|
||||
# pragma push_macro( "global" )
|
||||
# pragma push_macro( "internal" )
|
||||
# pragma push_macro( "local_persist" )
|
||||
# define global global
|
||||
# define internal internal
|
||||
# define local_persist local_persist
|
||||
# undef global
|
||||
# undef internal
|
||||
# undef local_persist
|
||||
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
@ -5112,13 +5112,13 @@ namespace gen
|
||||
|
||||
case TokType::Module_Import:
|
||||
{
|
||||
not_implemented();
|
||||
not_implemented( context );
|
||||
}
|
||||
//! Fallthrough intentional
|
||||
case TokType::BraceSquare_Open:
|
||||
case TokType::Attr_Keyword:
|
||||
{
|
||||
not_implemented();
|
||||
not_implemented( context );
|
||||
|
||||
// Standard attribute
|
||||
if ( currtok.Type == TokType::BraceSquare_Open )
|
||||
@ -6533,6 +6533,8 @@ namespace gen
|
||||
Buffer.free();
|
||||
}
|
||||
#pragma endregion Builder
|
||||
|
||||
// namespace gen
|
||||
}
|
||||
|
||||
#include "gen.pop_ignores.inline.hpp"
|
||||
|
@ -39,6 +39,24 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef GEN_SYSTEM_MACOS
|
||||
# include <copyfile.h>
|
||||
#endif
|
||||
|
||||
#ifdef GEN_SYSTEM_CYGWIN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined( GEN_SYSTEM_WINDOWS ) && ! defined( GEN_COMPILER_GCC )
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#if defined( GEN_SYSTEM_LINUX )
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef GEN_BENCHMARK
|
||||
// Timing includes
|
||||
#if defined( GEN_SYSTEM_MACOS ) || GEN_SYSTEM_UNIX
|
||||
@ -63,7 +81,6 @@
|
||||
#pragma endregion Macros & Includes
|
||||
|
||||
|
||||
|
||||
namespace gen {
|
||||
|
||||
#pragma region Debug
|
||||
@ -2062,9 +2079,15 @@ namespace gen {
|
||||
GEN_ASSERT_NOT_NULL( root );
|
||||
GEN_ASSERT_NOT_NULL( text );
|
||||
zero_item( root );
|
||||
|
||||
adt_make_branch( root, allocator, NULL, has_header ? false : true );
|
||||
char *p = text, *b = p, *e = p;
|
||||
sw colc = 0, total_colc = 0;
|
||||
|
||||
char* p = text;
|
||||
char* b = p;
|
||||
char* e = p;
|
||||
|
||||
sw colc = 0;
|
||||
sw total_colc = 0;
|
||||
|
||||
do
|
||||
{
|
||||
@ -2074,7 +2097,7 @@ namespace gen {
|
||||
break;
|
||||
ADT_Node row_item = { 0 };
|
||||
row_item.type = EADT_TYPE_STRING;
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
row_item.name_style = EADT_NAME_STYLE_NO_QUOTES;
|
||||
#endif
|
||||
|
||||
@ -2083,7 +2106,7 @@ namespace gen {
|
||||
{
|
||||
p = b = e = p + 1;
|
||||
row_item.string = b;
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
row_item.name_style = EADT_NAME_STYLE_DOUBLE_QUOTE;
|
||||
#endif
|
||||
do
|
||||
@ -2229,7 +2252,7 @@ namespace gen {
|
||||
{
|
||||
case EADT_TYPE_STRING :
|
||||
{
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
switch ( node->name_style )
|
||||
{
|
||||
case EADT_NAME_STYLE_DOUBLE_QUOTE :
|
||||
@ -2244,7 +2267,7 @@ namespace gen {
|
||||
{
|
||||
#endif
|
||||
str_fmt_file( file, "%s", node->string );
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3244,3 +3267,4 @@ namespace gen {
|
||||
|
||||
// namespace gen
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
# define GEN_ARCH_64_BIT 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef GEN_ARCH_32_BIT
|
||||
# ifndef GEN_ARCH_32_BItxt_StrCaT
|
||||
# define GEN_ARCH_32_BIT 1
|
||||
# endif
|
||||
#endif
|
||||
@ -91,6 +91,15 @@
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||
#endif
|
||||
|
||||
#if defined(GEN_GCC_VERSION_CHECK)
|
||||
# undef GEN_GCC_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(GEN_GCC_VERSION)
|
||||
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (0)
|
||||
#endif
|
||||
|
||||
#define GEN_DEF_INLINE static
|
||||
#define GEN_IMPL_INLINE static inline
|
||||
|
||||
@ -1283,6 +1292,7 @@ struct Array
|
||||
Type* target = Data + idx;
|
||||
|
||||
mem_move( target + 1, target, (header->Num - idx) * sizeof(Type) );
|
||||
header->Num++;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1309,7 +1319,6 @@ struct Array
|
||||
|
||||
mem_move( target, src, (header->Num - idx) * sizeof(Type) );
|
||||
mem_copy( src, items, item_num * sizeof(Type) );
|
||||
|
||||
header->Num += item_num;
|
||||
|
||||
return true;
|
||||
@ -1743,7 +1752,7 @@ u64 crc64( void const* data, sw len );
|
||||
};
|
||||
|
||||
#define txt_StrC( text ) \
|
||||
(StrC){ sizeof( text ) - 1, text }
|
||||
StrC { sizeof( text ) - 1, text }
|
||||
|
||||
StrC to_StrC( char const* str )
|
||||
{
|
||||
@ -2336,7 +2345,7 @@ GEN_DEF_INLINE s64 file_tell( FileInfo* file );
|
||||
* @param buffer Buffer to read from
|
||||
* @param size Size to read
|
||||
*/
|
||||
b32 file_write( FileInfo* file, void const* buffer, sw size );
|
||||
GEN_DEF_INLINE b32 file_write( FileInfo* file, void const* buffer, sw size );
|
||||
|
||||
/**
|
||||
* Writes to file at a specific offset
|
||||
@ -2543,7 +2552,7 @@ struct ADT_Node
|
||||
/* properties */
|
||||
ADT_Type type : 4;
|
||||
u8 props : 4;
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
u8 cfg_mode : 1;
|
||||
u8 name_style : 2;
|
||||
u8 assign_style : 2;
|
||||
@ -2566,7 +2575,7 @@ struct ADT_Node
|
||||
s64 integer;
|
||||
};
|
||||
|
||||
#ifndef ZPL_PARSER_DISABLE_ANALYSIS
|
||||
#ifndef GEN_PARSER_DISABLE_ANALYSIS
|
||||
/* number analysis */
|
||||
s32 base;
|
||||
s32 base2;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "gen.hpp"
|
||||
#include "gen.scanner.hpp"
|
||||
|
||||
namespace gen {
|
||||
|
||||
@ -52,9 +52,9 @@ struct Editor
|
||||
|
||||
static void set_allocator( AllocatorInfo allocator );
|
||||
|
||||
Array(FileInfo) Files;
|
||||
Array<FileInfo> Files;
|
||||
String Buffer;
|
||||
Array(RequestEntry) Requests;
|
||||
Array<RequestEntry> Requests;
|
||||
|
||||
void add_files( s32 num, char const** files );
|
||||
|
||||
@ -66,7 +66,7 @@ struct Editor
|
||||
void refactor( char const* file_path, char const* specification_path );
|
||||
# endif
|
||||
|
||||
bool process_requests( Array(Receipt) out_receipts );
|
||||
bool process_requests( Array<Receipt> out_receipts );
|
||||
};
|
||||
|
||||
// namespace gen
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "gen.push_ignores.inline.hpp"
|
||||
|
||||
//! If its desired to roll your own dependencies, define GENCPP_PROVIDE_DEPENDENCIES before including this file.
|
||||
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
||||
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
||||
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
||||
# include "gen.dep.hpp"
|
||||
@ -240,9 +240,9 @@ namespace ESpecifier
|
||||
# pragma push_macro( "global" )
|
||||
# pragma push_macro( "internal" )
|
||||
# pragma push_macro( "local_persist" )
|
||||
# define global global
|
||||
# define internal internal
|
||||
# define local_persist local_persist
|
||||
# undef global
|
||||
# undef internal
|
||||
# undef local_persist
|
||||
|
||||
# define Entry( Spec_, Code_ ) { sizeof(stringize(Code_)), stringize(Code_) },
|
||||
Define_Specifiers
|
||||
@ -348,7 +348,7 @@ namespace Attribute
|
||||
constexpr char const* API_Import = stringize( GEN_API_Import_Code );
|
||||
constexpr char const* Keyword = stringize( GEN_Attribute_Keyword);
|
||||
|
||||
#elif GEN_HAS_ATTRIBUTE( visibility ) || GEN_GCC_VERSION_CHECK( 3, 3, 0 ) || GEN_INTEL_VERSION_CHECK( 13, 0, 0 )
|
||||
#elif GEN_HAS_ATTRIBUTE( visibility ) || GEN_GCC_VERSION_CHECK( 3, 3, 0 )
|
||||
# define GEN_API_Export_Code __attribute__ ((visibility ("default")))
|
||||
# define GEN_API_Import_Code __attribute__ ((visibility ("default")))
|
||||
# define GEN_Attribute_Keyword __attribute__
|
||||
|
@ -29,15 +29,16 @@ struct Scanner
|
||||
|
||||
static void set_allocator( AllocatorInfo allocator );
|
||||
|
||||
Array(FileInfo) Files;
|
||||
Array<FileInfo> Files;
|
||||
String Buffer;
|
||||
Array(RequestEntry) Requests;
|
||||
Array<RequestEntry> Requests;
|
||||
|
||||
void add_files( s32 num, char const** files );
|
||||
|
||||
void add( SymbolInfo signature, Policy policy );
|
||||
|
||||
bool process_requests( Array(Receipt) out_receipts );
|
||||
bool process_requests( Array<Receipt> out_receipts );
|
||||
};
|
||||
k
|
||||
|
||||
// namespace gen
|
||||
}
|
Loading…
Reference in New Issue
Block a user