Skip to content

Commit

Permalink
Merge pull request #21 from avsm/add-sexp-decorator
Browse files Browse the repository at this point in the history
Add sexp decorator
  • Loading branch information
avsm committed Jun 8, 2014
2 parents 7bb0a8f + 8d451fe commit 86c028a
Show file tree
Hide file tree
Showing 19 changed files with 539 additions and 300 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ setup.log
_build/
dist/
*.docdir
*.byte
8 changes: 8 additions & 0 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ opam install ${OPAM_DEPENDS}
eval `opam config env`
make
./test.sh

make clean
opam pin cstruct .
unset OPAMVERBOSE
if [ "$OCAML_VERSION" = "4.00.1" ]; then
opam remove async
fi
opam install mirage-www
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ script: bash -ex .travis-ci.sh
env:
- OCAML_VERSION=4.01.0 OPAM_VERSION=1.1.0
- OCAML_VERSION=4.00.1 OPAM_VERSION=1.1.0
- OCAML_VERSION=3.12.1 OPAM_VERSION=1.1.0
18 changes: 17 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
1.1.0 (2014-02-19)
1.2.0 (2014-06-06):

Add a `sexp` optional decorator to `cenum` to output the values as s-expressions.
This is compatible with the `sexplib` convention. The syntax is;

```
cenum foo64 {
ONE64;
TWO64;
THREE64
} as uint64_t(sexp)
```

And `sexp_of_foo64` and `foo64_of_sexp` functions will also be available.
The representation of the Sexp is the string representation of the enum.

