More orthodox way of building the Swig module. I'm working on making

modules easier to link together by isolating the common types and functions
in a module that they all open.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5197 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Art Yerkes 2003-10-22 13:46:42 +00:00
commit c1e6a38f30
3 changed files with 54 additions and 4 deletions

View file

@ -537,14 +537,17 @@ mzscheme_clean:
##### Ocaml #####
##################################################################
SWIGWHERE=-I `$(SWIG) -ocaml -where`
OCC=@OCAMLC@ $(SWIGWHERE)
OCC=@OCAMLC@
OCAMLDLGEN=@OCAMLDLGEN@
OCAMLFIND=@OCAMLFIND@
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
NOLINK ?= false
ocaml_static: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
@ -558,6 +561,10 @@ ocaml_static: $(SRCS)
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
ocaml_dynamic: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(CXXSHARED) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
@ -576,6 +583,10 @@ ocaml_dynamic: $(SRCS)
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
ocaml_static_toplevel: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
@ -589,6 +600,10 @@ ocaml_static_toplevel: $(SRCS)
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
ocaml_static_cpp: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
@ -605,6 +620,10 @@ ocaml_static_cpp: $(SRCS)
-cclib "$(LIBS)" -cc '$(CXX)'
ocaml_static_cpp_toplevel: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
@ -621,6 +640,10 @@ ocaml_static_cpp_toplevel: $(SRCS)
-cclib "$(LIBS)" -cc '$(CXX)'
ocaml_dynamic_cpp: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
@ -643,6 +666,10 @@ ocaml_dynamic_cpp: $(SRCS)
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
ocaml_static_multi_cpp: $(SRCS)
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
$(OCC) -c swig.mli
$(OCC) -c swig.ml
$(SWIG) -c -ocaml -c++ $(SWIGOPT) \
$(INTERFACE)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)

View file

@ -2,5 +2,4 @@
# libswigocaml is not needed anymore.
swigp4.ml
swig.mli
swig.cmi
swig.cmo
swig.ml

View file

@ -23,6 +23,24 @@ type 'a c_obj_t =
| C_enum of 'a
| C_director_core of 'a c_obj_t * 'a c_obj_t option ref
type empty_enum = [ `Int of int ]
exception BadArgs of string
exception BadMethodName of string * string
exception NotObject of empty_enum c_obj_t
exception NotEnumType of empty_enum c_obj_t
exception LabelNotFromThisEnum of empty_enum c_obj_t
let invoke obj = match obj with C_obj o -> o | _ -> raise (NotObject obj)
let _ = Callback.register "swig_runmethod" invoke
let fnhelper fin f arg =
let args = match arg with C_list l -> l | C_void -> [] | _ -> [ arg ] in
match f args with
[] -> C_void
| [ x ] -> (if fin then Gc.finalise
(fun x -> ignore ((invoke x) "~" C_void)) x) ; x
| lst -> C_list lst
let rec get_int x =
match x with
C_bool b -> if b then 1 else 0
@ -84,6 +102,11 @@ let director_get_self obj =
| _ -> raise (Failure "Not a director core object")
let _ = Callback.register "caml_director_get_self" director_get_self
let addr_of obj = (invoke obj) "&" C_void
let _ = Callback.register "caml_obj_ptr" addr_of
let make_float f = C_float f
let make_double f = C_double f
let make_string s = C_string s
@ -98,3 +121,4 @@ let make_int i = C_int i
let make_uint i = C_uint (Int32.of_int i)
let make_int32 i = C_int32 (Int32.of_int i)
let make_int64 i = C_int64 (Int64.of_int i)