Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: add const unsigned char #377

Merged
merged 1 commit into from
Nov 5, 2024
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
1 change: 1 addition & 0 deletions cmd/codegen/arguments_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func getArgWrapper(
"const char**": charPtrPtrW,
"const char* const[]": charPtrPtrW,
"unsigned char": simpleW("uint", "C.uchar"),
"const unsigned char": simpleW("uint", "C.uchar"),
"unsigned char*": simplePtrW("uint", "C.uchar"),
"unsigned char**": uCharPtrW,
"size_t": simpleW("uint64", "C.xulong"),
Expand Down
105 changes: 53 additions & 52 deletions cmd/codegen/return_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,59 @@ func getReturnWrapper(
context *Context,
) (returnWrapper, error) {
returnWrapperMap := map[CIdentifier]returnWrapper{
"bool": {"bool", "%s == C.bool(true)", "C.bool"},
"bool*": simplePtrR("bool", "C.bool"),
"const bool*": simplePtrR("bool", "c.bool"),
"char": simpleR("rune", "C.char"),
"unsigned char": simpleR("uint", "C.char"),
"unsigned char*": {"*uint", "(*uint)(unsafe.Pointer(%s))", "C.uchar"}, // NOTE: This should work but I'm not 100% sure
"char*": {"string", "C.GoString(%s)", "*C.char"},
"const char*": {"string", "C.GoString(%s)", "*C.char"},
"const ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar": simpleR("Wchar", "C.ImWchar"),
"ImWchar16": simpleR("uint16", "C.ImWchar16"),
"float": simpleR("float32", "C.float"),
"float*": simplePtrR("float32", "C.float"),
"double": simpleR("float64", "C.double"),
"double*": simplePtrR("float64", "C.double"),
"int": simpleR("int32", "C.int"),
"int32_t": simpleR("int32", "C.int"),
"int*": simplePtrR("int32", "C.int"),
"unsigned int": simpleR("uint32", "C.uint"),
"unsigned int*": simplePtrR("uint32", "C.uint"),
"short": simpleR("int16", "C.short"),
"unsigned short": simpleR("uint16", "C.ushort"),
"unsigned short*": simplePtrR("uint16", "C.ushort"),
"ImS8": simpleR("int", "C.ImS8"),
"ImS16": simpleR("int16", "C.ImS16"),
"ImS16*": simplePtrR("int16", "C.ImS16"),
"ImS32": simpleR("int", "C.ImS32"),
"ImS64": simpleR("int64", "C.ImS64"),
"ImS64*": simplePtrR("int64", "C.ImS64"),
"ImU8": simpleR("byte", "C.ImU8"),
"ImU8*": simplePtrR("byte", "C.ImU8"),
"ImU16": simpleR("uint16", "C.ImU16"),
"ImU16*": simplePtrR("uint16", "C.ImU16"),
"ImU32": simpleR("uint32", "C.ImU32"),
"ImU32*": simplePtrR("uint32", "C.ImU32"),
"const ImU32*": simplePtrR("uint32", "C.ImU32"),
"ImU64": simpleR("uint64", "C.ImU64"),
"ImU64*": simplePtrR("uint64", "C.ImU64"),
"ImVec4": wrappableR(prefixGoPackage("Vec4", "imgui", context), "C.ImVec4"),
"const ImVec4*": imVec4PtrReturnW(context),
"ImVec2": wrappableR(prefixGoPackage("Vec2", "imgui", context), "C.ImVec2"),
"ImColor": wrappableR(prefixGoPackage("Color", "imgui", context), "C.ImColor"),
"ImPlotPoint": wrappableR(prefixGoPackage("PlotPoint", "implot", context), "C.ImPlotPoint"),
"ImRect": wrappableR(prefixGoPackage("Rect", "imgui", context), "C.ImRect"),
"ImPlotTime": wrappableR(prefixGoPackage("PlotTime", "implot", context), "C.ImPlotTime"),
"tm": wrappableR(prefixGoPackage("Tm", "implot", context), "C.tm"),
"const tm": wrappableR(prefixGoPackage("Tm", "implot", context), "C.tm"),
"uintptr_t": simpleR("uintptr", "C.uintptr_t"),
"size_t": simpleR("uint64", "C.size_t"),
"time_t": simpleR("uint64", "C.time_t"),
"void*": simpleR("unsafe.Pointer", "unsafe.Pointer"),
"bool": {"bool", "%s == C.bool(true)", "C.bool"},
"bool*": simplePtrR("bool", "C.bool"),
"const bool*": simplePtrR("bool", "c.bool"),
"char": simpleR("rune", "C.char"),
"unsigned char": simpleR("uint", "C.char"),
"const unsigned char": simpleR("uint", "C.char"),
"unsigned char*": {"*uint", "(*uint)(unsafe.Pointer(%s))", "C.uchar"}, // NOTE: This should work but I'm not 100% sure
"char*": {"string", "C.GoString(%s)", "*C.char"},
"const char*": {"string", "C.GoString(%s)", "*C.char"},
"const ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar": simpleR("Wchar", "C.ImWchar"),
"ImWchar16": simpleR("uint16", "C.ImWchar16"),
"float": simpleR("float32", "C.float"),
"float*": simplePtrR("float32", "C.float"),
"double": simpleR("float64", "C.double"),
"double*": simplePtrR("float64", "C.double"),
"int": simpleR("int32", "C.int"),
"int32_t": simpleR("int32", "C.int"),
"int*": simplePtrR("int32", "C.int"),
"unsigned int": simpleR("uint32", "C.uint"),
"unsigned int*": simplePtrR("uint32", "C.uint"),
"short": simpleR("int16", "C.short"),
"unsigned short": simpleR("uint16", "C.ushort"),
"unsigned short*": simplePtrR("uint16", "C.ushort"),
"ImS8": simpleR("int", "C.ImS8"),
"ImS16": simpleR("int16", "C.ImS16"),
"ImS16*": simplePtrR("int16", "C.ImS16"),
"ImS32": simpleR("int", "C.ImS32"),
"ImS64": simpleR("int64", "C.ImS64"),
"ImS64*": simplePtrR("int64", "C.ImS64"),
"ImU8": simpleR("byte", "C.ImU8"),
"ImU8*": simplePtrR("byte", "C.ImU8"),
"ImU16": simpleR("uint16", "C.ImU16"),
"ImU16*": simplePtrR("uint16", "C.ImU16"),
"ImU32": simpleR("uint32", "C.ImU32"),
"ImU32*": simplePtrR("uint32", "C.ImU32"),
"const ImU32*": simplePtrR("uint32", "C.ImU32"),
"ImU64": simpleR("uint64", "C.ImU64"),
"ImU64*": simplePtrR("uint64", "C.ImU64"),
"ImVec4": wrappableR(prefixGoPackage("Vec4", "imgui", context), "C.ImVec4"),
"const ImVec4*": imVec4PtrReturnW(context),
"ImVec2": wrappableR(prefixGoPackage("Vec2", "imgui", context), "C.ImVec2"),
"ImColor": wrappableR(prefixGoPackage("Color", "imgui", context), "C.ImColor"),
"ImPlotPoint": wrappableR(prefixGoPackage("PlotPoint", "implot", context), "C.ImPlotPoint"),
"ImRect": wrappableR(prefixGoPackage("Rect", "imgui", context), "C.ImRect"),
"ImPlotTime": wrappableR(prefixGoPackage("PlotTime", "implot", context), "C.ImPlotTime"),
"tm": wrappableR(prefixGoPackage("Tm", "implot", context), "C.tm"),
"const tm": wrappableR(prefixGoPackage("Tm", "implot", context), "C.tm"),
"uintptr_t": simpleR("uintptr", "C.uintptr_t"),
"size_t": simpleR("uint64", "C.size_t"),
"time_t": simpleR("uint64", "C.time_t"),
"void*": simpleR("unsafe.Pointer", "unsafe.Pointer"),
}

pureType := TrimPrefix(TrimSuffix(t, "*"), "const ")
Expand Down
15 changes: 15 additions & 0 deletions imgui/cimgui_funcs.go

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

Loading