2024-08-07 06:51:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-08-08 07:06:31 +00:00
|
|
|
"sort"
|
2024-08-07 06:51:51 +00:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
func (p CppParameter) RenderTypeCpp() string {
|
|
|
|
ret := p.ParameterType
|
2024-08-14 06:34:05 +00:00
|
|
|
switch p.ParameterType {
|
|
|
|
case "uint":
|
|
|
|
ret = "unsigned int"
|
|
|
|
case "ushort":
|
|
|
|
ret = "unsigned short"
|
|
|
|
case "ulong":
|
|
|
|
ret = "unsigned long"
|
|
|
|
case "qlonglong":
|
|
|
|
ret = "int64_t"
|
|
|
|
case "qulonglong":
|
|
|
|
ret = "uint64_t"
|
|
|
|
}
|
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
if p.Pointer || p.ByRef {
|
|
|
|
ret += "*"
|
|
|
|
}
|
2024-08-14 06:34:05 +00:00
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
return ret // ignore const
|
|
|
|
}
|
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
func emitReturnTypeCabi(p CppParameter) string {
|
|
|
|
if p.ParameterType == "QString" {
|
|
|
|
return "void" // Will be handled separately
|
|
|
|
|
2024-08-11 04:37:18 +00:00
|
|
|
} else if _, ok := p.QListOf(); ok {
|
|
|
|
return "void" // Will be handled separately
|
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
} else if (p.Pointer || p.ByRef) && p.QtClassType() {
|
2024-08-14 05:31:10 +00:00
|
|
|
return p.ParameterType + "*" // CABI type
|
2024-08-09 06:41:29 +00:00
|
|
|
|
2024-08-09 22:34:54 +00:00
|
|
|
} else if p.QtClassType() && !p.Pointer {
|
|
|
|
// Even if C++ returns by value, CABI is returning a heap copy (new'd, not malloc'd)
|
2024-08-14 05:31:10 +00:00
|
|
|
return p.ParameterType + "*" // CABI type
|
2024-08-09 22:34:54 +00:00
|
|
|
// return "void" // Handled separately with an _out pointer
|
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
} else {
|
|
|
|
return p.RenderTypeCpp()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func emitParametersCabi(m CppMethod, selfType string) string {
|
|
|
|
tmp := make([]string, 0, len(m.Parameters)+1)
|
2024-08-07 06:51:51 +00:00
|
|
|
|
|
|
|
if selfType != "" {
|
2024-08-08 06:55:47 +00:00
|
|
|
tmp = append(tmp, selfType+" self")
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
for _, p := range m.Parameters {
|
2024-08-08 06:54:13 +00:00
|
|
|
if p.ParameterType == "QString" {
|
|
|
|
// The Go code has called this with two arguments: char* and len
|
|
|
|
// Declare that we take two parameters
|
|
|
|
tmp = append(tmp, "const char* "+p.ParameterName+", size_t "+p.ParameterName+"_Strlen")
|
|
|
|
|
2024-08-11 04:37:18 +00:00
|
|
|
} else if t, ok := p.QListOf(); ok {
|
|
|
|
// The Go code has called this with two arguments: T* and len
|
|
|
|
// Declare that we take two parameters
|
|
|
|
// TODO support QList<int>
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, t.ParameterType+"* "+p.ParameterName+", size_t "+p.ParameterName+"_len")
|
2024-08-11 04:37:18 +00:00
|
|
|
|
2024-08-08 07:06:14 +00:00
|
|
|
} else if (p.ByRef || p.Pointer) && p.QtClassType() {
|
2024-08-08 06:54:13 +00:00
|
|
|
// Pointer to Qt type
|
|
|
|
// Replace with taking our PQ typedef by value
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, p.ParameterType+"* "+p.ParameterName)
|
2024-08-09 22:36:36 +00:00
|
|
|
|
|
|
|
} else if p.QtClassType() {
|
|
|
|
// Qt type passed by value
|
|
|
|
// The CABI will unconditionally take these by pointer and dereference them
|
|
|
|
// when passing to C++
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, p.ParameterType+"* "+p.ParameterName)
|
2024-08-09 22:36:36 +00:00
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
} else {
|
|
|
|
// RenderTypeCpp renders both pointer+reference as pointers
|
|
|
|
tmp = append(tmp, p.RenderTypeCpp()+" "+p.ParameterName)
|
|
|
|
}
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
2024-08-09 06:41:29 +00:00
|
|
|
|
|
|
|
// If the return type is QString, we need to handle returns via extra CABI
|
|
|
|
// parameters
|
|
|
|
// Qt C++: memory is in QString RAII
|
|
|
|
// CABI: memory is moved into C.malloc/C.free
|
|
|
|
// Go: converted to native Go string
|
|
|
|
if m.ReturnType.ParameterType == "QString" {
|
|
|
|
tmp = append(tmp, "char** _out, size_t* _out_Strlen")
|
2024-08-11 04:37:18 +00:00
|
|
|
|
|
|
|
} else if t, ok := m.ReturnType.QListOf(); ok {
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, t.ParameterType+"** _out, size_t* _out_len")
|
2024-08-11 04:37:18 +00:00
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 06:51:51 +00:00
|
|
|
return strings.Join(tmp, ", ")
|
|
|
|
}
|
|
|
|
|
2024-08-09 22:35:58 +00:00
|
|
|
func emitParametersCABI2CppForwarding(params []CppParameter) (preamble string, forwarding string) {
|
2024-08-07 06:51:51 +00:00
|
|
|
tmp := make([]string, 0, len(params)+1)
|
|
|
|
|
|
|
|
for _, p := range params {
|
2024-08-08 06:54:13 +00:00
|
|
|
if p.ParameterType == "QString" {
|
|
|
|
// The CABI has accepted two parameters - need to convert to one real QString
|
|
|
|
// Create it on the stack
|
2024-08-09 22:34:54 +00:00
|
|
|
preamble += "\tQString " + p.ParameterName + "_QString = QString::fromUtf8(" + p.ParameterName + ", " + p.ParameterName + "_Strlen);\n"
|
2024-08-08 06:54:13 +00:00
|
|
|
tmp = append(tmp, p.ParameterName+"_QString")
|
|
|
|
|
2024-08-11 04:37:18 +00:00
|
|
|
} else if _, ok := p.QListOf(); ok {
|
|
|
|
// The CABI has accepted two parameters - need to convert to one real QList<>
|
|
|
|
// Create it on the stack
|
|
|
|
preamble += "\t" + p.RenderTypeCpp() + " " + p.ParameterName + "_QList;\n"
|
|
|
|
preamble += "\t" + p.ParameterName + "_QList.reserve(" + p.ParameterName + "_len);\n"
|
|
|
|
preamble += "\tfor(size_t i = 0; i < " + p.ParameterName + "_len; ++i) {\n"
|
2024-08-14 05:31:10 +00:00
|
|
|
preamble += "\t\t" + p.ParameterName + "_QList.push_back(" + p.ParameterName + "++);\n"
|
2024-08-11 04:37:18 +00:00
|
|
|
preamble += "\t}\n"
|
|
|
|
tmp = append(tmp, p.ParameterName+"_QList")
|
|
|
|
|
2024-08-14 06:33:47 +00:00
|
|
|
} else if p.IntType() {
|
|
|
|
// Use the raw ParameterType to select an explicit integer overload
|
|
|
|
// Don't use RenderTypeCpp() since it canonicalizes some int types for CABI
|
|
|
|
castType := p.ParameterType
|
|
|
|
if p.Pointer {
|
|
|
|
castType += "*"
|
|
|
|
}
|
|
|
|
tmp = append(tmp, "static_cast<"+castType+">("+p.ParameterName+")")
|
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
} else if p.ByRef {
|
|
|
|
// We changed RenderTypeCpp() to render this as a pointer
|
|
|
|
// Need to dereference so we can pass as reference to the actual Qt C++ function
|
2024-08-09 22:34:54 +00:00
|
|
|
//tmp = append(tmp, "*"+p.ParameterName)
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, "*"+p.ParameterName)
|
2024-08-09 22:34:54 +00:00
|
|
|
|
|
|
|
} else if p.QtClassType() && !p.Pointer {
|
|
|
|
// CABI takes all Qt types by pointer, even if C++ wants them by value
|
|
|
|
// Dereference the passed-in pointer
|
2024-08-14 05:31:10 +00:00
|
|
|
tmp = append(tmp, "*"+p.ParameterName)
|
2024-08-09 22:34:54 +00:00
|
|
|
|
2024-08-14 05:31:10 +00:00
|
|
|
// } else if p.QtClassType() && p.Pointer {
|
2024-08-09 23:46:48 +00:00
|
|
|
// We need this static_cast<> anyway to convert from PQt (void*) to
|
|
|
|
// the real Qt type
|
2024-08-14 05:31:10 +00:00
|
|
|
// tmp = append(tmp, "static_cast<"+p.ParameterType+"*>("+p.ParameterName+")")
|
2024-08-09 23:46:48 +00:00
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
} else {
|
|
|
|
tmp = append(tmp, p.ParameterName)
|
|
|
|
}
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
2024-08-08 06:54:13 +00:00
|
|
|
|
|
|
|
return preamble, strings.Join(tmp, ", ")
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 06:34:27 +00:00
|
|
|
// getReferencedTypes finds all referenced Qt types in this file.
|
2024-08-14 05:31:30 +00:00
|
|
|
func getReferencedTypes(src *CppParsedHeader) []string {
|
2024-08-14 06:34:27 +00:00
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
foundTypes := map[string]struct{}{}
|
|
|
|
for _, c := range src.Classes {
|
2024-08-14 06:34:27 +00:00
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
foundTypes[c.ClassName] = struct{}{}
|
2024-08-14 06:34:27 +00:00
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
for _, ctor := range c.Ctors {
|
|
|
|
for _, p := range ctor.Parameters {
|
|
|
|
if p.QtClassType() {
|
|
|
|
foundTypes[p.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-14 06:34:27 +00:00
|
|
|
if t, ok := p.QListOf(); ok && t.QtClassType() {
|
|
|
|
foundTypes["QList"] = struct{}{}
|
|
|
|
foundTypes[t.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-08 07:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, m := range c.Methods {
|
|
|
|
for _, p := range m.Parameters {
|
|
|
|
if p.QtClassType() {
|
|
|
|
foundTypes[p.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-14 06:34:27 +00:00
|
|
|
if t, ok := p.QListOf(); ok && t.QtClassType() {
|
|
|
|
foundTypes["QList"] = struct{}{}
|
|
|
|
foundTypes[t.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-08 07:06:31 +00:00
|
|
|
}
|
|
|
|
if m.ReturnType.QtClassType() {
|
|
|
|
foundTypes[m.ReturnType.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-14 06:34:27 +00:00
|
|
|
if t, ok := m.ReturnType.QListOf(); ok && t.QtClassType() {
|
|
|
|
foundTypes["QList"] = struct{}{}
|
|
|
|
foundTypes[t.ParameterType] = struct{}{}
|
|
|
|
}
|
2024-08-08 07:06:31 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-14 06:34:27 +00:00
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
foundTypesList := make([]string, 0, len(foundTypes))
|
|
|
|
for ft := range foundTypes {
|
2024-08-14 05:31:30 +00:00
|
|
|
if strings.HasPrefix(ft, "QList<") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
foundTypesList = append(foundTypesList, ft)
|
|
|
|
}
|
|
|
|
sort.Strings(foundTypesList)
|
2024-08-14 05:31:30 +00:00
|
|
|
|
|
|
|
return foundTypesList
|
|
|
|
}
|
|
|
|
|
|
|
|
func emitBindingHeader(src *CppParsedHeader, filename string) (string, error) {
|
|
|
|
ret := strings.Builder{}
|
|
|
|
|
|
|
|
includeGuard := "GEN_" + strings.ToUpper(strings.Replace(filename, `.`, `_`, -1))
|
|
|
|
|
|
|
|
ret.WriteString(`#ifndef ` + includeGuard + `
|
|
|
|
#define ` + includeGuard + `
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
|
|
|
foundTypesList := getReferencedTypes(src)
|
|
|
|
|
|
|
|
ret.WriteString("#ifdef __cplusplus\n")
|
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
for _, ft := range foundTypesList {
|
2024-08-14 06:34:27 +00:00
|
|
|
if ft == "QList" {
|
|
|
|
continue
|
|
|
|
}
|
2024-08-14 05:31:30 +00:00
|
|
|
ret.WriteString(`class ` + ft + ";\n")
|
|
|
|
}
|
2024-08-11 04:37:18 +00:00
|
|
|
|
2024-08-14 05:31:30 +00:00
|
|
|
ret.WriteString("#else\n")
|
|
|
|
|
|
|
|
for _, ft := range foundTypesList {
|
2024-08-14 06:34:27 +00:00
|
|
|
if ft == "QList" {
|
|
|
|
continue
|
|
|
|
}
|
2024-08-14 05:31:30 +00:00
|
|
|
ret.WriteString(`typedef struct ` + ft + " " + ft + ";\n")
|
2024-08-08 07:06:31 +00:00
|
|
|
}
|
|
|
|
|
2024-08-14 05:31:30 +00:00
|
|
|
ret.WriteString("#endif\n")
|
|
|
|
|
2024-08-08 07:06:31 +00:00
|
|
|
ret.WriteString("\n")
|
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for _, c := range src.Classes {
|
2024-08-07 06:51:51 +00:00
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for i, ctor := range c.Ctors {
|
2024-08-14 05:31:10 +00:00
|
|
|
ret.WriteString(fmt.Sprintf("%s %s_new%s(%s);\n", c.ClassName+"*", c.ClassName, maybeSuffix(i), emitParametersCabi(ctor, "")))
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for _, m := range c.Methods {
|
2024-08-14 05:31:10 +00:00
|
|
|
ret.WriteString(fmt.Sprintf("%s %s_%s(%s);\n", emitReturnTypeCabi(m.ReturnType), c.ClassName, m.SafeMethodName(), emitParametersCabi(m, c.ClassName+"*")))
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-09 22:32:57 +00:00
|
|
|
// delete
|
2024-08-14 05:31:10 +00:00
|
|
|
ret.WriteString(fmt.Sprintf("void %s_Delete(%s* self);\n", c.ClassName, c.ClassName))
|
2024-08-09 22:32:57 +00:00
|
|
|
|
2024-08-07 06:51:51 +00:00
|
|
|
ret.WriteString("\n")
|
|
|
|
}
|
|
|
|
|
2024-08-09 06:41:29 +00:00
|
|
|
ret.WriteString(
|
|
|
|
`#ifdef __cplusplus
|
2024-08-07 06:51:51 +00:00
|
|
|
} /* extern C */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
`)
|
|
|
|
return ret.String(), nil
|
|
|
|
}
|
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
func emitBindingCpp(src *CppParsedHeader, filename string) (string, error) {
|
2024-08-07 06:51:51 +00:00
|
|
|
ret := strings.Builder{}
|
|
|
|
|
|
|
|
ret.WriteString(`#include "gen_` + filename + `"
|
|
|
|
#include "` + filename + `"
|
|
|
|
|
|
|
|
`)
|
|
|
|
|
2024-08-14 05:31:30 +00:00
|
|
|
for _, ref := range getReferencedTypes(src) {
|
2024-08-14 06:34:27 +00:00
|
|
|
if ref[0] != 'Q' {
|
|
|
|
continue
|
|
|
|
}
|
2024-08-14 05:31:30 +00:00
|
|
|
ret.WriteString(`#include <` + ref + ">\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
ret.WriteString("\n")
|
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for _, c := range src.Classes {
|
2024-08-07 06:51:51 +00:00
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for i, ctor := range c.Ctors {
|
2024-08-09 22:35:58 +00:00
|
|
|
preamble, forwarding := emitParametersCABI2CppForwarding(ctor.Parameters)
|
2024-08-07 06:51:51 +00:00
|
|
|
ret.WriteString(fmt.Sprintf(
|
2024-08-14 05:31:10 +00:00
|
|
|
"%s* %s_new%s(%s) {\n"+
|
2024-08-08 06:54:13 +00:00
|
|
|
"%s"+
|
|
|
|
"\treturn new %s(%s);\n"+
|
|
|
|
"}\n"+
|
|
|
|
"\n",
|
2024-08-10 00:52:45 +00:00
|
|
|
c.ClassName, c.ClassName, maybeSuffix(i), emitParametersCabi(ctor, ""),
|
2024-08-08 06:54:13 +00:00
|
|
|
preamble,
|
|
|
|
c.ClassName, forwarding,
|
2024-08-07 06:51:51 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2024-08-07 06:56:14 +00:00
|
|
|
for _, m := range c.Methods {
|
2024-08-07 06:51:51 +00:00
|
|
|
// Need to take an extra 'self' parameter
|
|
|
|
|
|
|
|
shouldReturn := "return "
|
2024-08-09 06:41:29 +00:00
|
|
|
afterCall := ""
|
|
|
|
|
2024-08-09 22:35:40 +00:00
|
|
|
if m.ReturnType.ParameterType == "void" && !m.ReturnType.Pointer {
|
2024-08-07 06:51:51 +00:00
|
|
|
shouldReturn = ""
|
2024-08-09 06:41:29 +00:00
|
|
|
|
|
|
|
} else if m.ReturnType.ParameterType == "QString" {
|
|
|
|
shouldReturn = "QString ret = "
|
|
|
|
afterCall = "\t// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory\n"
|
|
|
|
afterCall += "\tQByteArray b = ret.toUtf8();\n"
|
|
|
|
afterCall += "\t*_out = static_cast<char*>(malloc(b.length()));\n"
|
|
|
|
afterCall += "\tmemcpy(*_out, b.data(), b.length());\n"
|
|
|
|
afterCall += "\t*_out_Strlen = b.length();\n"
|
2024-08-09 22:34:54 +00:00
|
|
|
|
2024-08-11 04:37:18 +00:00
|
|
|
} else if t, ok := m.ReturnType.QListOf(); ok {
|
|
|
|
shouldReturn = m.ReturnType.ParameterType + " ret = "
|
|
|
|
afterCall += "\t// Convert QList<> from C++ memory to manually-managed C memory\n"
|
2024-08-14 05:31:49 +00:00
|
|
|
afterCall += "\t*_out = static_cast<" + t.RenderTypeCpp() + ">(malloc(sizeof(" + t.RenderTypeCpp() + ") * ret.length()));\n"
|
2024-08-11 04:37:18 +00:00
|
|
|
afterCall += "\tfor (int i = 0, e = ret.length(); i < e; ++i) {\n"
|
2024-08-14 05:31:49 +00:00
|
|
|
afterCall += "\t\t_out[i] = ret[i];\n"
|
2024-08-11 04:37:18 +00:00
|
|
|
afterCall += "\t}\n"
|
2024-08-14 05:31:49 +00:00
|
|
|
afterCall += "\t*_out_len = ret.length();\n"
|
2024-08-11 04:37:18 +00:00
|
|
|
|
2024-08-09 22:34:54 +00:00
|
|
|
} else if m.ReturnType.QtClassType() && !m.ReturnType.Pointer {
|
|
|
|
shouldReturn = m.ReturnType.ParameterType + " ret = "
|
|
|
|
// afterCall = "\t// Copy-construct value returned type into Go-allocated POCO\n"
|
|
|
|
// afterCall += "\t_*out = ret;\n"
|
|
|
|
afterCall = "\t// Copy-construct value returned type into heap-allocated copy\n"
|
2024-08-14 05:31:10 +00:00
|
|
|
afterCall += "\treturn static_cast<" + m.ReturnType.ParameterType + "*>(new " + m.ReturnType.ParameterType + "(ret));\n"
|
2024-08-09 22:34:54 +00:00
|
|
|
|
2024-08-09 23:46:27 +00:00
|
|
|
} else if m.ReturnType.Const {
|
|
|
|
shouldReturn += "(" + emitReturnTypeCabi(m.ReturnType) + ") "
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-09 22:35:58 +00:00
|
|
|
preamble, forwarding := emitParametersCABI2CppForwarding(m.Parameters)
|
2024-08-08 06:54:13 +00:00
|
|
|
|
2024-08-09 23:45:19 +00:00
|
|
|
nativeMethodName := m.MethodName
|
|
|
|
if m.OverrideMethodName != "" {
|
|
|
|
nativeMethodName = m.OverrideMethodName
|
|
|
|
}
|
|
|
|
|
2024-08-08 06:54:13 +00:00
|
|
|
ret.WriteString(fmt.Sprintf(
|
|
|
|
"%s %s_%s(%s) {\n"+
|
|
|
|
"%s"+
|
2024-08-14 06:34:38 +00:00
|
|
|
"\t%sself->%s(%s);\n"+
|
2024-08-09 06:41:29 +00:00
|
|
|
"%s"+
|
2024-08-08 06:54:13 +00:00
|
|
|
"}\n"+
|
|
|
|
"\n",
|
2024-08-14 05:31:10 +00:00
|
|
|
emitReturnTypeCabi(m.ReturnType), c.ClassName, m.SafeMethodName(), emitParametersCabi(m, c.ClassName+"*"),
|
2024-08-08 06:54:13 +00:00
|
|
|
preamble,
|
2024-08-14 06:34:38 +00:00
|
|
|
shouldReturn, nativeMethodName, forwarding,
|
2024-08-09 06:41:29 +00:00
|
|
|
afterCall,
|
2024-08-07 06:51:51 +00:00
|
|
|
))
|
|
|
|
}
|
2024-08-09 22:32:57 +00:00
|
|
|
|
|
|
|
// Delete
|
|
|
|
ret.WriteString(fmt.Sprintf(
|
2024-08-14 05:31:10 +00:00
|
|
|
"void %s_Delete(%s* self) {\n"+
|
2024-08-14 06:34:38 +00:00
|
|
|
"\tdelete self;\n"+
|
2024-08-09 22:32:57 +00:00
|
|
|
"}\n"+
|
|
|
|
"\n",
|
|
|
|
c.ClassName, c.ClassName,
|
|
|
|
))
|
2024-08-07 06:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret.String(), nil
|
|
|
|
}
|