ic_cserver.erl
来自「OTP是开放电信平台的简称」· ERL 代码 · 共 2,101 行 · 第 1/5 页
ERL
2,101 行
true -> Arg; _ -> "&" ++ Arg end end end, TypeAttrArgs1).%%------------------------------------------------------------%% Make decoder parameter list%%------------------------------------------------------------mk_dec_par_list(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [in], TypeAttrArgs0), lists:map( fun({Type, _Attr, Arg}) -> Ctype = mk_c_type(G, N, Type), case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "&" ++ Arg; Ctype == "CORBA_char *" -> Arg; record(Type, wstring) -> "&" ++ Arg; Ctype == "CORBA_wchar *" -> Arg; true -> "&" ++ Arg end; false -> case ictype:isArray(G, N, Type) of true -> Arg; _ -> "&" ++ Arg end end end, TypeAttrArgs1).%%------------------------------------------------------------%% Make encoder parameter list%%------------------------------------------------------------mk_enc_par_list(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [out], TypeAttrArgs0), lists:map( fun({Type, _Attr, Arg}) -> Ctype = mk_c_type(G, N, Type), case Ctype of "erlang_pid" -> "&" ++ Arg; "erlang_port" -> "&" ++ Arg; "erlang_ref" -> "&" ++ Arg; _ -> Arg end end, TypeAttrArgs1).%%------------------------------------------------------------%% Make type argument list%%------------------------------------------------------------mk_type_attr_arg_list(Types, Args) -> filterzip( fun(Type, {Attr, Arg}) -> {true, {Type, Attr, Arg}} end, Types, Args).%%------------------------------------------------------------%% Filter type argument list%%------------------------------------------------------------filter_type_attr_arg_list(G, X, InOrOut, TypeAttrArgs) -> lists:filter( fun({_Type, inout, Arg}) -> ic_error:error(G, {inout_spec_for_c, X, Arg}), false; ({_Type, Attr, _Arg}) -> lists:member(Attr, InOrOut) end, TypeAttrArgs).%%------------------------------------------------------------%% Make indirection operator%%------------------------------------------------------------mk_ind_op(in) -> "";mk_ind_op(inout) -> error;mk_ind_op(_) -> "*".%%------------------------------------------------------------%% Make parameter list for decoder%%------------------------------------------------------------mk_par_list_for_decoder(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [in], TypeAttrArgs0), lists:map( fun({Type, Attr, Arg}) -> Ctype = mk_c_type(G, N, Type), Dyn = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "**"; Ctype == "CORBA_char *" -> ""; record(Type, wstring) -> %% WSTRING "**"; Ctype == "CORBA_wchar *" -> %% WSTRING ""; true -> case ictype:isArray(G, N, Type) of true -> slice(Attr) ++ "*"; _ -> "**" end end; false -> case ictype:isArray(G, N, Type) of true -> ""; _ -> "*" end end, Ctype ++ Dyn ++ " " ++ Arg end, TypeAttrArgs1).%%------------------------------------------------------------%% Make parameter list for encoder%%------------------------------------------------------------mk_par_list_for_encoder(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [out], TypeAttrArgs0), lists:map( fun({Type, _Attr, Arg}) -> Ctype = mk_c_type(G, N, Type), Dyn = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "*"; Ctype == "CORBA_char *" -> ""; record(Type, wstring) -> %% WSTRING "*"; Ctype == "CORBA_wchar *" -> %% WSTRING ""; true -> case ictype:isArray(G, N, Type) of true -> ""; _ -> "*" end end; false -> if Ctype == "erlang_pid" -> "*"; Ctype == "erlang_port" -> "*"; Ctype == "erlang_ref" -> "*"; true -> "" end end, Ctype ++ " " ++ Dyn ++ Arg end, TypeAttrArgs1).%%------------------------------------------------------------%% Make parameter list for decoder prototypes%%------------------------------------------------------------mk_par_list_for_decoder_prototypes(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [in], TypeAttrArgs0), lists:map( fun({Type, Attr, _Arg}) -> Ctype = mk_c_type(G, N, Type), Dyn = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "**"; Ctype == "CORBA_char *" -> ""; record(Type, wstring) -> %% WSTRING "**"; Ctype == "CORBA_wchar *" -> %% WSTRING ""; true -> case ictype:isArray(G, N, Type) of true -> slice(Attr) ++ "*"; _ -> "**" end end; false -> case ictype:isArray(G, N, Type) of true -> ""; _ -> "*" end end, Ctype ++ Dyn end, TypeAttrArgs1).%%------------------------------------------------------------%% Make parameter list for encoder prototypes%%------------------------------------------------------------mk_par_list_for_encoder_prototypes(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [out], TypeAttrArgs0), lists:map( fun({Type, _Attr, _Arg}) -> Ctype = mk_c_type(G, N, Type), Dyn = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "*"; Ctype == "CORBA_char *" -> ""; record(Type, wstring) -> %% WSTRING "*"; Ctype == "CORBA_wchar *" -> %% WSTRING ""; true -> case ictype:isArray(G, N, Type) of true -> ""; _ -> "*" end end; false -> if Ctype == "erlang_pid" -> "*"; Ctype == "erlang_port" -> "*"; Ctype == "erlang_ref" -> "*"; true -> "" end end, Ctype ++ Dyn end, TypeAttrArgs1).%%------------------------------------------------------------%% Make parameter list for call-back prototypes%%------------------------------------------------------------mk_par_list_for_callback_prototypes(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [in, out], TypeAttrArgs0), lists:map( fun({Type, Attr, _Arg}) -> IndOp = mk_ind_op(Attr), Ctype = mk_c_type(G, N, Type), Dyn = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> "*" ++ IndOp; Ctype == "CORBA_char *" -> "" ++ IndOp; record(Type, wstring) -> %% WSTRING "*" ++ IndOp; Ctype == "CORBA_wchar *" -> %% WSTRING "" ++ IndOp; true -> case ictype:isArray(G, N, Type) of true -> ""; _ -> "*" ++ IndOp end end; false -> case ictype:isArray(G, N, Type) of true -> ""; _ -> case Attr of %% Should just be IndOp in -> "*" ++ IndOp; out -> IndOp end end end, Ctype ++ Dyn end, TypeAttrArgs1).%%------------------------------------------------------------%% Make variable declaration list %%------------------------------------------------------------ mk_var_decl_list(G, N, X, TypeAttrArgs0) -> TypeAttrArgs1 = filter_type_attr_arg_list(G, X, [in, out], TypeAttrArgs0), lists:map( fun({Type, Attr, Arg}) -> Ctype = mk_c_type(G, N, Type), VarDecl = case ic_cbe:is_variable_size(G, N, Type) of true -> if record(Type, string) -> Ctype ++ "* " ++ Arg ++ " = NULL"; Ctype == "CORBA_char *" -> Ctype ++ " " ++ Arg ++ " = NULL"; record(Type, wstring) -> %% WSTRING Ctype ++ "* " ++ Arg ++ " = NULL"; Ctype == "CORBA_wchar *" -> %% WSTRING Ctype ++ " " ++ Arg ++ " = NULL"; true -> case ictype:isArray(G, N, Type) of true -> Ctype ++ slice(Attr) ++ " " ++ Arg; _ -> Ctype ++ "* " ++ Arg end end; false -> Ctype ++ " " ++ Arg end, VarDecl end, TypeAttrArgs1).%%------------------------------------------------------------%% Slice%%------------------------------------------------------------slice(in) -> "_slice*";slice(_) -> "".%%------------------------------------------------------------%% Special comment functions%%------------------------------------------------------------emit_encoding_comment(G, N, F, String, RefOrVal, Type, Name) -> emit(F, [io_lib:format(" /* ~s parameter: ~s~s ~s */\n", [String, mk_c_type(G, N, Type), RefOrVal, Name])]).%%------------------------------------------------------------%% Make C type%%------------------------------------------------------------%%%% Warning this is NOT identical to mk_c_type in ic_cbe.erl%%mk_c_type(G, N, S) -> mk_c_type(G, N, S, evaluate).mk_c_type(G, N, S, evaluate) when element(1, S) == scoped_id -> {FullScopedName, _T, _TK, _} = ic_symtab:get_full_scoped_name(G, N, S), BT = ic_code:get_basetype(G, ic_util:to_undersc(FullScopedName)), case BT of "erlang_binary" -> "erlang_binary"; "erlang_pid" -> "erlang_pid"; "erlang_port" -> "erlang_port"; "erlang_ref" -> "erlang_ref"; "erlang_term" -> "ETERM*"; {enum, Type} -> mk_c_type(G, N, Type, evaluate); Type -> mk_c_type(G, N, Type, evaluate) end;mk_c_type(G, N, S, evaluate_not) when element(1, S) == scoped_id -> {FullScopedName, _T, _TK, _} = ic_symtab:get_full_scoped_name(G, N, S), BT = ic_code:get_basetype(G, ic_util:to_undersc(FullScopedName)), case BT of "erlang_binary" -> "erlang_binary"; "erlang_pid" -> "erlang_pid"; "erlang_port" -> "erlang_port"; "erlang_ref" -> "erlang_ref"; "erlang_term" -> "ETERM*"; Type -> Type end;mk_c_type(_G, _N, S, _) when list(S) -> S;mk_c_type(_G, _N, S, _) when record(S, string) -> "CORBA_char";mk_c_type(_G, _N, S, _) when record(S, wstring) -> %% WSTRING "CORBA_wchar";mk_c_type(_G, _N, {boolean, _}, _) -> "CORBA_boolean";mk_c_type(_G, _N, {octet, _}, _) -> "CORBA_octet";
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?