Re: [PATCH 18/25] write documentation for (system foreign declarative)

2016-07-18 Thread Dmitry Bogatov
[2016-07-18 21:41] Amirouche Boubekki > > On 2016-07-18 17:17, kact...@gnu.org wrote: > > From: Dmitry Bogatov > > > > Document '' record type and 'define-foreign-type' > > procedure. > > Can you compare this 'foreign-type' library with scheme-bytestructures > [0]. How > can both libraries help e

Re: [PATCH 18/25] write documentation for (system foreign declarative)

2016-07-18 Thread Amirouche Boubekki
On 2016-07-18 17:17, kact...@gnu.org wrote: From: Dmitry Bogatov Document '' record type and 'define-foreign-type' procedure. Can you compare this 'foreign-type' library with scheme-bytestructures [0]. How can both libraries help each other? Work hand in hand? [0] https://github.com/Tayla

Re: [PATCH 02/25] Define structure

2016-07-18 Thread Nala Ginrut
Hi Dmitry! Thanks for working on it! On Mon, 2016-07-18 at 18:17 +0300, kact...@gnu.org wrote: > From: Dmitry Bogatov >  > +(define-module (system foreign declarative) > +  #:export (make-foreign-type) > +  #:export (define-foreign-type)) > +(use-modules (srfi srfi-9)) You don't have to write #

Re: [PATCH 02/25] Define structure

2016-07-18 Thread Dmitry Bogatov
> > +(define-module (system foreign declarative) > > +  #:export (make-foreign-type) > > +  #:export (define-foreign-type)) > > +(use-modules (srfi srfi-9)) > You don't have to write #:export several times, one just enough > #:export (make-foreign-type define-foreign-type) Thanks for review. I kn

[PATCH 14/25] foreign/declarative: mirror more primitive types

2016-07-18 Thread KAction
From: Dmitry Bogatov New foreign-types: `unsigned-int:` and `unsigned-long:`. --- module/system/foreign/declarative.scm | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.

[PATCH 22/25] ice-9/xattr: implement `xattr-get' function

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/ice-9/xattr.scm | 40 +++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/module/ice-9/xattr.scm b/module/ice-9/xattr.scm index 2c81e91..090b233 100644 --- a/module/ice-9/xattr.scm +++ b/module/ice-9/xattr.scm @@

[PATCH 21/25] new module: (ice-9 xattr)

2016-07-18 Thread KAction
From: Dmitry Bogatov This module provides interface to extended filesystem attributes and serves as example of (system foreign declarative) usage. --- module/Makefile.am | 1 + module/ice-9/xattr.scm | 76 ++ 2 files changed, 77 insertions(+)

[PATCH 23/25] Do not throw exception on missing xattr

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/ice-9/xattr.scm (xattr-get): convert exception to #f if errno was ENOATTR --- module/ice-9/xattr.scm | 27 +++ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/module/ice-9/xattr.scm b/module/ice-9/xattr.scm index 090b233.

[PATCH 25/25] ice9/attr: implement xattr-list procedure

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/ice-9/xattr.scm | 43 ++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/module/ice-9/xattr.scm b/module/ice-9/xattr.scm index 5374901..6773126 100644 --- a/module/ice-9/xattr.scm +++ b/module/ice-9/xattr.scm

[PATCH 19/25] Document define-foreign-bitmask macro

2016-07-18 Thread KAction
From: Dmitry Bogatov --- doc/ref/api-foreign.texi | 16 1 file changed, 16 insertions(+) diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index 605dbed..6b0e34c 100644 --- a/doc/ref/api-foreign.texi +++ b/doc/ref/api-foreign.texi @@ -1124,6 +1124,22 @@ Here are

[PATCH 18/25] write documentation for (system foreign declarative)

2016-07-18 Thread KAction
From: Dmitry Bogatov Document '' record type and 'define-foreign-type' procedure. --- doc/ref/api-foreign.texi | 150 ++- 1 file changed, 147 insertions(+), 3 deletions(-) diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index c2c49ec.

[PATCH 15/25] New macro: with-pointer

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: macro 'with-pointer' simplifies work with input-output and input arguments to C functions. * test-suite/tests/foreign-declarative.test: test 'with-pointer' macro by time(2) function. Value returned via pointer must

[PATCH 24/25] Refactor defining foreign libattr function

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/ice-9/xattr.scm: new internal macro `define-libattr-functions', that generalize following properties of functions in libattr: - every function have form attr_ACTION or attr_ACTIONf, which have same signatures, except first argument, which is e

Foreign-declarative module

2016-07-18 Thread KAction
Hello! Below is set of patches, that (1-20) implement new module (system foreign declarative), that simplifies writing bindings to foreign C functions and provides documentation to it. This module is extracted from abandoned guile-bash project. Rest 5 patches (21-25) introduce module (ice-9 xattr

[PATCH 20/25] Document with-pointer macro

2016-07-18 Thread KAction
From: Dmitry Bogatov --- doc/ref/api-foreign.texi | 48 1 file changed, 48 insertions(+) diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index 6b0e34c..7114225 100644 --- a/doc/ref/api-foreign.texi +++ b/doc/ref/api-foreign.texi

[PATCH 11/25] system/foreign/declarative: new macro

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: new macro `define-foreign-bitmask' that defines `foreign-type' for bitmask, with proper encoding, decoding and validation. --- module/system/foreign/declarative.scm | 46 +++ test-suite/tests/

[PATCH 17/25] system/foreign/declarative: unexport internal macro

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/system/foreign/declarative.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.scm index 9930370..8ffc821 100644 --- a/module/system/foreign/declarative.scm +++ b/module/system/foreign/d

[PATCH 13/25] system/foreign/declarative.scm: export string foreign type

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/system/foreign/declarative.scm | 4 1 file changed, 4 insertions(+) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.scm index 62d40b8..596cce0 100644 --- a/module/system/foreign/declarative.scm +++ b/module/system/fore

[PATCH 16/25] Configure emacs file-local indention

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/system/foreign/declarative.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.scm index 66d35a8..9930370 100644 --- a/module/system/foreign/declarative.scm +++ b/module/system/foreign/

[PATCH 10/25] Refactor type validation in `define-foreign-function'

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/system/foreign/declarative.scm | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.scm index 5a5d688..fb949db 100644 --- a/module/system/foreign

[PATCH 12/25] Improve deriving c symbol name from scheme one

2016-07-18 Thread KAction
From: Dmitry Bogatov --- module/system/foreign/declarative.scm | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/module/system/foreign/declarative.scm b/module/system/foreign/declarative.scm index b0c31a0..62d40b8 100644 --- a/module/system/foreign/declarative.scm

[PATCH 05/25] Fix bug in `default' macro

2016-07-18 Thread KAction
From: Dmitry Bogatov The following code will cause error: (define (foo x) (define x (* 2 x)) (+ x 12)) (display (foo 12)) instead displaying 36, since in (* 2 x) form variable x is bound, but have value *unspecified*. In this case `set!' must be used. * module/system/foreign/decl

[PATCH 08/25] Add keywords for `define-foreign-function' macro

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm(define-foreign-function): new keywords arguments: - dynamic-library: dynamic library object where load symbol from - symbol: explicitly specify underlying C symbol, if automatic deriving from Scheme function name is n

[PATCH 07/25] Introduce foreign-type predicates

2016-07-18 Thread KAction
From: Dmitry Bogatov Introduce notion of foreign-type predicates. The following changed was made: * new field `ft-predicate-proc' in record. * new argument to `make-foreign-type' function * specify predicates for primitive types, which required change of helper `mirror-primitive-type' mac

[PATCH 03/25] Mirror types from system/foreign as

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: import (system foreign), where identifiers `int', 'long' and so on are declared * module/system/foreign/declarative.scm: with two helper macros `mirror-primitive-type' and `mirror-primitive-types' create for every

[PATCH 09/25] system/foreign/declarative: rename `predicate' to `validate'

2016-07-18 Thread KAction
From: Dmitry Bogatov With this renaming validation function is allowed to throw excection by itself to more accurately describe violated assumption. By convention, predicates never throws. --- module/system/foreign/declarative.scm | 20 ++-- 1 file changed, 10 insertions(+), 10

[PATCH 04/25] Write boilerplate for primitive types

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: for reason I do not understand, `mirror-primitive-typeS' macro mangled foreign type object name, so instead `int:' it defined something like `int:_some_uniq_string'. So it was replaced with manual calls to `mirror-pri

[PATCH 06/25] Basic implementation of `define-foreign-function'

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: new macro `define-foreign-function', that allows import from current binary C function with primitive (no strings, no pointers) arguments, that returns primitive type. * module/system/foreign/declarative.scm: test that

[PATCH 01/25] New module: system/foreign/declarative.scm

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: currently empty module, that successfully compiles and gets installed * module/Makefile.am: insert new module into list of known Guile modules --- module/Makefile.am| 6 ++ module/system/foreign/declar

[PATCH 02/25] Define structure

2016-07-18 Thread KAction
From: Dmitry Bogatov * module/system/foreign/declarative.scm: new structure , incapsulating information how convert objects from Scheme representation to C, and via-verse. * module/system/foreign/declarative.scm: create and export new functions `make-foreign-type' and `define-foreign-