[python-win32] returning from pyCOM-Servers

Lebkov Lebkov@iso.debryansk.ru
Thu, 10 Jan 2002 14:02:16 +0300


Hello All,
Can somebody explain to me, why Pythoncom puts value returned from
COM-server's method into first BYREF argument when COM-client intends simply
to ignore this value?

Consider simple COM-server:

class TestCom:
    _public_methods_ = ["test"]
    _reg_clsid_ = '{2af38090-05ac-11d6-9aad-0050da397eca}'
    _reg_progid_ = 'Python.SimpleServer'
    def test(self, n):
        return n*n

And then call TestCom.test from VBScript:
set x = CreateObject("Python.SimpleServer")
n = 2
x.test n ' We do not want to store x anywhere,
but after that call x will contain 4!!

If we want to change the value of BYREF arguments, then we can do it
explicitly:
    def test(self, n):
        return (n*n, 5)
For what the implicit variant is necessary?

I suppose, would be correctly to ignore value returned from test( or skip
first element of a tuple (if value  - tuple)) when
pVarResult == NULL (in PyGatewayBase::Invoke), because:
1) Inside TestCom.test we do not know whether pVarResult is NULL and we can
not change returned value depending on this condition
2) Other COM-clients can pass argument n BYVAL, for instance Javascript:
o = new ActiveXObject("Python.SimpleServer");
var n = 2;
o.test(n);
n is still equal 2 because it was passed BYVAL.

What you think of it?

Thanks,
    
-Victor