RE: Different DLL wrapping question(s)

new topic     » topic index » view thread      » older message » newer message

>From: ags <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Different DLL wrapping question(s)
>Date: Mon, 24 Oct 2005 16:41:01 -0700
>
>posted by: ags <eu at 531pi.co.nz>
>
>Hi All
>
>I'm about 70% through wrapping ming.dll (the SWF output library
>("gee I hope that hasn't been done already" :)) and am a bit stuck on what
>to do about FILE * pointers.
>

  I was going to...but luckily, I haven't done much of it at all.

>There is only one place so far where that needs to be done 
>(loadSWFFontFromFile)
>but that's a fairly important routine IMHO.
>
>So what to the rest of you dll wrapping guru's recommend?  The exact C 
>header
>is:
>
>SWFFont loadSWFFontFromFile(FILE *file);
>
>Should I allocate a chunk of memory sizeof(struct FILE) and poke the file 
>number
>into it?  Or would that mess with the whole purpose of the FILE struct?
>

  Definitely not the way a FILE structure works. They are meant to be 
transparent. You are not supposed to know about the contents, just the 
pointer.

>Should I write an fopen.dll and wrap fopen()? smile
>

Too many DLL's if you ask me. And sharing CRT info between DLL's is a pain. 
Better to leave it as one.

>BTW I hope Euphoria's open() returns the actual OS file number?  In other
>functions someone kindly provided file descriptor versions as well...
>

   No, I don't believe they are. That's why we're limited to something like 
23 open files.


What I did (in gd, for example) is export the fopen and fclose functions in 
the DLL (ming.dll in your case). Then you just import the two functions and 
use them like this:

global function loadSWFFontFromFile(sequence file)
atom lpf, fp, ret
lpf = allocate_string(file)
fp = c_func(fopen, {lpf})
free(lpf)
ret = c_func(cloadSWFFontFromFile, {fp})
VOID = c_proc(fclose, {fp})
	return ret
end function

This does not work, of course, if loadSWFFontFromFile is an incremental 
function, ie it needs the file to be open while doing work on it. In that 
case, you'd probably need to save the FILE pointer and fclose if when 
necessary (or maybe forget about it, there aren't any limits to open files 
that I know of like in Eu).

>ags
>

~[ WingZone ]~
http://wingzone.tripod.com/

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu