returning from pyCOM Servers

Lebkov Lebkov at iso.debryansk.ru
Fri Jan 18 01:31:37 EST 2002


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?

I'll be happy to listen any ideas.

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 way 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 return value depending on this condition
2) In TestCom.test we do not know how the arguments will be passed (BYREF or
BYVAL). 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 do you think about it?

Thanks,
    
-Victor





More information about the Python-list mailing list