Skip to content

Commit

Permalink
add dllimport property:CallingConvention=CallingConvention.Cdecl
Browse files Browse the repository at this point in the history
The default callingconvention has always been StdCall.
Starting with the .NET Framework 4, a streamlined interop marshaling architecture provides a significant performance improvement for transitions from managed code to unmanaged code. In earlier versions of the .NET Framework, the marshaling layer detected incorrect platform invoke declarations on 32-bit platforms and automatically fixed the stack.
  • Loading branch information
lslab committed Sep 5, 2013
1 parent 76b8eb3 commit a01c358
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
14 changes: 7 additions & 7 deletions SundownNet/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ public void Put(byte c)
bufputc(NativeHandle, c);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufput(IntPtr buf, IntPtr buffer, IntPtr size);

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufputs(IntPtr buf, IntPtr size);

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufputc(IntPtr buf, byte c);

#endregion
Expand All @@ -247,7 +247,7 @@ public void Grow(IntPtr size)
bufgrow(NativeHandle, size);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern int bufgrow(IntPtr buf, IntPtr size);
#endregion

Expand All @@ -257,7 +257,7 @@ public void Reset()
bufreset(NativeHandle);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufreset(IntPtr buf);
#endregion

Expand All @@ -270,7 +270,7 @@ void Release()
}
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufrelease(IntPtr buf);
#endregion

Expand All @@ -290,7 +290,7 @@ public void Slurp(long size)
Slurp(new IntPtr(size));
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern void bufslurp(IntPtr buf, IntPtr size);
#endregion
}
Expand Down
2 changes: 1 addition & 1 deletion SundownNet/ClrBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ClrBuffer(IntPtr size, bool alloc)
{
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr bufnewcb(IntPtr size, IntPtr malloc, IntPtr realloc, IntPtr free);

protected override void Alloc(IntPtr size)
Expand Down
3 changes: 2 additions & 1 deletion SundownNet/HtmlRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;


namespace Sundown
{
struct html_renderopt
Expand Down Expand Up @@ -42,7 +43,7 @@ public HtmlRenderer(HtmlRenderMode mode)
}
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sdhtml_renderer(ref md_callbacks callbacks, IntPtr options, uint render_flags);

protected override void Initialize()
Expand Down
10 changes: 5 additions & 5 deletions SundownNet/Markdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sundown
{
public sealed class Markdown : IDisposable
{
[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sd_version(out int major, out int minor, out int revision);

public static Version Version {
Expand All @@ -22,7 +22,7 @@ public static Version Version {
IntPtr ptr;
Renderer renderer;

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr sd_markdown_new(uint extensions, IntPtr max_nesting, IntPtr callbacks, IntPtr opaque);

public Markdown(Renderer renderer)
Expand Down Expand Up @@ -58,7 +58,7 @@ public void Dispose()
Dispose(true);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sd_markdown_free(IntPtr ptr);

void Dispose(bool disposing)
Expand Down Expand Up @@ -109,7 +109,7 @@ public void Render(Buffer @out, byte[] array, long length)
Render(@out, array, (IntPtr)length);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sd_markdown_render(IntPtr buf, IntPtr document, IntPtr documentSize, IntPtr md);

public void Render(Buffer @out, byte[] array, IntPtr length)
Expand Down Expand Up @@ -167,7 +167,7 @@ public static void SmartyPants(Buffer @out, byte[] array, long length)
SmartyPants(@out, array, (IntPtr)length);
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sdhtml_smartypants(IntPtr buf, IntPtr text, IntPtr size);

public static void SmartyPants(Buffer @out, byte[] array, IntPtr length)
Expand Down
2 changes: 1 addition & 1 deletion SundownNet/NativeBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Sundown
{
public class NativeBuffer : Buffer
{
[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr bufnew(IntPtr size);

public NativeBuffer()
Expand Down
2 changes: 1 addition & 1 deletion SundownNet/TableOfContentRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TableOfContentRenderer()
}
}

[DllImport("sundown")]
[DllImport("sundown", CallingConvention=CallingConvention.Cdecl)]
internal static extern void sdhtml_toc_renderer(ref md_callbacks callbacks, IntPtr options, uint render_flags);

protected override void Initialize()
Expand Down

0 comments on commit a01c358

Please sign in to comment.