Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cl/_testcpp/ctor_dtor/wrap.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <foo.h>

void _llcppg__ZN3barC1Ev(bar* this) {
extern "C" void _llcppg__ZN3barC1Ev(bar* this) {
this->bar();
}

void _llcppg__ZN3barC1EPKc(bar* this, const char * a) {
extern "C" void _llcppg__ZN3barC1EPKc(bar* this, const char * a) {
this->bar(a);
}

void _llcppg__ZN3barD1Ev(bar* this) {
extern "C" void _llcppg__ZN3barD1Ev(bar* this) {
this->~bar();
}
4 changes: 2 additions & 2 deletions cl/_testcpp/inline/wrap.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <foo.h>

unsigned int _llcppg__ZN3bar1fEi(bar* this, int a) {
extern "C" unsigned int _llcppg__ZN3bar1fEi(bar* this, int a) {
return this->f(a);
}

void _llcppg__ZN3bar2_gEv(bar* this) {
extern "C" void _llcppg__ZN3bar2_gEv(bar* this) {
this->_g();
}
11 changes: 7 additions & 4 deletions cl/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ func wrapInlineFunc(ctx *pkgCtx, manglingName string, fn clang.Cursor, cls *clas
}
w.WriteByte('\n')
wrapName := "_llcppg_" + manglingName
writeFunc(w, wrapName, fn, cls)
writeFunc(w, wrapName, fn, cls, ctx.lang)
return wrapName
}

// -----------------------------------------------------------------------------

type writerT = bytes.Buffer

func writeFunc(b *writerT, name string, fn clang.Cursor, cls *classCtx) {
func writeFunc(b *writerT, name string, fn clang.Cursor, cls *classCtx, lang Language) {
var call writerT
writeFuncProto(b, &call, name, fn, cls)
writeFuncProto(b, &call, name, fn, cls, lang)
b.WriteString(" {\n")
b.Write(call.Bytes())
b.WriteString("}\n")
}

func writeFuncProto(out, call *writerT, name string, fn clang.Cursor, cls *classCtx) {
func writeFuncProto(out, call *writerT, name string, fn clang.Cursor, cls *classCtx, lang Language) {
var b writerT
b.WriteString(name)
b.WriteByte('(')
Expand Down Expand Up @@ -109,6 +109,9 @@ func writeFuncProto(out, call *writerT, name string, fn clang.Cursor, cls *class
}
b.WriteByte(')')
call.WriteString(");\n")
if lang == LanguageCXX {
out.WriteString(`extern "C" `)
}
writeParam(out, retType, b.String())
}

Expand Down
Loading