[Open-scap] python - oval_results_model_new takes double pointer

Maros Barabas mbarabas at redhat.com
Mon Jan 4 16:39:00 UTC 2010


Hi Ed,

    on the first look this could seems like a SWIG problem as is described 
here: 
http://old.nabble.com/SWIG,-c%2B%2B-to-Python:-array-of-pointers-(double-
pointer)-not-working-tt22511211.html#a22511211 
and here:
http://old.nabble.com/c%2B%2B-extension,-problem-passing-argument-
tt22500889.html#a22511046

but I think that expected behavior is clearly wrong. If you will take a look 
on the code of *oval_results_model_new* function, it takes *array* of 
*oval_syschar_model* not the doubled pointer to a structure so behavior of 
this exception is good and it should not allow you to pass only one model.

On the other hand, there is currently no way how to define array of such 
structures in python, cause there is no support for translating lists or 
tuples to array of pointers in SWIG and it has to be done by typemaps 
mechanism so you're right that we have no way how to call this function now 
and we need to use typemaps or make functions to handle syschar model arrays. 

I found more these problems in our library and I'm working on solution by 
typemaps transformations right now as mentioned above.

Thank for you email, I will try to fix it soon !

Regards,
Maros Barabas


On Tuesday 22 December 2009 18:17:19 Ed wrote:
> The second argument in "oval_results_model_new" takes a double pointer
> to a oval_syschar_model. I see how you handle this in the example
> code, line 56-57 (array oval_syschar_model pointers). A python list
> does not account for the same structure.
> 
> >> openscap.oval_results_model_new(defmodel, syschars)
> 
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
> TypeError: in method 'oval_results_model_new', argument 2 of type
> 'struct oval_syschar_model **'
> 
> (Attached is the python example)
> 
> What would be the correct way for python to satisfy the double pointer
> in a list?
> 
> Would this require a typemap in the openscap.i file?
> 
> Thanks for your help!!
> 
> 
> ~Ed
> 




More information about the Open-scap-list mailing list