Quellcode durchsuchen

ft: 生成erlang还是得要根据msgid 找到msgname

master
SisMaker vor 1 Jahr
Ursprung
Commit
3f6d587a02
6 geänderte Dateien mit 46 neuen und 5 gelöschten Zeilen
  1. BIN
      genProto
  2. +2
    -0
      genProto.cmd
  3. +1
    -1
      proto/0_test.mpdf
  4. +1
    -1
      rebar.config
  5. +3
    -3
      src/writeErl/gErlGen.erl
  6. +39
    -0
      test/protoMsg.erl

BIN
genProto Datei anzeigen


+ 2
- 0
genProto.cmd Datei anzeigen

@ -0,0 +1,2 @@
@echo off
escript.exe "%~dpn0" %*

+ 1
- 1
proto/0_test.mpdf Datei anzeigen

@ -1,5 +1,5 @@
%% 测试协议 注释可以用 %% 也可以用 //
cs_test {
test {
string aa;
}

+ 1
- 1
rebar.config Datei anzeigen

@ -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

+ 3
- 3
src/writeErl/gErlGen.erl Datei anzeigen

@ -687,11 +687,11 @@ genErl(SortedSProtoList, SortedErrList, HrlDir, ErlDir) ->
{<<MsgHrlAcc/binary, HrlStr/binary>>, <<MsgEncodeAcc/binary, EncodeStr/binary>>, <<MsgDecodeAcc/binary, DecodeStr/binary>>, <<MsgIdAcc/binary, IdStr/binary>>, <<MsgNameAcc/binary, NameStr/binary>>}
end,
{MsgHrlStr, TMsgEncodeStr, TMsgDecodeStr, _TMsgIdStr, _TMsgNameStr} = lists:foldl(FunSpell, {<<>>, <<>>, <<>>, <<>>, <<>>}, SortedSProtoList),
{MsgHrlStr, TMsgEncodeStr, TMsgDecodeStr, _TMsgIdStr, TMsgNameStr} = lists:foldl(FunSpell, {<<>>, <<>>, <<>>, <<>>, <<>>}, SortedSProtoList),
MsgEncodeStr = <<TMsgEncodeStr/binary, "encodeIol(_, _) ->\n\t[].\n\n">>,
MsgDecodeStr = <<TMsgDecodeStr/binary, "decodeBin(_, _) ->\n\t{undefinedHer, undefined, {}}.\n\n">>,
_MsgIdStr = <<_TMsgIdStr/binary, "getMsgId(_) -> 0.\n\n">>,
_MsgNameStr = <<_TMsgNameStr/binary, "getMsgName(_) -> undefiend.\n\n">>,
MsgNameStr = <<TMsgNameStr/binary, "getMsgName(_) -> undefiend.\n\n">>,
ErrCodeStr = spellErrCodeHrl(SortedErrList, <<>>),
@ -703,7 +703,7 @@ genErl(SortedSProtoList, SortedErrList, HrlDir, ErlDir) ->
ErlHeaderStr = protoErlHeader(),
HrlHeaderStr = protoHrlHeader(),
OutputErlStr = <<ErlHeaderStr/binary, MsgEncodeRecStr/binary, MsgEncodeStr/binary, MsgDecodeRecStr/binary, MsgDecodeStr/binary>>,
OutputErlStr = <<ErlHeaderStr/binary, MsgEncodeRecStr/binary, MsgEncodeStr/binary, MsgDecodeRecStr/binary, MsgDecodeStr/binary, MsgNameStr/binary>>,
OutputHrlStr = <<HrlHeaderStr/binary, ErrCodeStr/binary, "\n\n", MsgHrlStr/binary>>,
HrlFilename = do_write_hrl(HrlDir, protoMsg, OutputHrlStr),
ErlFilename = do_write_erl(ErlDir, protoMsg, OutputErlStr),

+ 39
- 0
test/protoMsg.erl Datei anzeigen

@ -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.

Laden…
Abbrechen
Speichern