public void InitializeInterface(IDLInterface idlIntf) { this.bAddNamespace = false; this.ifName = CodeBuilderCommon.GetName(idlIntf.Name, null); this.nsName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new InterfaceVisitor()); this.service = CodeBuilderCommon.GetName(idlIntf.Name, null); this.nsServiceName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFServiceVisitor()); this.nsWCFInterfaceName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFContractVisitor()); this.wcfinterface = CodeBuilderCommon.GetName(idlIntf.Name, null); this.genInterfaceName = CodeBuilderCommon.GetName(idlIntf.Name, new InterfaceVisitor()); this.scopedGenInterfaceName = CodeBuilderCommon.GetScopedName(nsName, genInterfaceName); this.scopedWCFInterface = CodeBuilderCommon.GetScopedName(this.nsWCFInterfaceName, CodeBuilderCommon.GetName(idlIntf.Name, new InterfaceVisitor())); this.dbusservice = CodeBuilderCommon.GetName(idlIntf.Name, new DBUSServiceVisitor()); this.scopedDbusServiceName = CodeBuilderCommon.GetScopedName(this.nsName, this.dbusservice); this.callbackInterfaceName = CodeBuilderCommon.GetSignalCallbackInterfaceName(this.wcfinterface); this.scopedCallbackInterfaceName = CodeBuilderCommon.GetScopedName(this.nsWCFInterfaceName, this.callbackInterfaceName); this.typerefDbusInterface = new CodeTypeReference(this.scopedGenInterfaceName); this.typerefWCFInterface = new CodeTypeReference(this.scopedWCFInterface); this.typerefDbusMarshal = new CodeTypeReference(this.scopedDbusServiceName); this.typerefexprDbusMarshal = new CodeTypeReferenceExpression(this.typerefDbusMarshal); this.typerefWCFCallbackInterface = new CodeTypeReference(this.scopedCallbackInterfaceName); }
protected override ParamCodeTypeFactory HandleSignalArgument(IDLInterface idlIntf, IDLSignal idlSignal, IDLSignalArgument idlSignalArg) { ParamCodeTypeFactory signalArg = base.HandleSignalArgument(idlIntf, idlSignal, idlSignalArg); CodeTypeReference typerefArg = signalArg.paramtype.CodeType; string[] components = CodeBuilderCommon.GetSignalComponents(idlSignalArg.Name); string first = components[0]; components = Array.ConvertAll <string, string>(components, System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase); components[0] = first; string argFieldName = string.Join("", components); CodeFieldReferenceExpression fieldrefArg = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), argFieldName); CodeMemberField fieldArg = new CodeMemberField(typerefArg, argFieldName); fieldArg.CustomAttributes.Add(CodeBuilderCommon.attribDataMember); this.typeSignalArgs.Members.Add(fieldArg); CodeMemberProperty propArgField = new CodeMemberProperty(); propArgField.Attributes = MemberAttributes.Public | MemberAttributes.Final; propArgField.Type = typerefArg; propArgField.Name = argFieldName[0].ToString().ToUpper() + argFieldName.Substring(1); propArgField.GetStatements.Add(new CodeMethodReturnStatement(fieldrefArg)); this.typeSignalArgs.Members.Add(propArgField); this.constructorSignalArgs.Parameters.Add(new CodeParameterDeclarationExpression(typerefArg, argFieldName)); // * this.<signal_arg> = <signal_arg>; this.constructorSignalArgs.Statements.Add(new CodeAssignStatement(fieldrefArg, new CodeArgumentReferenceExpression(argFieldName))); return(signalArg); }
public override void ProcessNamespaces(IDLInterface idlIntf) { this.InitializeInterface(idlIntf); // TODO: SHOULD BE DONE IN THE MAIN GENERATE METHOD this.ns = new CodeNamespace(this.nsServiceName); CodeBuilderCommon.AddUsingNamespaces(this.ns, new WCFServiceVisitor()); }
public override void DeclareCodeType(IDLInterface idlIntf) { // Proxy class. typeProxy = new CodeTypeDeclaration(name + "Proxy"); typeProxy.IsClass = true; typeProxy.TypeAttributes = TypeAttributes.Public; eventsDeclarationHolder = new CodeTypeDeferredNamespaceDeclarationHolderEvents(idlIntf); typeProxy.BaseTypes.Add(genInterfaceName); // Interface field. CodeMemberField memberProxy = new CodeMemberField(genInterfaceName, proxyName); memberProxy.Attributes = MemberAttributes.Private; typeProxy.Members.Add(memberProxy); // TODO: Going to need a using or a fully qualified name. // Constructor. CodeConstructor constructor = new CodeConstructor(); constructor.Attributes = MemberAttributes.Public; // TODO - use the actual interface type rather than a string. paramProxy = new CodeParameterDeclarationExpression(genInterfaceName, proxyName); constructor.Parameters.Add(paramProxy); thisProxyFieldRef = new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), proxyName ); assignProxy = new CodeAssignStatement(thisProxyFieldRef, new CodeArgumentReferenceExpression(proxyName)); constructor.Statements.Add(assignProxy); typeProxy.Members.Add(constructor); declarationHolder = new CodeTypeIgnoredNamespaceDeclarationHolderParams(idlIntf); contextDeclarationHolder = declarationHolder; bAddNamespace = false; }
/// <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); }
public override void DeclareCodeType(IDLInterface idlIntf) { // Interface. type = new CodeTypeDeclaration(ifName); type.IsInterface = true; declarationHolder = this.CreateCodeTypeDeclarationHolder(idlIntf); //Implemented by subclasses }
public override void ProcessNamespaces(IDLInterface idlIntf) { string nsName = CodeBuilderCommon.GetNamespace(idlIntf.Name, this.visitorType); this.ifName = CodeBuilderCommon.GetName(idlIntf.Name, new InterfaceVisitor()); ns = CodeBuilderCommon.AddUsingNamespaces(new CodeNamespace(nsName), this.visitorType); }
override protected void PostHandleInterface(IDLInterface idlIntf, CodeCompileUnit unit, CodeNamespace ns, CodeTypeDeclaration typeInterface) { if (this.declarationHolder.ns != null) // If created namespace for parameter types { ns.Imports.Add(new CodeNamespaceImport(CodeBuilderCommon.nsDbusParams)); declarationHolder.ns.Imports.Add(new CodeNamespaceImport("System")); declarationHolder.ns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic")); unit.Namespaces.Add(declarationHolder.ns); } // Ends if created namespace for parameter types }
/// <summary> /// Interface defined requisite. Generates everything needed for properties /// </summary> /// <param name="idlIntf"></param> public override void GenerateProperties(IDLInterface idlIntf) { if (idlIntf.Properties != null) // If got properties { foreach (IDLProperty idlProperty in idlIntf.Properties) { type.Members.Add(HandleProperty(idlIntf, idlProperty)); } // Ends loop over properties } // Ends if got properties }
public override void PostHandleMembers(IDLInterface idlIntf) { this.PostHandleInterface(idlIntf, unit, ns, type); //TODO: Understand these bits before deciding what to do with them ns.Types.Add(type); //} // Ends if created namespace for parameter types unit.Namespaces.Add(ns); //END TODO }
/// <summary> /// Interface defined requisite. Generates everything needed for methods /// </summary> /// <param name="idlIntf">The IDL defined interface</param> public override void GenerateMethods(IDLInterface idlIntf) { if (idlIntf.Methods != null) // If got methods { foreach (IDLMethod idlMethod in idlIntf.Methods) { type.Members.Add(HandleMethod(idlIntf, idlMethod)); } // Ends loop over methods } // Ends if got methods }
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 override void ProcessNamespaces(IDLInterface idlIntf) { name = CodeBuilderCommon.GetName(idlIntf.Name, null); string nsName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new InterfaceVisitor()); genInterfaceName = CodeBuilderCommon.GetName(idlIntf.Name, new InterfaceVisitor()); // Namespace. ns = new CodeNamespace(nsName + ".Proxy"); CodeBuilderCommon.AddUsingNamespaces(ns, new ProxyVisitor()); }
public override void GenerateSignals(IDLInterface idlIntf) { if (idlIntf.Signals != null && idlIntf.Signals.Count > 0) // If got signals { this.bAddNamespace = true; GenerateSignals(idlIntf, nsName , this.typerefDbusInterface, this.typerefDbusMarshal, this.typerefWCFCallbackInterface , this.type); } // Ends if got signals }
protected virtual ParamCodeTypeFactory HandleSignalArgument(IDLInterface idlIntf, IDLSignal idlSignal, IDLSignalArgument idlSignalArg) { // 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 IDLSignalArgumentTypeNameBuilder(idlIntf, idlSignal); ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForMethod("in"); Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlSignalArg.Type, context); // Arguments return(paramtypeHolder); }
public override void GenerateMethods(IDLInterface idlIntf) { if ((idlIntf.Methods != null && idlIntf.Methods.Count > 0) || (idlIntf.Properties != null && idlIntf.Properties.Count > 0) || (idlIntf.Signals != null && idlIntf.Signals.Count > 0)) { this.fieldAddInit.InitExpression = new CodeObjectCreateExpression(this.typerefInitService); this.typedeclInitHostMakerRegistry.Members.Add(this.fieldAddInit); } else { this.fieldAddInit.InitExpression = new CodePrimitiveExpression(null); this.fieldAddInit.Comments.Add(new CodeCommentStatement("You may be expecting a field here, but since there are no methods or properties, there's no WCF interface.")); } }
public override void GenerateProperties(IDLInterface idlIntf) { if (idlIntf.Properties != null && idlIntf.Properties.Count > 0) // If got properties { this.bAddNamespace = true; foreach (IDLProperty idlProperty in idlIntf.Properties) { GenerateProperty(idlIntf, idlProperty , this.typerefDbusInterface, this.typerefDbusMarshal , this.type); } // Ends loop over properties } // Ends if got properties }
public override void GenerateMethods(IDLInterface idlIntf) { if (idlIntf.Methods != null && idlIntf.Methods.Count > 0) // If got methods { this.bAddNamespace = true; foreach (IDLMethod idlMethod in idlIntf.Methods) { GenerateMethod(idlIntf, idlMethod , this.declarationHolder, this.typerefDbusInterface, this.typerefDbusMarshal , this.type); } // Ends loop over methods } // Ends if got methods }
public override void PostHandleMembers(IDLInterface idlIntf) { if (bAddNamespace != false) { // Namespaces. if (declarationHolder.ns != null) // If created namespace for parameter types { unit.Namespaces.Add(declarationHolder.ns); ns.Imports.Add(new CodeNamespaceImport(declarationHolder.ns.Name)); } // Ends if created namespace for parameter types ns.Types.Add(typeProxy); unit.Namespaces.Add(ns); } }
//TODO - Figure this nasty bit of work out... //this.PostHandleSignalArgument(idlIntf, idlSignal, idlSignalArg, paramtypeHolder.paramtype.CodeType); is low hanging fruit public override void GenerateSignals(IDLInterface idlIntf) { if (idlIntf.Signals != null && idlIntf.Signals.Count > 0) // If got signals { foreach (IDLSignal idlSignal in idlIntf.Signals) { foreach (IDLSignalArgument idlSignalArg in idlSignal.Arguments) { HandleSignalArgument(idlIntf, idlSignal, idlSignalArg); } // Ends loop over signal arguments this.PostHandleSignal(idlIntf, idlSignal, unit, ns, type); } // Ends loop over signal } // Ends if got signals }
public override void GenerateProperties(IDLInterface idlIntf) { if (idlIntf.Properties != null && idlIntf.Properties.Count > 0) // If got properties { foreach (IDLProperty idlProperty in idlIntf.Properties) { bool hasGet = CodeBuilderCommon.HasGet(idlProperty); bool hasSet = CodeBuilderCommon.HasSet(idlProperty); if (!hasGet && !hasSet) { continue; } CodeMemberProperty property = new CodeMemberProperty(); property.Attributes = MemberAttributes.Public | MemberAttributes.Final; property.Name = CodeBuilderCommon.GetCompilableName(idlProperty.Name); property.HasGet = hasGet; property.HasSet = hasSet; property.Type = CodeBuilderCommon.PropertyType(CodeTypeFactory.Default, idlProperty.Type); property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlProperty.Access, idlProperty.Name, idlProperty.Type))); // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument. CodePropertyReferenceExpression proprefTargetProperty = new CodePropertyReferenceExpression(thisProxyFieldRef, property.Name); if (hasGet) { property.GetStatements.Add( new CodeMethodReturnStatement( proprefTargetProperty ) ); } if (hasSet) { property.SetStatements.Add( new CodeAssignStatement(proprefTargetProperty , new CodePropertySetValueReferenceExpression() ) ); } // Finish up. typeProxy.Members.Add(property); } // Ends loop over properties } // Ends if got properties }
public override void ProcessNamespaces(IDLInterface idlIntf) { //Get the necessary names this.ifName = CodeBuilderCommon.GetName(idlIntf.Name, null); this.nsName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new InterfaceVisitor()); this.nsContractName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFContractVisitor()); string nsServiceName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFServiceVisitor()); //Local scope, not needed later //Get the necessary scoped names this.scopedDbusServiceName = CodeBuilderCommon.GetScopedName(this.nsName, CodeBuilderCommon.GetName(idlIntf.Name, new DBUSServiceVisitor())); this.scopedWCFContractName = CodeBuilderCommon.GetScopedName(this.nsContractName, CodeBuilderCommon.GetName(idlIntf.Name, new InterfaceVisitor())); this.scopedWCFServiceName = CodeBuilderCommon.GetScopedName(nsServiceName, CodeBuilderCommon.GetName(idlIntf.Name, new WCFServiceVisitor())); //Get our the Host's namespace and give it all the imports it requires this.nsHost = new CodeNamespace(CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFHostVisitor())); CodeBuilderCommon.AddUsingNamespaces(this.nsHost, new WCFHostVisitor()); }
private void GenerateProperty(IDLInterface idlIntf, IDLProperty idlProperty , CodeTypeReference typerefDbusInterface , CodeTypeReference typerefDbusMarshal , CodeTypeDeclaration typeProxy) { bool hasGet = CodeBuilderCommon.HasGet(idlProperty); bool hasSet = CodeBuilderCommon.HasSet(idlProperty); if (hasGet || hasSet) { CodeMemberProperty property = new CodeMemberProperty(); property.Attributes = MemberAttributes.Public | MemberAttributes.Final; property.Name = CodeBuilderCommon.GetCompilableName(idlProperty.Name); property.HasGet = hasGet; property.HasSet = hasSet; property.Type = CodeBuilderCommon.PropertyType(CodeTypeFactory.DefaultProperty, idlProperty.Type); property.Comments.Add(new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlProperty.Access, idlProperty.Name, idlProperty.Type))); // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument. CodeVariableDeclarationStatement vardeclTarget = this.DeclareTargetVariable(typerefDbusInterface, typerefDbusMarshal); CodePropertyReferenceExpression proprefTargetProperty = new CodePropertyReferenceExpression(varrefTarget, property.Name); if (hasGet) { property.GetStatements.Add(vardeclTarget); property.GetStatements.Add( new CodeMethodReturnStatement( proprefTargetProperty ) ); } if (hasSet) { property.SetStatements.Add(vardeclTarget); property.SetStatements.Add( new CodeAssignStatement(proprefTargetProperty , new CodePropertySetValueReferenceExpression() ) ); } // Finish up. typeProxy.Members.Add(property); } }
public override void PostHandleMembers(IDLInterface idlIntf) { if (this.bAddNamespace != false) { // Namespaces. if (this.contextDeclarationHolder.ns != null) // If created namespace for parameter types { this.unit.Namespaces.Add(this.contextDeclarationHolder.ns); this.ns.Imports.Add(new CodeNamespaceImport(this.contextDeclarationHolder.ns.Name)); } // Ends if created namespace for parameter types } //TODO: Understand these bits before deciding what to do with them this.ns.Types.Add(this.type); //} // Ends if created namespace for parameter types this.unit.Namespaces.Add(this.ns); //END TODO }
override protected void PostHandleSignal(IDLInterface idlIntf, IDLSignal idlSignal, CodeCompileUnit unit, CodeNamespace ns, CodeTypeDeclaration typeInterface) { CodeMemberProperty propEventSignal = CodeBuilderCommon.CreateSignalEventProperty(idlSignal); typeInterface.Members.Add(propEventSignal); propEventSignal.HasGet = true; propEventSignal.HasSet = true; // * public class <signal_as_type>Args : EventArgs this.typeSignalArgs.Name = CodeBuilderCommon.GetSignalEventTypeName(idlSignal.Name); this.typeSignalArgs.CustomAttributes.Add(CodeBuilderCommon.attribDataContract); ns.Types.Add(this.typeSignalArgs); // Prepare for next signal. this.typeSignalArgs = new CodeTypeDeclaration(CodeBuilderCommon.GetSignalEventTypeName(idlSignal.Name)); this.constructorSignalArgs = new CodeConstructor(); this.InitFields(); }
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); }
public override void DeclareCodeType(IDLInterface idlIntf) { //Declare code type references this.typerefWCFService = new CodeTypeReference(this.scopedWCFServiceName); CodeTypeReference typerefConstants = new CodeTypeReference(CodeBuilderCommon.GetScopedName(this.nsName, CodeBuilderCommon.nameConstantsClass)); CodeTypeReference typerefWCFContract = new CodeTypeReference(this.scopedWCFContractName); CodeTypeReference typerefDbusService = new CodeTypeReference(this.scopedDbusServiceName); //No idea... this.type = BuildMakeServiceHostCreationDataImplementation(this.ifName, this.nsContractName, this.typerefWCFService, typerefWCFContract, typerefDbusService); this.nsHost.Types.Add(this.type); CodeTypeReference typeref = new CodeTypeReference(CodeBuilderCommon.GetScopedName(nsHost.Name, this.type.Name)); // Idiotic Partial class for initialisation. this.typedeclInitHostMakerRegistry = new CodeTypeDeclaration("InitHostMakerRegistry"); this.typedeclInitHostMakerRegistry.IsPartial = true; this.typedeclInitHostMakerRegistry.Attributes = MemberAttributes.Public | MemberAttributes.Final; this.typerefInitService = new CodeTypeReference(this.typeRegistryListEntry); this.typerefInitService.TypeArguments.Add(typeref); this.fieldAddInit = new CodeMemberField(typerefRegistryListEntryBase, "add" + typerefWCFService.BaseType.Replace('.', '_')); }
public override void GenerateSignals(IDLInterface idlIntf) { if (idlIntf.Signals != null && idlIntf.Signals.Count > 0) // If got signals { bAddNamespace = true; foreach (IDLSignal idlSignal in idlIntf.Signals) { // Signal. // * public System.EventHandler< <signal>Args > <signal> // * { // * get { return this.proxy.<signal>; } // * set { this.proxy.<signal> = value; } // * } CodeMemberProperty propSignal = CodeBuilderCommon.CreateSignalEventProperty(idlSignal); propSignal.Attributes = MemberAttributes.Public | MemberAttributes.Final; CodePropertyReferenceExpression proprefProxySignal = new CodePropertyReferenceExpression(thisProxyFieldRef, propSignal.Name); propSignal.GetStatements.Add(new CodeMethodReturnStatement(proprefProxySignal)); propSignal.SetStatements.Add(new CodeAssignStatement(proprefProxySignal, new CodePropertySetValueReferenceExpression())); typeProxy.Members.Add(propSignal); } // Ends loop over signal } // Ends if got signals }
public override void DeclareCodeType(IDLInterface idlIntf) { this.type = new CodeTypeDeclaration(CodeBuilderCommon.GetName(idlIntf.Name, new WCFServiceVisitor())); this.type.IsClass = true; this.type.TypeAttributes = System.Reflection.TypeAttributes.Public; this.BaseTypes(typerefWCFInterface, this.type); this.type.CustomAttributes.Add(attribServiceBehavior); // DbusServices field. this.DbusServiceTargetField(this.typerefDbusInterface, this.typerefDbusMarshal, this.type.Members); // Constructor. this.Constructor(this.type, this.typerefDbusInterface); // Target retrieval method. this.methodGetWCFMethodTarget = this.TargetRetrievalMethod(this.typerefDbusInterface, this.typerefDbusMarshal, this.typerefexprDbusMarshal); this.type.Members.Add(this.methodGetWCFMethodTarget); this.contextDeclarationHolder = new CodeTypeIgnoredNamespaceDeclarationHolderParams(idlIntf); this.declarationHolder = this.contextDeclarationHolder; }
/// <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); }
public virtual void PostHandleMembers(IDLInterface idlIntf) { return; }
protected override void PostHandleSignal(IDLInterface idlIntf, IDLSignal idlSignal, CodeCompileUnit unit, CodeNamespace ns, CodeTypeDeclaration typeInterface) { string nsName, intf; int lastDot = idlIntf.Name.LastIndexOf('.'); intf = idlIntf.Name.Substring(lastDot + 1); nsName = CodeBuilderCommon.GetNamespace(idlIntf.Name, new InterfaceVisitor()); CodeFieldReferenceExpression fieldrefCallback = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), CodeBuilderCommon.callback); CodeFieldReferenceExpression fieldrefTarget = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), CodeBuilderCommon.targetName); CodeNamespace nsClient = this.GetClientNamespace(unit, idlIntf.Name); CodeNamespace nsClientTypes = nsClient; if (this.typedeclCallbackInterface == null) // If no callback interface yet { CodeTypeReference typerefInterface = new CodeTypeReference(typeInterface.Name); // Declare callback interface and hold onto it in field. // * public interface I<interface>Callback // * { string nsWCFName, intfWCF; nsWCFName = CodeBuilderCommon.GetNamespace(idlIntf.Name, this.visitorType); intfWCF = CodeBuilderCommon.GetName(idlIntf.Name, null); string callbackInterfaceName = CodeBuilderCommon.GetSignalCallbackInterfaceName(intfWCF); typedeclCallbackInterface = new CodeTypeDeclaration(callbackInterfaceName); typedeclCallbackInterface.Attributes = MemberAttributes.Public; typedeclCallbackInterface.IsInterface = true; ns.Types.Add(typedeclCallbackInterface); // * class <interface>CallbackClient : I<interface>Callback string wcfCallbackClientName = CodeBuilderCommon.GetSignalCompilableName(intfWCF) + "CallbackClient"; CodeTypeReference typerefCallbackInterface = new CodeTypeReference(typedeclCallbackInterface.Name); CodeAttributeDeclaration attribdeclServiceContract = new CodeAttributeDeclaration(CodeBuilderCommon.typerefServiceContract, new CodeAttributeArgument("CallbackContract", new CodeTypeOfExpression(typerefCallbackInterface)) ); typeInterface.CustomAttributes.Add(attribdeclServiceContract); //string scopedCallbackInterfaceName = CodeBuilderCommon.GetScopedName(nsWCFName, proxyInterfaceName); //typedeclCallbackClient = new CodeTypeDeclaration(CodeBuilderCommon.GetSignalCallbackName(intf)); typedeclCallbackClient = new CodeTypeDeclaration(wcfCallbackClientName); CodeTypeReference typerefWCFCallbackInterface = new CodeTypeReference(typedeclCallbackInterface.Name); typedeclCallbackClient.BaseTypes.Add(typerefWCFCallbackInterface); nsClientTypes.Types.Add(typedeclCallbackClient); // * public class <interface>Proxy : Udbus.WCF.Client.CallbackProxy< <wcf_contracts.interface>, <interface>CallbackClient > this.typedeclProxy = new CodeTypeDeclaration(CodeBuilderCommon.GetSignalProxyName(intfWCF)); CodeTypeReference typerefCallbackProxy = new CodeTypeReference(typeof(Udbus.WCF.Client.CallbackProxy<,>)); CodeTypeReference typerefCallbackClient = new CodeTypeReference(typedeclCallbackClient.Name); typerefCallbackProxy.TypeArguments.Add(typerefInterface); typerefCallbackProxy.TypeArguments.Add(typerefCallbackClient); this.typedeclProxy.BaseTypes.Add(typerefCallbackProxy); AddProxyConstructors(this.typedeclProxy); nsClientTypes.Types.Add(this.typedeclProxy); } // Ends if no callback interface yet // Add signal property to Proxy. CodeMemberProperty propProxySignal = CodeBuilderCommon.CreateSignalEventProperty(idlSignal); propProxySignal.Attributes = MemberAttributes.Public | MemberAttributes.Final; CodePropertyReferenceExpression proprefProxyInterface = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "ProxyInterface"); CodePropertyReferenceExpression proprefProxyCallback = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Callback"); CodePropertyReferenceExpression proprefProxyCallbackEvent = new CodePropertyReferenceExpression(proprefProxyCallback, propProxySignal.Name); propProxySignal.GetStatements.Add(new CodeMethodReturnStatement(proprefProxyCallbackEvent)); propProxySignal.SetStatements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(proprefProxyCallbackEvent, CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(null)) , new CodeExpressionStatement(new CodeMethodInvokeExpression(proprefProxyInterface, CodeBuilderCommon.GetSignalRegisterFunction(idlSignal.Name))) )); propProxySignal.SetStatements.Add(new CodeAssignStatement(proprefProxyCallbackEvent, new CodePropertySetValueReferenceExpression())); this.typedeclProxy.Members.Add(propProxySignal); // Add callback method to callback interface. // * [System.ServiceModel.OperationContract(IsOneWay=true)] // * void On<signal>(<interface_ns>.<signal>Args args); CodeMemberMethod methodOnSignal = new CodeMemberMethod(); methodOnSignal.Name = CodeBuilderCommon.GetSignalCallbackMethodName(idlSignal.Name); string signalArgsTypeName = CodeBuilderCommon.GetSignalEventTypeName(idlSignal.Name); string scopedSignalArgsTypeName = CodeBuilderCommon.GetScopedName(nsName, signalArgsTypeName); CodeParameterDeclarationExpression paramdeclSignalArgs = new CodeParameterDeclarationExpression(scopedSignalArgsTypeName, CodeBuilderCommon.SignalArgsName); methodOnSignal.Parameters.Add(paramdeclSignalArgs); methodOnSignal.CustomAttributes.Add(CodeBuilderCommon.attribOperationContractOneWay); typedeclCallbackInterface.Members.Add(methodOnSignal); // Add registration method to wcf interface. // * [System.ServiceModel.OperationContract] // * void RegisterForStorageSpaceLow(); CodeMemberMethod methodRegister = new CodeMemberMethod(); methodRegister.Name = CodeBuilderCommon.GetSignalRegisterFunction(idlSignal.Name); methodRegister.CustomAttributes.Add(CodeBuilderCommon.attribOperationContract); typeInterface.Members.Add(methodRegister); // Add event to callback client implementation. // * private event System.EventHandler< <signal>Args > <signal>Event; CodeMemberEvent eventSignal = CodeBuilderCommon.CreateSignalEvent(idlSignal); typedeclCallbackClient.Members.Add(eventSignal); // * public virtual System.EventHandler< <signal>Args > <signal> // * { // * get { return this.<signal>Event; } // * set { this.<signal>Event = value; } // * } CodeMemberProperty propSignal = CodeBuilderCommon.CreateSignalEventProperty(idlSignal); propSignal.Attributes = MemberAttributes.Public | MemberAttributes.Final; CodeEventReferenceExpression eventrefSignal = new CodeEventReferenceExpression(new CodeThisReferenceExpression(), eventSignal.Name); propSignal.GetStatements.Add(new CodeMethodReturnStatement(eventrefSignal)); propSignal.SetStatements.Add(new CodeAssignStatement(eventrefSignal, new CodePropertySetValueReferenceExpression())); typedeclCallbackClient.Members.Add(propSignal); // * public void On<signal>(<ns>.<signal>Args args) // * { // * if (this.<signal> != null) // * { // * this.<signal>(this, args); // * } //} CodeMemberMethod methodSignal = new CodeMemberMethod(); methodSignal.Name = CodeBuilderCommon.GetSignalCallbackMethodName(idlSignal.Name); methodSignal.Attributes = MemberAttributes.Public; methodSignal.Parameters.Add(paramdeclSignalArgs); CodePropertyReferenceExpression proprefSignal = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), propSignal.Name); methodSignal.Statements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(eventrefSignal, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)) , new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), eventrefSignal.EventName, new CodeThisReferenceExpression(), new CodeArgumentReferenceExpression(paramdeclSignalArgs.Name))) )); typedeclCallbackClient.Members.Add(methodSignal); }
public virtual void DeclareCodeType(IDLInterface idlIntf) { return; }
public virtual void ProcessNamespaces(IDLInterface idlIntf) { return; }
protected override void PostHandleInterface(IDLInterface idlIntf, CodeCompileUnit unit, CodeNamespace ns, CodeTypeDeclaration typeInterface) { if (idlIntf.Signals == null || idlIntf.Signals.Count == 0) // If no signals { typeInterface.CustomAttributes.Add(CodeBuilderCommon.attribServiceContract); } // Ends if no signals // Add DbusServiceRelativeAddress constant to Constants class. // * public partial class Constants { CodeTypeDeclaration typedeclConstants = new CodeTypeDeclaration(CodeBuilderCommon.nameConstantsClass); typedeclConstants.Attributes = MemberAttributes.Public | MemberAttributes.Static; typedeclConstants.IsPartial = true; // * public const string DbusServiceRelativeAddress = "<contract_name>"; // * } CodeMemberField fieldRelativeAddress = new CodeMemberField(typeof(string), CodeBuilderCommon.nameRelativeAddress); fieldRelativeAddress.Attributes = MemberAttributes.Const | MemberAttributes.Public; fieldRelativeAddress.InitExpression = new CodePrimitiveExpression(idlIntf.Name.Replace('.', '/')); typedeclConstants.Members.Add(fieldRelativeAddress); ns.Types.Add(typedeclConstants); CodeTypeReference typerefInterface = new CodeTypeReference(CodeBuilderCommon.GetScopedName(ns.Name, typeInterface.Name)); CodeTypeReference typerefInterfaceProxy = new CodeTypeReference(typeof(Udbus.WCF.Client.Proxy<>)); typerefInterfaceProxy.TypeArguments.Add(typerefInterface); CodeTypeReference typerefProxy; // Worked out in following code... if (this.typedeclProxy == null) // If no proxy type defined yet { // Just knock up a nice vanilla one for consistency's sake. string nsWCFName, intfWCF; nsWCFName = CodeBuilderCommon.GetNamespace(idlIntf.Name, this.visitorType); intfWCF = CodeBuilderCommon.GetName(idlIntf.Name, null); CodeTypeDeclaration typedeclProxy = new CodeTypeDeclaration(CodeBuilderCommon.GetSignalProxyName(intfWCF)); typedeclProxy.BaseTypes.Add(typerefInterfaceProxy); AddProxyConstructors(typedeclProxy); CodeNamespace nsClient = this.GetClientNamespace(unit, idlIntf.Name); nsClient.Types.Add(typedeclProxy); typerefProxy = new CodeTypeReference(CodeBuilderCommon.GetScopedName(nsClient.Name, typedeclProxy.Name)); } // Ends if no proxy type defined yet else // Else added proxy type { // Grab holder of scoped type reference. string nsWCFClient = CodeBuilderCommon.GetNamespace(idlIntf.Name, new WCFClientVisitor()); typerefProxy = new CodeTypeReference(CodeBuilderCommon.GetScopedName(nsWCFClient, this.typedeclProxy.Name)); } // Ends else added proxy type // Reset helper types for next time. this.typedeclCallbackInterface = null; this.typedeclCallbackClient = null; this.typedeclProxy = null; // Add Proxy creation function to ProxyBuilder class via extension method. CodeTypeReference typerefEndpointComponents = new CodeTypeReference(typeof(Udbus.WCF.Client.DbusEndpointUriComponents)); CodeTypeReferenceExpression typerefexprEndpointComponents = new CodeTypeReferenceExpression(typerefEndpointComponents); CodeTypeReference typerefProxyManager = new CodeTypeReference(typeof(Udbus.WCF.Client.ProxyManager)); CodeTypeReferenceExpression typerefexprProxyManager = new CodeTypeReferenceExpression(typerefProxyManager); CodeTypeReference typerefProxyBuilder = new CodeTypeReference(typeof(Udbus.WCF.Client.ProxyBuilder)); CodeTypeReference typerefProxyBuilderExtension = new CodeTypeReference("this " + typerefProxyBuilder.BaseType); // No CodeDom support for extension methods. Awesome. CodeTypeReferenceExpression typerefexprProxyBuilder = new CodeTypeReferenceExpression(typerefProxyBuilder); CodeTypeReferenceExpression typerefexprConstants = new CodeTypeReferenceExpression(CodeBuilderCommon.GetScopedName(ns.Name, typedeclConstants.Name)); CodeParameterDeclarationExpression paramdeclInterfaceProxy = new CodeParameterDeclarationExpression(typerefInterfaceProxy, proxy); CodeParameterDeclarationExpression paramdeclProxyManagerExtension = new CodeParameterDeclarationExpression(typerefProxyBuilderExtension, proxyBuilder); CodeParameterDeclarationExpression paramdeclEndpointUri = new CodeParameterDeclarationExpression(typerefEndpointComponents, dbusEndpointUri); CodeArgumentReferenceExpression argrefProxy = new CodeArgumentReferenceExpression(proxy); CodeArgumentReferenceExpression argrefEndpointUri = new CodeArgumentReferenceExpression(paramdeclEndpointUri.Name); CodeExpression exprRelativeAddress = new CodeFieldReferenceExpression(typerefexprConstants, fieldRelativeAddress.Name); CodeArgumentReferenceExpression argrefProxyBuilder = new CodeArgumentReferenceExpression(proxyBuilder); CodePropertyReferenceExpression proprefBindingFactory = new CodePropertyReferenceExpression(argrefProxyBuilder, BindingFactory); // * static public partial class ProxyBuilderExtensions // * { CodeTypeDeclaration typedeclProxyBuilderExtensions = new CodeTypeDeclaration(CodeBuilderCommon.nameProxyBuilderExtensionsClass); typedeclProxyBuilderExtensions.Attributes = MemberAttributes.Public | MemberAttributes.Static; typedeclProxyBuilderExtensions.IsPartial = true; // http://stackoverflow.com/questions/6308310/creating-extension-method-using-codedom typedeclProxyBuilderExtensions.Attributes = MemberAttributes.Public; typedeclProxyBuilderExtensions.StartDirectives.Add(new CodeRegionDirective(CodeRegionMode.Start, Environment.NewLine + "\tstatic")); typedeclProxyBuilderExtensions.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty)); // * static public void Create(this Udbus.WCF.Client.ProxyBuilder proxyBuilder, out Udbus.WCF.Client.Proxy< <wcf_contract> > proxy // * , Udbus.WCF.Client.DbusEndpointUriComponents dbusEndpointUri) // * { // * proxy = Udbus.WCF.Client.ProxyManager.Create< <wcf_contract> >( // * dbusEndpointUri.CreateUri(<wcf_namespace>.wcf.Contracts.Constants.DbusServiceRelativeAddress) // * , proxyBuilder.BindingFactory // * ); // * } CodeMemberMethod methodCreateInterfaceProxyWithEndpoint = new CodeMemberMethod(); methodCreateInterfaceProxyWithEndpoint.Name = "Create"; methodCreateInterfaceProxyWithEndpoint.Attributes = MemberAttributes.Static | MemberAttributes.Public; paramdeclInterfaceProxy.Direction = FieldDirection.Out; methodCreateInterfaceProxyWithEndpoint.Parameters.Add(paramdeclProxyManagerExtension); methodCreateInterfaceProxyWithEndpoint.Parameters.Add(paramdeclInterfaceProxy); methodCreateInterfaceProxyWithEndpoint.Parameters.Add(paramdeclEndpointUri); // * dbusEndpointUri.CreateUri(<ns>.wcf.Contracts.Constants.DbusServiceRelativeAddress) CodeMethodInvokeExpression invokeCreateUri = new CodeMethodInvokeExpression(argrefEndpointUri, CreateUri, exprRelativeAddress); CodeMethodInvokeExpression invokeProxyManagerCreate = new CodeMethodInvokeExpression(typerefexprProxyManager, "Create", invokeCreateUri, proprefBindingFactory); invokeProxyManagerCreate.Method.TypeArguments.Add(typerefInterface); methodCreateInterfaceProxyWithEndpoint.Statements.Add( new CodeAssignStatement( argrefProxy , invokeProxyManagerCreate ) ); typedeclProxyBuilderExtensions.Members.Add(methodCreateInterfaceProxyWithEndpoint); // * static public void Create(this Udbus.WCF.Client.ProxyBuilder proxyBuilder, out Udbus.WCF.Client.Proxy< <wcf_contract> > proxy) // * { // * proxyBuilder.Create(out proxy, Udbus.WCF.Client.DbusEndpointUriComponents.Create(proxyBuilder.AbsoluteUribuilder)); // * } CodeMemberMethod methodCreateInterfaceProxy = new CodeMemberMethod(); methodCreateInterfaceProxy.Name = "Create"; methodCreateInterfaceProxy.Attributes = MemberAttributes.Static | MemberAttributes.Public; methodCreateInterfaceProxy.Parameters.Add(paramdeclProxyManagerExtension); methodCreateInterfaceProxy.Parameters.Add(paramdeclInterfaceProxy); CodeMethodInvokeExpression invokeProxyManagerExtensionCreate = new CodeMethodInvokeExpression( argrefProxyBuilder , "Create" , new CodeDirectionExpression(FieldDirection.Out, argrefProxy) , new CodeMethodInvokeExpression( typerefexprEndpointComponents , "Create" , new CodePropertyReferenceExpression(argrefProxyBuilder, AbsoluteUribuilder) ) ); methodCreateInterfaceProxy.Statements.Add(invokeProxyManagerExtensionCreate); typedeclProxyBuilderExtensions.Members.Add(methodCreateInterfaceProxy); CodeParameterDeclarationExpression paramdeclProxy = new CodeParameterDeclarationExpression(typerefProxy, proxy); paramdeclProxy.Direction = FieldDirection.Out; // * public static void Create(this Udbus.WCF.Client.ProxyBuilder proxyBuilder, out <namespace>.Contracts.Clients.<interface>Proxy proxy, Udbus.WCF.Client.DbusEndpointUriComponents dbusEndpointUri) // * { // * proxy = new <wcf_namespace>.Contracts.Clients.<interface>Proxy(proxyBuilder.BindingFactory, dbusEndpointUri.CreateUri(<namespace>.wcf.Contracts.Constants.DbusServiceRelativeAddress)); // * } CodeMemberMethod methodCreateProxyWithEndpoint = new CodeMemberMethod(); methodCreateProxyWithEndpoint.Name = "Create"; methodCreateProxyWithEndpoint.Attributes = MemberAttributes.Static | MemberAttributes.Public; methodCreateProxyWithEndpoint.Parameters.Add(paramdeclProxyManagerExtension); methodCreateProxyWithEndpoint.Parameters.Add(paramdeclProxy); methodCreateProxyWithEndpoint.Parameters.Add(paramdeclEndpointUri); methodCreateProxyWithEndpoint.Statements.Add(new CodeAssignStatement( argrefProxy , new CodeObjectCreateExpression(typerefProxy , proprefBindingFactory , invokeCreateUri ) )); typedeclProxyBuilderExtensions.Members.Add(methodCreateProxyWithEndpoint); // * public static void Create(this Udbus.WCF.Client.ProxyBuilder proxyBuilder, out <namespace>.Contracts.Clients.<interface>Proxy proxy) // * { // * proxyBuilder.Create(out proxy, Udbus.WCF.Client.DbusEndpointUriComponents.Create(proxyBuilder.AbsoluteUribuilder)); // * } CodeMemberMethod methodCreateProxy = new CodeMemberMethod(); methodCreateProxy.Name = "Create"; methodCreateProxy.Attributes = MemberAttributes.Static | MemberAttributes.Public; methodCreateProxy.Parameters.Add(paramdeclProxyManagerExtension); methodCreateProxy.Parameters.Add(paramdeclProxy); methodCreateProxy.Statements.Add(invokeProxyManagerExtensionCreate); typedeclProxyBuilderExtensions.Members.Add(methodCreateProxy); CodeNamespace nsClientExtensions = new CodeNamespace(CodeBuilderCommon.nsClientExtensions); nsClientExtensions.Types.Add(typedeclProxyBuilderExtensions); unit.Namespaces.Add(nsClientExtensions); // * } }
public override CodeTypeMember HandleProperty(IDLInterface idlIntf, IDLProperty idlProperty) { CodeMemberProperty property = (CodeMemberProperty)base.HandleProperty(idlIntf, idlProperty); if (property.HasGet || property.HasSet) { // Generate the property out of context. CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"); CodeGeneratorOptions genOptions = CodeBuilderHelper.getCodeGeneratorOptions(); StringWriter temp = new StringWriter(); provider.GenerateCodeFromMember(property, temp, genOptions); string propertyText = temp.ToString(); propertyText = propertyText.TrimStart(); //Get ready to store all the output StringBuilder result = new StringBuilder(); // Figure out how much comments exist before doing the real work int posSkipStatements = 0; while (posSkipStatements + 1 < propertyText.Length && propertyText[posSkipStatements] == '/' && propertyText[posSkipStatements + 1] == '/') { posSkipStatements = propertyText.IndexOf(temp.NewLine, posSkipStatements); posSkipStatements += temp.NewLine.Length; } //Insert comments into output if (posSkipStatements > 0) { result.Append(propertyText.Substring(0, posSkipStatements)); propertyText = propertyText.Substring(posSkipStatements); } //Remove abstract modifiers const string abstractName = "abstract "; if (propertyText.StartsWith(abstractName)) { propertyText = propertyText.Substring(abstractName.Length); } // Hacky rewrite of the getter/setter for CSharp. if (property.HasGet) { propertyText = AddOperationContractToProperty(propertyText, "get;", temp.NewLine); } if (property.HasSet) { propertyText = AddOperationContractToProperty(propertyText, "set;", temp.NewLine); } // Add the altered text. result.Append(propertyText); // Mess around with padding. string resultText = result.ToString(); resultText = resultText.Replace(temp.NewLine, temp.NewLine + " "); resultText = " " + resultText; // Add the snippet. CodeSnippetTypeMember snipProperty = new CodeSnippetTypeMember(resultText); snipProperty.Name = property.Name; return snipProperty; } else { return property; } }
protected virtual ParamCodeTypeFactory HandleSignalArgument(IDLInterface idlIntf, IDLSignal idlSignal, IDLSignalArgument idlSignalArg) { // 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 IDLSignalArgumentTypeNameBuilder(idlIntf, idlSignal); ParamCodeTypeFactory paramtypeHolder = this.CreateParamCodeTypeFactoryForMethod("in"); Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(declarationHolder); Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolder, nameBuilder, idlSignalArg.Type, context); // Arguments return paramtypeHolder; }
public override void GenerateMethods(IDLInterface idlIntf) { if (idlIntf.Methods != null) // If got methods { bAddNamespace = idlIntf.Methods.Count > 0; foreach (IDLMethod idlMethod in idlIntf.Methods) { // Structs for capturing input/output from method. Udbus.Parsing.CodeTypeDeferredStructHolder paramsHolder = new Udbus.Parsing.CodeTypeDeferredStructHolder(idlMethod.Name + "AsyncParams"); Udbus.Parsing.CodeTypeDeferredStructHolder resultHolder = new Udbus.Parsing.CodeTypeDeferredStructHolder(idlMethod.Name + "AsyncResult"); CodeConstructor constructorResults = new CodeConstructor(); CodeConstructor constructorParams = new CodeConstructor(); constructorResults.Attributes = constructorParams.Attributes = MemberAttributes.Public; // Create Call method. CodeMemberMethod methodCall = new CodeMemberMethod(); methodCall.Name = "Call" + idlMethod.Name; // Actual call to proxy arguments will be added to as we parse IDL arguments. CodeExpressionCollection callParameters = new CodeExpressionCollection(); CodeExpressionCollection callResultArgs = new CodeExpressionCollection(); CodeExpressionCollection interfaceCallArgs = new CodeExpressionCollection(); CodeArgumentReferenceExpression argrefCallData = new CodeArgumentReferenceExpression(dataName); // Event Args string eventName = idlMethod.Name + "EventArgs"; CodeTypeDeclaration typeEvent = new CodeTypeDeclaration(eventName); typeEvent.IsClass = true; typeEvent.TypeAttributes = TypeAttributes.Public; typeEvent.BaseTypes.Add(new CodeTypeReference(typeof(AsyncCompletedEventArgs))); CodeConstructor constructorEventArgs = new CodeConstructor(); eventsDeclarationHolder.Add(typeEvent); CodeExpressionCollection makeEventArgs = new CodeExpressionCollection(); // Event Raiser... string raiserName = "raiser" + idlMethod.Name; CodeTypeReference raiserRef = new CodeTypeReference("AsyncOperationEventRaiser", new CodeTypeReference(eventName)); CodeMemberField fieldRaiser = new CodeMemberField(raiserRef, raiserName); fieldRaiser.InitExpression = new CodeObjectCreateExpression(raiserRef); fieldRaiser.Attributes = MemberAttributes.Private; typeProxy.Members.Add(fieldRaiser); // Event raiser EventCompleted Property - unfortunately CodeMemberEvent is useless here since can't add custom add/remove. // So anything other than CSharp is now a bust. Brilliant. CodeSnippetTypeMember eventRaiser = new CodeSnippetTypeMember(); eventRaiser.Text = string.Format(@" public event System.EventHandler<{0}> {1}Completed {{ add {{ this.{2}.CompletedEvent += value; }} remove {{ this.{2}.CompletedEvent -= value; }} }} ", eventName, idlMethod.Name, raiserName ); // Adding text here. //CodeMemberEvent eventRaiser = new CodeMemberEvent(); //eventRaiser.Attributes = MemberAttributes.Public; //CodeParamDeclaredType declaredType = new CodeParamDeclaredType(typeEvent); //eventRaiser.Type = new CodeTypeReference(CodeBuilderCommon.EventHandlerType.Name, declaredType.CodeType); //eventRaiser.Name = idlMethod.Name + "Completed"; typeProxy.Members.Add(eventRaiser); // Async method. CodeMemberMethod methodAsync = new CodeMemberMethod(); methodAsync.Name = idlMethod.Name + "Async"; methodAsync.Attributes = MemberAttributes.Public; // Straight-forward interface method. CodeMemberMethod methodInterface = new CodeMemberMethod(); methodInterface.Name = idlMethod.Name; methodInterface.Attributes = MemberAttributes.Public; // CodeComment commentMethod = new CodeComment(idlMethod.Name); // method.Comments.Add(new CodeCommentStatement(idlMethod.Name)); CodeExpressionCollection asyncArgs = new CodeExpressionCollection(); Udbus.Parsing.BuildContext context = new Udbus.Parsing.BuildContext(contextDeclarationHolder); foreach (IDLMethodArgument idlMethodArg in idlMethod.Arguments) { CodeCommentStatement commentMethod = new CodeCommentStatement(string.Format("{0} {1} \"{2}\"", idlMethodArg.Direction, idlMethodArg.Name, idlMethodArg.Type)); methodAsync.Comments.Add(commentMethod); 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") // If out argument { // Add to interface parameters. interfaceCallArgs.Add(new CodeDirectionExpression(FieldDirection.Out, varrefMethodArg)); // Put into result holding struct... param.Direction = FieldDirection.Out; methodInterface.Parameters.Add(param); CodeTypeReference argType = CodeBuilderCommon.GetReadOnlyCodeReference(paramtypeHolder.paramtype.CodeType); CodeMemberField fieldResultArg = new CodeMemberField(argType, idlMethodArg.Name); fieldResultArg.Attributes = MemberAttributes.Public; resultHolder.CodeType.Members.Add(fieldResultArg); constructorResults.Parameters.Add(new CodeParameterDeclarationExpression(paramtype.CodeType, idlMethodArg.Name)); CodeFieldReferenceExpression thisArg = new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), idlMethodArg.Name ); constructorResults.Statements.Add(new CodeAssignStatement(thisArg, new CodeArgumentReferenceExpression(idlMethodArg.Name))); // Add placeholder variables to call method. methodCall.Statements.Add(new CodeVariableDeclarationStatement(paramtype.CodeType, idlMethodArg.Name)); // Add appropriate parameter in actual call to interface. callParameters.Add(new CodeDirectionExpression(FieldDirection.Out, varrefMethodArg)); // Add appropriate parameter in call to result constructor. callResultArgs.Add(new CodeArgumentReferenceExpression(idlMethodArg.Name)); // Put into event args class... string fieldEventArgName = idlMethodArg.Name + "_"; CodeMemberField fieldEventArg = new CodeMemberField(paramtype.CodeType, fieldEventArgName); fieldEventArg.Attributes = MemberAttributes.Private; typeEvent.Members.Add(fieldEventArg); // Add argument property to EventArgs. CodeMemberProperty propEventArg = new CodeMemberProperty(); propEventArg.Attributes = MemberAttributes.Public | MemberAttributes.Final; propEventArg.Name = idlMethodArg.Name; propEventArg.HasGet = true; propEventArg.Type = paramtype.CodeType; propEventArg.GetStatements.Add(new CodeMethodInvokeExpression(null, "RaiseExceptionIfNecessary")); propEventArg.GetStatements.Add(new CodeMethodReturnStatement(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), fieldEventArgName))); typeEvent.Members.Add(propEventArg); // Add constructor parameter and statement to EventArgs. constructorEventArgs.Parameters.Add(new CodeParameterDeclarationExpression(paramtype.CodeType, idlMethodArg.Name)); constructorEventArgs.Statements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldEventArgName), new CodeArgumentReferenceExpression(idlMethodArg.Name) )); // Add as parameter in call to EventArgs constructor. makeEventArgs.Add(new CodeFieldReferenceExpression(new CodeArgumentReferenceExpression(resultName), idlMethodArg.Name)); } // Ends if out argument else // Else in argument { // Add to interface parameters. interfaceCallArgs.Add(varrefMethodArg); // Put into parameter holding struct. CodeMemberField fieldArg = new CodeMemberField(CodeBuilderCommon.GetReadOnlyCodeReference(paramtype.CodeType), idlMethodArg.Name); fieldArg.Attributes = MemberAttributes.Public; paramsHolder.CodeType.Members.Add(fieldArg); constructorParams.Parameters.Add(new CodeParameterDeclarationExpression(paramtype.CodeType, idlMethodArg.Name)); CodeFieldReferenceExpression thisArg = new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), idlMethodArg.Name ); constructorParams.Statements.Add(new CodeAssignStatement(thisArg, new CodeArgumentReferenceExpression(idlMethodArg.Name))); // Add appropriate parameter in actual call to interface. callParameters.Add(new CodeFieldReferenceExpression(argrefCallData, idlMethodArg.Name)); // Add appropriate parameter to async method parameters constructor call. asyncArgs.Add(new CodeArgumentReferenceExpression(idlMethodArg.Name)); // Add parameter to async method. methodAsync.Parameters.Add(param); // Add parameter to interface method. methodInterface.Parameters.Add(param); } // Ends else in argument } // Ends loop over method arguments methodAsync.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "userState")); // Add method body, then sort out arguments code... CodeFieldReferenceExpression thisRaiser = new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), raiserName ); CodeTypeReference typerefResult = null; if (idlMethod.Return != null) // If method has return type { // Add result to Result type. // TODO replace typeof(string) with actual return type. typerefResult = new CodeTypeReference("???"); } CodeTypeReference typerefResults = null; CodeTypeReference typerefParams = null; CodeExpression exprAsyncParamValue = null; string asyncMethodName = "AsyncFuncImpl"; // Default is assuming that function returns something. if (paramsHolder.QuType()) // If got params type { typerefParams = new CodeTypeReference(paramsHolder.CodeType.Name); // Add proxy field to params struct. CodeMemberField memberParamsProxy = new CodeMemberField(new CodeTypeReference("readonly " + genInterfaceName), proxyName); memberParamsProxy.Attributes = MemberAttributes.Public; paramsHolder.CodeType.Members.Insert(0, memberParamsProxy); // TODO: Going to need a using or a fully qualified name. // Add initialisation to constructor constructorParams.Parameters.Insert(0, paramProxy); // Constructor will take proxy as first argument. constructorParams.Statements.Insert(0, assignProxy); paramsHolder.CodeType.TypeAttributes = TypeAttributes.NestedPrivate; paramsHolder.CodeType.IsStruct = true; constructorParams.Attributes = MemberAttributes.Public; paramsHolder.CodeType.Members.Add(constructorParams); typeProxy.Members.Add(paramsHolder.CodeType); asyncArgs.Insert(0, thisProxyFieldRef); exprAsyncParamValue = new CodeObjectCreateExpression(typerefParams, asyncArgs.Cast<CodeExpression>().ToArray()); } // Ends if got params type if (resultHolder.QuType()) // If got results type { typerefResults = new CodeTypeReference(resultHolder.CodeType.Name); methodCall.ReturnType = typerefResults; // Setup call method parameters. if (idlMethod.Return != null) { // Add result field to EventArgs. CodeMemberField fieldResult = new CodeMemberField(typerefResult, resultName); fieldResult.Attributes = MemberAttributes.Private; typeEvent.Members.Insert(0, fieldResult); // Add result property to EventArgs. CodeMemberProperty propResult = new CodeMemberProperty(); propResult.Attributes = MemberAttributes.Public; propResult.Name = resultName; propResult.HasGet = true; propResult.Type = typerefResult; propResult.GetStatements.Add(new CodeMethodInvokeExpression(null, "RaiseExceptionIfNecessary")); propResult.GetStatements.Add(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), resultName)); typeEvent.Members.Add(propResult); // Add suitable parameter as first EventArgs constructor argument. constructorEventArgs.Parameters.Insert(0, new CodeParameterDeclarationExpression(typerefResult, resultName)); // Add statement to initialise result member. CodeFieldReferenceExpression thisArg = new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), resultName ); // Include result in parameters to EventArgs in MakeEventArgs statements. makeEventArgs.Insert(0, new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), resultName)); // Add result to Result type. CodeTypeReference typerefReadOnlyResult = CodeBuilderCommon.GetReadOnlyCodeReference(typerefResult); CodeMemberField fieldReadOnlyResult = new CodeMemberField(typerefReadOnlyResult, resultName); fieldResult.Attributes = MemberAttributes.Public; resultHolder.CodeType.Members.Insert(0, fieldReadOnlyResult); // Add suitable parameter as first constructor argument. constructorResults.Parameters.Insert(0, new CodeParameterDeclarationExpression(typerefResult, resultName)); // Add statement to initialise result member. constructorResults.Statements.Insert(0, new CodeAssignStatement(thisArg, new CodeArgumentReferenceExpression(resultName))); } // End if there is a return statement resultHolder.CodeType.TypeAttributes = TypeAttributes.NestedPrivate; resultHolder.CodeType.IsStruct = true; resultHolder.CodeType.Members.Add(constructorResults); typeProxy.Members.Add(resultHolder.CodeType); } // Ends if got results type else // Else no results type { // Absolutely no results (including out parameters) means it's an Action. asyncMethodName = "AsyncActionImpl"; } // Ends else no results type // Time to bite the bullet. CodeTypeReference typerefEvent = new CodeTypeReference(typeEvent.Name); CodeMemberMethod methodMakeEventArgs = new CodeMemberMethod(); methodMakeEventArgs.Name = "Make" + idlMethod.Name + "AsyncEventArgs"; // Add missing parameters to EventArgs... constructorEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclException); constructorEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclCancelled); constructorEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclUserState); // Pass through to base class. constructorEventArgs.BaseConstructorArgs.Add(CodeBuilderCommon.argrefException); constructorEventArgs.BaseConstructorArgs.Add(CodeBuilderCommon.argrefCancelled); constructorEventArgs.BaseConstructorArgs.Add(CodeBuilderCommon.argrefUserState); // Add MakeEventArgs method... // Create MakeEventArgs method. methodMakeEventArgs.Attributes = MemberAttributes.Private | MemberAttributes.Static; if (typerefParams != null) // If got params type { methodMakeEventArgs.Parameters.Add(new CodeParameterDeclarationExpression(typerefParams, dataName)); } else // Else no params type { // The interface will be passed as the first parameter. methodMakeEventArgs.Parameters.Add(paramProxy); } // Ends else no params type if (typerefResults != null) // If got results type { methodMakeEventArgs.Parameters.Add(new CodeParameterDeclarationExpression(typerefResults, resultName)); } methodMakeEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclException); methodMakeEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclCancelled); methodMakeEventArgs.Parameters.Add(CodeBuilderCommon.paramdeclUserState); makeEventArgs.Add(CodeBuilderCommon.argrefException); makeEventArgs.Add(CodeBuilderCommon.argrefCancelled); makeEventArgs.Add(CodeBuilderCommon.argrefUserState); methodMakeEventArgs.Statements.Add(new CodeMethodReturnStatement( new CodeObjectCreateExpression( typerefEvent, makeEventArgs.Cast<CodeExpression>().ToArray() ) )); methodMakeEventArgs.ReturnType = typerefEvent; typeProxy.Members.Add(methodMakeEventArgs); // Setup call method parameters. methodCall.Attributes = MemberAttributes.Private | MemberAttributes.Static; CodeExpression exprProxyRef; //methodCall.ReturnType = new CodeTypeReference(resultHolder.CodeType.Name); if (typerefParams != null) // If passing parameters { methodCall.Parameters.Add(new CodeParameterDeclarationExpression(typerefParams, dataName)); exprProxyRef = new CodeFieldReferenceExpression(argrefCallData, proxyName); } // Ends if passing parameters else // Else just passing proxy { methodCall.Parameters.Add(new CodeParameterDeclarationExpression(genInterfaceName, proxyName)); exprProxyRef = new CodeArgumentReferenceExpression(proxyName); } // Ends else just passing proxy // Add call method body... // Invocation to proxy. CodeMethodReferenceExpression methodProxy = new CodeMethodReferenceExpression(exprProxyRef, idlMethod.Name); CodeMethodInvokeExpression invokeProxy = new CodeMethodInvokeExpression(methodProxy, callParameters.Cast<CodeExpression>().ToArray()); if (idlMethod.Return != null) // If got return type { // TODO - return values. // Add invocation of actual interface method and store result. CodeVariableDeclarationStatement exprResult = new CodeVariableDeclarationStatement(typerefResult, resultName, invokeProxy); methodCall.Statements.Add(exprResult); // Initialise result parameter in Result struct. callResultArgs.Insert(0, new CodeArgumentReferenceExpression(resultName)); } // Ends if got return type else // Else no return type { // Add invocation of actual interface method and ignore result. methodCall.Statements.Add(invokeProxy); } // Ends else no return type if (typerefResults != null) // If got result type { // Create Call return statement. CodeMethodReturnStatement retCall = new CodeMethodReturnStatement( new CodeObjectCreateExpression(typerefResults, callResultArgs.Cast<CodeExpression>().ToArray()) ); methodCall.Statements.Add(retCall); } // Ends if got result type // Add call method to type. typeProxy.Members.Add(methodCall); // Add async method implementation... if (exprAsyncParamValue == null) // If no params { // Just pass the proxy. exprAsyncParamValue = thisProxyFieldRef; } // Ends if no params methodAsync.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(thisRaiser, asyncMethodName) , new CodeArgumentReferenceExpression("userState") , exprAsyncParamValue , new CodeMethodReferenceExpression(null, methodCall.Name) , new CodeMethodReferenceExpression(null, methodMakeEventArgs.Name) )); methodInterface.Statements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(thisProxyFieldRef, idlMethod.Name) , interfaceCallArgs.Cast<CodeExpression>().ToArray() )); // Finish up. typeEvent.Members.Add(constructorEventArgs); constructorEventArgs.Attributes = MemberAttributes.Public; ns.Types.Add(typeEvent); typeProxy.Members.Add(methodAsync); typeProxy.Members.Add(methodInterface); } // Ends loop over methods } // Ends if got methods }
protected override Udbus.Parsing.ICodeTypeDeclarationHolder CreateCodeTypeDeclarationHolder(IDLInterface idlIntf) { return new Udbus.Parsing.CodeTypeNoOpHolder(); }
protected override ParamCodeTypeFactory CreateParamCodeTypeFactoryForProperty(IDLInterface idlIntf, string propertyName, string argName, string argType, string argDirection) { return new ParamCodeTypeFactory(WCFContractTypeFactoryProperty, argDirection == "out" ? FieldDirection.Out : FieldDirection.In); }
public virtual void GenerateSignals(IDLInterface idlIntf) { return; }
protected abstract ParamCodeTypeFactory CreateParamCodeTypeFactoryForProperty(IDLInterface idlIntf, string propertyName, string argName, string argType, string argDirection);
public virtual void GenerateProperties(IDLInterface idlIntf) { return; }
protected abstract void PostHandleSignal(IDLInterface idlIntf, IDLSignal idlSignal, CodeCompileUnit unit, CodeNamespace ns, CodeTypeDeclaration typeInterface);
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 abstract Udbus.Parsing.ICodeTypeDeclarationHolder CreateCodeTypeDeclarationHolder(IDLInterface idlIntf);
public virtual void GenerateMethods(IDLInterface idlIntf) { return; }