Skip to content

Commit

Permalink
0.2.2 : fixed str->Pystr and not Pybytes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbousque committed Feb 14, 2017
1 parent 9613d16 commit c5434ec
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.3
Name: lymp
Version: 0.2.1
Version: 0.2.2
Synopsis: Use Python functions and objects from OCaml
Authors: Dominik Bousquet
License: MIT
Expand Down
9 changes: 3 additions & 6 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: c02d186aa90742a3a64fb550dc83c43c) *)
(* DO NOT EDIT (digest: 67d8be4d2a457d862735fddf9d745e61) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -746,9 +746,6 @@ module MyOCamlbuildBase = struct
(* # 110 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)


let env_filename = Pathname.basename BaseEnvLight.default_filename


let dispatch_combine lst =
fun e ->
List.iter
Expand Down Expand Up @@ -881,7 +878,7 @@ module MyOCamlbuildBase = struct
end


# 884 "myocamlbuild.ml"
# 881 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{
Expand All @@ -896,6 +893,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 900 "myocamlbuild.ml"
# 897 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
24 changes: 11 additions & 13 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(* setup.ml generated for the first time by OASIS v0.4.7 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 3040b69b28b4e2c418d50938ddb1ddba) *)
(* DO NOT EDIT (digest: 927f2b8050520ed68536832beac9e0bf) *)
(*
Regenerated by OASIS v0.4.8
Regenerated by OASIS v0.4.7
Visit http://oasis.forge.ocamlcore.org for more information and
documentation about functions used in this file.
*)
Expand Down Expand Up @@ -658,7 +658,6 @@ module OASISContext = struct
ignore_unknown_fields: bool;
printf: level -> string -> unit;
srcfs: source OASISFileSystem.fs;
load_oasis_plugin: string -> bool;
}


Expand All @@ -683,7 +682,6 @@ module OASISContext = struct
ignore_unknown_fields = false;
printf = printf;
srcfs = new OASISFileSystem.host_fs(Sys.getcwd ());
load_oasis_plugin = (fun _ -> false);
}


Expand Down Expand Up @@ -3162,7 +3160,7 @@ module OASISFileUtil = struct
end


# 3165 "setup.ml"
# 3163 "setup.ml"
module BaseEnvLight = struct
(* # 22 "src/base/BaseEnvLight.ml" *)

Expand Down Expand Up @@ -3242,7 +3240,7 @@ module BaseEnvLight = struct
end


# 3245 "setup.ml"
# 3243 "setup.ml"
module BaseContext = struct
(* # 22 "src/base/BaseContext.ml" *)

Expand Down Expand Up @@ -5665,7 +5663,7 @@ module BaseCompat = struct
end


# 5668 "setup.ml"
# 5666 "setup.ml"
module InternalConfigurePlugin = struct
(* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)

Expand Down Expand Up @@ -6471,7 +6469,7 @@ module InternalInstallPlugin = struct
end


# 6474 "setup.ml"
# 6472 "setup.ml"
module OCamlbuildCommon = struct
(* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)

Expand Down Expand Up @@ -6844,7 +6842,7 @@ module OCamlbuildDocPlugin = struct
end


# 6847 "setup.ml"
# 6845 "setup.ml"
open OASISTypes;;

let setup_t =
Expand All @@ -6865,7 +6863,7 @@ let setup_t =
{
oasis_version = "0.3";
ocaml_version = None;
version = "0.2.1";
version = "0.2.2";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
Expand Down Expand Up @@ -7078,16 +7076,16 @@ let setup_t =
plugin_data = []
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.8";
oasis_digest = Some "\183\209\b\218\214D\187\250\149~j=\006\148\243R";
oasis_version = "0.4.7";
oasis_digest = Some "\206\169LEMb\021\197\247\204y7\171z\025\252";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7091 "setup.ml"
# 7089 "setup.ml"
let setup_t = BaseCompat.Compat_0_3.adapt_setup_t setup_t
open BaseCompat.Compat_0_3
(* OASIS_STOP *)
Expand Down
4 changes: 2 additions & 2 deletions srcs/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: 2038362c7c546da70db0f48e752a04ac)
version = "0.2.1"
# DO NOT EDIT (digest: 931b1bc95e7203f20003ff83e3a48a3e)
version = "0.2.2"
description = "Use Python functions and objects from OCaml"
requires = "bson unix threads"
archive(byte) = "lymp.cma"
Expand Down
2 changes: 1 addition & 1 deletion srcs/lymp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ and deserialize py doc =
| "l" -> Pylist (deserialize_list py (Bson.get_list element))
| "f" -> Pyfloat (Bson.get_double element)
| "b" -> Pybool (Bson.get_boolean element)
| "B" -> Pybytes (Bson.get_user_binary element)
| "B" -> Pybytes (Bson.get_generic_binary element)
| "r" -> let r = {py = py ; ref_nb = int_of_string (Bson.get_jscode element) ; released = false} in
Gc.finalise release_reference r ;
Pyref (Pyreference r)
Expand Down
11 changes: 7 additions & 4 deletions srcs/lymp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def int_to_int64_bytes(i):
def py_to_bson(val):
if type(val) is int:
return bson.int64.Int64(val)
if sys.version_info.major == 2 and type(val) is str:
return bson.binary.Binary(val)
return val

def exit_lymp():
Expand Down Expand Up @@ -63,9 +65,10 @@ class ExecutionHandler:
bool: "b",
bytes: "B"
}
# for python 2, unicode is str
# for python 2, unicode is str and str is bytes
if sys.version_info.major == 2:
to_ret_types[unicode] = "s"
to_ret_types[str] = "B"

def __init__(self, reader_writer):
self.reader_writer = reader_writer
Expand Down Expand Up @@ -94,9 +97,6 @@ def loop(self):

def ret_to_msg(self, ret, ret_ref):
msg = {}
# if python 2 and type is str, convert to unicode and send as string (assume utf-8)
if sys.version_info.major == 2 and type(ret) is str:
ret = ret.decode('utf-8')
# reference (type not supported or explicitely asked to)
if ret_ref or (type(ret) not in self.to_ret_types):
self.ref_nb += 1
Expand Down Expand Up @@ -137,6 +137,9 @@ def resolve_args(self, args):
named[str(arg[0])[1:]] = self.resolve_args(arg[1])[0]
del args[i]
continue
# if bytes
if type(arg) is bson.binary.Binary:
args[i] = bytes(arg)
# resolve reference args (using bson jscode)
if type(arg) is bson.code.Code:
args[i] = self.objs[int(arg)]
Expand Down

0 comments on commit c5434ec

Please sign in to comment.