MakeID

This forum is for general developer support questions.
Post Reply
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 5:47 pm
Contact:

MakeID

Post by JosDuchIt »

I found a definition of the MakeID macro here http://www.martinreddy.net/gfx/2d/IFF.txt

#define MakeID(a,b,c,d) ( (a)<<<<24 | (b)<<<<16 | (c)<<<<8 | (d) )

I am a bit closer to understanding its use (although i don't understand the macro itself)

In the Gui4CLI (source) file i find a large number of such defines and two of them are pointing to the same definition.
#define LVFILTER MakeID('L','V','F','I') //
#define LVFILL MakeID('L','V','F','I') // def=ON - Draw a box under short lvs


The second seems to be effective
The first one which is used to filter out files (eg .info) in directory listviews does not.

My first impression was some kind of interference.
Can i disregard this as a cause?




The file in which i find these is Glob_Attr.h
======= extracts Glob_Attr.h ==============

// ############# private
// contains defines for gadget Attributes, INFO & SET commands

// Listview attributes
#define LVFILTER MakeID('L','V','F','I') //

// TextIn attributes
....

// Sound effect
#define SOUND MakeID('S','O','U','N') // sound Alias

// SET command keywords
#define LVFILL MakeID('L','V','F','I') // def=ON - Draw a box under short lvs
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: MakeID

Post by nbache »

MakeID is simply a tool to create a 32-bit number consisting of the four 8-bit values corresponding to the ASCII values of your four letters, each taking up their own 8 bits of the number.

The << operators are binary shifts, i.e. the "move" the 8 bits of the value the specified number of bits to the left in the 32-bit value, until each of them ends up in their designated 8-bit part of the 32-bit number.

It might be easier to look at the 32-bit number in hexadecimal, as that will show as 4 pairs of hex digits, each pair corresponding to one of the original letters.

But the sole purpose is to have a "pretty" way to define some 32-bit number which acts as an ID for something (e.g. a chunk ID in an IFF file or a gadget ID or whatever you need to identify).

Hope this helped rather than confuse more ;-).

About the two IDs consisting of the same letters; this is likely to be a mistake, at least it results in having two symbolic names for the same ID (LVFT), which doesn't strike me as particularly useful. It might of course be some attempt to avoid changing references in the program, if e.g. two objects were merged into one at some point in time. But that would be a bit messy.


Best regards,

Niels
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1479
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: MakeID

Post by tonyw »

"MakeID" sounds like a home-brewed version. The original is in include/libraries/iffparse.h:


#define MAKE_ID(a,b,c,d) \
((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))

It's used throughout all the Prefs editors and anything else that uses IFF.
cheers
tony
Post Reply