Deprecated functions in reaction_macros.h

Have a question about our Software Developer Kit? Ask them here.

Deprecated functions in reaction_macros.h

Postby trixie » Thu Jun 30, 2011 5:43 pm

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.
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Deprecated functions in reaction_macros.h

Postby broadblues » Thu Jun 30, 2011 9:28 pm

Your right they do, I've made a note in bugzilla bug #7108
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 484
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Deprecated functions in reaction_macros.h

Postby ssolie » Thu Jun 30, 2011 9:50 pm

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.
AmigaOS Development Team Lead
Be authentic. Get AmigaOS.
User avatar
ssolie
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 1000
Joined: Mon Dec 20, 2010 9:51 pm
Location: Canada

Re: Deprecated functions in reaction_macros.h

Postby trixie » Fri Jul 01, 2011 9:43 am

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?
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Deprecated functions in reaction_macros.h

Postby broadblues » Fri Jul 01, 2011 11:17 am

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
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 484
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Deprecated functions in reaction_macros.h

Postby trixie » Fri Jul 01, 2011 11:58 am

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 :-)
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic


Return to SDK Support

Who is online

Users browsing this forum: No registered users and 3 guests