Ejemplo n.º 1
0
        private BlockSyntax GetConstrctorBody(MethodDescription description)
        {
            var callJvmExpression = CallJvmExpression(
                "NewObject",
                classRefName,
                ServiceUtils.GetMethodRefProperty(description),
                description.ParametersDescription);

            return(SyntaxFactory.Block(
                       RoslynUtils
                       .AssignmentExpression(jObjectName, callJvmExpression)
                       .ToStatement()));
        }
Ejemplo n.º 2
0
        private static BlockSyntax AddLockStatement(
            this BlockSyntax blockSyntax,
            string lockObjectName,
            string fieldName,
            ExpressionSyntax fieldIdentifierName,
            ExpressionSyntax fieldAssignmentExpression)
        {
            var assignmentStatement = RoslynUtils.AssignmentExpression(fieldName, fieldAssignmentExpression);
            var fieldNullStatement  = RoslynUtils.CheckNullStatement(fieldName,
                                                                     assignmentStatement.ToStatement());

            var lockStat = RoslynUtils.LockStatement(
                SyntaxFactory.IdentifierName(lockObjectName),
                SyntaxFactory.Block(fieldNullStatement, SyntaxFactory.ReturnStatement(fieldIdentifierName))
                );

            return(blockSyntax.AddStatements(lockStat));
        }
Ejemplo n.º 3
0
        private ExpressionSyntax GenerateJValueExpressionFor(ParameterDescription parameter)
        {
            var isPrimitive = JavaUtils.IsPrimitive(parameter.Type);
            ExpressionSyntax jValueParameter = SyntaxFactory.IdentifierName(isPrimitive
                ? parameter.Name
                : $"{SyntaxFactory.IdentifierName(parameter.Name)}_using");

            if (!isPrimitive)
            {
                jValueParameter = jValueParameter.MemberAccessExpression("Ptr");
            }

            return(RoslynUtils.NewExpression(
                       "JValue",
                       RoslynUtils.CollectionInitExpression(new[]
            {
                RoslynUtils.AssignmentExpression(
                    JavaUtils.GetTypeName(parameter.Type),
                    jValueParameter)
            })));
        }