Deprecated functions in reaction_macros.h

Have a question about our Software Developer Kit? Ask them here.
Post Reply
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Deprecated functions in reaction_macros.h

Post by trixie »

Although the Autodocs specifically mention that functions like CHECKBOX_GetClass() or GETFILE_GetClass() are deprecated as of V52, the reaction_macros.h include file still contains many object macro definitions using these obsolete functions instead of the public class ID.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Deprecated functions in reaction_macros.h

Post by broadblues »

Your right they do, I've made a note in bugzilla bug #7108
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

Re: Deprecated functions in reaction_macros.h

Post by ssolie »

trixie wrote:Although the Autodocs specifically mention that functions like CHECKBOX_GetClass() or GETFILE_GetClass() are deprecated as of V52, the reaction_macros.h include file still contains many object macro definitions using these obsolete functions instead of the public class ID.
If it was my personal choice I would abolish those macros entirely. I know some think it makes their code more readable or whatever but I found in practice it just hides nasty bugs especially in any sizable project. The names are far too generic and easily clash. We inherited the code so I suppose we are stuck with it now but I would love to just deprecate the entire macro mess.

I would also like to point out that you should be using IIntuition->OpenClass() and IIntuition->CloseClass() exclusively when loading/unloading BOOPSI classes. The only time you do not need these functions is when accessing classes already loaded into RAM (e.g. intuition.library) in which case you access them via their class name.
ExecSG Team Lead
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: Deprecated functions in reaction_macros.h

Post by trixie »

ssolie wrote:I would also like to point out that you should be using IIntuition->OpenClass() and IIntuition->CloseClass() exclusively when loading/unloading BOOPSI classes.
The autodoc for OpenClass() says: "Use of this function can eliminate the need for getting the class interface ..." I'm slightly puzzled by this "CAN eliminate". So DOES it eliminate GetInterface() or not?
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Deprecated functions in reaction_macros.h

Post by broadblues »

The autodoc for OpenClass() says: "Use of this function can eliminate the need for getting the class interface ..." I'm slightly puzzled by this "CAN eliminate". So DOES it eliminate GetInterface() or not?
If all you need from the interface is the #?_GetClass() function then yes it eleiminates the need for that.

Some gadget inetrfaces have more functions than that tough, so in those cases you might need to get the inetface as well.

An example of the latter would be listbrowser.gadget it has quite a few functiosn for allocating and editiong nodes columns etc.
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: Deprecated functions in reaction_macros.h

Post by trixie »

broadblues wrote:Some gadget inetrfaces have more functions than that tough, so in those cases you might need to get the inetface as well.
I see, so whenever I want to call IListBrowser->AllocListBrowserNode() or similar functions, I do need to GetInterface() first. OK, that makes good sense.

To sum it up, in order to open a ReAction class and create an object from it, I need to declare as many as four variables:

Code: Select all

struct ClassLibrary *MyClassBase;  /* the class library base pointer */
struct MyClassIFace *IMyClass;  /* the class interface pointer */
Class *MyClass;  /* the class pointer */
Object *MyObject;  /* the object pointer */
I then call OpenClass():

Code: Select all

MyClassBase = IExec->OpenClass("classname", version, &MyClass);
Open the interface:

Code: Select all

IMyClass = IExec->GetInterface( (struct Library *) MyClassBase, "main", 1L, NULL);
And finally create the object like this:

Code: Select all

MyObject = IIntuition->NewObject(MyClass, NULL, tags ...);
No need for the macros now :-)
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Post Reply