Re: Rob, Gurus, Question for You...

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

Georg Wrede wrote:
> 
> Robert Craig wrote:
> > 
> > cklester wrote:
> > > I wonder if creating a dll with Euphoria code would work...?
> > 
> > You can call Windows .dll's and (Linux/FreeBSD) shared libraries
> > written in Euphoria, from other languages. The only problem is
> > that you are limited to passing integers (31-bit) as arguments,
> 
> Can you explain the reason behind this?
> 
> If this really can't be avoided, then one could use structs to 
> pass other kinds of data? But the addresses may not fit in 31
> bits?

The only bit patterns that Euphoria and the rest of the world
agree on, are the integers from minus one billion (roughly),
to plus one billion. Other values cannot be passed directly from
another language to a Euphoria-coded .dll (or shared library) 
as arguments.
(A Euphoria program can pass *any* Euphoria values, atoms or
complex sequences, to a Euphoria .dll)

Of course, if you manage to pass a pointer to a block of memory, 
you can store any values you want in that block,
and have your Euphoria program peek() the values according to 
any pre-arranged format that you've decided on. But when you pass 
that initial pointer from another language, make sure it only 
needs 31 bits, or else pass it as say two 16-bit values to be 
combined by the .dll routine into a proper 32-bit (atom) pointer 
that Euphoria can use for peek/poke.
(If you know the pointer must be aligned on say a 4-byte boundary,
you could pass it shifted down 2 bits, and solve the problem that way.
C's malloc() always returns aligned pointers.)

This was discussed many months ago as I recall.
You might dig up some more ideas on this by searching.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu