Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: callbacks

From: gregg:pointillistic at: 1-Nov-2007 10:11

Hi Max, I did something similar a few years ago. Not callback related, but filling a struct with data allocated by an API (IIRC). get-dereferenced-data: func [ {Given a pointer to memory, copy the target data into a REBOL struct.} pointer [struct!] "LPINT structure whose /value is the data pointer" struct-def [block!] "The struct you want returned with data" /local struct data orig-pointer result ] [ struct: make struct! compose/deep/only [ ; make wrapper struct sub [struct! (struct-def)] ] none orig-pointer: third struct ; store original inner pointer change third struct third pointer ; change inner pointer to ref'd data data: copy third struct/sub ; copy data from the inner struct change third struct orig-pointer ; restore inner pointer result: make struct! struct-def none ; make result struct change third result data ; change data in result struct struct: data: orig-pointer: none result ] -- Gregg