From: Rick M. <obj...@gm...> - 2008-07-27 22:36:30
|
It was actually less code than the worst-case example you gave that convinced me to do it :-) Rick On Sun, Jul 27, 2008 at 6:35 PM, Mark Miesfeld <mie...@gm...> wrote: > That was quick. I went out to mow the lawn, came back and its done. <grin> > > -- > Mark Miesfeld > > On Sun, Jul 27, 2008 at 2:43 PM, Rick McGuire <obj...@gm...> wrote: >> Ok, this is in. Pretty easy to add, actually. >> >> Rick >> >> On Sun, Jul 27, 2008 at 5:00 PM, Mark Miesfeld <mie...@gm...> wrote: >>> On Sun, Jul 27, 2008 at 1:35 PM, Rick McGuire <obj...@gm...> wrote: >>>> Mark's recent questions about his RECT class sort of triggered a >>>> thought ... >>> >>>> 2) An ObjectToCSelf() API that can extract the CSELF information for >>>> another object would allow objects primarily implemented as native >>>> code to operate together better. This will return NULL if not CSELF >>>> variable is found in any scope of the instance. >>> >>> So with the above ObjectToCSelf(), instead of doing this: >>> >>> bool rxGetRect(RexxMethodContext *context, RexxObjectPtr r, int >>> argPos, RECT *rect) >>> { >>> RexxClassObject RectClass = context->FindContextClass("RECT"); >>> if ( ! context->IsInstanceOf(r, RectClass) ) >>> { >>> goto errReturn; >>> } >>> >>> RexxObjectPtr i = context->SendMessage0(r, "LEFT"); >>> if ( i == NULLOBJECT || ! context->IsInteger(i) ) >>> { >>> goto errReturn; >>> } >>> context->ObjectToNumber(i, &rect->left); >>> >>> i = context->SendMessage0(r, "TOP"); >>> if ( i == NULLOBJECT || ! context->IsInteger(i) ) >>> { >>> goto errReturn; >>> } >>> context->ObjectToNumber(i, &rect->top ); >>> >>> i = context->SendMessage0(r, "RIGHT"); >>> if ( i == NULLOBJECT || ! context->IsInteger(i) ) >>> { >>> goto errReturn; >>> } >>> context->ObjectToNumber(i, &rect->right); >>> >>> i = context->SendMessage0(r, "BOTTOM"); >>> if ( i == NULLOBJECT || ! context->IsInteger(i) ) >>> { >>> goto errReturn; >>> } >>> context->ObjectToNumber(i, &rect->bottom); >>> >>> /* Should we enforce positive numbers? >>> if ( (rect->right >= rect->left) && (rect->bottom >= rect->top) ) >>> { >>> return true; >>> } >>> */ >>> return true; >>> >>> errReturn: >>> >>> char buf[256]; >>> _snprintf(buf, sizeof(buf), >>> "Method argument %d requires a .RECT object with indexes >>> 'left', 'top', 'right, and 'bottom'", argPos); >>> >>> context->RaiseException1(Rexx_Error_Incorrect_method_user_defined, >>> context->NewStringFromAsciiz(buf)); >>> return false; >>> } >>> >>> I could do something like this: >>> >>> RECT *rxGetRect(RexxMethodContext *context, RexxObjectPtr r, int argPos) >>> { >>> RECT *pRect; >>> >>> RexxClassObject RectClass = context->FindContextClass("RECT"); >>> if ( ! context->IsInstanceOf(r, RectClass) ) >>> { >>> // raise exception >>> } >>> >>> pRect = (RECT *)context->ObjectToCSelf(r); >>> >>> // Let the caller worry about NULL >>> return pRect; >>> } >>> >>> Based on the above, adding ObjectToCSelf() would get my vote. <grin> >>> >>> -- >>> Mark Miesfeld >>> >>> ------------------------------------------------------------------------- >>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >>> Build the coolest Linux based applications with Moblin SDK & win great prizes >>> Grand prize is a trip for two to an Open Source event anywhere in the world >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>> _______________________________________________ >>> Oorexx-devel mailing list >>> Oor...@li... >>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel >>> >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Oorexx-devel mailing list >> Oor...@li... >> https://lists.sourceforge.net/lists/listinfo/oorexx-devel >> > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Oorexx-devel mailing list > Oor...@li... > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > |