Esempio n. 1
0
        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;
        }
 public override void DeclareCodeType(IDLInterface idlIntf)
 {
     // Interface.
     type              = new CodeTypeDeclaration(ifName);
     type.IsInterface  = true;
     declarationHolder = this.CreateCodeTypeDeclarationHolder(idlIntf); //Implemented by subclasses
 }
 public override void DeclareCodeType(IDLInterface idlIntf)
 {
     // Interface.
     type =  new CodeTypeDeclaration(ifName);
     type.IsInterface = true;
     declarationHolder = this.CreateCodeTypeDeclarationHolder(idlIntf); //Implemented by subclasses
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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;
        }