[GH-ISSUE #320] make header declarations robust to my broken C parser #258

Closed
opened 2026-05-05 12:03:04 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @mwette on GitHub (Jan 13, 2021).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/320

Originally assigned to: @jmcnamara on GitHub.

In styles.h exists the declaration

void lxw_styles_write_rich_font(lxw_styles *lxw_styles, lxw_format *format);

I'm (sheepishly) asking that the variable name lxw_styles not be a typedef name, which my API generator can't parse.
For example, change lsw_styles *lxw_styles to lxw_styles *styles.

My API generator works like the tool swig: it reads header files and generates API wrapper code for Guile (GNU's Scheme implementation). I know the bug is my parser, but it's a realy hard fix.

Originally created by @mwette on GitHub (Jan 13, 2021). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/320 Originally assigned to: @jmcnamara on GitHub. In ``styles.h`` exists the declaration ``` void lxw_styles_write_rich_font(lxw_styles *lxw_styles, lxw_format *format); ``` I'm (sheepishly) asking that the variable name ``lxw_styles`` not be a typedef name, which my API generator can't parse. For example, change ``lsw_styles *lxw_styles`` to ``lxw_styles *styles``. My API generator works like the tool ``swig``: it reads header files and generates API wrapper code for Guile (GNU's Scheme implementation). I know the bug is my parser, but it's a realy hard fix.
gitea-mirror 2026-05-05 12:03:04 -06:00
Author
Owner

@jmcnamara commented on GitHub (Jan 13, 2021):

Sure. No problem. Fixed on master.

<!-- gh-comment-id:759745414 --> @jmcnamara commented on GitHub (Jan 13, 2021): Sure. No problem. Fixed on master.
Author
Owner

@mwette commented on GitHub (Jan 13, 2021):

Thanks!
From this:

(define-ffi-module (ffi xlsxwriter)
  #:include '("xlsxwriter.h") 
  #:library '("libxlsxwriter") 
  #:inc-filter (lambda (f p) (string-contains p "xlsxwriter" 0))
  #:inc-dirs '("/usr/local/include"))

my tool (nyacc's ffi-helper) generates several 1000's lines of scheme code using Guile's API for libffi. Then a user can do this:

(use-modules (ffi xlsxwriter))
(use-modules (system ffi-help-rt))

(define workbook (workbook_new "xlsxdemo.xlsx"))
(define worksheet (workbook_add_worksheet workbook NULL))

(define format (workbook_add_format workbook))
(format_set_bold format)
(worksheet_set_column worksheet 0 0 20 NULL)
(worksheet_write_string worksheet 0 0 "Hello" NULL)
(worksheet_write_string worksheet 1 0 "World" NULL)
(worksheet_write_number worksheet 2 0 123 NULL)
(worksheet_write_number worksheet 3 0 123.456 NULL)
(worksheet_insert_image worksheet 1 2 "xlsxlogo.png")
(workbook_close workbook)
<!-- gh-comment-id:759754714 --> @mwette commented on GitHub (Jan 13, 2021): Thanks! From this: ``` (define-ffi-module (ffi xlsxwriter) #:include '("xlsxwriter.h") #:library '("libxlsxwriter") #:inc-filter (lambda (f p) (string-contains p "xlsxwriter" 0)) #:inc-dirs '("/usr/local/include")) ``` my tool (nyacc's ffi-helper) generates several 1000's lines of scheme code using Guile's API for libffi. Then a user can do this: ``` (use-modules (ffi xlsxwriter)) (use-modules (system ffi-help-rt)) (define workbook (workbook_new "xlsxdemo.xlsx")) (define worksheet (workbook_add_worksheet workbook NULL)) (define format (workbook_add_format workbook)) (format_set_bold format) (worksheet_set_column worksheet 0 0 20 NULL) (worksheet_write_string worksheet 0 0 "Hello" NULL) (worksheet_write_string worksheet 1 0 "World" NULL) (worksheet_write_number worksheet 2 0 123 NULL) (worksheet_write_number worksheet 3 0 123.456 NULL) (worksheet_insert_image worksheet 1 2 "xlsxlogo.png") (workbook_close workbook) ```
Author
Owner

@jmcnamara commented on GitHub (Jan 13, 2021):

That's really cool.

<!-- gh-comment-id:759826461 --> @jmcnamara commented on GitHub (Jan 13, 2021): That's really cool.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#258
No description provided.