How to read an entire list using memcpy?

Started by ale870, May 02, 2012, 02:40:17 PM

Previous topic - Next topic

ale870

Hello,

I need to read/write newlisp lists using an external program (like dll), so since I don't want to pass back and forth an entire list, can I read it using memcpy or similar?

I already read/write strings  and numbers (float and int) but lists....



Thank you!
--

HPW

#1
Hello,



Not sure waht you want to do in your DLL, but (source ..)+(eval-string ..) would be an option.



Hans-Peter
Hans-Peter

ale870

#2
Ok, I'm sorry, I did not post a good question :-)



I use newLisp as a DLL, and my program access to newLisp functionalities with such DLL.



My application does this:



1) My app Starts (!)

2) Open newLisp DLL

3) My app send a newlisp script to DLL

4) My app recall a newlisp function

5) This newlisp function fills a global variable (let's say, for example:  (setq myVar ("a" "b" "c")   )

6) Now I need to read that var myVar from My app.

7) The problem is myVar contains a list, so I need to access to list as a whole, since I don't want to access, from MyVar, to MyVar elements one by one. In order to improve performance I wish to get a reference to MyVar, then I need to access to list elements from MyVar (without newlisp intervention). So I need to access to newLisp memory using memcpy or similar.



Thank you  for your help!
--

HPW

#3
Hello,



I my understanding newlisp stores your list in several lisp-cells(connected via pointers).

So there is no linear memory stream which you can read easily.



So maybe a custom lisp-function can flatten it to a big string using a delimiter,

and you read this and parse it in MyApp back.



Or a lisp-function use a callback to set an array in MyApp for each list-element.



Just some thoughts.



Hans-Peter
Hans-Peter