glob2-devel
[Top][All Lists]
Advanced

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

Re: Networking (was Re: [glob2-devel] Glob2 salvage proposal)


From: Andrew Sayers
Subject: Re: Networking (was Re: [glob2-devel] Glob2 salvage proposal)
Date: Tue, 25 Oct 2005 17:17:46 +0100
User-agent: Mutt/1.5.11

On Mon, Oct 24, 2005 at 05:38:23PM +0100, Andrew Sayers wrote:
> I said that I was going to have a long think about networking, and here
> are my first ideas:
> 
> *** Synchronisation/portability
> 
> I've not checked that this will work yet, but I think that we can put
> some safeguards in the code to ensure that only portable code is used.
> My current plan is to do this by requiring every Glob2 class to be
> declared inside the "Glob2" namespace (which is only good practice
> anyway).  Then we can define:
> 
> namespace Glob2
> {
>       typedef int nonportable_int;
>       typedef void int;
>       // same thing for short, long, signed and unsigned ints, floats
>       // and doubles
> 
>       Uint32 rand() { return syncRand(); };
>       Uint32 random() { return syncRand(); };
> }
> 
> These would have to be put in a standard header that all files include -
> I'm thinking of using <GAGSys.h> - what is its current job, and could it
> stand to be included in every file?
> 

I've checked, and I can't find any clean way of redefining ints without
breaking lots of standard headers.  How about we require all Glob2 code
to be in the "Glob2" namespace, and all code that is not intended to be
run synchronously to be in the "Glob2::nonportable" namespace?  Then we
can add the following to our standard header:

#include <SDL_types.h> // Sint8, Uint32 etc.
namespace Glob2
{

        Uint32 rand() { return syncRand(); };
        Uint32 random() { return rand(); };

        namespace nonportable
        {
                typedef signed int Sint;
                typedef unsigned int Uint;
                typedef signed short int SintS;
                typedef unsigned short int UintS;
                typedef signed long int SintL;
                typedef unsigned long int UintL;
                typedef signed long long SintLL;
                typedef unsigned long long UintLL;
                typedef float Sfloat;
                typedef double SfloatL;
                typedef long double SfloatLL;
        }
}

Then, we can simply search the code base for all instances of " int ",
" float " etc. to find non-portable code.

        - Andrew




reply via email to

[Prev in Thread] Current Thread [Next in Thread]