[Scummvm-devel] Splitting common/util.h -> engines/util.h, maybe splitting common

Max Horn max at quendi.de
Thu Jun 16 15:40:48 CEST 2011


Hi folks,

this email is about reviewing and revising our file hierarchy and where we put things. Maybe we should even add some dirs or move others around...

You see, my personal vision is that common/ should contain:
* glue code between backends and frontends (such as FSNode, error/warning, Archive, ...)
* generic data structures (Array, List, HashMap, ... but also Rational, Rect, ...)
* algorithms 
* code that can be used by backends, engines, GUI, base, such as the XML parser, zlib wrapper, ...

Everything else is a bit dubious, in my eyes at least. If it is used by several main level "directories", then it may have some justification in there, but should be carefully reviewed.

Now look at common/util.h. These days it contains tons of stuff -- and most of it is only interesting for engines (and on some cases for the GUI / command  line code). I am talking about things like platform & language keys, render modes and GUI options.

Wouldn't it make more sense to have this in a engines/util.h header instead? In particular, this way backends code that just wants e.g. the ARRAYSIZE macro wouldn't have to see all this stuff. Nor would adding, say, a new platform, require recompiling the backend. One could argue that this should be in common/ since engines/, gui/ and base/ use some of these. Then again, these are all highly game/engine specific structs and functions, so they are similar to say engines/game.h and engines/savestate.h.

If I hear no objections (or alternatives), I'd like to perform this move someday soon.


Going beyond this, there is now quite some more code in common/ which I wonder about:

(1) dcl.* -> used only by engines/
(2) serializer.h -> used only by engines/ -- and by its unit tests
(3) macresman.* -> used by engines/ plus common/quicktime.cpp
(4) winexe*  -> used by engines/ and graphics/ (for Windows cursor/font support)
(5) quicktime.* -> used only by audio/ (though I guess the plan is to use it from video/ eventually, too?)


For 1 & 2, they seem to clearly belong into engines/ , unless I am missing something.

Then there are 3 and 4, both are about accessing files in a certain "encoding". So is  5, quicktime.cpp. So is common/iff_container.* (which I did not list because so many main level dirs use it). 

These are all files that are of interest for multiple modules, but *only* for frontend modules. They all are about certain decoding certain (file) formats. They are relatively generic for that. Maybe it's time for another module? Either a top-level one ("formats/" ? "decoders/" ? ), or one below common/ ("common/formats/" ? "common/decoders" ?) ?

Note that more stuff could be put in there, if viewed from this angle: E.g. the XML parser, the config-file.* code, even unarj.* and unzip.* (the latter is, like the XML parser, also used by backend code).


Thoughts, opinions, outcries, silence?


Bye,
Max



More information about the Scummvm-devel mailing list