|
From: Nikita Z. <coo...@ma...> - 2018-03-07 14:41:17
|
Hello. I'm writing gnuplot plugin, which allowes gnuplot to guide qalculate. https://github.com/nick87720z/gnuplot-qalc-plugin I have question about some mean of variadic function arguments or as alternative - generating of gnuplot functions by plugin with arbitrary name/args. And second - about plugin finalization by gnuplot_fini(). However, i have trouble due to lack of any mean to have variadic arguments - neither by itself, not by array argument. I is not problem, to return value with type DATABLOCK. But if i try to use array of values - i get "unsupported array operation" error in both when i create "array arr = [.......]" and try to run some function with it, or when for experiment i tried to return ARRAY, filling it for test with INTGR values. Why i search for variadic arguments: in my plugin are functions - to load function via text formula (takes name and expression str arguments), delete (by name), list (using fictive argument, as gnuplot doesn't allow to create functions with void arguments) and execute functions... this is what i'm about. Exec function actually takes two parameters: - name_or_id (accepts both string and position in list, which should be got for that) - numeric argument. For now, due to disluck, it supports only single arguments. Even without variadic arguments - would be enough to have ability to just generate gnuplot function - so, that if i run (for example): gnuplot> qalc_hyperbola = qalc_ufunc_new('qalc_hyperbola', '1/x') ...it could be called by just (lvalue has only name, without (x,y,etc)). gnuplot> print qalc_hyperbola(4.5) # or gnuplot> plot qalc_hyperbola(x) And another question: example plugin declares gnuplot_init() and gnuplot_fini(), but doesn't define. I copied declaration without change and defined both, but only gnuplot_init() is called automatically. As for fini(), i had to add exported qalc_fini(), which should be run by command before to quit gnuplot. Source file external.c has mention about argument, which gnuplot_init() gets, that it should be freed later. I added it to qalc_fini() - is it right usage? (i remember, i had buch if memory leaks from gnuplot side, might be due to this) |