basic enum processing
authorD Herring <dherring@at.tentpost.dot.com>
Tue, 5 Apr 2011 03:41:48 +0000 (23:41 -0400)
committerD Herring <dherring@at.tentpost.dot.com>
Tue, 5 Apr 2011 03:41:48 +0000 (23:41 -0400)
Makefile [new file with mode: 0644]
enums.txt [new file with mode: 0644]
read-enums.lisp [new file with mode: 0644]
types.lisp

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..5b2498f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+INCLUDEDIR=/mnt/samsung2tb/slack64/include
+
+# two-step so if the first fails, the file won't update...
+# tr for name canonicalization
+enums.txt:
+       sed -n -e '/enum .*{/,/} *H5/ p' $(INCLUDEDIR)/H*public.h | cpp | sed -e '/#/ d' -e '/^$$/ d' -e 's/[(,);=]//g' -e '/typedef/ d' -e 's/}[ \t]*//' | tr A-Z_ a-z- > $@.tmp
+       mv $@.tmp $@
diff --git a/enums.txt b/enums.txt
new file mode 100644 (file)
index 0000000..95d0516
--- /dev/null
+++ b/enums.txt
@@ -0,0 +1,260 @@
+    h5d-layout-error  -1
+    h5d-compact  0
+    h5d-contiguous  1
+    h5d-chunked  2
+    h5d-nlayouts  3
+h5d-layout-t
+    h5d-chunk-btree  0
+h5d-chunk-index-t
+    h5d-alloc-time-error  -1
+    h5d-alloc-time-default  0
+    h5d-alloc-time-early  1
+    h5d-alloc-time-late  2
+    h5d-alloc-time-incr  3
+h5d-alloc-time-t
+    h5d-space-status-error  -1
+    h5d-space-status-not-allocated  0
+    h5d-space-status-part-allocated  1
+    h5d-space-status-allocated  2
+h5d-space-status-t
+    h5d-fill-time-error  -1
+    h5d-fill-time-alloc  0
+    h5d-fill-time-never  1
+    h5d-fill-time-ifset  2
+h5d-fill-time-t
+    h5d-fill-value-error -1
+    h5d-fill-value-undefined 0
+    h5d-fill-value-default 1
+    h5d-fill-value-user-defined 2
+h5d-fill-value-t
+    h5e-major
+    h5e-minor
+h5e-type-t
+    h5e-walk-upward  0
+    h5e-walk-downward  1
+h5e-direction-t
+    h5f-scope-local  0
+    h5f-scope-global  1
+h5f-scope-t
+    h5f-close-default  0
+    h5f-close-weak  1
+    h5f-close-semi  2
+    h5f-close-strong  3
+h5f-close-degree-t
+    h5fd-mem-nolist  -1
+    h5fd-mem-default  0
+    h5fd-mem-super  1
+    h5fd-mem-btree  2
+    h5fd-mem-draw  3
+    h5fd-mem-gheap  4
+    h5fd-mem-lheap  5
+    h5fd-mem-ohdr  6
+    h5fd-mem-ntypes
+h5f-mem-t
+    h5f-libver-earliest
+    h5f-libver-latest
+h5f-libver-t
+    h5g-storage-type-unknown  -1
+    h5g-storage-type-symbol-table
+    h5g-storage-type-compact
+    h5g-storage-type-dense
+h5g-storage-type-t
+    h5g-unknown  -1
+    h5g-group
+    h5g-dataset
+    h5g-type
+    h5g-link
+    h5g-udlink
+    h5g-reserved-5
+    h5g-reserved-6
+    h5g-reserved-7
+h5g-obj-t
+    h5i-uninit  -2
+    h5i-badid  -1
+    h5i-file  1
+    h5i-group
+    h5i-datatype
+    h5i-dataspace
+    h5i-dataset
+    h5i-attr
+    h5i-reference
+    h5i-vfl
+    h5i-genprop-cls
+    h5i-genprop-lst
+    h5i-error-class
+    h5i-error-msg
+    h5i-error-stack
+    h5i-ntypes
+h5i-type-t
+    h5lt-lang-err  -1
+    h5lt-ddl  0
+    h5lt-c  1
+    h5lt-fortran  2
+    h5lt-no-lang  3
+h5lt-lang-t
+    h5l-type-error  -1
+    h5l-type-hard  0
+    h5l-type-soft  1
+    h5l-type-external  64
+    h5l-type-max  255
+h5l-type-t
+    h5o-type-unknown  -1
+    h5o-type-group
+    h5o-type-dataset
+    h5o-type-named-datatype
+    h5o-type-ntypes
+h5o-type-t
+    h5r-badtype  -1
+    h5r-object
+    h5r-dataset-region
+    h5r-maxtype
+h5r-type-t
+    h5s-no-class  -1
+    h5s-scalar  0
+    h5s-simple  1
+    h5s-null  2
+h5s-class-t
+    h5s-select-noop  -1
+    h5s-select-set  0
+    h5s-select-or
+    h5s-select-and
+    h5s-select-xor
+    h5s-select-notb
+    h5s-select-nota
+    h5s-select-append
+    h5s-select-prepend
+    h5s-select-invalid
+h5s-seloper-t
+    h5s-sel-error  -1
+    h5s-sel-none  0
+    h5s-sel-points  1
+    h5s-sel-hyperslabs  2
+    h5s-sel-all  3
+    h5s-sel-n
+h5s-sel-type
+    h5t-no-class  -1
+    h5t-integer  0
+    h5t-float  1
+    h5t-time  2
+    h5t-string  3
+    h5t-bitfield  4
+    h5t-opaque  5
+    h5t-compound  6
+    h5t-reference  7
+    h5t-enum  8
+    h5t-vlen  9
+    h5t-array  10
+    h5t-nclasses
+h5t-class-t
+    h5t-order-error  -1
+    h5t-order-le  0
+    h5t-order-be  1
+    h5t-order-vax  2
+    h5t-order-mixed  3
+    h5t-order-none  4
+h5t-order-t
+    h5t-sgn-error  -1
+    h5t-sgn-none  0
+    h5t-sgn-2  1
+    h5t-nsgn  2
+h5t-sign-t
+    h5t-norm-error  -1
+    h5t-norm-implied  0
+    h5t-norm-msbset  1
+    h5t-norm-none  2
+h5t-norm-t
+    h5t-cset-error  -1
+    h5t-cset-ascii  0
+    h5t-cset-utf8  1
+    h5t-cset-reserved-2  2
+    h5t-cset-reserved-3  3
+    h5t-cset-reserved-4  4
+    h5t-cset-reserved-5  5
+    h5t-cset-reserved-6  6
+    h5t-cset-reserved-7  7
+    h5t-cset-reserved-8  8
+    h5t-cset-reserved-9  9
+    h5t-cset-reserved-10  10
+    h5t-cset-reserved-11  11
+    h5t-cset-reserved-12  12
+    h5t-cset-reserved-13  13
+    h5t-cset-reserved-14  14
+    h5t-cset-reserved-15  15
+h5t-cset-t
+    h5t-str-error  -1
+    h5t-str-nullterm  0
+    h5t-str-nullpad  1
+    h5t-str-spacepad  2
+    h5t-str-reserved-3  3
+    h5t-str-reserved-4  4
+    h5t-str-reserved-5  5
+    h5t-str-reserved-6  6
+    h5t-str-reserved-7  7
+    h5t-str-reserved-8  8
+    h5t-str-reserved-9  9
+    h5t-str-reserved-10  10
+    h5t-str-reserved-11  11
+    h5t-str-reserved-12  12
+    h5t-str-reserved-13  13
+    h5t-str-reserved-14  14
+    h5t-str-reserved-15  15
+h5t-str-t
+    h5t-pad-error  -1
+    h5t-pad-zero  0
+    h5t-pad-one  1
+    h5t-pad-background  2
+    h5t-npad  3
+h5t-pad-t
+    h5t-conv-init  0
+    h5t-conv-conv  1
+    h5t-conv-free  2
+h5t-cmd-t
+    h5t-bkg-no  0
+    h5t-bkg-temp  1
+    h5t-bkg-yes  2
+h5t-bkg-t
+    h5t-pers-dontcare  -1
+    h5t-pers-hard  0
+    h5t-pers-soft  1
+h5t-pers-t
+    h5t-dir-default  0
+    h5t-dir-ascend  1
+    h5t-dir-descend  2
+h5t-direction-t
+    h5t-conv-except-range-hi  0
+    h5t-conv-except-range-low  1
+    h5t-conv-except-precision  2
+    h5t-conv-except-truncate  3
+    h5t-conv-except-pinf  4
+    h5t-conv-except-ninf  5
+    h5t-conv-except-nan  6
+h5t-conv-except-t
+    h5t-conv-abort  -1
+    h5t-conv-unhandled  0
+    h5t-conv-handled  1
+h5t-conv-ret-t
+    h5z-so-float-dscale  0
+    h5z-so-float-escale  1
+    h5z-so-int  2
+h5z-so-scale-type-t
+    h5z-error-edc  -1
+    h5z-disable-edc  0
+    h5z-enable-edc  1
+    h5z-no-edc  2
+h5z-edc-t
+    h5z-cb-error  -1
+    h5z-cb-fail  0
+    h5z-cb-cont  1
+    h5z-cb-no  2
+h5z-cb-return-t
+    h5-iter-unknown  -1
+    h5-iter-inc
+    h5-iter-dec
+    h5-iter-native
+    h5-iter-n
+h5-iter-order-t
+    h5-index-unknown  -1
+    h5-index-name
+    h5-index-crt-order
+    h5-index-n
+h5-index-t
diff --git a/read-enums.lisp b/read-enums.lisp
new file mode 100644 (file)
index 0000000..e4cc337
--- /dev/null
@@ -0,0 +1,28 @@
+(defun read-enums (&optional (filename "enums.txt"))
+  (let ((kw (find-package :keyword)))
+    (with-open-file (file filename)
+      (do (enums
+           values
+           (line (read-line file nil)
+                 (read-line file nil)))
+          ((not line)
+           enums)
+        (with-input-from-string (sline line)
+          (if (char= (char line 0) #\Space)
+              ;; value
+              (let* ((*package* kw)
+                     (name (read sline))
+                     (value (read sline nil)))
+                (if value
+                    (push (list name value) values)
+                    (push name values)))
+              ;; enum
+              (prog1
+                  (let ((clause (list (read sline)  'cffi:defcenum)))
+                    (dolist (v (reverse values))
+                      (push v clause))
+                    (push (reverse clause) enums))
+                (setf values nil))))))))
+
+(defmacro hdf5-enums ()
+  (cons 'progn (read-enums)))
index 58ef93e..2286a5b 100644 (file)
@@ -17,6 +17,12 @@ The following appears to extract all the enums is a parseable format.
 It is plausible to get enum names, members, and even values.
 # sed -n -e '/enum .*{/,/} *H5/ p' * | cpp | sed -e '/#/ d' -e '/^$/ d'
 
+Here is a list of enumerated values.
+# sed -n -e '/enum .*{/,/} *H5/ p' H*public.h | cpp | sed -e '/#/ d' -e '/^$/ d' -e '/typedef/ d' -e '/}/ d' -e 's/^[ \t]*//' -e 's/[ ,].*//'
+
+and an easily parseable form.
+# sed -n -e '/enum .*{/,/} *H5/ p' H*public.h | cpp | sed -e '/#/ d' -e '/^$/ d' -e 's/[(,);=]//g' -e '/typedef/ d' -e 's/}[ \t]*//'
+
 
 ;; constants
 H5P_DEFAULT
@@ -56,5 +62,5 @@ Final expression:
 ;; functions
 
 Since they use the H5_DLL macro to control exporting, the following should provide a complete list of interesting stuff.
-Note the DLLVAR marks functions used to define some "constants".
-# grep H5_DLL H*public.h | grep -v H5_DLLVAR
+Note that H5_DLLVAR marks functions used to define some "constants".
+# sed -n -e '/^H5_DLL [^)]*$/,/)/ p' -e '/^H5_DLL .*)/ p' H*public.h | cpp | sed -e '/#/ d' -e 's/H5_DLL //'