Commits

Yosuke Onoue committed d05baea

Python3.2 support

Comments (0)

Files changed (2)

otypes/bootstrap.py

     ArgArray = ctypes.c_char_p * (len(sys.argv) + 1)
     args = ArgArray()
     for i,arg in enumerate(sys.argv):
-        args[i] = ctypes.c_char_p(arg)
+        args[i] = ctypes.c_char_p(arg.encode())
     args[len(sys.argv)] = None
     lib.caml_startup(args)
     return lib
     #mod.context.caml_modify_generation_global_root.restype = None
 
     # mlvalues.h
-    mod.context.caml_get_public_method.restype = mod.ml_value
+    #mod.context.caml_get_public_method.restype = mod.ml_value
     #mod.context.caml_hash_variant.restype = mod.ml_value
     mod.context.caml_string_length.restype = mod.ml_mlsize_t
     #mod.context.caml_Double_val.restype = ctypes.c_double

otypes/template.py

     '''
     CAMLextern value * caml_named_value (char const * name);
     '''
-    return context.caml_named_value(ctypes.c_char_p(name)).contents
+    return context.caml_named_value(ctypes.c_char_p(name.encode())).contents
 
 def caml_callback(*args):
     '''
     '''
     CAMLextern value caml_copy_string (char const *);
     '''
-    return context.caml_copy_string(ctypes.c_char_p(string))
-
-def caml_copy_string_array(strings):
-    '''
-    CAMLextern value caml_copy_string_array (char const **);
-    '''
-    return context.caml_copy_string_array(strings) # TODO
+    return context.caml_copy_string(ctypes.c_char_p(string.encode()))
 
 def caml_copy_double(f):
     '''
     '''
     array = (ctypes.c_char_p * (len(strings) + 1))()
     for i, string in enumerate(strings):
-        array[i] = string
+        array[i] = string.encode()
     array[-1] = None
     return context.caml_copy_string_array(array)
 
 
     #define Byte(x, i) (((char *) (x)) [i])            /* Also an l-value. */
     '''
-    return ctypes.POINTER(ctypes.c_char).from_buffer(v)[n]
+    return ctypes.POINTER(ctypes.c_char).from_buffer(v)[n].decode()
 
 def bp_val(v):
     '''
 
     #define String_val(x) ((char *) Bp_val(x))
     '''
-    return bp_val(x).value
+    return bp_val(x).value.decode()
 
 def double_val(v):
     '''