Re: External Interfacing: pointer to pointer...
- From: Bill Schwab <bschwab@xxxxxxxxxxxxx>
- Date: Sat, 11 Oct 2008 10:41:31 -0400
Chris,
I am trying to interface with the winpcap DLL. This function has been driving me crazy:
int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
This is how I have defined it in Smalltalk:
<stdcall: dword pcap_next_ex lpvoid lpvoid* lpvoid*>
I can call it, and I get a return code that indicates success. This is how I am calling it:
header := ExternalAddress new.
data := ExternalAddress new.
wp pcap_next_ex: wph header: header data: data.
The problem I have is getting the data in header and data. This is how I try to get the header data:
[snip]
This is probably one of those situations in which one must out-smart Dolphin's desire to pass by reference. At least I find it easier to assume that than that you have made a mistake elsewhere.
The most recent struggle I recall was in wrapping the GNU Scientific Library. I don't know that I ever figured out why what I finally did works, but it clearly does. Specifically, GSL specifies algorithms (e.g. bisection, Newton-Raphson) by exports from the DLL. I am not sure if they are pointers to data or functions (probably the latter), but getting the correct addresses was tricky. I will take a look at how I solved that and report back later. How much use it will be is in question though; you would probably have to dive into the GSL Win32 source to decide whether it is in fact the same thing.
Another example that comes to mind will be a little harder to track down. I was implementing a COM component that had to pass a pointer on to another COM component, or something like that. Pass by reference really got in the way. IIRC, I had to create an intermediate byte object to allow the VM to strip away the indirection, ending up with the correct value in the receiver. I still suspect that the reference convention prevents more trouble than it causes, but it can be a big pain at times.
The example above will be a little hard to find, as it involves DCOM. Given how long ago I stopped trusting a certain vendor, that goes back more than a few years. I will see what I can do.
Bill
--
Wilhelm K. Schwab, Ph.D.
bills@xxxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: External Interfacing: pointer to pointer...
- From: Christopher J. Demers
- Re: External Interfacing: pointer to pointer...
- References:
- External Interfacing: pointer to pointer...
- From: Christopher J. Demers
- External Interfacing: pointer to pointer...
- Prev by Date: External Interfacing: pointer to pointer...
- Next by Date: object-arts.com is down
- Previous by thread: External Interfacing: pointer to pointer...
- Next by thread: Re: External Interfacing: pointer to pointer...
- Index(es):
Relevant Pages
|