From f63bc1dc8c7732fb44ff4a781b249accbee809a3 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 19 Sep 2006 16:40:42 +0000 Subject: [PATCH] 2006-09-19 18:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexprb.c * harbour/source/vm/hvm.c + added support to compiler for sending messages with multi parameters resolved by macro operator: s:="1,2,3"; o:msg(&s) It works just like for functions and it also needs XBASE extension support enabled during compilation, -kx switch in compiler, it's enabled by default. * harbour/source/rdd/usrrdd/usrrdd.c ! added missing DBOI_* index in parameters passed to user ORDINFO() method. --- harbour/ChangeLog | 13 ++++++ harbour/include/hbexprb.c | 63 ++++++++++++++++++++++-------- harbour/source/rdd/usrrdd/usrrdd.c | 3 +- harbour/source/vm/hvm.c | 1 + 4 files changed, 62 insertions(+), 18 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 52d26d38e8..e6290400f0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ + arguments are passed ( HB_APARAMS() == HB_APARAMS(0) ) + + SYNTAX for variable number of parameters + 1) [FUNCTION|PROCEDURE] name( ... ) + or + 2) [FUNCTION|PROCEDURE] name( var1, var2, varN, ... ) + + To access passed parameters use the following: + PCOUNT() - returns number of passed parameters + HB_PVALUE( iParamNum ) - returns parameter + HB_APARAMS() - returns array with all passed parameters + or usual name of parameter variable in case of syntax 2) + 2006-09-19 18:40 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbexprb.c diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index 35446f1875..b4cf5ae2f3 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -1657,22 +1657,22 @@ static HB_EXPR_FUNC( hb_compExprUseFunCall ) if( ( strcmp( "AT", pName->value.asSymbol ) == 0 ) && usCount == 2 ) { - hb_compExprReduceAT( pSelf, HB_MACRO_PARAM ); + hb_compExprReduceAT( pSelf, HB_MACRO_PARAM ); + } + else if( ( strcmp( "CHR", pName->value.asSymbol ) == 0 ) && usCount ) + { + hb_compExprReduceCHR( pSelf, HB_MACRO_PARAM ); + } + else if( ( strcmp( "LEN", pName->value.asSymbol ) == 0 ) && usCount ) + { + if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) + hb_compExprReduceLEN( pSelf, HB_MACRO_PARAM ); + } + else if( ( strcmp( "ASC", pName->value.asSymbol ) == 0 ) && usCount ) + { + if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) + hb_compExprReduceASC( pSelf, HB_MACRO_PARAM ); } - else if( ( strcmp( "CHR", pName->value.asSymbol ) == 0 ) && usCount ) - { - hb_compExprReduceCHR( pSelf, HB_MACRO_PARAM ); - } - else if( ( strcmp( "LEN", pName->value.asSymbol ) == 0 ) && usCount ) - { - if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) - hb_compExprReduceLEN( pSelf, HB_MACRO_PARAM ); - } - else if( ( strcmp( "ASC", pName->value.asSymbol ) == 0 ) && usCount ) - { - if( HB_COMP_ISSUPPORTED(HB_COMPFLAG_HARBOUR) ) - hb_compExprReduceASC( pSelf, HB_MACRO_PARAM ); - } } } break; @@ -2197,6 +2197,7 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) if( pSelf->value.asMessage.pParms ) /* Is it a method call ? */ { + BOOL fMacroList = FALSE; int iParms = hb_compExprListLen( pSelf->value.asMessage.pParms ); HB_EXPR_PCODE2( hb_compGenMessage, pSelf->value.asMessage.szMessage, bIsObject ); if( bIsObject ) @@ -2210,9 +2211,37 @@ static HB_EXPR_FUNC( hb_compExprUseSend ) if( iParms == 1 && pSelf->value.asMessage.pParms->value.asList.pExprList->ExprType == HB_ET_NONE ) --iParms; if( iParms ) - HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); + { + if( HB_SUPPORT_XBASE ) + { + /* check if ¯o is used as a function call argument */ + HB_EXPR_PTR pExpr = pSelf->value.asMessage.pParms->value.asList.pExprList; + while( pExpr ) + { + if( pExpr->ExprType == HB_ET_MACRO ) + { + /* ¯o was passed - handle it differently then in a normal statement */ + pExpr->value.asMacro.SubType |= HB_ET_MACRO_LIST; + pExpr->value.asMacro.pFunCall = pSelf; + fMacroList = TRUE; + } + pExpr = pExpr->pNext; + } + } + if( fMacroList ) + { + pSelf->value.asMessage.pParms->ExprType = HB_ET_MACROARGLIST; + iParms = hb_compExprMacroListLen( pSelf->value.asMessage.pParms ); + HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); + pSelf->value.asMessage.pParms->ExprType = HB_ET_ARGLIST; + } + else + HB_EXPR_USE( pSelf->value.asMessage.pParms, HB_EA_PUSH_PCODE ); + } - if( iParms > 255 ) + if( fMacroList ) + HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_MACROSEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ), ( BOOL ) 1 ); + else if( iParms > 255 ) HB_EXPR_GENPCODE3( hb_compGenPCode3, HB_P_SEND, HB_LOBYTE( iParms ), HB_HIBYTE( iParms ), ( BOOL ) 1 ); else HB_EXPR_GENPCODE2( hb_compGenPCode2, HB_P_SENDSHORT, ( BYTE ) iParms, ( BOOL ) 1 ); diff --git a/harbour/source/rdd/usrrdd/usrrdd.c b/harbour/source/rdd/usrrdd/usrrdd.c index 4add3237f6..c5612ab66c 100644 --- a/harbour/source/rdd/usrrdd/usrrdd.c +++ b/harbour/source/rdd/usrrdd/usrrdd.c @@ -2241,8 +2241,9 @@ static ERRCODE hb_usrOrderInfo( AREAP pArea, USHORT uiIndex, LPDBORDERINFO pOrde pItem = hb_usrOrderInfoToItem( pOrderInfo ); hb_vmPushInteger( pArea->uiArea ); + hb_vmPushInteger( uiIndex ); hb_vmPush( pItem ); - hb_vmDo( 2 ); + hb_vmDo( 3 ); pResult = hb_arrayGetItemPtr( pItem, UR_ORI_RESULT ); if( pResult && !HB_IS_NIL( pResult ) ) diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index dcf55676e8..34066458c0 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -3912,6 +3912,7 @@ static void hb_vmMacroSend( USHORT uiArgSets ) lArgs = hb_vmArgsJoin( -1, uiArgSets ); hb_stackDecrease( uiArgSets ); hb_vmSend( lArgs ); + hb_stackPushReturn(); } static void hb_vmMacroArrayGen( USHORT uiArgSets )