Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions cimgui_enums.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimgui_funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimgui_structs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimgui_structs_accessor.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!


#include "cimgui_wrapper.h"
#include "cimgui_structs_accessor.h"
Expand Down
2 changes: 2 additions & 0 deletions cimgui_structs_accessor.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#pragma once

#include "cimgui_wrapper.h"
Expand Down
2 changes: 2 additions & 0 deletions cimgui_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#include "cimgui_wrapper.h"
#include "cimgui/cimgui.h"

Expand Down
2 changes: 2 additions & 0 deletions cimgui_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#pragma once

#include "cimgui/cimgui.h"
Expand Down
2 changes: 2 additions & 0 deletions cimplot_enums.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimplot_funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimplot_structs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cimplot_structs_accessor.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!


#include "cimplot_wrapper.h"
#include "cimplot_structs_accessor.h"
Expand Down
2 changes: 2 additions & 0 deletions cimplot_structs_accessor.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#pragma once

#include "cimplot_wrapper.h"
Expand Down
2 changes: 2 additions & 0 deletions cimplot_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#include "cimplot_wrapper.h"
#include "cimplot/cimplot.h"

Expand Down
2 changes: 2 additions & 0 deletions cimplot_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!

#pragma once

#include "cimplot/cimplot.h"
Expand Down
8 changes: 6 additions & 2 deletions cmd/codegen/gencpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func generateCppWrapper(prefix, includePath string, funcDefs []FuncDef) []FuncDe

// Generate header
var headerSb strings.Builder
headerSb.WriteString(cppFileHeader)
headerSb.WriteString(fmt.Sprintf(`#pragma once

#include "%s"
Expand All @@ -26,6 +27,7 @@ extern "C" {
`, includePath))

var cppSb strings.Builder
cppSb.WriteString(cppFileHeader)
cppSb.WriteString(fmt.Sprintf(`#include "%s_wrapper.h"
#include "%s"

Expand Down Expand Up @@ -357,8 +359,10 @@ func generateCppStructsAccessor(prefix string, validFuncs []FuncDef, structs []S
skipFuncNames = append(skipFuncNames, f.FuncName)
}

var sbHeader strings.Builder
var sbCpp strings.Builder
var sbHeader, sbCpp strings.Builder

sbHeader.WriteString(cppFileHeader)
sbCpp.WriteString(cppFileHeader)

sbHeader.WriteString(fmt.Sprintf(`#pragma once

Expand Down
13 changes: 7 additions & 6 deletions cmd/codegen/gengo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var structMemberTypeMap = map[string]*TypeMap{
func generateGoEnums(prefix string, enums []EnumDef) []string {
var sb strings.Builder

sb.WriteString("package cimgui\n\n")
sb.WriteString(goPackageHeader)

var enumNames []string
for _, e := range enums {
Expand Down Expand Up @@ -63,9 +63,9 @@ func generateGoEnums(prefix string, enums []EnumDef) []string {
func generateGoStructs(prefix string, structs []StructDef) []string {
var sb strings.Builder

sb.WriteString(fmt.Sprintf(`package cimgui

// #include "%s_wrapper.h"
sb.WriteString(goPackageHeader)
sb.WriteString(fmt.Sprintf(
`// #include "%s_wrapper.h"
import "C"
import "unsafe"

Expand Down Expand Up @@ -113,9 +113,10 @@ func generateGoFuncs(prefix string, validFuncs []FuncDef, enumNames []string, st
var sb strings.Builder
convertedFuncCount := 0

sb.WriteString(fmt.Sprintf(`package cimgui
sb.WriteString(goPackageHeader)

// #include "extra_types.h"
sb.WriteString(fmt.Sprintf(
`// #include "extra_types.h"
// #include "%[1]s_structs_accessor.h"
// #include "%[1]s_wrapper.h"
import "C"
Expand Down
6 changes: 6 additions & 0 deletions cmd/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"github.com/thoas/go-funk"
)

const (
generatorInfo = "// Code generated by cmd/codegen of https://github.com/AllenDang/cimgui-go DO NOT EDIT!\n\n"
goPackageHeader = generatorInfo + "package cimgui\n\n"
cppFileHeader = generatorInfo
)

type ArgDef struct {
Name string `json:"name"`
Type string `json:"type"`
Expand Down