Return list using SWIG from C to Python -


I have the following functions that I am trying to SWIG-ify:

  Zero GetAttOrder (full node, DCE_ORDER command, float at [3]);  

Which I want to call in Python and access through:

  node = 0; Order = DCD_TYPR; Attitude = GetAttOrder (node, command); Attitude [0] // 45.232  

I first applied the DCE_ORDER type as

  Type Defed Enum {DCD_TPYR = 0, DCD_TYPR, DCD_TYRP, Was there. .. DCD_PRYT} DCE_ORDER;  

I have found some documentation about similar problems, but I have not got any luck to implement any solution. I have also looked at some other stack overflow questions (closed with suspicion), even to no avail. I suspect that I should use a TypeMap here, but when it comes to SWIG I am young and stupid.

Any suggestions or hints?

Many thanks.

After solving it some days, if you have a vector that you want to get away, Some can do:

 % typemap (in, numinputs = 0) float vec3out [3] (float temp [3]) {$ 1 = temporary; }% TypeMap (Argout) Float Wake Out 3 [3] {Int Eye; $ Result = PyList_New (3); {PyObject * o = PyFloat_FromDouble (double) $ 1 [i]) for (i = 0; i & lt; 3; i ++); PyList_SetItem ($ Result, I, O); }}  

And then this function can be accessed via python, as I have requested above, in addition, if you have another function that you want to be a list (function You can use the following code:

 % typemap (in) float vec3in [3] (float temp [3]) {Int i; If (PySequence_Check ($ input)) {PyErr_SetString (PyExc_ValueError, "Expected a Sequence"); Return tap; } If (PySequence_Length ($ input)! = 3) {PyErr_SetString (PyExc_ValueError, "size mismatch 3. expected 3 elements"); Return tap; } (I = 0; i  

which will allow you to pass in a list.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -