NAME
CodeGen::Cpppp - The C Perl-Powered Pre-Processor
VERSION
version 0.001_02
SYNOPSIS
Does that mean it's more powerful? ...Is it more powerful?
Well, it's one layer of abstraction higher, isn't it? It's not m4
. You see, most blokes gonna be templating with cpp
or m4
, you're on m4
here all the way up, all the way up, Where can you go from there? Where?
Nowhere! Exactly.
What we do is if we need that extra, push, over the cliff, you know what we do?
perl
, exactly.
These go to perl
.
Input:
#! /usr/bin/env cpppp
## for (my $bits= 8; $bits <= 32; $bits <<= 1) {
struct tree_node_$bits {
uint${bits}_t left: ${{$bits-1}},
color: 1,
right: ${{$bits-1}};
};
## }
Output:
struct tree_node_8 {
uint8_t left: 7,
right: 7,
color: 1;
};
struct tree_node_16 {
uint16_t left: 15,
right: 15,
color: 1;
};
struct tree_node_32 {
uint32_t left: 31,
right: 31,
color: 1;
};
DESCRIPTION
WARNING: this API is complete and totally unstable.
This module is a preprocessor for C,
If you have an interest in this, contact me, because I could use help brainstorming ideas about how to accommodate the most possibilities, here.
Possibilities:
Scan existing headers to discover available macros, structs, and functions on the host.
Pass a list of headers through the real cpp and analyze the macro output.
Shell out to a compiler to find 'sizeof' information for structs.
CONSTRUCTOR
Bare-bones for now, it accepts whatever hash values you hand to it.
METHODS
compile_template
$cpppp->compile_template($input_fh, $filename);
$cpppp->compile_template(\$scalar_tpl, $filename, $line_offset);
This reads the input file handle (or scalar-ref) and builds a perl subroutine out of it, then evals that subroutine so it is ready to run (and spits out any compile errors in the template).
render
$cpppp->render();
Execute the template previously compiled. Passing arguments to this template is a TODO item.
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2023 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 361:
You forgot a '=back' before '=head1'