Skip to main content

CCG.

CCG is a C/C++ code generation framework for python. It encapsulates the language syntax and grammar with python objects to be able to manipulate them more easily and generate code automatically, with a configurable style.

This library will be the developer's friend for code generation applications. It can be the language abstraction layer for any code generation project for C/C++. It won't do anything that couldn't be done manipulating strings but the code written with it will be easier to write and understand and the style of the generated code won't be embedded in the application, leaving the option to the developer to pass all the style choices to the end user without any effort.

Documentation

https://ccg.readthedocs.io/

Quick Demonstration

Declare an C/C++ object, for instance, a function:

f = CFunction(
        name="examplefun",
        return_type=Cuint32,
        static=True,
        arguments=[
            CFunction.Argument(name="first", c_type=Cuint32, doc=Doc("First argument")),
            CFunction.Argument(name="second", c_type=Cdouble, default=CLiteral(2), doc=Doc("Second Argument"))
        ],
        doc=Doc("Awesome function", "This function is awesome because it does marvellous things",
                ret="returns a lucky number"),
        content=CStatements([
            CVariable("local_var", Cint8).declare()
        ])
)

Modify the default style and add your own choices:

my_style = Style()
my_style.function_bracket.new_line_open_before = False

Print the declaration:

print(f.declare().render(my_style))
/**
* @brief Awesome function
*
* This function is awesome because it does marvellous things
* @param first First argument
* @param second Second Argument
* @return returns a lucky number
*/
static uint32_t 
examplefun(uint32_t first, double second = 2);

And print the definition:

print(f.define().render(my_style))
uint32_t examplefun(uint32_t first, double second){
	int8_t local_var;
};

Release files for ccg 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ccg 0.1.0
File Size Uploaded
ccg-0.1.0.tar.gz 22.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ccg 0.1.0
File Interpreter ABI Platform
ccg-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.4 kB

Release files / ccg-0.1.0.tar.gz

Download URL ccg-0.1.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03150f58dca262bf5c0e166ae3e35c6ddcb6429dbbf6876b66151920c5d9a770
BLAKE2b-256 checksum
How to use checksums
9e8cde715ba45e09aa6b8d53345627e842f847b93fde7a0eac7204d8c6837c81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5

Release files / ccg-0.1.0-py3-none-any.whl

Download URL ccg-0.1.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29ff49e7b2de75d216a5f80f16076c7aa6f7170d345168bf157f724dfecbd5b8
BLAKE2b-256 checksum
How to use checksums
bc1a97b7127c29d6779bedac28bd628263f3adf4e74b686c986ee31ba9b4f97f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page