Using SWIG, dereference a C array pointer to a TCL variable -


the scenario. use software (a) allow me use tcl script (b). since have many operations in b, build c code (c) use via swig , math. now, i'm running in parallel, , i'm able use built-in tcl-functions of send , receive variable of b via mpi. the problem 1 of variables c array.

i know swig interchanges memory address between c , tcl, send computers useless. think have dereference array tcl variable.

could give me idea of how this?

ps: don't know swig.

typemaps way go here. allow provide swig code snippets added top , bottom of wrappers. in other words, can control how parse arguments , how clean once operation complete.

from explanation hard me tell trying achieve. maybe pseudo-code make things clearer. user of swig python , know nothing tcl, try explain how i'd setup.

lets function being wrapped:

double[] foo_c (double bar[], int a_size);

you want return value of function "dereferenced". want function return not-a-pointer. in python, lets want function return python list.

typemap(out) double[] foo_c //signature of function behavior modified {     $result = pylist_new (a_size); //$result swig return     (int i=0; i<a_size; ++i) {         pyobject *o = pyfloat_fromdouble ($1[i]);          //$1 denotes return variable before swig wrapping goodness          pylist_setitem ($result,j,o);     } } 

as can see, of code in c/c++ doesn't matter took python example. need have @ tcl/c api figure out functionality needing purposes.

hope helps!


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -