bugnyacc parser generator - Bugs: bug #57949, function pointer in struct

 
 

bug #57949: function pointer in struct

Submitted by:  None
Submitted on:  Tue 03 Mar 2020 04:27:27 PM UTC
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  In Progress
Privacy:  Public Assigned to:  mwette
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Tue 05 Apr 2022 07:35:14 PM UTC, comment #2: 

I've made progress on this: see dev-1.07 branch,
commit cef6ceacdfd5f6f1ce60eca61626b39b83b0a422

For your example it produces:

(define-public struct-foo-desc
  (bs:struct
    (list `(bar ,(fh:function 'void (list 'void))))))
(define-fh-compound-type struct-foo struct-foo-desc struct-foo?
 make-struct-foo)
(export struct-foo struct-foo? make-struct-foo)
(define-public struct-foo*-desc
  (fh:pointer struct-foo-desc))
(define-fh-pointer-type struct-foo* struct-foo*-desc struct-foo*?
 make-struct-foo*)
(export struct-foo* struct-foo*? make-struct-foo*)
(fh-ref<=>deref!
  struct-foo*
  make-struct-foo*
  struct-foo
  make-struct-foo)

Matt Wette <mwette>
Project Administrator
Wed 04 Mar 2020 01:06:16 AM UTC, comment #1: 

Normally objects returned from function calls are wrapped w/ FH types, but hi this case I would have to wrap fh-object-ref results somehow.   That would be useful but eat memory.   Not a trivial task.   I need to think about this a bit.

Matt Wette <mwette>
Project Administrator
Tue 03 Mar 2020 04:27:27 PM UTC, original submission:  

Example:

struct foo
{
        void bar(void);
};

Processing the above C code with compile-ffi produces the following Scheme code:

;; struct foo {
;;   void bar(void);
;; };
(define-public struct-foo-desc
  (bs:struct (list `(bar ,(bs:pointer 'void)))))
(define-fh-compound-type struct-foo struct-foo-desc struct-foo?
 make-struct-foo)
(export struct-foo struct-foo? make-struct-foo)
(define-public struct-foo*-desc
  (bs:pointer struct-foo-desc))
(define-fh-pointer-type struct-foo* struct-foo*-desc struct-foo*?
 make-struct-foo*)
(export struct-foo* struct-foo*? make-struct-foo*)
(ref<->deref!
  struct-foo*
  make-struct-foo*
  struct-foo
  make-struct-foo)

AFAICT bar's type information is not included in the Scheme code, so there's no way to call bar from Scheme short of taking bar's address (as returned by fh-object-ref) and converting it using pointer->procedure. It would be great if fh-object-ref would return a procedure that calls bar in this case.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mwette (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-05 mwette StatusNone => In Progress
    2020-03-04 mwette Assigned toNone => mwette

    Back to the top


    Powered by Savane 3.9