gencpp/project
Ed_ 1c133bfc8d Massive total progress on c_library generation: (Summary of last 3 WIP commits)
- No longer using GEN_API_C_* macros as C-library wont need them and if you need C linkage there is no need to use the c++ library.
- GEN_C_LIKE_CPP replaces GEN_SUPPORT_CPP_MEMBER_FEATURES && GEN_SUPPORT_CPP_REFERENCES
  a. If users don't want to use member functions, function overloading, or referencese they can just this one macro to before including the library.
- Enums aren't accomodated in C++ sources, they entirely converted in c_libray.cpp
- ast.hpp now properly generates with C variant
- Fully prepared code_types.hpp for C library gen (not tested yet)
- Generated enums managed by helper.hpp now properly generate for C library.
2024-12-07 17:58:56 -05:00
..
auxillary DId a pass on ast.hpp, types.hpp and helper.hpp for C compatability (unfortuantely clang-format doesn't like my enum macro... 2024-12-06 05:29:17 -05:00
components Massive total progress on c_library generation: (Summary of last 3 WIP commits) 2024-12-07 17:58:56 -05:00
dependencies Massive total progress on c_library generation: (Summary of last 3 WIP commits) 2024-12-07 17:58:56 -05:00
enums WIP: Broken af 2024-12-07 17:17:02 -05:00
helpers Massive total progress on c_library generation: (Summary of last 3 WIP commits) 2024-12-07 17:58:56 -05:00
bootstrap.cpp WIP: Broken af 2024-12-07 17:17:02 -05:00
gen.cpp First compiling version of operator overloading for C! (on both msvc and clang using -std=c11 flag, using _Generic selection with some helper macros) 2024-12-05 17:04:17 -05:00
gen.dep.cpp Runtime fixed 2023-08-21 22:48:05 -04:00
gen.dep.hpp gencpp : General refactors to dependencies 2024-10-27 18:58:37 -04:00
gen.hpp First compiling version of operator overloading for C! (on both msvc and clang using -std=c11 flag, using _Generic selection with some helper macros) 2024-12-05 17:04:17 -05:00
Readme.md Progresss 2024-12-01 21:59:43 -05:00

Documentation

The library is fragmented into a series of headers and source files meant to be scanned in and then generated to a tailored format for the target gen files.

The principal (user) files are gen.hpp and gen.cpp.
They contain includes for its various components: components/<component_name>.<hpp/cpp>

Dependencies are bundled into gen.dep.<hpp/cpp>.
Just like the gen.<hpp/cpp> they include their components: dependencies/<dependency_name>.<hpp/cpp>

Code not making up the core library is located in auxiliary/<auxiliary_name>.<hpp/cpp>. These are optional extensions or tools for the library.

Both libraries use pre-generated (self-hosting I guess) version of the library to then generate the latest version of itself.

The default gen.bootstrap.cpp located in the project folder is meant to be produce a standard segmented library, where the components of the library
have relatively dedicated header and source files. Dependencies included at the top of the file and each header starting with a pragma once.
The output will be in the project/gen directory (if the directory does not exist, it will create it).

Use those to get a general idea of how to make your own tailored version.

Feature Macros:

  • GEN_DEFINE_ATTRIBUTE_TOKENS : Allows user to define their own attribute macros for use in parsing.
    • This is auto-generated if using the bootstrap or single-header generation
    • Note: The user will use the AttributeTokens.csv when the library is fully self-hosting.
  • GEN_DEFINE_LIBRARY_CORE_CONSTANTS : Optional typename codes as they are non-standard to C/C++ and not necessary to library usage
  • GEN_DONT_ENFORCE_GEN_TIME_GUARD : By default, the library ( gen.hpp/ gen.cpp ) expects the macro GEN_TIME to be defined, this disables that.
  • GEN_ENFORCE_STRONG_CODE_TYPES : Enforces casts to filtered code types.
  • GEN_EXPOSE_BACKEND : Will expose symbols meant for internal use only.
  • GEN_ROLL_OWN_DEPENDENCIES : Optional override so that user may define the dependencies themselves.
  • GEN_DONT_ALLOW_INVALID_CODE (Not implemented yet) : Will fail when an invalid code is constructed, parsed, or serialized.

By default the base library implementation strictly uses a C-like interface. This is to allow for the generation of a C-variant of the library using gen_c_library. However, the library was written in C++ and supports some of its features:

  • GEN_SUPPORT_CPP_REFERENCES : Will enable support for reference interface on some definitions
  • GEN_SUPPORT_CPP_MEMBER_FEATURES : Will enable support for definitions to have their interface as members.

Note: A variant of the C++ library could be generated where those additonal support features are removed (see gen_c_library implementation for an idea of how)

On multi-threading

Currently unsupported. I want the library to be stable and correct, with the addition of exhausting all basic single-threaded optimizations before I consider multi-threading.

Extending the library

This library is relatively very small, and can be extended without much hassle.

The convention you'll see used throughout the interface of the library is as follows:

  1. Check name or parameters to make sure they are valid for the construction requested
  2. Create a code object using make_code.
  3. Populate immediate fields (Name, Type, ModuleFlags, etc)
  4. Populate sub-entires using add_entry. If using the default serialization function to_string, follow the order at which entires are expected to appear (there is a strong ordering expected).

Names or Content fields are interned strings and thus showed be cached using get_cached_string if its desired to preserve that behavior.

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.

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.

The parser is documented under docs/Parsing.md and docs/Parser_Algo.md.

A note on compilation and runtime generation speed

The library is designed to be fast to compile and generate code at runtime as fast as resonable possible on a debug build. Its recommended that your metaprogam be compiled using a single translation unit (unity build).