[racket] users Digest, Vol 114, Issue 3
Sent via the Samsung GALAXY S® 5, an AT&T 4G LTE smartphone
-------- Original message --------
From: users-request at racket-lang.org
Date:02/02/2015 11:00 AM (GMT-06:00)
To: users at racket-lang.org
Cc:
Subject: users Digest, Vol 114, Issue 3
Send users mailing list submissions to
users at racket-lang.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.racket-lang.org/users/listinfo
or, via email, send a message with subject or body 'help' to
users-request at racket-lang.org
You can reach the person managing the list at
users-owner at racket-lang.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of users digest..."
[Racket Users list:
http://lists.racket-lang.org/users ]
Today's Topics:
1. Re: forward pointer declarations (Anthony Carrico)
2. Re: forward pointer declarations (Sam Tobin-Hochstadt)
3. Re: forward pointer declarations (Anthony Carrico)
----------------------------------------------------------------------
Message: 1
Date: Mon, 02 Feb 2015 08:02:43 -0500
From: Anthony Carrico <acarrico at memebeam.org>
To: Matthew Flatt <mflatt at cs.utah.edu>
Cc: racket Users <users at racket-lang.org>
Subject: Re: [racket] forward pointer declarations
Message-ID: <54CF7573.6060000 at memebeam.org>
Content-Type: text/plain; charset="utf-8"
On 02/02/2015 01:17 AM, Matthew Flatt wrote:
> It's also valid to reference `wl_interface-pointer` directly:
...
>
> I don't have a nicer solution if you want to refer to
> `_wl_message-pointer`, though.
>
The forward reference is actually in wl_message, like this:
(define-cstruct _wl_message
((name _string/utf-8)
(signature _string/utf-8)
(types (_cpointer 'wl_interface))))
(define-cstruct _wl_interface
((name _string/utf-8)
(version _int)
(method_count _int)
(methods _wl_message-pointer)
(event_count _int)
(events _wl_message-pointer)))
I ended up just inlining (_cpointer 'wl_interface) for the forward
reference. This ends up creating two (_cpointer 'wl_interface) ctypes,
but it's no problem, correct?
I don't think it is possible to "reference 'wl_interface-pointer'
directly" as you suggest in this case because of the "cannot reference
an identifier before its definition" error.
--
Anthony Carrico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/f5494983/attachment-0001.sig>
------------------------------
Message: 2
Date: Mon, 02 Feb 2015 14:04:25 +0000
From: Sam Tobin-Hochstadt <samth at cs.indiana.edu>
To: Anthony Carrico <acarrico at memebeam.org>, Matthew Flatt
<mflatt at cs.utah.edu>
Cc: racket Users <users at racket-lang.org>
Subject: Re: [racket] forward pointer declarations
Message-ID:
<CAK=HD+bSzeuvOm+pjuM53MfidOfy6=mJC0M7KwSjDJ7qj3LwGQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Maybe a ctype which is a delay node, along the lines of
'recursive-contract', is the right thing here.
Sam
On Mon, Feb 2, 2015, 8:05 AM Anthony Carrico <acarrico at memebeam.org> wrote:
> On 02/02/2015 01:17 AM, Matthew Flatt wrote:
> > It's also valid to reference `wl_interface-pointer` directly:
> ...
> >
> > I don't have a nicer solution if you want to refer to
> > `_wl_message-pointer`, though.
> >
>
> The forward reference is actually in wl_message, like this:
>
> (define-cstruct _wl_message
> ((name _string/utf-8)
> (signature _string/utf-8)
> (types (_cpointer 'wl_interface))))
>
> (define-cstruct _wl_interface
> ((name _string/utf-8)
> (version _int)
> (method_count _int)
> (methods _wl_message-pointer)
> (event_count _int)
> (events _wl_message-pointer)))
>
> I ended up just inlining (_cpointer 'wl_interface) for the forward
> reference. This ends up creating two (_cpointer 'wl_interface) ctypes,
> but it's no problem, correct?
>
> I don't think it is possible to "reference 'wl_interface-pointer'
> directly" as you suggest in this case because of the "cannot reference
> an identifier before its definition" error.
>
> --
> Anthony Carrico
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/0b9778b6/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 02 Feb 2015 09:41:46 -0500
From: Anthony Carrico <acarrico at memebeam.org>
To: users at racket-lang.org
Subject: Re: [racket] forward pointer declarations
Message-ID: <54CF8CAA.60500 at memebeam.org>
Content-Type: text/plain; charset="windows-1252"
Along these lines, I also am a little foggy on unions. This:
http://docs.racket-lang.org/foreign/C_Union_Types.html
says, "Unions are always treated like structs." But I have no idea what
that phrase means. I don't get the impression that unions have tags like
structs can have. Or can they? Maybe any pointer can be tagged? For example:
(define _wl_argument
(_union _int32
_uint32
_wl_fixed
_string/utf-8
(_cpointer/null 'wl_object)
_uint32
_wl_array-pointer
_int32))
Now suppose I need to pass an array of _wl_argument. Does it even make
sense to use a tag in the _cpointer?
(define _wl_argument-pointer (_cpointer 'wl_argument))
(define-wl-client wl_proxy_marshal_array_constructor
(_fun #:save-errno 'posix
_wl_proxy-pointer
_uint32
_wl_argument-pointer
_wl_interface-pointer
-> _wl_proxy-pointer/null
))
So as I said, I'm just a little foggy on some of the concepts, but I do
think the FFI is very nice. Maybe I'm just trying to use stronger typing
than actually exists in the ffi. I've started reading
Eli Barzilay/Dmitry Orlovsky "Foreign Interface for PLT Scheme".
--
Anthony Carrico
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/b5d986ce/attachment-0001.sig>
End of users Digest, Vol 114, Issue 3
*************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/80acda44/attachment-0001.html>