*~
+*.cmi
+*.cmo
+*.cmx
Makefile
Makefile.in
/aclocal.m4
--- /dev/null
+# wrappi
+# Copyright (C) 2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX
+OCAMLOPTFLAGS = $(OCAMLCFLAGS)
+
+PP = -pp '$(CAMLP4O) ../preprocessor/pa_wrap.cmo -impl'
+
+#API_FILES = $(wildcard *.api)
+API_FILES = mkdir.api mknod.api
+
+OBJ_FILES = $(patsubst %.api,%.cmo,$(API_FILES))
+
+noinst_SCRIPTS = $(OBJ_FILES)
+
+%.cmo: %.api
+ $(OCAMLFIND) ocamlc $(OCAMLOPTFLAGS) $(PP) -impl $< -c -o $@
+
+CLEANFILES = *.cmi *.cmo *.cmx *~
+
+SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly .api
-object block_device
+system_object block_device
dir_list "/sys/block/[hsv]d[a-z]*"
property string name << return safe_strdup ($basename); >>
-function err mkdir (pathname path, fileperm perm) (* implicit *);;
+entry_point err mkdir (pathname path, fileperm perm) (* implicit *);;
-function
-err mknod_char (pathname path, fileperm perm, int<??> major, int<??> minor)
+entry_point
+err mknod_char (pathname path, fileperm perm, int64 major, int64 minor)
<<
return mknod (path, S_IFCHR | perm, makedev (major, minor));
>>
-<:doc<
-
-
-
->>
;;
-object process
+system_object process
dir_list "/proc/[1-9]*"
constructor <<
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ACLOCAL_AMFLAGS = -I m4
+
+# The API files are actually linked into the generator, but an extra
+# camlp4-based preprocessor must be compiled first before we can
+# compile the rest of the generator. Hence the rather convoluted set
+# of subdirectories here.
+SUBDIRS = preprocessor APIs generator
+
+# The C library.
+SUBDIRS += lib
dnl Check support for 64 bit file offsets.
AC_SYS_LARGEFILE
-dnl Check for OCaml compiler and camlp4.
+dnl Check for OCaml compiler.
AC_PROG_OCAML
if test "$OCAMLC" = "no"; then
AC_MSG_ERROR([You must install the OCaml compiler])
fi
+dnl Camlp4 is required.
AC_PROG_CAMLP4
if test "$CAMLP4" = "no"; then
AC_MSG_ERROR([You must install camlp4 (the OCaml macro preprocessor)])
fi
+dnl OCaml findlib ("ocamlfind") is required.
+AC_PROG_FINDLIB
+if test "$OCAMLFIND" = "no"; then
+ AC_MSG_ERROR([You must install OCaml findlib (the ocamlfind command)])
+fi
+
AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile
+ APIs/Makefile
+ generator/Makefile
+ lib/Makefile
+ preprocessor/Makefile])
AC_OUTPUT
--- /dev/null
+# wrappi
+# Copyright (C) 2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX
+OCAMLOPTFLAGS = $(OCAMLCFLAGS)
+
+%.cmi: %.mli
+ $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
+%.cmo: %.ml
+ $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
+%.cmx: %.ml
+ $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
+
+CLEANFILES = *.cmi *.cmo *.cmx *~
+
+depend: .depend
+
+.depend: $(wildcard *.mli) $(wildcard *.ml)
+ rm -f $@ $@-t
+ $(OCAMLFIND) ocamldep $^ | \
+ $(SED) -e 's/ *$$//' | \
+ $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+ LANG=C sort > $@-t
+ mv $@-t $@
+
+include .depend
+
+SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
--- /dev/null
+# wrappi
+# Copyright (C) 2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--- /dev/null
+pa_wrap.cmo: wrappi_types.cmo
+pa_wrap.cmx: wrappi_types.cmx
+wrappi_types.cmo:
+wrappi_types.cmx:
--- /dev/null
+# wrappi
+# Copyright (C) 2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX
+OCAMLOPTFLAGS = $(OCAMLCFLAGS)
+
+noinst_SCRIPTS = pa_wrap.cmo
+
+pa_wrap.cmo: pa_wrap.ml wrappi_types.cmo
+ $(OCAMLFIND) ocamlc -I +camlp4 dynlink.cma camlp4lib.cma \
+ -pp $(CAMLP4OF) \
+ wrappi_types.cmo -c $< -o $@
+
+%.cmi: %.mli
+ $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
+%.cmo: %.ml
+ $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
+%.cmx: %.ml
+ $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
+
+CLEANFILES = *.cmi *.cmo *.cmx *~
+
+depend: .depend
+
+.depend: $(wildcard *.mli) $(wildcard *.ml)
+ rm -f $@ $@-t
+ $(OCAMLFIND) ocamldep -pp $(CAMLP4OF) $^ | \
+ $(SED) -e 's/ *$$//' | \
+ $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+ LANG=C sort > $@-t
+ mv $@-t $@
+
+include .depend
+
+SUFFIXES = .cmo .cmi .cmx .ml .mli .mll .mly
--- /dev/null
+(* wrappi
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+(* For general information about camlp4, see:
+ * http://brion.inria.fr/gallium/index.php/Camlp4
+ * For information about quotations, see:
+ * http://brion.inria.fr/gallium/index.php/Quotation
+ *)
+
+open Camlp4.PreCast
+open Syntax
+open Ast
+
+open Wrappi_types
+
+let add_entry_point _loc name parameters return_type code =
+ (* XXX *)
+ <:str_item< >>
+
+let () =
+ (* Quotation expander for C code. *)
+ let c_quotation_expander _loc _ code =
+ (* XXX Expand %- or $- expressions in code. *)
+ ExStr (_loc, code)
+ in
+ Quotation.add "c" Quotation.DynAst.expr_tag c_quotation_expander;
+
+ (* Default quotation expander (<< .. >>) should be C code ("c"). *)
+ Quotation.default := "c"
+
+;;
+
+(* Extend the regular OCaml grammar. *)
+EXTEND Gram
+ GLOBAL: str_item;
+
+ (* A parameter or return type. *)
+ any_type: [
+ [ "int32" -> TInt32 ]
+ | [ "int64" -> TInt64 ]
+ | [ t = LIDENT -> Type t ]
+ ];
+
+ (* A return type. *)
+ return_type: [
+ [ "err" -> RErr ]
+ | [ t = any_type -> Return t ]
+ ];
+
+ (* A single function parameter. *)
+ parameter: [[ t = any_type; name = LIDENT -> (t, name) ]];
+
+ str_item: LEVEL "top" [
+ [ "entry_point";
+ return_type = return_type; name = LIDENT;
+ "("; parameters = LIST0 parameter SEP ","; ")";
+ code = OPT [ code = expr -> code ] ->
+ add_entry_point _loc name parameters return_type code
+ ]
+ ];
+
+END
--- /dev/null
+(* wrappi
+ * Copyright (C) 2011 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+type any_type = TInt32 | TInt64 | Type of string
+
+type return_type = RErr | Return of any_type