Commits

camlspotter committed 963bb97 Merge

merge

Comments (0)

Files changed (7)

 .DEFAULT: $(OCamlProgram test_bug1, test_bug1)
 
 .PHONY: install
-install: opycaml.cma opycaml.cmxa libopycaml_python.so
-	$(OCAMLFIND) install opycaml opycaml.cmi opycaml.cma opycaml.cmxa opycaml.a dllopycaml.so libopycaml.a autoapi.ml api.ml META libopycaml_python.so
+install: opycaml.cma opycaml.cmxa
+	$(OCAMLFIND) install opycaml opycaml.cmi opycaml.cma opycaml.cmxa opycaml.a dllopycaml.so libopycaml.a autoapi.ml api.ml META
 typedef int Py_ssize_t; // not sure
 typedef int size_t; // not sure
 
+typedef [abstract] void FILE;
+
 #include "err.idl"
 #include "object.idl"
 #include "base.idl"

example/OMakefile

 OCAMLPACKS = opycaml
 
 .DEFAULT: $(OCamlProgram test, test)
+.DEFAULT: $(OCamlProgram module_new, module_new)
 
 .PHONY: clean
 clean:

example/module_new.ml

+open Opycaml.Api
+
+let _ =
+  Base.initialize ();
+  let mdl = Module.new_ "MyModule" in
+  let mdldic = Import.getModuleDict () in
+  Dict.setItemString mdldic "MyModule" mdl;
+  let dic = Module.getDict mdl in
+  Dict.setItemString dic "answer" (Int.fromLong 42);
+  ignore (Base.main []);
+  Base.finalize ()
+;;
+
+
+  
 // int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
 // Read and execute a single statement from a file associated with an interactive device according to the flags argument. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 when the input was executed successfully, -1 if there was an exception, or an error code from the errcode.h include file distributed as part of Python if there was a parse error. (Note that errcode.h is not included by Python.h, so must be included specifically if needed.)
 
-// int PyRun_InteractiveLoop(FILE *fp, const char *filename);
+int PyRun_InteractiveLoop([in] FILE *fp, [string] const char *filename);
 // This is a simplified interface to PyRun_InteractiveLoopFlags() below, leaving flags set to NULL.
+//
+// ( ゚∀゚)o彡°O'PyCaml: FILE is not implemented. Always use [Run.interactiveLoop None "-"] in order to read from STDIN for the moment.
 
 // int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
 // Read and execute statements from a file associated with an interactive device until EOF is reached. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 at EOF.
             $rem =~ s/py([A-z]+)_p_noincr/py$1/g;
             $rem =~ s/py([A-z]+)_p_incr/py$1/g;
             $rem =~ s/py([A-z]+)_p/py$1/g;
-    
+	    # FILE
+	    $rem =~ s/fILE/_FILE/g;
+
 	    # introduce polymorphism (pretty dirty)
 	    # pyAbcd ... -> ==> [>_Abcd] t ... ->
 	    while( $rem =~ s/py([A-Z][A-z]+)(.*->)/[>_$1] t$2/g ){
 type hash_or_fail = nativeint
 type py_ssize_t = int
 type size_t = int
+type _FILE (* not implemented yet *)
 
 exception Error of _Object t (* type *) * _Object t (* detail value *)