mirror of
https://github.com/Ed94/gencpp.git
synced 2024-11-10 02:54:53 -08:00
Update readme and scripts
Both bootstrap and singleheader now name the files the same as the library's default. Output now directed toward gen directory for the corresponding dir (project, singleheader, or test)
This commit is contained in:
parent
9c81504178
commit
88d36f5d06
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@ build/*
|
|||||||
.vs
|
.vs
|
||||||
|
|
||||||
**/*.gen.*
|
**/*.gen.*
|
||||||
|
**/gen/gen.hpp
|
||||||
|
**/gen/gen.cpp
|
||||||
|
|
||||||
gencpp.hpp
|
gencpp.hpp
|
||||||
gencpp.cpp
|
gencpp.cpp
|
||||||
|
34
Readme.md
34
Readme.md
@ -48,13 +48,15 @@ The project has no external dependencies beyond:
|
|||||||
Dependencies for the project are wrapped within `GENCPP_ROLL_OWN_DEPENDENCIES` (Defining it will disable them).
|
Dependencies for the project are wrapped within `GENCPP_ROLL_OWN_DEPENDENCIES` (Defining it will disable them).
|
||||||
The majority of the dependency's implementation was derived from the [c-zpl library](https://github.com/zpl-c/zpl).
|
The majority of the dependency's implementation was derived from the [c-zpl library](https://github.com/zpl-c/zpl).
|
||||||
|
|
||||||
This library was written a subset of C++ where the following are avoided:
|
This library was written a subset of C++ where the following are not used at all:
|
||||||
|
|
||||||
* RAII (Constructors/Destructors), lifetimes are managed using named static or regular functions.
|
* RAII (Constructors/Destructors), lifetimes are managed using named static or regular functions.
|
||||||
* Language provide dynamic dispatch, RTTI
|
* Language provide dynamic dispatch, RTTI
|
||||||
* Object-Oriented Inheritance
|
* Object-Oriented Inheritance
|
||||||
|
* Exceptions
|
||||||
|
|
||||||
Member-functions are used as an ergonomic choice, along with a conserative use of operator overloads.
|
Polymorphic & Member-functions are used as an ergonomic choice, along with a conserative use of operator overloads.
|
||||||
|
There are only 4 template definitions in the entire library. (`Array<Type>`, `Hashtable<Type>`, `swap<Type>`, and `AST/Code::cast<Type>`)
|
||||||
|
|
||||||
A `natvis` and `natstepfilter` are provided in the scripts directory.
|
A `natvis` and `natstepfilter` are provided in the scripts directory.
|
||||||
|
|
||||||
@ -133,19 +135,20 @@ Code header = parse_struct( code(
|
|||||||
### Untyped
|
### Untyped
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
Code header = untyped_str( code(
|
Code header = code_str(
|
||||||
struct ArrayHeader
|
struct ArrayHeader
|
||||||
{
|
{
|
||||||
uw Num;
|
uw Num;
|
||||||
uw Capacity;
|
uw Capacity;
|
||||||
allocator Allocator;
|
allocator Allocator;
|
||||||
};
|
};
|
||||||
));
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`name` is a helper macro for providing a string literal with its size, intended for the name parameter of functions.
|
`name` is a helper macro for providing a string literal with its size, intended for the name parameter of functions.
|
||||||
`code` is a helper macro for providing a string literal with its size, but intended for code string parameters.
|
`code` is a helper macro for providing a string literal with its size, but intended for code string parameters.
|
||||||
`args` is a helper macro for providing the number of arguments to varadic constructors.
|
`args` is a helper macro for providing the number of arguments to varadic constructors.
|
||||||
|
`code_str` is a helper macro for writting `untyped_str( code( <content> ))`
|
||||||
|
|
||||||
All three constrcuton interfaces will generate the following C code:
|
All three constrcuton interfaces will generate the following C code:
|
||||||
|
|
||||||
@ -164,6 +167,8 @@ struct ArrayHeader
|
|||||||
|
|
||||||
An example of building is provided within project, singleheader, and test.
|
An example of building is provided within project, singleheader, and test.
|
||||||
|
|
||||||
|
(All generated files go to a corresponding `*/gen` directory)
|
||||||
|
|
||||||
**Project**
|
**Project**
|
||||||
|
|
||||||
`gen.bootstrap.cpp` generates a segmented version of the library following a more traditional cpp convention.
|
`gen.bootstrap.cpp` generates a segmented version of the library following a more traditional cpp convention.
|
||||||
@ -171,7 +176,7 @@ With the exception that: *The component hpp and cpp files are all included into
|
|||||||
|
|
||||||
**Singleheader**
|
**Singleheader**
|
||||||
|
|
||||||
`gen.singleheader.cpp` generated a single-header version of the library following the convention shown in popular libraries such as: gb, stb, and zpl.
|
`gen.singleheader.cpp` generates a single-header version of the library following the convention shown in popular libraries such as: gb, stb, and zpl.
|
||||||
|
|
||||||
**Test**
|
**Test**
|
||||||
|
|
||||||
@ -285,12 +290,12 @@ The width dictates how much the static array can hold before it must give way to
|
|||||||
constexpr static
|
constexpr static
|
||||||
uw ArrSpecs_Cap =
|
uw ArrSpecs_Cap =
|
||||||
(
|
(
|
||||||
AST_POD_Size
|
AST_POD_Size
|
||||||
- sizeof(AST*) * 3
|
- sizeof(AST*) * 3
|
||||||
- sizeof(StringCached)
|
- sizeof(StringCached)
|
||||||
- sizeof(CodeT)
|
- sizeof(CodeT)
|
||||||
- sizeof(ModuleFlag)
|
- sizeof(ModuleFlag)
|
||||||
- sizeof(s32)
|
- sizeof(s32)
|
||||||
)
|
)
|
||||||
/ sizeof(SpecifierT) -1; // -1 for 4 extra bytes (Odd num of AST*)
|
/ sizeof(SpecifierT) -1; // -1 for 4 extra bytes (Odd num of AST*)
|
||||||
```
|
```
|
||||||
@ -330,6 +335,8 @@ Two generic templated containers are used throughout the library:
|
|||||||
|
|
||||||
Both Code and AST definitions have a `template< class Type> Code/AST cast()`. Its just an alternative way to explicitly cast to each other.
|
Both Code and AST definitions have a `template< class Type> Code/AST cast()`. Its just an alternative way to explicitly cast to each other.
|
||||||
|
|
||||||
|
`template< class Type> swap( Type& a, Type& b)` is used over a macro.
|
||||||
|
|
||||||
Otherwise the library is free of any templates.
|
Otherwise the library is free of any templates.
|
||||||
|
|
||||||
The following CodeTypes are used which the user may optionally use strong typing with if they enable: `GEN_ENFORCE_STRONG_CODE_TYPES`
|
The following CodeTypes are used which the user may optionally use strong typing with if they enable: `GEN_ENFORCE_STRONG_CODE_TYPES`
|
||||||
@ -704,7 +711,8 @@ Names or Content fields are interned strings and thus showed be cached using `ge
|
|||||||
|
|
||||||
`def_operator` is the most sophisticated constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid.
|
`def_operator` is the most sophisticated constructor as it has multiple permutations of definitions that could be created that are not trivial to determine if valid.
|
||||||
|
|
||||||
If extendeding parsing capability, ECode, ESpecifier, may need to be modified along with making a new `AST_<Name>` and `Code<Name>` if its desired to preserve the same interface. The lexer (see the `Parser` namespace in `gen.cpp`) will most likely also need to be extended to support any unsupported or custom tokens.
|
The library has its code segmented into component files, use it to help create a derived version without needing to have to rewrite a generated file directly or build on top of the header via composition or inheritance.
|
||||||
|
When the scanner is implemented, this will be even easier to customize.
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
@ -720,7 +728,7 @@ If extendeding parsing capability, ECode, ESpecifier, may need to be modified al
|
|||||||
* It would allow me to remove the filesystem dependencies and related functions outside of gen base headers. ( At least 1k loc reduced )
|
* It would allow me to remove the filesystem dependencies and related functions outside of gen base headers. ( At least 1k loc reduced )
|
||||||
* ADT and the CSV parser depend on it as well. The `str_fmt_file` related functions do as well but they can be ommited.
|
* ADT and the CSV parser depend on it as well. The `str_fmt_file` related functions do as well but they can be ommited.
|
||||||
* Scanner and editor will also depend on it so they would need to include w/e the depency header for all three file-interacting interfaces.
|
* Scanner and editor will also depend on it so they would need to include w/e the depency header for all three file-interacting interfaces.
|
||||||
* `gen.dep.files.hpp`
|
* `gen.files_handling.hpp`
|
||||||
* Convert GlobalAllocator to a slab allocator:
|
* Convert GlobalAllocator to a slab allocator:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Documentation
|
# Documentation
|
||||||
|
|
||||||
The core library is contained within `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>` )
|
Things related to the editor and scanner are in their own respective files. (Ex: `gen.scanner.<hpp/cpp>` )
|
||||||
|
|
||||||
Dependencies are within `gen.dep.<hpp/cpp>`
|
Dependencies are within `gen.dep.<hpp/cpp>`
|
||||||
@ -8,11 +8,12 @@ Dependencies are within `gen.dep.<hpp/cpp>`
|
|||||||
The library is fragmented into a series of headers and sources files meant to be scanned in and then generated to a tailored format for the target
|
The library is fragmented into a series of headers and sources files meant to be scanned in and then generated to a tailored format for the target
|
||||||
`gen` files.
|
`gen` files.
|
||||||
|
|
||||||
Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.
|
Both libraries use *pre-generated* (self-hosting I guess) version of the library to then generate the latest version of itself.
|
||||||
(sort of a verification that the generated version is equivalent)
|
(sort of a verification that the generated version is equivalent)
|
||||||
|
|
||||||
The default `gen.bootstrap.cpp` located in the project folder is meant to be produce a standard segmeneted library, where the components of the library
|
The default `gen.bootstrap.cpp` located in the project folder is meant to be produce a standard segmeneted library (WIP), where the components of the library
|
||||||
have relatively dedicated header and source files. With dependencies included at the top of the file and each header starting with a pragma once.
|
have relatively dedicated header and source files. With dependencies included at the top of the file and each header starting with a pragma once.
|
||||||
|
This will overwrite the existing library implementation in the immediate directory.
|
||||||
|
|
||||||
Use those to get a general idea of how to make your own tailored version.
|
Use those to get a general idea of how to make your own tailored version.
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ int gen_main()
|
|||||||
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
||||||
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
||||||
|
|
||||||
gen_header.open( "gencpp.hpp" );
|
gen_header.open( "gen/gen.hpp" );
|
||||||
gen_header.print_fmt("#pragma once\n\n");
|
gen_header.print_fmt("#pragma once\n\n");
|
||||||
gen_header.print( push_ignores );
|
gen_header.print( push_ignores );
|
||||||
gen_header.print( header_start );
|
gen_header.print( header_start );
|
||||||
|
@ -16,6 +16,7 @@ foreach ( $arg in $args )
|
|||||||
$path_root = git rev-parse --show-toplevel
|
$path_root = git rev-parse --show-toplevel
|
||||||
$path_project = Join-Path $path_root project
|
$path_project = Join-Path $path_root project
|
||||||
$path_project_build = Join-Path $path_project build
|
$path_project_build = Join-Path $path_project build
|
||||||
|
$path_project_gen = Join-Path $path_project gen
|
||||||
|
|
||||||
write-host "`n`nBuilding gencpp bootstrap`n"
|
write-host "`n`nBuilding gencpp bootstrap`n"
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ Push-Location $path_root
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
Push-location $path_project
|
Push-location $path_project
|
||||||
|
if ( -not(Test-Path($path_project_gen) )) {
|
||||||
|
New-Item -ItemType Directory -Path $path_project_gen
|
||||||
|
}
|
||||||
|
|
||||||
# Run meta-program
|
# Run meta-program
|
||||||
$gencpp_bootstrap = Join-Path $path_project_build gencpp_bootstrap.exe
|
$gencpp_bootstrap = Join-Path $path_project_build gencpp_bootstrap.exe
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ $path_gen_build = Join-Path $path_gen build
|
|||||||
$path_test_build = Join-Path $path_test build
|
$path_test_build = Join-Path $path_test build
|
||||||
$path_project_build = Join-Path $path_project build
|
$path_project_build = Join-Path $path_project build
|
||||||
$path_singleheader_build = Join-Path $path_singleheader build
|
$path_singleheader_build = Join-Path $path_singleheader build
|
||||||
|
$path_project_gen = Join-Path $path_project gen
|
||||||
|
$path_singleheader_gen = Join-Path $path_singleheader gen
|
||||||
|
|
||||||
if ( Test-Path $path_project_build)
|
if ( Test-Path $path_project_build)
|
||||||
{
|
{
|
||||||
@ -28,17 +30,17 @@ if ( Test-Path $path_gen_build )
|
|||||||
Remove-Item $path_gen_build -Recurse
|
Remove-Item $path_gen_build -Recurse
|
||||||
}
|
}
|
||||||
|
|
||||||
[string[]] $include = 'gencpp.hpp', 'gencpp.cpp'
|
[string[]] $include = 'gen.hpp', 'gen.cpp'
|
||||||
[string[]] $exclude =
|
[string[]] $exclude =
|
||||||
|
|
||||||
$files = Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude
|
$files = Get-ChildItem -Recurse -Path $path_project_gen -Include $include -Exclude $exclude
|
||||||
|
|
||||||
if ( $files )
|
if ( $files )
|
||||||
{
|
{
|
||||||
Remove-Item $files
|
Remove-Item $files
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = Get-ChildItem -Recurse -Path $path_singleheader -Include $include -Exclude $exclude
|
$files = Get-ChildItem -Recurse -Path $path_singleheader_gen -Include $include -Exclude $exclude
|
||||||
|
|
||||||
if ( $files )
|
if ( $files )
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@ foreach ( $arg in $args )
|
|||||||
$path_root = git rev-parse --show-toplevel
|
$path_root = git rev-parse --show-toplevel
|
||||||
$path_singleheader = Join-Path $path_root singleheader
|
$path_singleheader = Join-Path $path_root singleheader
|
||||||
$path_singleheader_build = Join-Path $path_singleheader build
|
$path_singleheader_build = Join-Path $path_singleheader build
|
||||||
|
$path_singleheader_gen = Join-Path $path_singleheader gen
|
||||||
|
|
||||||
write-host "`n`nBuilding gencpp bootstrap`n"
|
write-host "`n`nBuilding gencpp bootstrap`n"
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ Push-Location $path_root
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
Push-location $path_singleheader
|
Push-location $path_singleheader
|
||||||
|
if ( -not(Test-Path($path_singleheader_gen) )) {
|
||||||
|
New-Item -ItemType Directory -Path $path_singleheader_gen
|
||||||
|
}
|
||||||
|
|
||||||
# Run meta-program
|
# Run meta-program
|
||||||
$gencpp_singleheader = Join-Path $path_singleheader_build gencpp_singleheader.exe
|
$gencpp_singleheader = Join-Path $path_singleheader_build gencpp_singleheader.exe
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ int gen_main()
|
|||||||
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
||||||
|
|
||||||
Builder gen_header;
|
Builder gen_header;
|
||||||
gen_header.open( "gencpp.hpp" );
|
gen_header.open( "gen/gen.hpp" );
|
||||||
gen_header.print( push_ignores );
|
gen_header.print( push_ignores );
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
|
Loading…
Reference in New Issue
Block a user