diff --git a/ebin/genProto.app b/ebin/genProto.app index 0d34d26..e12e605 100644 --- a/ebin/genProto.app +++ b/ebin/genProto.app @@ -1,10 +1,10 @@ -{application,genProto, - [{description,"An OTP library"}, - {vsn,"0.1.0"}, - {registered,[]}, - {applications,[kernel,stdlib]}, - {env,[]}, - {modules,[protoCode,protoCode_bak,protoField,protoGen, - protoParse]}, - {licenses,["Apache 2.0"]}, - {links,[]}]}. +{application, genProto, + [{description, "An OTP library"}, + {vsn, "0.1.0"}, + {registered, []}, + {applications, [kernel, stdlib]}, + {env, []}, + {modules, [protoCode, protoCode_bak, protoField, protoGen, + protoParse]}, + {licenses, ["Apache 2.0"]}, + {links, []}]}. diff --git a/src/protoCode.erl b/src/protoCode.erl index b44b300..f3b7f0e 100644 --- a/src/protoCode.erl +++ b/src/protoCode.erl @@ -1,8 +1,6 @@ -module(protoCode). -compile([export_all, nowarn_unused_function, nowarn_export_all]). - - -export([encode/1, decode/1, encodeRec/1, decodeBin/2]). -define(min8, -128). @@ -114,7 +112,7 @@ deBoolList(N, MsgBin, RetList) -> end. deInt8List(0, MsgBin, RetList) -> - {RetList, MsgBin}; + {lists:reverse(RetList), MsgBin}; deInt8List(N, MsgBin, RetList) -> <> = MsgBin, deInt8List(N - 1, LeftBin, [Int | RetList]). diff --git a/src/protoGen.erl b/src/protoGen.erl index d511958..5723327 100644 --- a/src/protoGen.erl +++ b/src/protoGen.erl @@ -21,7 +21,6 @@ protoHrlHeader() -> protoErlHeader() -> "-module(protoMsg).\n\n - -compile([nowarn_unused_vars]). -export([encode/1, decode/1, encodeRec/1, decodeBin/2]). @@ -135,7 +134,7 @@ deBoolList(N, MsgBin, RetList) -> end. deInt8List(0, MsgBin, RetList) -> - {RetList, MsgBin}; + {lists:reverse(RetList), MsgBin}; deInt8List(N, MsgBin, RetList) -> <> = MsgBin, deInt8List(N - 1, LeftBin, [Int | RetList]). @@ -351,7 +350,7 @@ genDecodeBin({MsgName, MsgId, FieldList}, SortedSProtoList, IsForBin) -> UseLeftBinStr2 = useIndexStr(pd_leftBin), BoolStr = "\t<> = LeftBin" ++ GetLeftBinStr2 ++ ",\n", UseVStr = useIndexStr(pd_v), - VStr = "\tcase Bool" ++ UseBoolStr ++ " =:= 1 of\n\t\ttrue ->\n\t\t\tV" ++ UseVStr ++" = true;\n\t\t_ ->\n\t\t\tV" ++ UseVStr ++" = false\n\tend,\n", + VStr = "\tcase Bool" ++ UseBoolStr ++ " =:= 1 of\n\t\ttrue ->\n\t\t\tV" ++ UseVStr ++ " = true;\n\t\t_ ->\n\t\t\tV" ++ UseVStr ++ " = false\n\tend,\n", {false, StrAcc ++ TemStr ++ BoolStr ++ VStr}; "int8" -> TemStr = @@ -719,7 +718,7 @@ convertDir(ProtoDir, HrlDir, ErlDir) -> EncodeStr = genEncodeRec(MsgInfo, false), resetPd(), DecodeStr = genDecodeBin(MsgInfo, SortedSProtoList, false), - {[EncodeStr |SubEncodeAcc], [DecodeStr | SubDecodeAcc]} + {[EncodeStr | SubEncodeAcc], [DecodeStr | SubDecodeAcc]} end, {MsgEncodeRecStr, MsgDecodeRecStr} = lists:foldl(FunSubRec, {["encodeRec(_) ->\n\t[].\n\n"], ["decodeRec(_, _) ->\n\t{{}, <<>>}.\n\n"]}, SortedSubRecList), diff --git a/test/genProto.bat b/test/genProto.bat index 90774bc..017c66d 100644 --- a/test/genProto.bat +++ b/test/genProto.bat @@ -1 +1 @@ -erl -pa ../ebin -s protoGen convertDir ../proto ./ ./ +erl -pa ../ebin -s protoGen convert ../proto ./ ./ diff --git a/test/genProto.sh b/test/genProto.sh new file mode 100644 index 0000000..017c66d --- /dev/null +++ b/test/genProto.sh @@ -0,0 +1 @@ +erl -pa ../ebin -s protoGen convert ../proto ./ ./ diff --git a/test/remake.sh b/test/remake.sh new file mode 100644 index 0000000..a04f35d --- /dev/null +++ b/test/remake.sh @@ -0,0 +1 @@ +erlc -W0 -o .