[Prev][Next][Index][Thread]
Re: machine hacking
A few more hours of persistence paid off here....
You have to make use of the <C-raw-...> types that allow anything goes...
define C-union <DOPPELGANGER>
slot float-value :: <C-float>;
slot long-value :: <C-raw-unsigned-long>;
array slot uchar-value :: <C-raw-unsigned-char>, length: 4;
pointer-type-name: <DOPPELGANGER*>;
end C-union;
define method poke-word (buf :: <simple-vector>,
offset :: <integer>,
wrd :: <machine-word>)
=> ()
let off :: <integer> = 4 * offset;
with-stack-structure (d :: <DOPPELGANGER*>)
d.long-value := wrd;
for(ix :: <integer> from 0 below 4)
buf[off + ix] := uchar-value(d, ix);
end;
end;
end method;
Thanks,
- DM
Chris Double wrote in message ...
>"David McClain" <dmcclain@azstarnet.com> writes:
>
>> The trouble arises because the value #xbadc0db4 can't be converted
>> to <integer> since integers are only 29 bits or so. And I have to
>> coerce the value to something acceptable to storing into a <c-long>
>> value. Type <abstract-integer> doesn't work here, since <c-long>
>> still expects an <integer>.
>
>A similar problem came up a couple of years ago on the newsgroup but
>the solution appears to have vanished off deja.com unfortunately.
>
>Take a look at c-mapped-subtype in the online help. It shows an
>example of converting integers to raw ints, etc. Using something like
>this I think you can do what you want. I'm pretty sure the solution on
>the newsgroup used that in some manner.
>
>Chris.
>--
>http://www.double.co.nz/dylan
References: