Re: [comtypes-users] comtypes and safearray of structs as out parameter

2009-09-09 Thread Eduardo Arias
 thanks for the detailed analysis and the clear explanation.  I've been
looking
 at the code and probably have another, even better, approach.
 
 The missing 'extra' parameter in the create(cls, value, extra=None)
implementaition
 in comtypes\safearray.py, line 62, that you retrieve from the 'value'
parameter
 is defined in an outer scope of this method, in line 44 in the enclosing
 '_make_safearray_type' function.  So it seems the easiest way to pass this
parameter
 to 'create(...)' is this simple patch:
 
 (...)

I've tried your approach and it works. You're right, your solution is
better, I did not see that the extra variable was bound in the
_make_safearray_type closure.

 This patch also has the advantage that you not only can pass a sequence
 of 'Pair' structures, in your case, as return value from your
ITest_Test(...)
 method, but you can also return simply a sequence of tuples like so:
 
  def ITest_Test(self, in, out):
return [(u'1', u'2'), (u'2', u'3')]

Right, that's how I wanted to write the return value originally, but because
I thought I needed to get a value for extra somehow, I had to return a list
of Pair instances.

Saludos,


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] comtypes and safearray of structs as out parameter

2009-09-09 Thread Thomas Heller
 So it seems the easiest way to pass this
 parameter
 to 'create(...)' is this simple patch:
 
 (...)
 
 I've tried your approach and it works. You're right, your solution is
 better, I did not see that the extra variable was bound in the
 _make_safearray_type closure.

Ok, I'll commit it into the repository and add some unittests for it.

  PS: Thinking about the code I'm wondering why I didn't use the outer
 definition
  of 'extra' in the create(...) method directly instead of passing it as a
 parameter...
 
 That could be another solution, to remove the 'extra' parameter from create
 (though I don't know whether someone may already be using it and this could
 break that code). Another one could be renaming the 'extra' parameter in
 create, and assign the bound 'extra' variable if None is provided as an
 argument (or filled in by the default value).

I'll leave this as it is to not break existing code.

-- 
Thanks,
Thomas


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users