コード例 #1
0
        /// <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);
        }
コード例 #2
0
        protected override CodeParameterDeclarationExpression HandleMethodArgument(IDLMethodArgument idlMethodArg, ParamCodeTypeFactory paramtypeHolder)
        {
            CodeParameterDeclarationExpression toReturn = base.HandleMethodArgument(idlMethodArg, paramtypeHolder);

            if (idlMethodArg.Type.IndexOf('v') != -1)
            {
                this.gotVariant = true;
            }
            return(toReturn);
        }
コード例 #3
0
        /// <summary>
        /// Given an IDLMethodArgument, generate the necessary bits
        /// </summary>
        /// <remarks>Override to expand functionality or replace it</remarks>
        /// <param name="idlMethodArg"></param>
        /// <param name="paramtypeHolder"></param>
        /// <returns></returns>
        protected virtual CodeParameterDeclarationExpression HandleMethodArgument(IDLMethodArgument idlMethodArg, ParamCodeTypeFactory paramtypeHolder)
        {
            CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, idlMethodArg.Name);

            if (idlMethodArg.Direction == "out")
            {
                param.Direction = FieldDirection.Out;
            }

            return(param);
        }
コード例 #4
0
 public override CodeExpression MarshalArgument(string idlMethodName, IDLMethodArgument idlMethodArg)
 {
     // Marshal value as normal, but interface_name as connection parameter property, and property_name as primitive string.
     CodeExpression exprResult;
     switch (idlMethodArg.Name )
     {
         case "value":
             exprResult = base.MarshalArgument(idlMethodName, idlMethodArg);
             break;
         case "interface_name":
             exprResult = new CodePropertyReferenceExpression(proprefConnectionParameters, "Interface");
             break;
         case "property_name":
             exprResult = new CodePrimitiveExpression(idlMethodName);
             break;
         default:
             exprResult = base.MarshalArgument(idlMethodName, idlMethodArg);
             break;
     }
     return exprResult;
 }
コード例 #5
0
 public virtual CodeExpression MarshalArgument(string idlMethodName, IDLMethodArgument idlMethodArg)
 {
     return new CodeArgumentReferenceExpression(idlMethodArg.Name);
 }
コード例 #6
0
        public virtual void MakeInArgument(CodeTypeFactory codetypefactoryIn
            , string idlMethodName
            , ref int nInArgCounter
            , Udbus.Parsing.BuildContext context
            , ref CodeThrowExceptionStatement throwargInPrev
            , IDLMethodArgument idlMethodArg
            , Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder
            , ref ParamCodeTypeHolderMarshalBase paramtypeHolder
            , ref CodeTypeReference typerefParam
            , out CodeConditionStatement condVarResult)
        {
            marshal.inward.ParamCodeTypeHolderMarshalIn paramtypeHolderIn = new marshal.inward.ParamCodeTypeHolderMarshalIn(codetypefactoryIn);
            Udbus.Parsing.CodeBuilderHelper.BuildCodeParamType(paramtypeHolderIn, nameBuilder, idlMethodArg.Type, context);
            paramtypeHolder = paramtypeHolderIn;
            /*typerefParamIter = */
            typerefParam = paramtypeHolder.paramtype.CodeType;

            condVarResult = new CodeConditionStatement(
                // * if (this.result == 0)
                exprResultOk
                , new CodeStatement[] // True statements
                {
                    // * this.result = builder.Marshal<arg_type>(<marshal_function>, <arg_name>);
                    new CodeAssignStatement(fieldrefResult,
                        paramtypeHolderIn.BuildWriteExpression(varrefBuilder,
                            MarshalArgument(idlMethodName, idlMethodArg)))
                }
                , new CodeStatement[] // False statements
                {
                    throwargInPrev
                }
                );

            throwargInPrev = new CodeThrowExceptionStatement(
                new CodeMethodInvokeExpression(MarshalBuilderHelper.typerefexprArgumentInException, "Create",
                    new CodePrimitiveExpression(nInArgCounter + 1),
                    new CodePrimitiveExpression(idlMethodArg.Name),
                    new CodeTypeOfExpression(typerefParam),
                    fieldrefResult,
                    new CodePrimitiveExpression(idlMethodName),
                    fieldrefConnectionParameters
                )
            );

            ++nInArgCounter;
        }
コード例 #7
0
 protected override CodeParameterDeclarationExpression HandleMethodArgument(IDLMethodArgument idlMethodArg, ParamCodeTypeFactory paramtypeHolder)
 {
     CodeParameterDeclarationExpression toReturn = base.HandleMethodArgument(idlMethodArg, paramtypeHolder);
     if (idlMethodArg.Type.IndexOf('v') != -1) this.gotVariant = true;
     return toReturn;
 }
コード例 #8
0
        /// <summary>
        /// Given an IDLMethodArgument, generate the necessary bits
        /// </summary>
        /// <remarks>Override to expand functionality or replace it</remarks>
        /// <param name="idlMethodArg"></param>
        /// <param name="paramtypeHolder"></param>
        /// <returns></returns>
        protected virtual CodeParameterDeclarationExpression HandleMethodArgument(IDLMethodArgument idlMethodArg, ParamCodeTypeFactory paramtypeHolder)
        {
            CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, idlMethodArg.Name);
            if (idlMethodArg.Direction == "out")
            {
                param.Direction = FieldDirection.Out;
            }

            return param;
        }
コード例 #9
0
        /// <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;
        }