From 059ca01e77e61a7a8e68f157045c69ce1eab26c7 Mon Sep 17 00:00:00 2001 From: andri lim Date: Sat, 30 Jan 2016 11:29:46 +0700 Subject: [PATCH] Updated Playing with CPP VTABLE from Nim (markdown) --- Playing-with-CPP--VTABLE-from-Nim.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Playing-with-CPP--VTABLE-from-Nim.md b/Playing-with-CPP--VTABLE-from-Nim.md index 506c47b..091eecc 100644 --- a/Playing-with-CPP--VTABLE-from-Nim.md +++ b/Playing-with-CPP--VTABLE-from-Nim.md @@ -3,9 +3,9 @@ Imagine you are trying to communicate with a C++ app from Nim, and the C++ inter ### Case example, notepad++ plugin: notepad++ plugin is a normal dll with normal interface. Standard notepad++ plugin requires standard cdecl calling convention for it's binary interface, not a big problem, Nim ffi can handle that perfectly. But things get more interesting when we want to make an external lexer for notepad++ editor engine: Scintilla. -Although that external lexer we want to create must also be reside in the same dll with our notepad++ plugin, it has different calling convention, scintilla requires stdcall calling convention for all functions it needed. Again, this is not a problem for Nim, just use {.stdcall.} pragma. But there is another requirement for notepad++ plugin: all exported function name must not be decorated ala normal stdcall, so we need to activate -Wl,--kill-at switch when compile the plugin project, and the C/C++ compiler will handle that. +Although that external lexer we want to create must also be reside in the same dll with our notepad++ plugin, it has different calling convention, scintilla requires stdcall calling convention for all functions it needed. Again, this is not a problem for Nim, just use {.stdcall.} pragma. But there is another requirement for notepad++ plugin: all exported function name must not be decorated ala normal stdcall, so we need to activate `-Wl,--kill-at` switch when compile the plugin project, and the C/C++ compiler will handle that. -OK, so far no C++ feature we already met. But wait, that's not the real interface to Scintilla, it's only entry point for a more complicated interface. +OK, so far no C++ features we already met. But wait, that's not the real interface to Scintilla, it's only entry point for a more complicated interface. ### The C++ interface ```C++