COM in newLISP

Started by codernwo, November 10, 2007, 01:50:09 AM

Previous topic - Next topic

Lutz

#15
Can you explain in words what you are trying to do? Or explain in terms of 'C' language? It should not be necessary to copy to another address before unpacking:


> (set 'x 0x01020304)
16909060
> (unpack "c" (+ 0 (address x)))
(4)
> (unpack "c" (+ 1 (address x)))
(3)
> (unpack "c" (+ 2 (address x)))
(2)
> (unpack "c" (+ 3 (address x)))
(1)
>


or


> (unpack "c" "01020304")
(1)
> (unpack "d" "01020304")
(513)
> (unpack "ld" "01020304")
(67305985)


Perhaps this can help: http://newlisp.org/CodePatterns.html#extending">http://newlisp.org/CodePatterns.html#extending



Lutz



ps: all examples on little endian CPU architecture

m35

#16
Sorry, I guess I should have explained what I was trying to do.



For get-short, I'm trying to duplicate the behavior of get-int, but I just want 16-bits instead of 32-bits.



For get-single, I'm trying to duplicate the behavior of get-float, but I want a 32-bit floating point number instead of a 64-bit one.



...



And now I read the manual a little closer and it says
Quote(unpack str-format str-addr-packed)



Note that str-addr-packed may also be an integer representing a memory address.


So I guess this should do that I need.
(define (get-short int-address)
    (first (unpack "d" int-address))
)

(define (get-single int-address)
    (first (unpack "f" int-address))
)


Heh, silly me ^^;;

m35

#17
New version fixes memory leak and has the better get-short and get-single functions.



http://www.autohotkey.net/~easycom/winscript.lsp">http://www.autohotkey.net/~easycom/winscript.lsp

Lutz

#18
Thanks Mike, I updated it on http://newlisp.org/modules">http://newlisp.org/modules and also have put a location header pointing to the original. If this is not Ok, let me know.



Lutz

m35

#19
Quote from: "Lutz"put a location header pointing to the original.

No problem Lutz.



I made yet another update to fix another bug.



v0.12

http://www.autohotkey.net/~easycom/winscript.lsp">http://www.autohotkey.net/~easycom/winscript.lsp

m35

#20
In case anyone is actually using the winscript module, a quick warning about the current version (v0.12):



Looking again at winscript.lsp, I see there are a number of memory leaks. These occur in places where a (throw) skips the code to finish the memory handling. The script needs to be corrected with code that would essentially be found in a "finally" block -- releasing temporary memory, and memory that was going to be returned before the error occurred. Of course since there is no finally block, I need to do a partial re-design of the code.



If you're using the module, let me know. It will spur me on to fix this sooner.

pjot

#21
Well I am not using it yet, but I find this idea really useful! In the past I did a lot of things with VBscript, it is cool that it can be embedded in newLisp now.



Peter

SHX

#22
I too have plans aon using this important module.



Steven

m35

#23
winscript v0.20



Memory leaks fixed, and errors better handled. No change to the interface, except added (WINSCRIPT:LastResult) function to get verbose details on errors and internal win32api function results.



http://www.autohotkey.net/~easycom/winscript.lsp">winscript.lsp



I can't say I'm super happy with how the new code design turned out, but it works (I hope). I would like to use a more elegant approach, but nothing has come to me.

m35

#24
winscript v0.21



-Added some missing cleanup if failure during initialization.



http://www.autohotkey.net/~easycom/winscript.lsp">winscript.lsp

m35

#25
winscript v0.22



-Minor documentation improvements.

-Added check at initialization if already initialized.

-Fixed error handling when the error doesn't come from the script control.

-Lots of internal cleaning and commenting.



http://www.autohotkey.net/~easycom/winscript.lsp">winscript.lsp