[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Portable Code (am I dreaming? :))
From:       "Gerke Kok" <gerke.kok () tpa-nl ! com>
Date:       2002-01-24 11:24:24
[Download RAW message or body]

Hi,
you all get me so confused. Wy do you need to write binary to a stream. I thought all \
koffice apps are using XML as the standard output format. And any other files will be \
standard formats any way. So you will have to create those objects in the given way. \
And if you need your own objects (new objects other than PGN/TIFF/what ever) you use \
XML... Just my two cents (or what ever they are called with the silly Euro... :-) )
wkr,
Gerke Kok


*********** REPLY SEPARATOR  ***********

On 24/01/02 at 22:22 Clarence Dang wrote:

> On Wed, 23 Jan 2002 13:39, shaheed wrote:
> > Clarence,
> > 3. Don't worry about the direction of bit shifts for the reason Nicolas
> > gave, and don't worry about the performance of bit shifts since the
> > compiler will almost certainly put the original value in a register.
> 
> It's not the performance of bit shifts that I'm worried about but it's the
> overhead of function calls.
> e.g. if I had:
> 
> class SOME_IMPORTANT_STRUCTURE
> {
> public:
> 	short a;
> 	char b;
> 	long c;
> }
> 
> Currently, I can just make one function call (fread) and read in the whole
> structure.
> But if I'm going to make it portable, I would have to make 3 function
> calls (to read in a, then b, then c).
> Imagine a structure with 15 variables :(
> n number of function calls (even inline ones) cannot beat 1 function call
> in terms of speed (n > 1).
> But I guess this is unavoidable anyway.
> 
> btw, If I write "fread (buffer, 4, 1, filepointer)", will this always read
> in a long int "correctly" or will I get endian issues?
> And also, what is the difference between:
> 
> fread (buffer, 4, 1, filepointer);
> fread (buffer, 2, 2, filepointer);
> fread (buffer, 1, 4, filepointer);
> 
> Are they all the same or can they give different output?
> 
> > The
> > current msword code does some of this, and a typical routine looks like
> > this:
> > 
> > unsigned MsWordGenerated::read(const U8 *in, __UNAL SHD *out, unsigned
> > count) {
> > U32 shifterU32;
> > U16 shifterU16;
> > U8 shifterU8;
> > U8 *ptr;
> > unsigned bytes = 0;
> > 
> > ptr = (U8 *)out;
> > shifterU32 = shifterU16 = shifterU8 = 0;
> > for (unsigned i = 0; i < count; i++)
> > {
> > bytes += read(in + bytes, &shifterU16);
> > out->icoFore = shifterU16;
> > shifterU16 >>= 5;
> > out->icoBack = shifterU16;
> > shifterU16 >>= 5;
> > out->ipat = shifterU16;
> > shifterU16 >>= 6;
> > out++;
> > }
> > return bytes;
> > } // SHD
> > 
> > Note that the _UNAL will disappear as soon as I get round to eliminating
> a
> > few sizeof()s used by the current code. In the example, I have an
> > overloaded read() function for the different primitive types.
> > 
> Can all the packing/alignment business be avoided if I get rid of sizeof()s
> and instead have #define <structure name>_SIZEOF everywhere instead?
> 
> > Finally, if you can, I heartily recommend a code generator...that way, if
> > you get the implementation wrong, you can at least change it.
> > 
> A code generator?  Do you mean generating data structures from a data
> format specification automatically?
> Or do you mean something else?  I mean a code generator sounds like a
> great way to reduce work :)
> 
> Thanks!
> Clarence
> 
> _______________________________________________
> koffice-devel mailing list
> koffice-devel@mail.kde.org
> http://mail.kde.org/mailman/listinfo/koffice-devel



_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic