11cint4:

Now let's add a second TEFEL tool (but a very simple one): generating all
the signature flag variables in a package source file is obviously a pain,
is tremendously error prone, and breaks the DRY principle.

We can't help but notice that all the information is present in the
package source file, contained (of course) in each package function we declare.

So instead, let's autogenerate them from marked up package files.  Instead
of writing pkg1.c in plain C, let's replace it with pkg1.pkg as
follows:

/*
 *	pkg1: a collection of C functions, that may accidentally satisfy
 *	      one or more interfaces that don't yet exist..
 */

#include <stdio.h>
#include <stdlib.h>

%func int pkg1_f1( void )
{
	printf( "pkg1::f1\n" );
}

%func int pkg1_f2( void )
{
	printf( "pkg1::f2, returning 1\n" );
	return 1;
}

%func void pkg1_f3( char *s, int x )
{
	printf( "pkg1::f3, s='%s', x=%d\n", s, x );
}

%func void *pkg1_f4( int n )
{
	printf( "pkg1::f4, x=%d, returning NULL\n", n );
	return NULL;
}

Now our goal becomes: implement a small companion TEFEL tool called "cpkg"
which reads the .pkg file as shown above, and translates each %func entry
to plain C, adding the corresponding flag variable as it goes.  At some
time, either at beginning or end, cpkg will also emit the "useflagvars"
meta-flag variable itself.

You will of course notice that our %func syntax above is EXACTLY THE SAME
as we used in the .interface files - and hence the new cpkg tool can use
all the TEFEL infrastructure that we painstakingly built up for cint.

In particular it uses the unmodified Support.pm parsing module, and the
unmodified Sig.pm signature module, and cpkg itself is basically a cloned
and simplified version of cint.  cpkg only produces a .c file, so we remove
the code that writes out a .h file.

The main change is that all the results of handle_line() are accumulated in
a $text Perl string and written out to the .c file at the end.

Several data structures are no longer needed, so are removed.

Most of cint's code generation logic (functions makestruct(), makebind(),
c_preamble() and makebindbody()) are removed.

Within handle_line(), for every parsed %func line, we generate the signature
immediately, and then run the following action code:

	print "debug: found func $origline with sig $sig\n";

	my $name = $funcname;
	$name =~ s/^${package}_//;	# remove the package name
	my $sigvar = "${package}_${name}_${sig}";

	my $text = "char $sigvar;\t// $funcname signature variable:\n".
		   "$origline\t// $funcname function:\n";
	return $text;

Right at the end, we add the "useflagvars" flag as follows:

	$text .= "\nchar ${package}_useflagvars;          // check the existence of the flag variables\n";

cpkg is only 108 lines long, considerably less than half of the length
of cint.
