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())); }
static public void MakeMethodParameters(CodeTypeFactory codetypefactoryOut, CodeTypeFactory codetypefactoryIn, Udbus.Parsing.CodeMemberDeferredClassHolder declarationHolder, IDLInterface idlIntf, string methodName, string idlMethodName, IList<IDLMethodArgument> arguments, CodeParameterDeclarationExpressionCollection parameters, CodeStatementCollection statements, Udbus.Parsing.BuildContext context, MarshalBuilderHelper codebuilder) { CodeStatementCollection statementsTryRecv = new CodeStatementCollection(); CodeConditionStatement condMethodSignature = new CodeConditionStatement( exprResultOk , new CodeStatement[] { codebuilder.SetSignature() } , new CodeStatement[] { // * throw Udbus.Core.Exceptions.UdbusMessageBuilderException.Create("BodyAdd", serial, "<method_name>", this.result, this.ConnectionParameters); codebuilder.ThrowMessageBuilderException(idlMethodName, "BodyAdd") } ); // Check for in parameters. bool bInParameters = codebuilder.InitialiseSignature(arguments, statements); int nInArgSigCounter = 0; int nInArgCounter = 0; 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. CodeConditionStatement condIn = null; // Root if statement for in parameters. CodeConditionStatement condInIter = null; // Most nested if statement for in parameters. CodeStatementCollection stmtsFinishResult = new CodeStatementCollection(); //Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); CodeTypeReference typerefParamIter = CodeBuilderCommon.typerefUnknownParameters; string argNameIter = arguments != null && arguments.Count > 0 ? arguments[0].Name : "UnknownParameters"; CodeThrowExceptionStatement throwargOutPrev = codebuilder.CreateArgumentOutException(idlMethodName); CodeThrowExceptionStatement throwargInPrev = codebuilder.ThrowMessageBuilderException(idlMethodName, "SetSignature"); foreach (IDLMethodArgument idlMethodArg in arguments) { argNameIter = idlMethodArg.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; CodeParameterDeclarationExpression param = null; CodeTypeReference typerefParam = null; if (idlMethodArg.Direction == "out") // If output parameter { if (condOut == null) { codebuilder.PrefixOutParams(ref condOut, ref condOutIter, idlMethodName, ref nOutArgCounter, ref throwargOutPrev); } CodeConditionStatement condVarResult; codebuilder.MakeOutArgument(statements , stmtsFinishResult , idlMethodName , codetypefactoryOut // Yeah I messed up the naming , ref nOutArgCounter , context , ref throwargOutPrev , idlMethodArg , nameBuilder , ref paramtypeHolder , ref typerefParam , out condVarResult ); codebuilder.StoreCondIterator(ref condOut, ref condOutIter, condVarResult); } // Ends if output parameter else // Else not output parameter { // Add signature for argument. nInArgSigCounter = codebuilder.DeclareSignature(statements, nInArgSigCounter, idlMethodArg.Type); CodeConditionStatement condVarResult; codebuilder.MakeInArgument(codetypefactoryIn // Yeah I messed up the naming //, method.Statements , idlMethodName , ref nInArgCounter , context , ref throwargInPrev , idlMethodArg , nameBuilder , ref paramtypeHolder , ref typerefParam , out condVarResult ); codebuilder.StoreCondIterator(ref condIn, ref condInIter, condVarResult); } // Ends else not output parameter param = codebuilder.AddParameter(parameters, idlMethodArg.Name, idlMethodArg.Direction, typerefParam); } // Ends loop over arguments codebuilder.AssignResults(statementsTryRecv, condOut, condOutIter, stmtsFinishResult, throwargOutPrev ,idlMethodName, ref nOutArgCounter ); codebuilder.TerminateSignature(statements, bInParameters, nInArgSigCounter); codebuilder.AddSerialNumber(statements); codebuilder.InitialiseMessageBuilder(statements); codebuilder.DeclareMessageHandle(statements); CodeStatement stmtBuildMethod = codebuilder.InvokeBuild(statements, methodName); condIn = codebuilder.FinishInArguments(idlMethodName, codebuilder, condMethodSignature, condIn, condInIter, throwargInPrev); // Add a using statement ??? Nope. Add a try/finally statement. Ahhh CodeDOM is there no construct you can't mangle ? CodeVariableReferenceExpression varrefSendHandle = codebuilder.DeclareSendHandle(); CodeStatementCollection statementsTrySend = new CodeStatementCollection(); #if !USE_FLUID_MESSAGE_BUILDER // Use individual statements to build message. statementsTrySend.Add(stmtBuildMethod); if (condIn != null) { statementsTrySend.Add(condIn); } else { // Need to set the signature even for methods with no parameters (?). //statementsTrySend.Add(condMethodSignature); } #endif // !USE_FLUID_MESSAGE_BUILDER codebuilder.CallSend(idlMethodName, varrefSendHandle, statementsTrySend); codebuilder.TryCatchSend(statements, varrefSendHandle, statementsTrySend); List<CodeStatement> statementsReponse = new List<CodeStatement>(); // Now receive the response. codebuilder.HandleResponse(idlMethodName, statementsTryRecv, statementsReponse); statements.Add(new CodeConditionStatement(exprResultOk, statementsReponse.ToArray() )); }