1.1.0 (2014-02-19):
* Improve bounds checks on sub, shift, set_len, add_len.
* Add `to_bigarray` to convert back into a Bigarray slice.

Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ val bar16_to_string : bar16 -> string
val string_to_bar16 : string -> bar16 option
```

You can also add a `(sexp)` decorator to output s-expression convertors
for use with the `sexplib` library.

```
cenum foo32 {
ONE32;
TWO32 = 0xfffffffel;
THREE32
} as uint32_t(sexp)
```

And `sexp_of_foo64` and `foo64_of_sexp` functions will also be available.
The representation of the Sexp is the string representation of the enum.


Please see the `lib_test/` directory for more in-depth examples.

[![Build Status](https://travis-ci.org/avsm/ocaml-cstruct.png)](https://travis-ci.org/avsm/ocaml-cstruct)
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.3
Name: cstruct
Version: 1.1.0
Version: 1.2.0
Synopsis: Manipulate external buffers as C-like structs
Authors: Anil Madhavapeddy, Richard Mortier, Thomas Gazagnaire, Pierre Chambart
License: ISC
Expand Down
30 changes: 15 additions & 15 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
true: inline(10)
true: debug
# OASIS_START
# DO NOT EDIT (digest: 623ae0a45fad2527c26cc490691b077a)
# DO NOT EDIT (digest: cf7382094a64bb443a07a02beeb4573e)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand All @@ -28,45 +28,45 @@ true: debug
"lib/cstruct_stubs.c": pkg_ocplib-endian.bigstring
# Library async_cstruct
"async/async_cstruct.cmxs": use_async_cstruct
<async/*.ml{,i}>: use_cstruct
<async/*.ml{,i}>: pkg_bigarray
<async/*.ml{,i}>: pkg_async
<async/*.ml{,i}>: pkg_threads
<async/*.ml{,i}>: pkg_bigarray
<async/*.ml{,i}>: pkg_ocplib-endian
<async/*.ml{,i}>: pkg_ocplib-endian.bigstring
<async/*.ml{,i}>: pkg_threads
<async/*.ml{,i}>: use_cstruct
# Library lwt_cstruct
"lwt/lwt_cstruct.cmxs": use_lwt_cstruct
<lwt/*.ml{,i}>: use_cstruct
<lwt/*.ml{,i}>: pkg_bigarray
<lwt/*.ml{,i}>: pkg_lwt.unix
<lwt/*.ml{,i}>: pkg_ocplib-endian
<lwt/*.ml{,i}>: pkg_ocplib-endian.bigstring
<lwt/*.ml{,i}>: use_cstruct
# Library unix_cstruct
"unix/unix_cstruct.cmxs": use_unix_cstruct
<unix/*.ml{,i}>: use_cstruct
<unix/*.ml{,i}>: pkg_unix
<unix/*.ml{,i}>: pkg_bigarray
<unix/*.ml{,i}>: pkg_ocplib-endian
<unix/*.ml{,i}>: pkg_ocplib-endian.bigstring
<unix/*.ml{,i}>: pkg_unix
<unix/*.ml{,i}>: use_cstruct
# Library cstruct-syntax
"syntax/cstruct-syntax.cmxs": use_cstruct-syntax
<syntax/*.ml{,i}>: pkg_bigarray
<syntax/*.ml{,i}>: pkg_camlp4.extend
<syntax/*.ml{,i}>: pkg_camlp4.lib
<syntax/*.ml{,i}>: pkg_camlp4.quotations.r
<syntax/*.ml{,i}>: pkg_camlp4.extend
<syntax/*.ml{,i}>: pkg_bigarray
# Executable test_bounds
"lib_test/bounds.byte": use_cstruct
"lib_test/bounds.byte": pkg_unix
"lib_test/bounds.byte": pkg_oUnit
"lib_test/bounds.byte": pkg_bigarray
"lib_test/bounds.byte": pkg_oUnit
"lib_test/bounds.byte": pkg_ocplib-endian
"lib_test/bounds.byte": pkg_ocplib-endian.bigstring
<lib_test/*.ml{,i}>: use_cstruct
<lib_test/*.ml{,i}>: pkg_unix
<lib_test/*.ml{,i}>: pkg_oUnit
"lib_test/bounds.byte": pkg_unix
"lib_test/bounds.byte": use_cstruct
<lib_test/*.ml{,i}>: pkg_bigarray
<lib_test/*.ml{,i}>: pkg_oUnit
<lib_test/*.ml{,i}>: pkg_ocplib-endian
<lib_test/*.ml{,i}>: pkg_ocplib-endian.bigstring
<lib_test/*.ml{,i}>: pkg_unix
<lib_test/*.ml{,i}>: use_cstruct
# OASIS_STOP
<syntax/*.ml>: syntax_camlp4o, pkg_camlp4
<lib_test/*.ml{i}>: syntax_camlp4o, pkg_camlp4, pkg_cstruct.syntax
Expand Down
4 changes: 4 additions & 0 deletions async/async_cstruct.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OASIS_START
# DO NOT EDIT (digest: 3fe20d2f06c0b5b704604b021ed17e72)
Async_cstruct
# OASIS_STOP
18 changes: 8 additions & 10 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: b4981197fe71fb2a248209688d5e96a0)
version = "1.1.0"
# DO NOT EDIT (digest: 6a48e0fe41e5ab0028bf48ddcf4b3d5a)
version = "1.2.0"
description = "Manipulate external buffers as C-like structs"
requires = "bigarray ocplib-endian ocplib-endian.bigstring"
archive(byte) = "cstruct.cma"
Expand All @@ -9,7 +9,7 @@ archive(native) = "cstruct.cmxa"
archive(native, plugin) = "cstruct.cmxs"
exists_if = "cstruct.cma"
package "unix" (
version = "1.1.0"
version = "1.2.0"
description = "Manipulate external buffers as C-like structs"
requires = "cstruct unix"
archive(byte) = "unix_cstruct.cma"
Expand All @@ -20,20 +20,18 @@ package "unix" (
)

package "syntax" (
version = "1.1.0"
version = "1.2.0"
description = "Syntax extension for Cstruct"
requires = "camlp4"
archive(syntax, preprocessor) = "cstruct-syntax.cma"
archive(syntax, toploop) = "cstruct-syntax.cma"
archive(syntax, byte) = "cstruct-syntax.cma"
archive(syntax, byte, plugin) = "cstruct-syntax.cma"
archive(syntax, native) = "cstruct-syntax.cmxa"
archive(syntax, native, plugin) = "cstruct-syntax.cmxs"
archive(syntax, preprocessor, native) = "cstruct-syntax.cmxa"
archive(syntax, preprocessor, native, plugin) = "cstruct-syntax.cmxs"
exists_if = "cstruct-syntax.cma"
)

package "lwt" (
version = "1.1.0"
version = "1.2.0"
description = "Manipulate external buffers as C-like structs"
requires = "cstruct lwt.unix"
archive(byte) = "lwt_cstruct.cma"
Expand All @@ -44,7 +42,7 @@ package "lwt" (
)

package "async" (
version = "1.1.0"
version = "1.2.0"
description = "Manipulate external buffers as C-like structs"
requires = "cstruct async threads"
archive(byte) = "async_cstruct.cma"
Expand Down
4 changes: 4 additions & 0 deletions lib/cstruct.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OASIS_START
# DO NOT EDIT (digest: 1e0fe6af05a6e3ed01c123c49f04dcbb)
Cstruct
# OASIS_STOP
2 changes: 1 addition & 1 deletion lib_test/enum.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cenum foo64 {
ONE64;
TWO64;
THREE64
} as uint64_t
} as uint64_t(sexp)

cenum foo32 {
ONE32;
Expand Down
2 changes: 1 addition & 1 deletion lib_test/enum.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cenum foo64 {
ONE64;
TWO64;
THREE64
} as uint64_t
} as uint64_t(sexp)

cenum foo32 {
ONE32;
Expand Down
4 changes: 4 additions & 0 deletions lwt/lwt_cstruct.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OASIS_START
# DO NOT EDIT (digest: d1391b5d2c30f723aff19f224fcc3c16)
Lwt_cstruct
# OASIS_STOP
Loading

0 comments on commit 86c028a

Please sign in to comment.