So I'm currently in the process of migrating a descent sized program from Rebol 3 to Red. Said program relies on a large binding to a C library (clang). I have rewritten the binding portion in Red/System, and am interfacing that code with Red through wrapper routines. The current convention I have been using is to cast the pointers and void pointers needed as parameters and returned by the C code to red/system integers and box them up as Red integers. This is fairly easy and convenient.
Since I can only access the raw integer! data instead of the actual struct, I would suspect then that I can't pass a pointer back out through a parameter (as the boxed data is being copied before being passed) using the above methodology, anymore.
So, is there a recommended methodology to passing pointers back out through parameters, aka how do we pass by reference with routines?
twiddle: routine [
arg [integer!]
return: [integer!]
] [
arg: 321
test: declare struct! [
dummy [integer!]
]
test/dummy: 456
as integer! test
]
a: 123
b: twiddle a
print a ;If I could pass by reference this would be 321
print b