[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading the PakCompiler source.




Ok, I'm writing this message as I browse the source, so excuse
me if it is a bit incoherent.


---------------------------------------------------------------
1) (trivial) PakCompiler.cc
>	if (!PcOptions.StringValue ("--vendorid").empty ())
>			VendorID = PcOptions.StringValue ("--vendorid");

Dunno about you but I'd do something like:

  if ( !(str_val = PcOptions.StringValue("--vendorid")).empty() )
        VendorID = str_val;

Or for the purists

  str_val = PcOptions.StringValue("--vendorid");
  if(! str_val.empty() ) VendorID = str_val;


----------------------------------------------------------------
2)(trivial) OutPakFile.cc
	// Stub functions needed for correct template instantiation
	ppOutPakFile &_writeintint8 (int Val, streamsize num=1)
	{ return WriteInt8 (Val, num);}

	ppOutPakFile &_writeuintint8 (unsigned int Val, streamsize num=1)
	{ return WriteInt8 (Val, num);}

	ppOutPakFile &_writelongint8 (long Val, streamsize num=1)
	{ return WriteInt8 (Val, num);}

	ppOutPakFile &_writeulongint8 (unsigned long Val, streamsize num=1)
	{ return WriteInt8 (Val, num);}

        .
        .
        .

The thing is, I can't for the life of me figure out what these
members are actually for.  Template instantiation you say?
How exactly.  I'm srue there is a reason, its just beyond me,
this is the problem with C++.


----------------------------------------------------------------
3)


>	// "allocate" enough space for the entire dir structure
>	Target.WriteInt8 (0, StructSize ());
>	Target.seekp (position);

???  A bit dodgy isn't it?  from reading that, it seems
it would be OK to just write straight out to Target.
If not, Target, should export and allocate() method.
Either way this doesn't seem necassary.




>	// Directory Entries -- 1st step: entries representing files
>	for (FI = files.begin () ; FI != files.end () ; FI++)
>		(*FI)->WriteDirEntry (Target);
>
>	// Directory Entries -- 2nd step: entries representing subdirs
>	for (DI = directories.begin () ; DI != directories.end () ; DI++)
>		(*DI)->WriteDirEntry (Target);

Why are files and subdirs different?  Is there some PakFile format
thing saying that directories must come after files?  Otherwise
the whole point of polymorphism is that you shouldn't be doing
this sort of thing.


----------------------------------------------------------------
4) GetDirInfo.c

First, why did you write it in C?  (Other than "because
I can").

Next, that GetEntryXXXX interface is worryingly stateful.






Hmm, well I think thats about all I found.  Bye.