Sharing typedefs between templates and scripts

I have a lot of simple (that is, non-structured) typedefs where each is derived ultimately from a built-in type, but with a kind of specialization reminiscent of inheritance in object-oriented languages:

For example (not one I really use), this one makes it easy to declare unsigned int-sized variables or structure fields that will display as hex in the Template Results.

typedef unsigned int hexUint <format=hex>;

A simplification of one’ve tried:

typedef byte bool < read=boolAsString >;
string boolAsString( bool &b )
{
	if ( b == 0 ) return "false";
	if ( b == 1) return "true";
	return Str( "0x%02X", b );
}

Since I have a good number of such definitions, it’s convenient to place them in an “include” file for easy re-use.

However, this doesn’t work well if I include that file in a template for a specific kind of file, and also in a script for that type of file, and run them against the same file.

(I’m running short of time and will add or improve my example later, if you can’t already explain why this might not work, or can’t reproduce it.)

If you run a template on a data file, and then run a script on the same data file, the script should automatically be able to access all the types defined in the template (using #include in the script is not necessary). If you have a case where this is not working properly, can you provide us with some sample code?

Graeme
SweetScape Software

As I’ve dug further into the problems that led me to post this, I’ve found several unclear aspects of the interaction between a script and a template (when running on the same file).

I will likely be submitting some more posts about each of these, as I separate them out and explore each of them.

So let’s just wrap up this thread.

P.S. Just curious: as the forum is currently set up, the “tag” field for new topics isn’t usable. Do you anticipate allowing forum topics to use tags eventually?

Related post: Curious, and new feature idea: "Watching" a type has unexpected result