Commit 1f7cfe34 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

lurette unstable.3 Thu, 01 Feb 2007 10:32:02 +0100 by jahier

Parent-Version:      unstable.2
Version-Log:         empty
Project-Description: Lurette
parent d5e465d2
......@@ -49,6 +49,7 @@
(install/pixmaps/open_plus.xpm 787 1137765987 n/19_open_plus. 1.1)
(source/gen_stubs_sildex.mli 648 1090504025 h/37_gen_stubs_ 1.2)
(xlurette/Scade/Images/gnuplot.bmp 822 1122044801 i/26_gnuplot.bm 1.1)
(GBDDML/bdd.ml 2119 1170322322 r/36_bdd.ml 1.1)
(source/Makefile.luc4c 3146 1161778160 r/23_Makefile.l 1.1)
(examples/xlurette/Scade-win32/pilot.saofdm 394 1137765987 l/31_pilot.saof 1.1)
(source/sol_nb.mli 721 1099986649 i/16_sol_nb.mli 1.1)
......@@ -95,6 +96,7 @@
(examples/xlurette/Gyro/giro2.luc 2836 1137765987 m/41_giro2.luc 1.1)
(source/lustreExp.ml 41154 1165588586 g/45_lustreExp. 1.14.2.1)
(source/Makefile.luc2c 1295 1139330945 n/45_Makefile.l 1.2)
(GBDDML/gbdd.cc 49536 1170322322 r/34_gbdd.cc 1.1)
(FAQ 2004 1137765987 i/15_FAQ 1.2)
(polka/documentation/Makefile 476 1165588586 e/18_Makefile 1.2)
(source/fair_bddd.mli 2505 1137765987 g/39_fair_bddd. 1.9)
......@@ -112,7 +114,9 @@
(examples/lucky/other/Makefile 1554 1165855990 k/47_Makefile 1.2)
(examples/xlurette/Scade-win32/Pilot.saofd 3645 1137765987 l/46_Pilot.saof 1.1)
(source/value.ml 2681 1078751438 c/23_value.ml 1.9)
(GBDDML/._d/bdd.d 0 1170322322 r/41_bdd.d 1.1)
(examples/xlurette/Scade-win32/det_mvt_mode_cstext.c 703 1137765987 l/42_det_mvt_mo 1.1)
(GBDDML/gbdd.h 28283 1170322322 r/33_gbdd.h 1.1)
(source/var.mli 3632 1127735479 g/50_var.mli 1.13)
(examples/xlurette/tram/passerelle.luc 641 1138025047 o/17_passerelle 1.1)
(examples/xlurette/Gyro/onlyroll2.lus 18345 1137765987 m/30_onlyroll2. 1.1)
......@@ -121,6 +125,7 @@
(install/xlurette_sh.in 719 1137765987 g/20_xlurette_s 1.2)
(doc/figs/nh-gen-pict.fig 3181 1138034376 q/43_nh-gen-pic 1.1)
(examples/lucky/tut-examples/simple.luc 174 1137765987 k/27_simple.luc 1.1)
(GBDDML/OCamlMakefile 21208 1170322322 r/37_OCamlMakef 1.1)
(doc/figs/nh-lurette-start.fig 2042 1138034376 q/49_nh-lurette 1.1)
(examples/rml/Makefile 764 1169542477 k/13_Makefile 1.1.1.2)
(source/solver.mli 1793 1137765987 38_solver.mli 1.25)
......@@ -168,6 +173,7 @@
(source/luc_exe.ml 12023 1149596800 b/32_ima_exe.ml 1.59)
(source/Makefile.gnuplot-socket 416 1138025047 i/32_Makefile.g 1.2)
(polka/caml/polkaIO.ml 1651 1071844798 d/44_polkaIO.ml 1.2)
(GBDDML/bdd.mli.hide 1654 1170322322 r/35_bdd.mli.hi 1.1)
(examples/xlurette/Scade-win32/lib_pilot.vsw 435 1137765987 l/32_lib_pilot. 1.1)
(source/gnuplot-socket.ml 1773 1137765987 i/18_gnuplot-so 1.3)
(source/Makefile.lucky 4698 1165588586 b/41_Makefile.i 1.39.1.1)
......@@ -180,6 +186,7 @@
(examples/xlurette/Scade-sparc/Makefile 552 1137765987 l/10_Makefile 1.1)
(polka/caml/polka_lexer.mli 200 1047029868 d/41_polka_lexe 1.1)
(source/solver.ml 11994 1169542477 39_solver.ml 1.67)
(GBDDML/.test.ml.swp 12288 1170322322 r/40_.test.ml.s 1.1)
(examples/ocaml/crazy-rabbit/rabbit-dir-obstacle.luc 1849 1137765987 j/48_rabbit-dir 1.1)
(examples/xlurette/Gyro/giro.luc 2445 1137765987 m/33_giro.luc 1.1)
(examples/lucky/tut-examples/fairness.luc 281 1137765987 k/30_fairness.l 1.1)
......@@ -190,6 +197,7 @@
(source/Makefile.gen_lustre 943 1122044801 j/8_Makefile.g 1.1)
(source/type.mli 756 1149596800 h/11_type.mli 1.4)
(examples/xlurette/Scade-win32/telemetry_validation.saofd 4738 1137765987 l/30_telemetry_ 1.1)
(GBDDML/Makefile.R1 1031 1170322322 r/39_Makefile.R 1.1)
(install/set_env_var.in 1672 1165588586 g/23_set_env_va 1.9.2.1)
(examples/xlurette/Scade-win32/C_SQRT.saofd 214 1137765987 m/2_C_SQRT.sao 1.1)
(examples/ocaml/crazy-rabbit/crazy_rabbit-rabbit_speed.luc 3547 1137765987 j/41_crazy_rabb 1.1)
......@@ -299,9 +307,10 @@
(doc/lurette-man/batch.jpg 307 1138032075 q/3_batch.jpg 1.1)
(examples/xlurette/Sildex/test.rif.exp 1048702 1138025047 o/25_test.rif.e 1.1)
(install/Makefile.lurette.in 5158 1137765987 b/38_Makefile.l 1.38)
(GBDDML/Makefile 2975 1170322322 r/30_Makefile 1.1)
(examples/rml/window.out.exp 2210 1137765987 k/6_window.out 1.1)
(examples/xlurette/heater/test1.res 0 1137765987 m/22_test1.res 1.1)
(source/version.ml 21 1169542477 n/43_version.ml 1.7)
(source/version.ml 21 1170322322 n/43_version.ml 1.8)
(examples/xlurette/Scade-win32/Pilot.ewo 785 1137765987 l/28_Pilot.ewo 1.1)
(RELEASE-NOTES 3737 1165588586 h/45_RELEASE-NO 1.7.1.1)
(examples/lucky/C/test.res 0 1149596800 r/18_test.res 1.1)
......@@ -429,6 +438,7 @@
(source/print.mli 1130 1078751438 46_print.mli 1.15)
(examples/xlurette/tram/utiles.lus 411 1138025047 o/13_utiles.lus 1.1)
(source/Makefile.lurette_debug 2576 1137765987 j/5_Makefile.l 1.2)
(GBDDML/Makefile.pascal2 2360 1170322322 r/38_Makefile.p 1.1)
(source/socket_client.ml 603 1122044801 i/43_socket_cli 1.1)
(source/type.ml 2900 1149596800 h/12_type.ml 1.3)
(examples/xlurette/Scade-sparc/exo1.saofdm 321 1137765987 l/18_exo1.saofd 1.1)
......@@ -497,6 +507,7 @@
(doc/lurette-man/Makefile 1497 1165588586 q/14_Makefile 1.2)
(install/pixmaps/open.ppm 1741 1137765987 n/6_open.ppm 1.1)
(source/exp.ml 10797 1137765987 g/47_exp.ml 1.13)
(GBDDML/gbdd_cml.cc 9076 1170322322 r/32_gbdd_cml.c 1.1)
(doc/tutorial/figs/lucky-ex.fig 1531 1138032075 q/34_lucky-ex.f 1.1)
(examples/xlurette/heater/test3.res 0 1137765987 m/24_test3.res 1.1)
(xlurette/makefile 4587 1138032075 q/21_makefile 1.1)
......@@ -504,6 +515,7 @@
(install/pixmaps/halt.xpm 511 1137765987 n/21_halt.xpm 1.1)
(source/Makefile.luc4ocaml 4773 1165588586 j/0_Makefile.o 1.3.1.2)
(source/command_line_luc_exe.mli 1412 1122044801 b/34_command_li 1.19)
(GBDDML/test.ml 366 1170322322 r/31_test.ml 1.1)
(polka/C/config.h 78 1071844798 e/13_config.h 1.2)
(examples/xlurette/tram/porte.luc 651 1138025047 o/16_porte.luc 1.1)
(polka/caml/vector.idl 10381 1076684617 d/35_vector.idl 1.4)
......
#------------------------------------------------------------------
# wrappeur ocaml pour gbdd
#------------------------------------------------------------------
# n.b. on recompile gbdd.o plutot que d'utiliser la librairie standard
# du LUSTRE_INSTALL (pour tre sur d'utiliser des compilos
# caml et gcc compatibles)
#------------------------------------------------------------------
# Pour utiliser la librairie, il faut linker avec une commande du style :
#
# pour gcc > 3.* !
# ocamlopt bdd.cmx $(MES_CMX) gbdd_cml.o gbdd.o -cclib -lstdc++ -o $(MON_PRG)
#
#------------------------------------------------------------------
# SOURCES
#------------
# * bdd.ml => bdd.cmi et bdd.cmx
# (interface + qq utils en ocaml)
#
# * gbdd_cml.cc => gbdd_cml.o
# (le gros de l'implementation de bdd.ml
# en C++ compatible C via macro extern "C")
#
# * gbdd.cc/gbdd.h => gbdd.o
# (le source du module C++ originel)
#
# * test.ml => un test pour voir ...
#
#------------------------------------------------------------------
#OCAML_INSTALL=$OCAMLLIB
ifeq ($(HOST_TYPE),win32)
# windows
OCAML_LIB="c:\TEMP\ocaml\lib"
OCAMLOPT = /cygdrive/c/TEMP/ocaml/bin/ocamlopt
OCAMLC = /cygdrive/c/TEMP/ocaml/bin/ocamlc
OCAML = /cygdrive/c/TEMP/ocaml/bin/ocaml
CPP_COMPILER=g++ -mno-cygwin
CPP_LINKER=g++ -mno-cygwin
else
ifeq ($(HOST_TYPE),sparc-sun)
OCAML_LIB=ocaml
OCAMLOPT =ocamlopt
OCAMLC = ocamlc
CPP_COMPILER=g++
CPP_LINKER=g++
else
OCAML_LIB=ocaml
OCAMLOPT =ocamlopt
OCAMLC = ocamlc
CPP_COMPILER=g++ # -DGBDD_CML_PARANO -DGBDD_CML_DBG
CPP_LINKER=g++
endif
endif
#OCAMLOPT = ocamlopt
CPP_FLAGS=-g g-O0 -fno-operator-names -I$(OCAML_LIB)
LFLAGS = -cclib -lstdc++
# bdd.cmi : bdd.mli
# ocamlopt -c bdd.mli
bdd.cmx : bdd.ml
$(OCAMLOPT) -c bdd.ml
test.cmx : test.ml
$(OCAMLOPT) -c test.ml
gbdd_cml.o : gbdd.h gbdd_cml.cc
$(CPP_COMPILER) -c $(CPP_FLAGS) gbdd_cml.cc -o gbdd_cml.o
gbdd.o : gbdd.h gbdd.cc
$(CPP_COMPILER) -c $(CPP_FLAGS) gbdd.cc -o gbdd.o
test : bdd.cmx gbdd_cml.o gbdd.o test.cmx
$(OCAMLOPT) bdd.cmx test.cmx gbdd_cml.o gbdd.o $(LFLAGS) -o test
libbdd_stubs.a : gbdd_cml.o gbdd.o
ar rc libbdd_stubs.a gbdd_cml.o gbdd.o
ranlib libbdd_stubs.a
%.cmo: %.ml %.cmi
$(OCAMLC) -c $<
bdd.cma: bdd.cmo
$(OCAMLC) -a -o bdd.cma bdd.cmo
bdd.cmxa : bdd.ml libbdd_stubs.a bdd.cmx
$(OCAMLOPT) -a -verbose -cclib -lstdc++ -cclib -lbdd_stubs \
-o bdd.cmxa bdd.cmx
bdd.a: bdd.cmx
ar rc bdd.a bdd.o
ranlib bdd.a
all : bdd.a libbdd_stubs.a bdd.cmxa bdd.cma
clean:
rm -f *.o *.cmo *.cmi *.cmx *.a *.cma *.cmxa
cp:
cp libbdd_stubs.a ../$(HOSTTYPE)/lib/
cp bdd.a ../$(HOSTTYPE)/lib/
cp bdd.a ../$(HOSTTYPE)/lib/libbdd.a
cp bdd.cm* ../$(HOSTTYPE)/lib/
VERIMAG_INSTALL_DIR=`ocamlc -where`/lucky
cp-verimag:
cp libbdd_stubs.a $(VERIMAG_INSTALL_DIR)
cp bdd.a $(VERIMAG_INSTALL_DIR)
cp bdd.a $(VERIMAG_INSTALL_DIR)/libbdd.a
cp bdd.cm* $(VERIMAG_INSTALL_DIR)
OCAMLMAKEFILE = ./OCamlMakefile
ifeq ($(HOST_TYPE),cygwin)
# windows
OCAML_LIB="c:\TEMP\ocaml\lib"
OCAMLLIB=c:\TEMP\ocaml\lib
OCAMLOPT = /cygdrive/c/TEMP/ocaml/bin/ocamlopt
OCAMLC = /cygdrive/c/TEMP/ocaml/bin/ocamlc
OCAML = /cygdrive/c/TEMP/ocaml/bin/ocaml
GCC=g++ -O2 -mno-cygwin
CXX=g++ -O2 -fno-operator-names -mno-cygwin
else
# OCAML_LIB=/usr/local/soft/ocaml/3.08/lib/ocaml
# OCAMLLIB=/usr/local/soft/ocaml/3.08/lib/ocaml
# OCAMLOPT = /usr/local/soft/ocaml/3.08/bin/ocamlopt
GCC=g++ -O2
CXX=g++ -O2 -fno-operator-names
endif
CFLAGS= -g -fno-operator-names
OCAMLLDFLAGS= -verbose -cclib -lstdc++
SOURCES = gbdd_cml.cc gbdd.cc bdd.ml
RESULT = bdd
all: ncl bdd.cma
include $(OCAMLMAKEFILE)
cp: ncl
cp libbdd_stubs.a $(HOME)/$(HOSTTYPE)/lib/
cp bdd.a $(HOME)/$(HOSTTYPE)/lib/
cp bdd.cm* $(HOME)/$(HOSTTYPE)/lib/
up:clean
cp /home/raymond/other_tools/gcc3/GBDDML/gbdd.cc .
cp /home/raymond/other_tools/gcc3/GBDDML/gbdd_cml.cc .
cp /home/raymond/other_tools/gcc3/GBDDML/gbdd.h .
make cp
\ No newline at end of file
#------------------------------------------------------------------
# wrappeur ocaml pour gbdd
#------------------------------------------------------------------
# n.b. on recompile gbdd.o plutot que d'utiliser la librairie standard
# du LUSTRE_INSTALL (pour tre sur d'utiliser des compilos
# caml et gcc compatibles)
#------------------------------------------------------------------
# Pour utiliser la librairie, il faut linker avec une commande du style :
#
# ocamlopt bdd.cmx $(MES_CMX) gbdd_cml.o gbdd.o -cclib -lstdc++ -o $(MON_PRG)
#
#------------------------------------------------------------------
# SOURCES
#------------
# * bdd.ml => bdd.cmi et bdd.cmx
# (interface + qq utils en ocaml)
#
# * gbdd_cml.cc => gbdd_cml.o
# (le gros de l'implementation de bdd.ml
# en C++ compatible C via macro extern "C")
#
# * gbdd.cc/gbdd.h => gbdd.o
# (le source du module C++ originel)
#
# * test.ml => un test pour voir ...
#
#------------
# TARGETS
#------------
# * test => un exemple d'executable natif
#
# * lib => bdd.cma
#
# * runtime => ocamlbddrun (ocaml + bdd runtime)
#
# * toplevel => ocamlbdd (ocaml + bdd toplevel)
#
#------------------------------------------------------------------
OCAML_INSTALL=/usr/local/soft/ocaml/3.08
OCAML_LIB=$(OCAML_INSTALL)/lib/ocaml/
CPP_COMPILER=g++
CPP_LINKER=g++
C_COMPILER=gcc
C_LINKER=gcc
CPP_FLAGS=-g -fno-operator-names -I$(OCAML_LIB)
LFLAGS = -cclib -lstdc++
# -ccopt -L$(LUSTRE_INSTALL)/lib -cclib -lgbdd
# -ccopt -L$(OCAML_LIB) -cclib -lcamlrun
all : test
lib : bdd.cma
toplevel : ocamlbdd
runtime : ocamlbddrun
test : bdd.cmx gbdd_cml.o gbdd.o test.cmx
ocamlopt bdd.cmx test.cmx gbdd_cml.o gbdd.o $(LFLAGS) -o test
bdd.cma : bdd.cmo gbdd_cml.o gbdd.o
ocamlc -a -o bdd.cma -custom bdd.cmo gbdd_cml.o gbdd.o $(LFLAGS)
# ocamlopt -a -o bdd.cma -custom bdd.cmx gbdd_cml.o gbdd.o $(LFLAGS)
ocamlbdd : bdd.cma
ocamlmktop -o ocamlbdd bdd.cma
ocamlbddrun : bdd.cma
ocamlc -make-runtime -o ocamlbddrun bdd.cma
bdd.cmo : bdd.ml
ocamlc -c bdd.ml
bdd.cmx : bdd.ml
ocamlopt -c bdd.ml
test.cmx : test.ml
ocamlopt -c test.ml
gbdd_cml.o : gbdd.h gbdd_cml.cc
$(CPP_COMPILER) -c $(CPP_FLAGS) gbdd_cml.cc -o gbdd_cml.o
gbdd.o : gbdd.h gbdd.cc
$(CPP_COMPILER) -c $(CPP_FLAGS) gbdd.cc -o gbdd.o
clean:
rm -f *.o *.cmo *.cmi *.cmx
This diff is collapsed.
(* ----------------------------------------------------------------
Interface ocaml pour gbdd
-------------------------------------------------------------------
On garde les noms compatibles "cudd-idl" utiliss dans lurette :
Bdd._print ??
Bdd.draw
Bdd.nbminterms
---------------------------------------------------------------- *)
(* Le type abstrait *)
type t
(* Init du module *)
external init : unit -> unit = "gbdd_cml_init"
(* Accs aux noeuds *)
external root_var : t -> int = "gbdd_cml_root_var"
external high_part : t -> t = "gbdd_cml_high_part"
external low_part : t -> t = "gbdd_cml_low_part"
(* Tests *)
external is_leaf : t -> bool = "gbdd_cml_is_leaf"
external is_true : t -> bool = "gbdd_cml_is_true"
external is_false : t -> bool = "gbdd_cml_is_false"
(* Constantes *)
external dtrue : unit -> t = "gbdd_cml_true"
external dfalse : unit -> t = "gbdd_cml_false"
external null : unit -> t = "gbdd_cml_null"
(* Identit et Inverse *)
external idy : int -> t = "gbdd_cml_idy"
external nidy : int -> t = "gbdd_cml_nidy"
(* Oprations boolennes *)
external dnot : t -> t = "gbdd_cml_not"
external dor : t -> t -> t = "gbdd_cml_or"
external dand : t -> t -> t = "gbdd_cml_and"
external xor : t -> t -> t = "gbdd_cml_xor"
external eq : t -> t -> t = "gbdd_cml_eq"
external ite : t -> t -> t -> t = "gbdd_cml_ite"
(* Infos sur la structure *)
external size : t -> int = "gbdd_cml_size"
external supportsize : t -> int = "gbdd_cml_supportsize"
(* Extra *)
external print_mons : t -> unit = "gbdd_cml_print_mons"
(* compatibilit cudd *)
external topvar : t -> int = "gbdd_cml_root_var"
external dthen : t -> t = "gbdd_cml_high_part"
external delse : t -> t = "gbdd_cml_low_part"
external ithvar : int -> t = "gbdd_cml_idy"
external is_cst : t -> bool = "gbdd_cml_is_leaf"
external support : t -> t = "gbdd_cml_cube"
(* Extra programms directement en caml *)
let rec list_of_support (b: t) = (
let rec los x = (
if(is_leaf x) then []
else (
(topvar x)::(los (dthen x))
)
) in
los (support b)
)
type t
(* Init du module *)
external init : unit -> unit = "gbdd_cml_init"
(* Accs aux noeuds *)
external root_var : t -> int = "gbdd_cml_root_var"
external high_part : t -> t = "gbdd_cml_high_part"
external low_part : t -> t = "gbdd_cml_low_part"
(* Tests *)
external is_leaf : t -> bool = "gbdd_cml_is_leaf"
external is_true : t -> bool = "gbdd_cml_is_true"
external is_false : t -> bool = "gbdd_cml_is_false"
(* Constantes *)
external dtrue : unit -> t = "gbdd_cml_true"
external dfalse : unit -> t = "gbdd_cml_false"
external null : unit -> t = "gbdd_cml_null"
(* Identit et Inverse *)
external idy : int -> t = "gbdd_cml_idy"
external nidy : int -> t = "gbdd_cml_nidy"
(* Oprations boolennes *)
external dnot : t -> t -> t = "gbdd_cml_not"
external dor : t -> t -> t = "gbdd_cml_or"
external dand : t -> t -> t = "gbdd_cml_and"
external xor : t -> t -> t = "gbdd_cml_xor"
external eq : t -> t -> t = "gbdd_cml_eq "
external ite : t -> t -> t -> t = "gbdd_cml_ite"
(* Infos sur la structure *)
external size : t -> int = "gbdd_cml_size"
external supportsize : t -> int = "gbdd_cml_supportsize"
(* Extra *)
external print_mons : t -> unit = "gbdd_cml_print_mons"
(* compatibilit cudd *)
external topvar : t -> int = "gbdd_cml_root_var"
external dthen : t -> t = "gbdd_cml_high_part"
external delse : t -> t = "gbdd_cml_low_part"
external ithvar : int -> t = "gbdd_cml_idy"
external is_leaf : t -> bool = "gbdd_cml_is_leaf"
external support : t -> t = "gbdd_cml_cube"
(* Extra programms directement en caml *)
val list_of_support : t -> int list
This diff is collapsed.
This diff is collapsed.
extern "C" {
#include <stdio.h>
#include <assert.h>
#include "caml/fail.h"
#include "caml/alloc.h"
#include "caml/custom.h"
#include "caml/memory.h"
#include "caml/callback.h"
#include "caml/camlidlruntime.h"
#include "caml/mlvalues.h"
}
#include "gbdd.h"
//#define GBDD_CML_DBG
#define GBDD_CML_PARANO
#ifdef GBDD_CML_PARANO
#define CHECK_NOT_NULL(v) assert(GBdd_value(v) && !GBdd_value(v)->is_null())
#define CHECK_NOT_LEAF(v) assert(!GBdd_value(v)->is_leaf())
#else
#define CHECK_NOT_NULL(v)
#define CHECK_NOT_LEAF(v)
#endif
#define _30_BITS_CODE(x) (x & 0x1FFFFFFF)
typedef GBdd* PGBdd;
extern "C" {
/*------------------------------------------------------
Les rfrences "GBdd*" sont stockes dans des
custom blocks caml
------------------------------------------------------*/
inline GBdd** GBdd_value_adr(value v){
return ((GBdd**)(Data_custom_val(v)));
}
#ifdef GBDD_CML_PARANO
GBdd* GBdd_value(value v){
PGBdd* p = (PGBdd*)Data_custom_val(v);
GBdd* res = *p;
return res;
}
#else
inline GBdd* GBdd_value(value v){
return *((GBdd**)(Data_custom_val(v)));
}
#endif
//------------------------------
//table des oprations
//------------------------------
//finalization:
void finalize_gbdd_block(value v){
#ifdef GBDD_CML_DBG
printf("deleting %lx\n", v);
#endif
GBdd* pb = GBdd_value(v);
delete pb;
}
int compare_gbdd_block(value b1, value b2){
CAMLparam2(b1,b2);
CHECK_NOT_NULL(b1);
CHECK_NOT_NULL(b2);
int res = compare(*GBdd_value(b1), *GBdd_value(b2));
//CAMLreturn(Val_int(res));
CAMLreturn(res);
}
long hash_gbdd_block(value b){
CAMLparam1(b);
CHECK_NOT_NULL(b);
GBdd* pb = GBdd_value(b);
long res = _30_BITS_CODE(pb->code());
CAMLreturn(res);
}
static custom_operations GBDD_BLOCK_OPS = {
"gbdd", //char *identifier;
finalize_gbdd_block, //void (*finalize)(value v);
compare_gbdd_block, //int (*compare)(value v1, value v2);
hash_gbdd_block, //long (*hash)(value v);
custom_serialize_default,
//void (*serialize)(value v, unsigned long* wsize_32, unsigned long* wsize_64);
custom_deserialize_default
//unsigned long (*deserialize)(void* dst);
};
//----------------------------------
// Allocation d'un block
//----------------------------------
// on associe au bloc un pointeur
// sur un GBdd tout neuf ...
//----------------------------------
static value alloc_gdbb_block() {
value res = alloc_custom(
&GBDD_BLOCK_OPS,
sizeof(GBdd*),
1, //used
1000 //max
);
*(GBdd_value_adr(res)) = new GBdd();
return res;
}
static void set_gbdd_value(value b, const GBdd& v){
*(GBdd_value(b)) = v ;
}
/*-------------------------------------------------
Implmentation des primitives ocaml
---------------------------------------------------
N.B. on descend "un cran plus bas" que
l'interface C++ de GBdd, en s'autorisant la
manipulation des GBddValue
-------------------------------------------------*/
value gbdd_cml_compare(value b1, value b2){
CAMLparam2(b1,b2);
CHECK_NOT_NULL(b1);
CHECK_NOT_NULL(b2);
int res = compare(*GBdd_value(b1), *GBdd_value(b2));
CAMLreturn(Val_int(res));
}
value gbdd_cml_hash(value b){
CAMLparam1(b);
CHECK_NOT_NULL(b);
GBdd* pb = GBdd_value(b);
long res = _30_BITS_CODE(pb->code());
printf("gbdd_cml_hash->%d\n", res);
CAMLreturn(Val_long(res));
}
// INIT
value gbdd_cml_init (value /*unit*/) {
CAMLparam0();
GBdd::init_module();
// fprintf(stderr, "gbdd_cml_init \n");
// fflush(stderr);
GBdd::set_verbose_mode();
CAMLreturn(Val_unit);
}
// CONSTANTES
value gbdd_cml_true (value /*unit*/) {
CAMLparam0();
CAMLlocal1(res);