示例#1
0
        static public void MakeSignalParameters(CodeTypeDeclaration typedeclArgs,
            CodeTypeFactory codetypefactoryOut,
            Udbus.Parsing.CodeMemberDeferredClassHolder declarationHolder,
            IDLInterface idlIntf,
            string methodName,
            string idlSignalName,
            IList<IDLSignalArgument> arguments,
            CodeParameterDeclarationExpressionCollection parameters,
            CodeStatementCollection statements,
            Udbus.Parsing.BuildContext context,
            MarshalBuilderHelper codebuilder)
        {
            CodeStatementCollection statementsTryRecv = new CodeStatementCollection();
            int nOutArgCounter = 0;
            List<CodeMethodInvokeExpression> invokemethodsBuild = new List<CodeMethodInvokeExpression>();
            CodeConditionStatement condOut = null; // Root if statement for out parameters.
            CodeConditionStatement condOutIter = null; // Most nested if statement for out parameters.
            CodeStatementCollection stmtsFinishResult = new CodeStatementCollection();
            CodeTypeReference typerefParamIter = CodeBuilderCommon.typerefUnknownParameters;
            string argNameIter = arguments != null && arguments.Count > 0 ? arguments[0].Name : "UnknownParameters";

            CodeThrowExceptionStatement throwargOutPrev = codebuilder.CreateArgumentOutException(idlSignalName);

            // WAXME
            //CodeConstructor constructorArgs = new CodeConstructor();
            //constructorArgs.Attributes = MemberAttributes.Public;
            foreach (IDLSignalArgument idlSignalArg in arguments)
            {
                argNameIter = idlSignalArg.Name;

                // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument.
                //Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLMethodArgumentTypeNameBuilder(idlIntf, idlMethod, idlMethodArg);
                Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLArgumentTypeNameBuilder(idlIntf, methodName);
                ParamCodeTypeHolderMarshalBase paramtypeHolder = null;
                CodeTypeReference typerefParam = null;
                if (condOut == null)
                {
                    codebuilder.PrefixOutParams(ref condOut, ref condOutIter, idlSignalName, ref nOutArgCounter, ref throwargOutPrev);
                }

                // Handle the signal argument in the message.
                CodeConditionStatement condVarResult;
                codebuilder.MakeOutArgument(statements
                    , stmtsFinishResult
                    , idlSignalName
                    , codetypefactoryOut // Yeah I messed up the naming
                    , ref nOutArgCounter
                    , context
                    , ref throwargOutPrev
                    , idlSignalArg
                    , nameBuilder
                    , ref paramtypeHolder
                    , ref typerefParam
                    , out condVarResult
                );

                codebuilder.StoreCondIterator(ref condOut, ref condOutIter, condVarResult);

                // WAXME
                // Add a field to the <signal>Args class.
                //string argFieldName = CodeBuilderCommon.GetSignalArgFieldName(idlSignalArg.Name);
                //CodeFieldReferenceExpression fielrefdRefArgField = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), argFieldName);
                //typedeclArgs.Members.Add(new CodeMemberField(paramtypeHolder.paramtype.CodeType, argFieldName));
                //CodeMemberProperty propArgField = new CodeMemberProperty();
                //propArgField.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                //propArgField.Type = paramtypeHolder.paramtype.CodeType;
                //propArgField.Name = PropertyNameFromFieldName(argFieldName);
                //propArgField.GetStatements.Add(new CodeMethodReturnStatement(fielrefdRefArgField));
                //typedeclArgs.Members.Add(propArgField);
                //constructorArgs.Parameters.Add(new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, argFieldName));
                //// * this.<signal_arg> = <signal_arg>;
                //constructorArgs.Statements.Add(new CodeAssignStatement(fielrefdRefArgField, new CodeArgumentReferenceExpression(argFieldName)));

            } // Ends loop over arguments

            //typedeclArgs.Members.Add(constructorArgs);

            codebuilder.AssignResults(statementsTryRecv, condOut, condOutIter, stmtsFinishResult, throwargOutPrev
                , idlSignalName, ref nOutArgCounter
            );
            List<CodeStatement> statementsReponse = new List<CodeStatement>();

            // Now receive the response.
            // Create message reader.
            // * Udbus.Core.UdbusMessageReader reader = new Udbus.Core.UdbusMessageReader(msgHandleResp);
            statementsTryRecv.Insert(0, codebuilder.CreateMessageReader());
            statementsReponse.AddRange(statementsTryRecv.Cast<CodeStatement>());
            statements.Add(new CodeConditionStatement(exprResultOk, statementsReponse.ToArray()));
        }