Re: implications, flames, etc.
-----Original Message-----
From: Brian Broker <bkb at CNW.COM>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Wednesday, February 02, 2000 7:25 PM
Subject: Re: implications, flames, etc.
Hi Brian.
This mailing list thing really does work quickly, doesn't it!
>On Wed, 2 Feb 2000 18:51:23 +1030, Mark Brown wrote:
>
>>I'm a Euphoria newbie but have already found frustration in not being able
>>to get at the location of my variables. I wouldn't want to know for my own
>>code but so much of what I want to call expects me to know where that
>>variable is.
>
>Forgive me if I'm stating something you've already considered but if you
>need the pointer for a C variable/structure, why not use allocate/poke?
>That is, after all, the reason these routines exist...
>
This is what I have been doing (following stuff I've learned from you guys
(and Todd Riggins) actually!). I guess what I mean is that I would like to
turn the following (for example) :-
atom view_direction,p1,p2,p3
view_direction = allocate(3*8)
p1 = allocate(3*8)
p2 = allocate(3*8)
p3 = allocate(3*8)
--
global function Morfit_math_is_clockwise_from_direction(sequence
my_view_direction, sequence my_p1, sequence my_p2, sequence my_p3)
-- rip the values from the sequence(s) and poke them into the array(s)
poke(view_direction, atom_to_float64(my_view_direction[1]))
poke(view_direction+8, atom_to_float64(my_view_direction[2]))
poke(view_direction+16, atom_to_float64(my_view_direction[3]))
--
poke(p1, atom_to_float64(my_p1[1]))
poke(p1+8, atom_to_float64(my_p1[2]))
poke(p1+16, atom_to_float64(my_p1[3]))
--
poke(p2, atom_to_float64(my_p2[1]))
poke(p2+8, atom_to_float64(my_p2[2]))
poke(p2+16, atom_to_float64(my_p2[3]))
--
poke(p3, atom_to_float64(my_p3[1]))
poke(p3+8, atom_to_float64(my_p3[2]))
poke(p3+16, atom_to_float64(my_p3[3]))
return c_func(xMorfit_math_is_clockwise_from_direction,{view_direction,
p1, p2, p3})
end function
into something more like :-
ret_val = c_func(Morfit_math_is_clockwise_from_direction,{&
view_direction, &p1, &p2, &p3)
where &view_direction etc.... are just the location in memory of my
sequence(s). This would mean I wouldn't have to poke into memory, everything
I've just put into my sequence(s) so that the c function I'm calling knows
where to get what it needs (and often I've found, where it needs to return
stuff, which results in a whole new round of grabing the values from the
memory locations and putting them in my sequences.
I suppose we can just deal with the memory without loading and unloading the
sequences but it seems to me to make doing anything else with the data a bit
of a chore.
The "atom_to_float" thing in the above also makes me wonder whether, just
for using stuff in the C world etc, it might be a good idea to have fixed
length types available in Euphoria (such as Double). From the flexible to
the totally inflexible!. I think Rob is going to hate me for that one.
Perhaps, something like :-
sequence p1[3*8]
I'm well out of my depth here so if any of this is junk, please just chuckle
and go on.
Mark.
|
Not Categorized, Please Help
|
|