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/SWIG@5197 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
dff2895809
commit
b6bf9d6036
3 changed files with 54 additions and 4 deletions
|
|
@ -537,14 +537,17 @@ mzscheme_clean:
|
||||||
##### Ocaml #####
|
##### Ocaml #####
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
SWIGWHERE=-I `$(SWIG) -ocaml -where`
|
OCC=@OCAMLC@
|
||||||
OCC=@OCAMLC@ $(SWIGWHERE)
|
|
||||||
OCAMLDLGEN=@OCAMLDLGEN@
|
OCAMLDLGEN=@OCAMLDLGEN@
|
||||||
OCAMLFIND=@OCAMLFIND@
|
OCAMLFIND=@OCAMLFIND@
|
||||||
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
|
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
|
||||||
NOLINK ?= false
|
NOLINK ?= false
|
||||||
|
|
||||||
ocaml_static: $(SRCS)
|
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)
|
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
|
||||||
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
||||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||||
|
|
@ -558,6 +561,10 @@ ocaml_static: $(SRCS)
|
||||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
|
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
|
||||||
|
|
||||||
ocaml_dynamic: $(SRCS)
|
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)
|
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
|
||||||
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
||||||
$(CXXSHARED) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
|
$(CXXSHARED) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
|
||||||
|
|
@ -576,6 +583,10 @@ ocaml_dynamic: $(SRCS)
|
||||||
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
|
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
|
||||||
|
|
||||||
ocaml_static_toplevel: $(SRCS)
|
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)
|
$(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
|
||||||
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
|
||||||
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
|
||||||
|
|
@ -589,6 +600,10 @@ ocaml_static_toplevel: $(SRCS)
|
||||||
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
|
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
|
||||||
|
|
||||||
ocaml_static_cpp: $(SRCS)
|
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)
|
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
|
||||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||||
|
|
@ -605,6 +620,10 @@ ocaml_static_cpp: $(SRCS)
|
||||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||||
|
|
||||||
ocaml_static_cpp_toplevel: $(SRCS)
|
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)
|
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
|
||||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
||||||
|
|
@ -621,6 +640,10 @@ ocaml_static_cpp_toplevel: $(SRCS)
|
||||||
-cclib "$(LIBS)" -cc '$(CXX)'
|
-cclib "$(LIBS)" -cc '$(CXX)'
|
||||||
|
|
||||||
ocaml_dynamic_cpp: $(SRCS)
|
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)
|
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
|
||||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||||
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
|
$(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)'
|
$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
|
||||||
|
|
||||||
ocaml_static_multi_cpp: $(SRCS)
|
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) \
|
$(SWIG) -c -ocaml -c++ $(SWIGOPT) \
|
||||||
$(INTERFACE)
|
$(INTERFACE)
|
||||||
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,4 @@
|
||||||
# libswigocaml is not needed anymore.
|
# libswigocaml is not needed anymore.
|
||||||
swigp4.ml
|
swigp4.ml
|
||||||
swig.mli
|
swig.mli
|
||||||
swig.cmi
|
swig.ml
|
||||||
swig.cmo
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,24 @@ type 'a c_obj_t =
|
||||||
| C_enum of 'a
|
| C_enum of 'a
|
||||||
| C_director_core of 'a c_obj_t * 'a c_obj_t option ref
|
| 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 =
|
let rec get_int x =
|
||||||
match x with
|
match x with
|
||||||
C_bool b -> if b then 1 else 0
|
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")
|
| _ -> raise (Failure "Not a director core object")
|
||||||
let _ = Callback.register "caml_director_get_self" director_get_self
|
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_float f = C_float f
|
||||||
let make_double f = C_double f
|
let make_double f = C_double f
|
||||||
let make_string s = C_string s
|
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_uint i = C_uint (Int32.of_int i)
|
||||||
let make_int32 i = C_int32 (Int32.of_int i)
|
let make_int32 i = C_int32 (Int32.of_int i)
|
||||||
let make_int64 i = C_int64 (Int64.of_int i)
|
let make_int64 i = C_int64 (Int64.of_int i)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue