Skip to main content

C/C++ code generation framework

Project description

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;
};

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccg-0.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

ccg-0.1.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file ccg-0.1.0.tar.gz.

File metadata

  • Download URL: ccg-0.1.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ccg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03150f58dca262bf5c0e166ae3e35c6ddcb6429dbbf6876b66151920c5d9a770
MD5 d6fc528e5961bd5eaaf362c05471ba42
BLAKE2b-256 9e8cde715ba45e09aa6b8d53345627e842f847b93fde7a0eac7204d8c6837c81

See more details on using hashes here.

File details

Details for the file ccg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ccg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for ccg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29ff49e7b2de75d216a5f80f16076c7aa6f7170d345168bf157f724dfecbd5b8
MD5 a71a96a6d72dcf5f28d80521b605ba81
BLAKE2b-256 bc1a97b7127c29d6779bedac28bd628263f3adf4e74b686c986ee31ba9b4f97f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page