public virtual void EmitPublicCall(CodeBuilder b)
    {
        var apiCall = string.Format("CfxApi.{2}.{0}({1})", Owner.CfxApiFunctionName, PublicArgumentList, Owner.PublicClassName.Substring(3));

        for (var i = 0; i <= ManagedArguments.Length - 1; i++)
        {
            ManagedArguments[i].EmitPrePublicCallStatements(b);
        }

        var b1 = new CodeBuilder(b.CurrentIndent);

        for (var i = 0; i <= ManagedArguments.Length - 1; i++)
        {
            ManagedArguments[i].EmitPostPublicStatements(b1);
        }

        if (PublicReturnType.IsVoid)
        {
            b.AppendLine(apiCall + ";");
            b.AppendBuilder(b1);
        }
        else
        {
            if (b1.IsNotEmpty)
            {
                b.AppendLine("var __retval = {0};", apiCall);
                b.AppendBuilder(b1);
                b.AppendLine("return {0};", PublicReturnType.PublicReturnExpression("__retval"));
            }
            else
            {
                b.AppendLine("return {0};", PublicReturnType.PublicReturnExpression(apiCall));
            }
        }
    }
Пример #2
0
    public virtual void EmitNativeReturnStatements(CodeBuilder b, string functionCall, CodeBuilder postCallStatements)
    {
        if (IsVoid)
        {
            b.AppendLine("{0};", NativeWrapExpression(functionCall));
            b.AppendBuilder(postCallStatements);
            return;
        }

        if (postCallStatements.IsNotEmpty)
        {
            b.AppendLine("{0} __ret_val_ = {1};", NativeSymbol, NativeWrapExpression(functionCall));
            b.AppendBuilder(postCallStatements);
            b.AppendLine("return __ret_val_;");
        }
        else
        {
            b.AppendLine("return {0};", NativeWrapExpression(functionCall));
        }
    }
Пример #3
0
 public override void EmitNativeReturnStatements(CodeBuilder b, string functionCall, CodeBuilder postCallStatements)
 {
     Debug.Assert(Category == StructCategory.Values);
     b.AppendLine("{0} *__retval = malloc(sizeof({0}));", OriginalSymbol, functionCall);
     b.AppendLine("if(__retval) *__retval = {0};", functionCall);
     if (postCallStatements.IsNotEmpty)
     {
         b.AppendBuilder(postCallStatements);
     }
     b.AppendLine("return __retval;");
 }
Пример #4
0
 public override void EmitNativeReturnStatements(CodeBuilder b, string functionCall, CodeBuilder postCallStatements)
 {
     b.AppendLine("{0} __retval_tmp = {1};", OriginalSymbol, functionCall);
     if (postCallStatements.IsNotEmpty)
     {
         b.AppendLine("{0} *__retval = ({0}*)cfx_copy_structure(&__retval_tmp, sizeof({0}));", OriginalSymbol);
         b.AppendBuilder(postCallStatements);
         b.AppendLine("return __retval;");
     }
     else
     {
         b.AppendLine("return ({0}*)cfx_copy_structure(&__retval_tmp, sizeof({0}));", OriginalSymbol);
     }
 }