diff --git a/genProto b/genProto new file mode 100644 index 0000000..6c13fc7 Binary files /dev/null and b/genProto differ diff --git a/genProto.cmd b/genProto.cmd new file mode 100644 index 0000000..179789b --- /dev/null +++ b/genProto.cmd @@ -0,0 +1,2 @@ +@echo off +escript.exe "%~dpn0" %* diff --git a/proto/0_test.mpdf b/proto/0_test.mpdf index c788407..bd44970 100644 --- a/proto/0_test.mpdf +++ b/proto/0_test.mpdf @@ -1,5 +1,5 @@ %% 测试协议 注释可以用 %% 也可以用 // -cs_test { +test { string aa; } diff --git a/rebar.config b/rebar.config index 8633870..1068041 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,4 @@ -{erl_opts, [no_debug_info, deterministic]}. +{erl_opts, [no_debug_info, deterministic, {i, "include"}]}. {deps, []}. {escript_main_app, genProto}. % specify which app is the escript app diff --git a/src/writeErl/gErlGen.erl b/src/writeErl/gErlGen.erl index cf8e748..d98bfa9 100644 --- a/src/writeErl/gErlGen.erl +++ b/src/writeErl/gErlGen.erl @@ -687,11 +687,11 @@ genErl(SortedSProtoList, SortedErrList, HrlDir, ErlDir) -> {<>, <>, <>, <>, <>} end, - {MsgHrlStr, TMsgEncodeStr, TMsgDecodeStr, _TMsgIdStr, _TMsgNameStr} = lists:foldl(FunSpell, {<<>>, <<>>, <<>>, <<>>, <<>>}, SortedSProtoList), + {MsgHrlStr, TMsgEncodeStr, TMsgDecodeStr, _TMsgIdStr, TMsgNameStr} = lists:foldl(FunSpell, {<<>>, <<>>, <<>>, <<>>, <<>>}, SortedSProtoList), MsgEncodeStr = <\n\t[].\n\n">>, MsgDecodeStr = <\n\t{undefinedHer, undefined, {}}.\n\n">>, _MsgIdStr = <<_TMsgIdStr/binary, "getMsgId(_) -> 0.\n\n">>, - _MsgNameStr = <<_TMsgNameStr/binary, "getMsgName(_) -> undefiend.\n\n">>, + MsgNameStr = < undefiend.\n\n">>, ErrCodeStr = spellErrCodeHrl(SortedErrList, <<>>), @@ -703,7 +703,7 @@ genErl(SortedSProtoList, SortedErrList, HrlDir, ErlDir) -> ErlHeaderStr = protoErlHeader(), HrlHeaderStr = protoHrlHeader(), - OutputErlStr = <>, + OutputErlStr = <>, OutputHrlStr = <>, HrlFilename = do_write_hrl(HrlDir, protoMsg, OutputHrlStr), ErlFilename = do_write_erl(ErlDir, protoMsg, OutputErlStr), diff --git a/test/protoMsg.erl b/test/protoMsg.erl index e184942..70aca5b 100644 --- a/test/protoMsg.erl +++ b/test/protoMsg.erl @@ -853,3 +853,42 @@ decodeBin(1001, LeftBin0) -> decodeBin(_, _) -> {undefinedHer, undefined, {}}. +getMsgName(1)-> test; +getMsgName(2)-> phoneNumber; +getMsgName(3)-> person; +getMsgName(4)-> addressBook; +getMsgName(5)-> union; +getMsgName(6)-> tbool; +getMsgName(7)-> tint8; +getMsgName(8)-> tuint8; +getMsgName(9)-> tint16; +getMsgName(10)-> tuint16; +getMsgName(11)-> tint32; +getMsgName(12)-> tuint32; +getMsgName(13)-> tint64; +getMsgName(14)-> tuint64; +getMsgName(15)-> tinteger; +getMsgName(16)-> tnumber; +getMsgName(17)-> tfloat; +getMsgName(18)-> tdouble; +getMsgName(19)-> tstring; +getMsgName(20)-> tlistbool; +getMsgName(21)-> tlistint8; +getMsgName(22)-> tlistuint8; +getMsgName(23)-> tlistint16; +getMsgName(24)-> tlistuint16; +getMsgName(25)-> tlistint32; +getMsgName(26)-> tlistuint32; +getMsgName(27)-> tlistint64; +getMsgName(28)-> tlistuint64; +getMsgName(29)-> tlistinteger; +getMsgName(30)-> tlistnumber; +getMsgName(31)-> tlistfloat; +getMsgName(32)-> tlistdouble; +getMsgName(33)-> tliststring; +getMsgName(34)-> tlistunion; +getMsgName(35)-> allType; +getMsgName(36)-> testnull; +getMsgName(1001)-> person1; +getMsgName(_) -> undefiend. +