From 35bd8f293bee7faf63ebcf60ce71bc177ad0e150 Mon Sep 17 00:00:00 2001 From: andri lim Date: Sat, 30 Jan 2016 11:27:58 +0700 Subject: [PATCH] Updated Playing with CPP VTABLE from Nim (markdown) --- Playing-with-CPP--VTABLE-from-Nim.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Playing-with-CPP--VTABLE-from-Nim.md b/Playing-with-CPP--VTABLE-from-Nim.md index 33e4402..506c47b 100644 --- a/Playing-with-CPP--VTABLE-from-Nim.md +++ b/Playing-with-CPP--VTABLE-from-Nim.md @@ -142,6 +142,7 @@ proc nvGetCharRange*(dv: IDocument, buf: cstring, pos, len: int) = Again, we can see how actually C++ compilers translate `->` operator when calling virtual functions, it will use the right index to the vtable and call the function via pointer, that what we also do in Nim, cast the typeless pointer to proc pointer and call it, don't forget that the first argument is also a pointer to the class instance. +### Conclusion That's it, not too difficult heh? It's not too difficult because we are not dealing with C++ name mangling here, only dealing with pointers and calling convention, Nim can handle that perfectly, although a bit verbose compared to C++ style. What about C++ ordinary [member] functions?, well that's another story, C++ name mangling can be a nightmare if you try to solve that in Nim, because every C++ compiler have their own flavor/style of name mangling, but if you know the exact formula of C++ name mangling, please write another wiki! \ No newline at end of file