- edited description
Passing variable by value
Hi I'm trying to call service program function (MQOPEN) WebSphere MQ API on iSeries. The MQOPEN procedure is defined as
D* MQOPEN Function -- Open Object
D******************************************************
DMQOPEN PR EXTPROC('MQOPEN')
D* Connection handle
D HCONN 10I 0 VALUE
D* Object descriptor
D OBJDSC 468A
D* Options that control the action of MQOPEN
D OPTS 10I 0 VALUE
D* Object handle
D HOBJ 10I 0
D* Completion code
D CMPCOD 10I 0
......
As you can see 1st and 3rd parameters are passed by VALUE.
But the doc says that passing by value is untested and should not be used (I'm using XML -> DB2 connection) I could create an ILE RPG which accepts parameters by reference then call appropriate api with variable passed by value. But I'm wondering if it's possible to fix it ? I was trying to debug plugxml.rpgle and looks like list of parameters pointers were corrupted
// by value argument?
if node.xmlPrmRet = XML_IS_PARM
and node.xmlBy = XML_BY_VAL
and node.xmlCallAs = XML_FUNC_SRVPGM;
pCopy = pArgv; <------------ ?!?!?!?!!
endif;
Regards Sebastian
Comments (6)
-
reporter -
reporter - edited description
-
Account Deleted Yep. Pass by value is not tested. 99.8% of all RPG programs pass by reference, therefore, a place holder was added, but never really tested completely. We will put it on the list.
For now, you are much better off simply staying with pass-by-reference, aka, forget const correctness, nobody does it anyway, except the real geeks. BTW -- you could wrap your API in by refernce and call by value on your own as well.
-
Account Deleted Correct answer: The new version xjservice (json version) plan support 'value' or 'const' (Common 2017).
Hack answer: However, most people do not know that anything > 16 byte 'const' or 'value is actually passed by reference anyway (compiler copy passed by ref). That is to say, xmlservice does not support by value for 1-16 bytes values. Unfortunately any packed or zoned by value will fit in 16 bytes (exotic types by value fit 2 registers <= 16 bytes). While 'glass half full', may help some people with 'value' or 'const' > 16 bytes. See this link Yips value - not what you think.
-
Account Deleted The new version of xmlservice 1.9.9.2 (+), supports pass by value. See the commits for how to use.
-
Account Deleted - changed status to closed
The new version of xmlservice 1.9.9.2 (+), supports pass by value. See the commits for how to use.
- Log in to comment