diff --git a/cmd/codegen/arguments_wrapper.go b/cmd/codegen/arguments_wrapper.go index c7d801f8..1f6d2383 100644 --- a/cmd/codegen/arguments_wrapper.go +++ b/cmd/codegen/arguments_wrapper.go @@ -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"), diff --git a/cmd/codegen/return_wrapper.go b/cmd/codegen/return_wrapper.go index 5896eca7..41c944c5 100644 --- a/cmd/codegen/return_wrapper.go +++ b/cmd/codegen/return_wrapper.go @@ -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 ") diff --git a/imgui/cimgui_funcs.go b/imgui/cimgui_funcs.go index 3d4f3a3a..261f4ff0 100644 --- a/imgui/cimgui_funcs.go +++ b/imgui/cimgui_funcs.go @@ -6928,6 +6928,21 @@ func InternalImFontAtlasBuildMultiplyCalcLookupTable(out_table *[256]uint, in_mu } } +func InternalImFontAtlasBuildMultiplyRectAlpha8(table *[256]uint, pixels *uint, x int32, y int32, w int32, h int32, stride int32) { + tableArg := make([]C.uchar, len(table)) + for i, tableV := range table { + tableArg[i] = C.uchar(tableV) + } + pixelsArg, pixelsFin := internal.WrapNumberPtr[C.uchar, uint](pixels) + C.igImFontAtlasBuildMultiplyRectAlpha8((*C.uchar)(&tableArg[0]), pixelsArg, C.int(x), C.int(y), C.int(w), C.int(h), C.int(stride)) + + for i, tableV := range tableArg { + (*table)[i] = uint(tableV) + } + + pixelsFin() +} + func InternalImFontAtlasBuildPackCustomRects(atlas *FontAtlas, stbrp_context_opaque uintptr) { atlasArg, atlasFin := atlas.Handle() C.wrap_igImFontAtlasBuildPackCustomRects(internal.ReinterpretCast[*C.ImFontAtlas](atlasArg), C.uintptr_t(stbrp_context_opaque))