Main
AutoGen
Pages
Home
Announce
FAQ
docs
XML Defs
testimonials
downloads
Automated
Options
AutoOpts
Comparison
Man example
Redistribute
Licensing
local use
using getopt
GCC's
Fixincludes
fixincludes
Automated
FSM
description
example
usagefsm
Addons
addon
Autoconf
Config
Tests
create form
M4 Quoting
Automated
XDR
xdr project
After banging my head on a wall with C++ templates and related compiler incompatibilities I found AutoGen. I have done RTFM...but I haven't found a straightforward way to generate combinations/permutations.
An example: implementing routines for graphics composition where parameters can be either bitmaps or constant colors.
process( bitmap*, bitmap*, bitmap*, bitmap* ); // Bitmap only form ... process( color, bitmap*, color, color ); // mixed bitmaps and colors ... process( color, color, color, color ); // all colors
You could do this in the definition file [by laboriously enumerating the various possibilities, but that does not seem to buy you anything.]
Any tips?
AutoGen definitions can derive their string value from the output of a
shell script. Therefore, you can grep and sed
the `configure.ac' file.
`configure' (`configure.ac') is just a shell script, too.
It can run a script whose purpose is to echo out the version,
so both `configure' and AutoGen can easily use
the same script.
You can make an `configure.ac.tpl' template and generate `configure.ac' from AutoGen. This would mean, however, you could not run configure before this.
You can make a `version.def.in' file and create `version.def' when you run configure. Likewise, this would mean you would have to configure the product before generating any files that needed the version from `version.def'.
There is now a sample project, blocksort. This sample integrates the redistributable libopts library source.
For most users, this is likely too much work. For simple, locally built projects, this is likely to be sufficient:
In your project directory create the option definition file:
``projopts.def'', per instructions in the manual.
Add to Makefile.am (or Makefile):
projopts.c projopts.h : opts-stamp opts-stamp : projopts.def autogen projopts.def && touch $@ project.1 : projopts.def autogen -Tagman-cmd.tpl -b project projopts.def projinvoke.texi : projopts.def project autogen -Taginfo.tpl -bprojinvoke -DLEVEL=section projopts.def
And add ``-I${prefix}/include'' to your compiles and ``-L${prefix}/lib -lopts'' to your link, where ``${prefix}'' is the autogen installation prefix.
If you use autoconf and automake, this can be done in an automated fashion. Place the distributed file "autoopts.m4" in your configure directory. In your configure.ac file, invoke the AG_PATH_AUTOOPTS macro. Now back to your Makefile.am. Use the following substitution values for your compile and link commands.
$(AUTOOPTS_CFLAGS) $(AUTOOPTS_LDFLAGS)
--Fumble-bumble --fumble_Bumble --Fumble^BumbleOf course, the leading hyphens must be hyphens.
Because handling it yourself is trivial, handling it in a fully integrated fashion is hard and I don't use floating point myself.
That's the short answer. Here are the details for the first two parts:
Write your own callback routine.
flag = {
name = something;
value = s;
arg-type = string;
arg-name = float;
descrip = "floating point argument";
doc = "Example of an option with a floating point arg.";
flag-code = <<- EOF
extern double val;
sscanf( pOptDesc->pzLastArg, "%f", &val );
if (validations_fail) {
fprintf( stderr, "bad float for 'something'\n" );
USAGE( EXIT_FAILURE );
}
EOF ;
};Provide a patch to extend the arg-type handling. :-)
You would probably need to fiddle with the various opt*.tpl files and the documentation templates (agman-cmd.tpl and agtexi-cmd.tpl) and you would need to add a bit flag to the option descriptor flag bits and worry about how to save the data (save.c) and even how to keep the data (since floating point numbers do not fit in void*/char* buckets).
This would be a fair bit of work, but it would be very nice to have. I don't use floating point myself (or it would already be done). The do-it-yourself solution is pretty easy, but, if you do do this and get it working (or even mostly working), I'll accept the patch and add first-class support for floating point option arguments.
cat > process.tpl <<_EOF_ [+ autogen5 template h +] [+ FOR arg1 in "bitmap*" color \+] [+ FOR arg2 in "bitmap*" color \+] [+ FOR arg3 IN "bitmap*" color +]process( [+arg1+], [+arg2+], [+arg3+] ); [+ ENDFOR \+] [+ ENDFOR \+] [+ ENDFOR \+] _EOF_ autogen -b process --no-defin -Tprocess.tpl
And you wind up with this process.h file:
process( bitmap*, bitmap*, bitmap* ); process( bitmap*, bitmap*, color ); process( bitmap*, color, bitmap* ); process( bitmap*, color, color ); process( color, bitmap*, bitmap* ); process( color, bitmap*, color ); process( color, color, bitmap* ); process( color, color, color );
I'll also take a guess that you would want a similar nested set of loops for the method implementation code that would convert their color args to bit maps and invoke the canonical method:
process(bitmap*, bitmap*, bitmap*)That implementation code can be generated, too.
process(color a, bitmap* b, color c) {
return process( color2bits(a), b, color2bits(c));
}
top Viewable With Any Browser SourceForge Logo Support This Project Valid XHTML 1.0!