public override void EmitPublicCall(CodeBuilder b, string apiClassName, string apiFunctionName)
    {
        var countFunc = countFunction.Substring(countFunction.IndexOf(":") + 1);

        // it's translated into a property
        Debug.Assert(countFunc.StartsWith("Get"));
        countFunc = countFunc.Substring(3);
        b.AppendLine("var count = {0};", countFunc);
        b.AppendLine("if(count == 0) return new {0}[0];", Parameters[2].ParameterType.PublicSymbol);
        var code =
            @"IntPtr[] ptrs = new IntPtr[count];
var ptrs_p = new PinnedObject(ptrs);
CfxApi.{2}.{0}(NativePtr, (UIntPtr)count, ptrs_p.PinnedPtr);
ptrs_p.Free();
{1}[] retval = new {1}[count];
for(ulong i = 0; i < count; ++i) {{
    retval[i] = {1}.Wrap(ptrs[i]);
}}
return retval;";

        b.AppendMultiline(code,
                          apiFunctionName,
                          Parameters[2].ParameterType.PublicSymbol,
                          apiClassName);
    }
    protected override void EmitRemoteProcedure(CodeBuilder b, string apiClassName, string apiFunctionName)
    {
        Debug.Assert(Parameters[2].ParameterType.PublicSymbol == "CfxPostDataElement");
        var code =
            @"var count = CfxApi.PostData.cfx_post_data_get_element_count(@this);
__retval = new IntPtr[(ulong)count];
if(__retval.Length == 0) return;
var ptrs_p = new PinnedObject(__retval);
CfxApi.PostData.cfx_post_data_get_elements(@this, count, ptrs_p.PinnedPtr);
ptrs_p.Free();
";

        b.AppendMultiline(code,
                          apiFunctionName,
                          Parameters[2].ParameterType.PublicSymbol);
    }
Пример #3
0
    protected override void EmitExecuteInTargetProcess(CodeBuilder b)
    {
        Debug.Assert(Arguments[2].ArgumentType.PublicSymbol == "CfxPostDataElement");
        var code =
            @"var count = CfxApi.PostData.cfx_post_data_get_element_count(@this);
__retval = new IntPtr[(ulong)count];
if(__retval.Length == 0) return;
var ptrs_p = new PinnedObject(__retval);
CfxApi.PostData.cfx_post_data_get_elements(@this, count, ptrs_p.PinnedPtr);
ptrs_p.Free();
";

        b.AppendMultiline(code,
                          Owner.CfxApiFunctionName,
                          Arguments[2].ArgumentType.PublicSymbol);
    }
    public override void EmitPublicCall(CodeBuilder b)
    {
        var countFunc = Owner.CefConfig.CountFunction.Substring(Owner.CefConfig.CountFunction.IndexOf(":") + 1);

        // it's translated into a property
        Debug.Assert(countFunc.StartsWith("Get"));
        countFunc = countFunc.Substring(3);
        b.AppendLine("int count = {0};", countFunc);
        b.AppendLine("if(count == 0) return new {0}[0];", Arguments[2].ArgumentType.PublicSymbol);
        var code =
            @"IntPtr[] ptrs = new IntPtr[count];
var ptrs_p = new PinnedObject(ptrs);
CfxApi.{0}(NativePtr, count, ptrs_p.PinnedPtr);
ptrs_p.Free();
{1}[] retval = new {1}[count];
for(int i = 0; i < count; ++i) {{
    retval[i] = {1}.Wrap(ptrs[i]);
}}
return retval;";

        b.AppendMultiline(code,
                          Owner.CfxApiFunctionName,
                          Arguments[2].ArgumentType.PublicSymbol);
    }