/// <summary> /// Given an IDLProperty, generate all the necessaries /// </summary> /// <remarks>Override to expand functionality or replace it</remarks> /// <param name="idlIntf"></param> /// <param name="idlProperty"></param> /// <returns></returns> public virtual CodeTypeMember HandleProperty(IDLInterface idlIntf, IDLProperty idlProperty) { CodeMemberProperty property = new CodeMemberProperty(); property.Comments.Add(new CodeCommentStatement(idlProperty.Name)); property.Name = CodeBuilderCommon.GetCompilableName(idlProperty.Name); property.Attributes = MemberAttributes.Abstract; IDLMethodArgument idlMethodArgGet = new IDLMethodArgument { Direction = "out", Name = "value", Type = idlProperty.Type }; IDLMethod idlMethodGet = new IDLMethod { Arguments = new List <IDLMethodArgument>(new IDLMethodArgument[] { idlMethodArgGet }), Name = "get", }; Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLMethodArgumentTypeNameBuilder(idlIntf, idlMethodGet); property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArgGet.Direction, idlMethodArgGet.Name, idlMethodArgGet.Type))); // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument. ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForProperty(idlIntf, idlProperty.Name, idlMethodArgGet.Name, idlMethodArgGet.Type, idlMethodArgGet.Direction); Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArgGet.Type, context); // Arguments. CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, idlMethodArgGet.Name); property.Type = paramtypeHolder.paramtype.CodeType; property.HasGet = CodeBuilderCommon.HasGet(idlProperty); property.HasSet = CodeBuilderCommon.HasSet(idlProperty); property.Parameters.Add(param); return(property); }
private void GenerateMethod(IDLInterface idlIntf, IDLMethod idlMethod , Udbus.Parsing.ICodeTypeDeclarationHolder contextDeclarationHolder , CodeTypeReference typerefDbusInterface , CodeTypeReference typerefDbusMarshal , CodeTypeDeclaration typeProxy) { // Straight-forward interface method. CodeMemberMethod methodInterface = new CodeMemberMethod(); CodeExpressionCollection interfaceCallArgs = new CodeExpressionCollection(); methodInterface.Name = idlMethod.Name; methodInterface.Attributes = MemberAttributes.Public; Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(contextDeclarationHolder); #region Methods args foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { CodeCommentStatement commentMethod = new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type)); methodInterface.Comments.Add(commentMethod); // 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); ParamCodeTypeFactory paramtypeHolder = new ParamCodeTypeFactory(CodeTypeFactory.Default, idlMethodArg.Direction == "out" ? FieldDirection.Out : FieldDirection.In); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArg.Type, context); Udbus.Parsing.ICodeParamType paramtype = paramtypeHolder.paramtype; // Arguments. CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtype.CodeType, idlMethodArg.Name); CodeVariableReferenceExpression varrefMethodArg = new CodeVariableReferenceExpression(idlMethodArg.Name); if (idlMethodArg.Direction == "out") { // Add to interface parameters. interfaceCallArgs.Add(new CodeDirectionExpression(FieldDirection.Out, varrefMethodArg)); // Add parameter to interface method. param.Direction = FieldDirection.Out; } else { interfaceCallArgs.Add(varrefMethodArg); } methodInterface.Parameters.Add(param); } // Ends loop over method arguments #endregion methodInterface.Statements.Add(this.DeclareTargetVariable(typerefDbusInterface, typerefDbusMarshal)); methodInterface.Statements.Add(new CodeMethodInvokeExpression(varrefTarget, idlMethod.Name, interfaceCallArgs.Cast <CodeExpression>().ToArray())); //methodInterface.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(thisProxyFieldRef, idlMethod.Name) // , interfaceCallArgs.Cast<CodeExpression>().ToArray() //)); // Finish up. typeProxy.Members.Add(methodInterface); }
protected override CodeMemberMethod HandleMethod(IDLInterface idlIntf, IDLMethod idlMethod) { CodeMemberMethod method = base.HandleMethod(idlIntf, idlMethod); // [System.ServiceModel.OperationContractAttribute()] // Indicates that a method defines an operation that is part of a service contract in a Windows Communication Foundation (WCF) application method.CustomAttributes.Add(CodeBuilderCommon.attribOperationContract); if (this.gotVariant) { this.gotVariant = false; //Reinitialise for next loop // [Udbus.WCF.Contracts.DbusContainerAttribute()] method.CustomAttributes.Add(CodeBuilderCommon.attribDbusContainer); } return(method); }
/// <summary> /// Given an IDL Method, generate the necessary bits /// </summary> /// <remarks>Override to expand functionality or replace it</remarks> /// <param name="idlIntf"></param> /// <param name="idlMethod"></param> /// <returns></returns> protected virtual CodeMemberMethod HandleMethod(IDLInterface idlIntf, IDLMethod idlMethod) { // Method. CodeMemberMethod method = new CodeMemberMethod(); method.Comments.Add(new CodeCommentStatement(idlMethod.Name)); method.Name = idlMethod.Name; Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { method.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type))); // 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); ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForMethod(idlMethodArg.Direction); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArg.Type, context); Console.WriteLine(idlMethodArg.Type); // Arguments. method.Parameters.Add(HandleMethodArgument(idlMethodArg, paramtypeHolder)); } // Ends loop over method arguments return(method); }
protected override CodeMemberMethod HandleMethod(IDLInterface idlIntf, IDLMethod idlMethod) { CodeMemberMethod method = base.HandleMethod(idlIntf, idlMethod); // [System.ServiceModel.OperationContractAttribute()] // Indicates that a method defines an operation that is part of a service contract in a Windows Communication Foundation (WCF) application method.CustomAttributes.Add(CodeBuilderCommon.attribOperationContract); if (this.gotVariant) { this.gotVariant = false; //Reinitialise for next loop // [Udbus.WCF.Contracts.DbusContainerAttribute()] method.CustomAttributes.Add(CodeBuilderCommon.attribDbusContainer); } return method; }
/// <summary> /// Given an IDLProperty, generate all the necessaries /// </summary> /// <remarks>Override to expand functionality or replace it</remarks> /// <param name="idlIntf"></param> /// <param name="idlProperty"></param> /// <returns></returns> public virtual CodeTypeMember HandleProperty(IDLInterface idlIntf, IDLProperty idlProperty) { CodeMemberProperty property = new CodeMemberProperty(); property.Comments.Add(new CodeCommentStatement(idlProperty.Name)); property.Name = CodeBuilderCommon.GetCompilableName(idlProperty.Name); property.Attributes = MemberAttributes.Abstract; IDLMethodArgument idlMethodArgGet = new IDLMethodArgument { Direction = "out", Name = "value", Type = idlProperty.Type }; IDLMethod idlMethodGet = new IDLMethod { Arguments = new List<IDLMethodArgument>(new IDLMethodArgument[] { idlMethodArgGet }), Name = "get", }; Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLMethodArgumentTypeNameBuilder(idlIntf, idlMethodGet); property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArgGet.Direction, idlMethodArgGet.Name, idlMethodArgGet.Type))); // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument. ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForProperty(idlIntf, idlProperty.Name, idlMethodArgGet.Name, idlMethodArgGet.Type, idlMethodArgGet.Direction); Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArgGet.Type, context); // Arguments. CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, idlMethodArgGet.Name); property.Type = paramtypeHolder.paramtype.CodeType; property.HasGet = CodeBuilderCommon.HasGet(idlProperty); property.HasSet = CodeBuilderCommon.HasSet(idlProperty); property.Parameters.Add(param); return property; }
/// <summary> /// Given an IDL Method, generate the necessary bits /// </summary> /// <remarks>Override to expand functionality or replace it</remarks> /// <param name="idlIntf"></param> /// <param name="idlMethod"></param> /// <returns></returns> protected virtual CodeMemberMethod HandleMethod(IDLInterface idlIntf, IDLMethod idlMethod) { // Method. CodeMemberMethod method = new CodeMemberMethod(); method.Comments.Add(new CodeCommentStatement(idlMethod.Name)); method.Name = idlMethod.Name; Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { method.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type))); // 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); ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForMethod(idlMethodArg.Direction); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArg.Type, context); Console.WriteLine(idlMethodArg.Type); // Arguments. method.Parameters.Add(HandleMethodArgument(idlMethodArg, paramtypeHolder)); } // Ends loop over method arguments return method; }
private void GenerateMethod(IDLInterface idlIntf, IDLMethod idlMethod , Udbus.Parsing.ICodeTypeDeclarationHolder contextDeclarationHolder , CodeTypeReference typerefDbusInterface , CodeTypeReference typerefDbusMarshal , CodeTypeDeclaration typeProxy) { // Straight-forward interface method. CodeMemberMethod methodInterface = new CodeMemberMethod(); CodeExpressionCollection interfaceCallArgs = new CodeExpressionCollection(); methodInterface.Name = idlMethod.Name; methodInterface.Attributes = MemberAttributes.Public; Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(contextDeclarationHolder); #region Methods args foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { CodeCommentStatement commentMethod = new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type)); methodInterface.Comments.Add(commentMethod); // 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); ParamCodeTypeFactory paramtypeHolder = new ParamCodeTypeFactory(CodeTypeFactory.Default, idlMethodArg.Direction == "out" ? FieldDirection.Out : FieldDirection.In); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlMethodArg.Type, context); Udbus.Parsing.ICodeParamType paramtype = paramtypeHolder.paramtype; // Arguments. CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtype.CodeType, idlMethodArg.Name); CodeVariableReferenceExpression varrefMethodArg = new CodeVariableReferenceExpression(idlMethodArg.Name); if (idlMethodArg.Direction == "out") { // Add to interface parameters. interfaceCallArgs.Add(new CodeDirectionExpression(FieldDirection.Out, varrefMethodArg)); // Add parameter to interface method. param.Direction = FieldDirection.Out; } else { interfaceCallArgs.Add(varrefMethodArg); } methodInterface.Parameters.Add(param); } // Ends loop over method arguments #endregion methodInterface.Statements.Add(this.DeclareTargetVariable(typerefDbusInterface, typerefDbusMarshal)); methodInterface.Statements.Add(new CodeMethodInvokeExpression(varrefTarget, idlMethod.Name, interfaceCallArgs.Cast<CodeExpression>().ToArray())); //methodInterface.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(thisProxyFieldRef, idlMethod.Name) // , interfaceCallArgs.Cast<CodeExpression>().ToArray() //)); // Finish up. typeProxy.Members.Add(methodInterface); }
public IDLMethodArgumentTypeNameBuilder(IDLInterface intf, IDLMethod method) { this.intf = intf; this.method = method; }
public IDLMethodArgumentTypeNameBuilder(IDLInterface intf, IDLMethod method) { this.intf = intf; this.method = method; }
static public CodeMemberMethod MakeMethod(CodeTypeFactory codetypefactoryOut, CodeTypeFactory codetypefactoryIn, Udbus.Parsing.CodeMemberDeferredClassHolder declarationHolder, IDLInterface idlIntf, IDLMethod idlMethod, MarshalBuilderHelper codebuilder) { CodeMemberMethod method = new CodeMemberMethod(); CodeComment commentMethod = new CodeComment(idlMethod.Name); method.Comments.Add(new CodeCommentStatement(idlMethod.Name)); method.Name = idlMethod.Name; method.Attributes = MemberAttributes.Public; foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { method.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type))); } // Context used for all arguments in method. Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); MakeMethodParameters(codetypefactoryOut, codetypefactoryIn, declarationHolder, idlIntf, method.Name, idlMethod.Name, idlMethod.Arguments, method.Parameters, method.Statements, context, codebuilder ); return method; }
static public CodeMemberMethod MakeMethod(CodeTypeFactory codetypefactoryOut, CodeTypeFactory codetypefactoryIn, Udbus.Parsing.CodeMemberDeferredClassHolder declarationHolder, IDLInterface idlIntf, IDLMethod idlMethod) { return MakeMethod(codetypefactoryOut, codetypefactoryIn, declarationHolder, idlIntf, idlMethod, new MarshalBuilderHelperMethod()); }