Commits

camlspotter committed a4260e8

fix

Comments (0)

Files changed (3)

     ./module.pl *.idl.in > $@
 
 autoapioo.ml: autoapi.ml pa/pa_opycaml.cmo
-    camlp4o ./pa/pa_opycaml.cmo -impl autoapi.ml -printer Camlp4AutoPrinter > $@
+    camlp4o ./pa/pa_opycaml.cmo -impl autoapi.ml -printer Camlp4OCamlPrinter > $@
 
 auto_stubs.o: auto_stubs.c auto.h api_ml.h autoclasses.h
 
   rm -f $(filter-proper-targets $(ls R, .))
 
 MyOCamlPackageExtras[] = opycaml_python.o from_python_c.o
-MyOCamlPackage(opycaml, utils type autoapi api, auto_stubs api_ml, -lpython$(PY_VERSION) -L$(PREFIX)/lib/ocaml $(L_CAMLIDL_FINDLIB) -lcamlidl)
+MyOCamlPackage(opycaml, utils type autoapi api autoapioo OOApi, auto_stubs api_ml, -lpython$(PY_VERSION) -L$(PREFIX)/lib/ocaml $(L_CAMLIDL_FINDLIB) -lcamlidl)
 
 opycaml_python.o: opycaml.cmx libopycaml.a dllopycaml.so
 	$(OCamlOpt) -output-obj -o $@ opycaml.cmx -cclib -lopycaml -ccopt -L$(OCAML_WHERE) $(CCOPT_L_CAMLIDL_FINDLIB) -ccopt -Wl,-rpath,$(OCAML_WHERE) -cclib -lpython$(PY_VERSION) -cclib -lcamlidl
 include Type
 
-open Autoapi
-
 module Py = struct
   module OCaml = struct
     module String = String
     module Callback = Callback
+    module List = List
   end
     
+  open Autoapi
+
   module String = String
   module ByteArray = ByteArray
   module Number = Number
       val to_list : _Tuple t -> _Object t list
     end = struct
       let from_list lst =
-	let tpl = new_ (List.length lst) in
+	let tpl = new_ (OCaml.List.length lst) in
 	Utils.List.iteri (setItem tpl) lst;
 	tpl
   
         Printf.eprintf "%s : %d : %nx : %s\n%!" name cnt address repr
     
       external _main : int -> string list -> int = "opycaml_Py_Main"
-      let main argv = _main (List.length argv) argv
+      let main argv = _main (OCaml.List.length argv) argv
 
       external unsafe_embed : 'a -> _CObject t = "opycaml_embed_ocaml_value"
       external unsafe_extract : _CObject t -> 'a = "opycaml_extract_embeded_ocaml_value"
               let return ty =
                 let _loc = Loc.ghost in
                 match ty with
-                | <:ctyp< $ <:ctyp@tyloc< Autoapi . $lid:clsname$ >> $ t >> ->
+                | <:ctyp< $ <:ctyp@tyloc< $lid:clsname$ >> $ t >> ->
                     (fun e -> <:expr@_loc< new $lid:"o" ^ clsname$ $e$ >>), <:ctyp@tyloc< $lid: "o" ^ clsname$ >>
                 | _ -> (fun e -> e), ty
               in
                   in
 
                   let mk_method name loc ty_rest =
-                    let id = <:expr@loc< Autoapi . $lid:modname$.$lid:name$ >> in
+                    let id = <:expr@loc< Autoapi . $uid:modname$.$lid:name$ >> in
                     let poly_type, expr = wrap_oo <:expr@loc<$id$ t>> ty_rest in
                     <:class_str_item@loc<
                      method $name$ : $poly_type$ = $expr$
                      >>
                   in
 
-                  let non_meths = concat_str_items 
-                    (List.map (fun (name, loc, ty) -> mk_non_method name loc ty) non_meths)
-                  in
-
                   let meths =
                     concat_class_str_items
                       (List.map (fun (name, loc, ty_rest) -> mk_method name loc ty_rest) meths)
               | _ -> assert false
             in
             classes := class_expr :: !classes;
-            let sitems' = <:str_item<
-                      $non_meths$
-              >>
-            in
-            let meStr = <:module_expr@sloc< 
-                             struct 
-                               open $ <:ident< Autoapi . $lid:modname$ >> $ 
-                               $sitems'$ 
-                             end 
-              >> 
-            in
-            modules := <:str_item@mloc< module $modname$ = $meStr$ >> :: !modules;
+
+            begin match non_meths with
+            | [] -> ()
+            | _ ->
+                  let non_meths = concat_str_items 
+                    (List.map (fun (name, loc, ty) -> mk_non_method name loc ty) non_meths)
+                  in
+
+                let sitems' = <:str_item<
+                  $non_meths$
+                  >>
+                in
+                let meStr = 
+                  <:module_expr@sloc< 
+                      struct 
+                        open $ <:ident< Autoapi . $uid:modname$ >> $ 
+                        $sitems'$ 
+                      end 
+                  >>
+                in
+                modules := <:str_item@mloc< module $modname$ = $meStr$ >> :: !modules;
+            end
 
           | _sitem -> ()) sitem;
         let _loc = Loc.ghost in
         let class_defs = concat_class_exprs (List.rev !classes) in
         <:str_item@_loc< 
           open Type
-          $ class_defs $
+          module Classes = struct $ class_defs $ end
+          open Classes  
           $ concat_str_items (List.rev !modules) $
         >>