From: Ethan A M. <eam...@gm...> - 2018-03-09 04:23:13
|
On Friday, 09 March 2018 02:22:10 Nikita Zlobin via gnuplot-info wrote: > Somehow discussion moved out of mailing list. Last time i got email > without any field like to or cc, containing mailing list address. And > replied out of it without carry (it was automatically set _to_ to > sfeam's email). > > In Wed, 07 Mar 2018 16:40:45 -0800 > sfeam <eam...@gm...> wrote: > > Given the current implementation, it is not possible to return an > > array from an expression. The closest I can see is to pass an array > > in and replace the individual entries. Because it is passed by > > reference, the changes will be visible to the rest of the program. > > Of course you must free any strings or datablocks before your replace > > them. > The biggest trouble is lack of any doc about api, even in headers (that > was heppy to find mention in external.c, that object, passed to > gnuplot_init must be freed, and i did it in fini func, i still don't > get crash due to double free, which would likely happen, be i > misunderstood. I sympathize with the lack of documentation. There is never enough :-) Up until now the primary use of the plugin mechanism was to allow gnuplot to call into existing 3rd-party math libraries. It's great that you are interested in doing something entirely different, but so far as I know you are the first person to try it. So you get to be the guinea pig. Also there isn't much of documentation on how to do it because, well, you are the first to try it. Your suggestions and questions have already been useful. For example the project probably should put more thought into what headers, example source files, documentation, or additional tools might go into a "developer's package". Where a particular distribution might choose to install these is another question, but that's for them to decide. > due to lack of api doc - how value array defines its end? > Whilc for datasetarray it is NULL-terminated pointers array, for array > of struct value's it would be something else. Is it INVALID_VALUE? Each user variable is described by a structure (eval.h) /* user-defined variable table entry */ typedef struct udvt_entry { struct udvt_entry *next_udv; /* pointer to next value in linked list */ char *udv_name; /* name of this value entry */ t_value udv_value; /* value it has */ } udvt_entry; This structure holds the variable's name and its current value. The value is held in a structure (gp_types.h) typedef struct value { enum DATA_TYPES type; union { intgr_t int_val; struct cmplx cmplx_val; char *string_val; char **data_array; struct value *value_array; } v; } t_value; In the case of an array variable type = ARRAY value_array[0].int_val = size_of_array and value_array is allocated to hold (size_of_array + 1) values, each of which may be INTGR, CMPLX, or STRING Ethan |