Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode-ffi-field - syntax checking for field properties #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spchamp
Copy link
Contributor

@spchamp spchamp commented Apr 26, 2020

This patch represents a single changeset, developed previously under a local development branch. It's submitted here, from a patch branch under the thinkum-contrib mirror at GitHub

The patch was tested, previously, in October of 2019, under a Debian 10 amd64 installation. I've now tested the ffigen5 build under FreeBSD 12.1. With regards to tooling: Subsequent of a review of the latest port update for CCL, I'd like to create a ccl-devel port under FreeBSD ports and test out ffigen5 under the latter. I believe that a port could serve as a nice context for containing the list of header files to process, for CCL itself and for such as GTK. Pursuant of any tractable success in this, will try to publish the ports patch under a new FreeBSD ports mirror and mention to the CCL mailing list.

I've tested this patch out, only under interactive I/O on the Debian 10 host.

Original changelog message (spell-checked here, syntax updated for Markdown processing)
lib/db-io.lisp: Provide some syntax checking in encode-ffi-field

Under some build configurations, after processing OS header files in
some host environments, ffigen5 may produce field information having
non-positive offset and/or width properties, in some specific fields.

This changeset provides a rudimentary parse-time syntax check for such
data, implemented here in encode-ffi-field. On encountering a negative
offset or width for a field, the type check will signal a continuable
error of type simple-type-definition-error. The continuation form
would throw to the symbol, ignore-type, with no values.

Furthermore, if encountering a zero width for a field, tentatively the
updated encode-ffi-field would produce a warning condition of type
simple-type-definition-warning

This also updates the following functions, to gracefully handle the
catch symbol ignore-type, such that may be thrown from the updated
encode-ffi-field

  • save-ffi-objc-message
  • db-write-byte-list
  • save-ffi-function
  • save-ffi-typedef
  • save-ffi-struct
  • save-ffi-union
  • save-ffi-transparent-union
  • db-define-var
  • save-ffi-objc-class

The following condition classes are added, each in a tentative
definition, such as to be used in this simple type checking for ffigen
data, in encode-ffi-field

  • simple-type-definition-error
  • simple-type-definition-warning

This patch was originally developed circa October, 2019

The patch has been tested, to a limited extent, under a Debian 10 amd64
installation.

(cherry picked from commit 333a1f8)

Original changelog message:
lib/db-io.lisp: Provide some syntax checking in encode-ffi-field

Under some build configurations, after processing OS header files in
some host environments, ffigen5 may produce field information having
non-positive offset and/or width properties, in some specific fields.

This changeset provides a rudimentary parse-time syntax check for such
data, implemented here in `encode-ffi-field'. On encountering a negative
offset or width for a field, the type check will signal a continuable
error of type `simple-type-definition-error'. The continuation form
would throw to the symbol, `ignore-type', with no values.

Furthermore, if encountering a zero width for a field, tentatively the
updated `encode-ffi-field' would produce a warning condition of type
`simple-type-definition-warning'

This also updates the following functions, to gracefully handle the
catch symbol `ignore-type', such that may be thrown from the updated
`encode-ffi-field'
* save-ffi-objc-message
* db-write-byte-list
* save-ffi-function
* save-ffi-typedef
* save-ffi-struct
* save-ffi-union
* save-ffi-transparent-union
* db-define-var
* save-ffi-objc-class

The following condition classes are added, each in a tentative
definition, such as to be used in this simple type checking for ffigen
data, in `encode-ffi-field'
* simple-type-definition-error
* simple-type-definition-warning

This patch was originally developed circa October, 2019

The patch has been tested, to a limited extent, under a Debian 10 amd64
installation.

(cherry picked from commit 333a1f8)
(ffi-function-string fun)
encoding
t)))
(catch 'ignore-type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems superfluous. DB-WRITE-BYTE-LIST already has a catch 'ignore-type; do you expect that encode-ffi-function is going to throw as well in some way?

(ffi-typedef-string def)
(encode-ffi-type (ffi-typedef-type def))
t))
(catch 'ignore-type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants