On 11.07.2024 17:52, Rick McGuire wrote:
I'm going to answer this out of line because I want to answer the last question 
first.

Thank you!


The problem with the compile error results in how RexxActivation is defined in Activity.hpp. It's declaration is just "class RexxActivation", which tells the compiler that RexxActivation is a class...and nothing else. This allows RexxActivation * to be used in prototypes since there is enough information available for that purpose. To get the full definition of RexxActivation, you would need to replace "class RexxActivation" with "#include "RexxActivation.hpp". However, I suspect doing that will result in some circular dependencies between the two header files.

Indeed.


Any you would probably need to define Activity as friend to the RexxActivation class to make that enum visible.

Given the relationship between RexxActivation and Activity, and that both classes need the information, having the enum defined in RexxActivation feels like the wrong place to for that to be located. It feels like it should belong in Activity. However, those values are really only used for things created for RexxActivation.

A better solution would be to refactor the code a bit. Activity::traceOutput() . The first two lines of TraceOutput deal with the creation of the TraceObject, which really should be something that the RexxActivation is responsible for. Move the stuff involved with that to RexxActivation and then only pass the constructed TraceObject to the traceOutput() method which is now just responsible for handling the output. Now there's no need for TracePrefix to be visible outside of RexxActivation.

There are the following places in Activity that cause the use of traceOutput() 
directly and indirectly:

 *

   wholenumber_t Activity::error()

   /** Force error termination on an activity, returning the resulting REXX 
error code.
   * @return The resulting Rexx error code. */

 *

   wholenumber_t Activity::error(ActivationBase *activation, DirectoryClass 
*errorInfo)

   /** Force error termination on an activity, returning the resulting REXX 
error code.
     * @param activation The activation raising the error.
     * @param errorInfo  The directory containing the error condition 
information.
     * @return The Rexx error code.  */

 *

   wholenumber_t Activity::displayCondition(DirectoryClass *errorInfo)

   /** Display error information and traceback lines for a Syntax condition.
     * @param errorInfo The condition object with the error information
     * @return The major error code for the syntax error, if this is  indeed a 
syntax conditon. */

 *

   void Activity::display(DirectoryClass *exobj) ...

   /** Display information from an exception object.  *@param exobj  The 
exception object.  */

 *

   void Activity::displayDebug(DirectoryClass *exobj)

   /** Display information about an error in interactive debug. @param exobj  
The exception  */

What should be done with these?

Oh, and in the process, could you please make CreateTraceObject() into a method of RexxActivation? Doing things via functions really doesn't belong in this code base.

+1

---rony




On Thu, Jul 11, 2024 at 11:24 AM Rony G. Flatscher <[email protected]> 
wrote:

    The enum TracePrefix type gets defined RexxActivation.hpp and is public 
(needs to be used from
    RexxActivation.cpp and Activit.cpp).

    What is the proper way to become able to refer to the enum TracePrefix in 
Activity.hpp and
    Activity.cpp?

    Currently "Activity.hpp" defines the prototype for traceOutput(...) as

        void traceOutput(RexxActivation *, RexxString *, RexxString *, 
RexxObject *, RexxObject *);

    and should be changed to allow for a TracePrefix argument as the third 
argument, hence trying to:

        void traceOutput(RexxActivation *, RexxString *, TracePrefix, 
RexxString *, RexxObject *, RexxObject *);

    If doing so the compiler yields an error "error C2664: ... cannot convert 
argument 3 from
    'RexxActivation::TracePrefix' to 'TracePrefix'".

    Therefore changing the prototype to

          void traceOutput(RexxActivation *, RexxString *, 
RexxActivation::TracePrefix, RexxObject *, RexxObject *, RexxObject *);

    yields the compiler error messages:

        ...\Activity.hpp(210): error C2027: use of undefined type 
'RexxActivation'
        ...\Activity.hpp(73): note: see declaration of 'RexxActivation'

    The type "RexxActivation" can be used in Activity.hpp (defines at the top 
"class
    RexxActivation;") do define prototypes.

    ---

    The question: what needs to be defined where in order to become able to 
reference the enum
    TracePrefix from Activity.hpp and Activity.cpp without an error?

    ---rony

_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to