>>>That [out] has now become an __in because the caller allocates the buffer.
> 
>> If you are *implementing* this method - is there a problem at all?
>> The caller HAS already allocated the buffer, you only have to fill it.
>> Anyway, if you have special requirements that can not be fullfilled by
>> the 'high level' method implementation then you should use the 'low level'
>> implementation; I have posted several times about them.
> 
> Yes, I'am implementing the event handler, and yes, as I tried to
> explain in the previous mail there is a problem as there is a mismatch
> between "reality" and the comtypes generated prototype.
> 
> The argument is specified as [out] -as data is flowing from the
> implementation (callee) to the caller.  That means for the
> (high-level) comtypes: the buffer never reaches my implementation of
> the event handler.
> 
> As the buffer is preallocated by the caller that should really be
> interpreted as an [in] argument.
> 
> I guess then, there is nothing else to do but to modify the generated
> file, or use the low-level stuff (but i really like high level...
> -That's why I used Python in the first place :) )
> 

IMO the difference between low level and high level, when *implementing*
a COM method, is not so large.  In my own experience from working with
a lot of com objects implemented in comtypes, sometimes the first is more
convenient, sometimes the latter.  Consider this implementation for a
fairly normal method:

IDL:  HRESULT my_method([in] int a, [in] int b, [out, retval] int *presult)

low level impl:

   def my_method(self, this, a, b, presult):
      if not presult: return E_POINTER # optional, check for NULL pointer
      presult[0] = a + b               # store the result
      return S_OK                      # return success

high level impl:

    def my_method(self, a, b):
       return a + b

Surely the high level impl is a lot more Pythonic, but low level one should be
easy to understand as well.  When you want to check argument values, and return
error codes depending on them (assuming the method should return the quotient
of the two numbers), you would write code like this:

low level impl:

    def my_method(self, this, a, b, presult):
      if not presult: return E_POINTER # optional, check for NULL pointer
      if b == 0:                       # check for valid values
        return E_INVALIDARG
      presult[0] = a / b               # store the result
      return S_OK                      # return success

high level impl:

    def my_method(self, a, b):
        if b == 0:
            raise ReturnHRESULT(E_INVALIDARG)
        return a / b

In this case it is not so clear to me which way to prefer.
But I should really write the docs for that...

Anyway, I understand that you don't like to use the low level impl,
but you can live with that?

Thomas


-------------------------------------------------------------------------
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=/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to