Page 1 of 1

Deprecated functions in reaction_macros.h

Posted: Thu Jun 30, 2011 4:43 pm
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.

Re: Deprecated functions in reaction_macros.h

Posted: Thu Jun 30, 2011 8:28 pm
by broadblues
Your right they do, I've made a note in bugzilla bug #7108

Re: Deprecated functions in reaction_macros.h

Posted: Thu Jun 30, 2011 8:50 pm
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.

Re: Deprecated functions in reaction_macros.h

Posted: Fri Jul 01, 2011 8:43 am
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?

Re: Deprecated functions in reaction_macros.h

Posted: Fri Jul 01, 2011 10:17 am
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.

Re: Deprecated functions in reaction_macros.h

Posted: Fri Jul 01, 2011 10:58 am
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 :-)