diff --git a/cmd/codegen/arguments_wrapper.go b/cmd/codegen/arguments_wrapper.go index 32f4ede19..b8f244a5a 100644 --- a/cmd/codegen/arguments_wrapper.go +++ b/cmd/codegen/arguments_wrapper.go @@ -46,6 +46,7 @@ func getArgWrapper( "unsigned char*": simplePtrW("uint", "C.uchar"), "unsigned char**": uCharPtrW, "size_t": simpleW("uint64", "C.xulong"), + "time_t": simpleW("uint64", "C.xulong"), "size_t*": sizeTPtrW, "float": simpleW("float32", "C.float"), "const float": simpleW("float32", "C.float"), @@ -74,6 +75,7 @@ func getArgWrapper( "const ImS16*": simplePtrSliceW("C.ImS16", "int"), "ImS32": simpleW("int", "C.ImS32"), "ImS32*": simplePtrW("int32", "C.ImS32"), + "int32_t": simpleW("int32", "C.int32_t"), "const ImS32*": simplePtrSliceW("C.ImS32", "int32"), "ImS64": simpleW("int64", "C.ImS64"), "ImS64*": simplePtrW("int64", "C.ImS64"), @@ -89,6 +91,7 @@ func getArgWrapper( "bool": simpleW("bool", "C.bool"), "const bool": simpleW("bool", "C.bool"), "bool*": boolPtrW, + "const bool*": boolPtrW, "ImWchar": simpleW(prefixGoPackage("Wchar", "imgui", context), "C.ImWchar"), "ImWchar*": simpleW("("+prefixGoPackage("*Wchar", "imgui", context)+")", "(*C.ImWchar)"), "const ImWchar*": simpleW("("+prefixGoPackage("*Wchar", "imgui", context)+")", "(*C.ImWchar)"), @@ -117,6 +120,10 @@ func getArgWrapper( "const ImPlotTime": wrappableW(prefixGoPackage("PlotTime", "implot", context), "C.ImPlotTime"), "ImPlotTime*": wrappablePtrW(prefixGoPackage("*PlotTime", "implot", context), "C.ImPlotTime"), "const ImPlotTime*": wrappablePtrW(prefixGoPackage("*PlotTime", "implot", context), "C.ImPlotTime"), + "tm": wrappableW(prefixGoPackage("Tm", "implot", context), "C.struct_tm"), + "const tm": wrappableW(prefixGoPackage("Tm", "implot", context), "C.struct_tm"), + "tm*": wrappablePtrW(prefixGoPackage("*Tm", "imgui", context), "C.struct_tm"), + "const tm*": wrappablePtrW(prefixGoPackage("*Tm", "imgui", context), "C.struct_tm"), } if a.Name == "type" || a.Name == "range" { diff --git a/cmd/codegen/return_wrapper.go b/cmd/codegen/return_wrapper.go index e23c5b98f..57cf2094d 100644 --- a/cmd/codegen/return_wrapper.go +++ b/cmd/codegen/return_wrapper.go @@ -20,6 +20,8 @@ func getReturnWrapper( ) (returnWrapper, error) { returnWrapperMap := map[CIdentifier]returnWrapper{ "bool": {"bool", "%s == C.bool(true)"}, + "bool*": simplePtrR("bool"), + "const bool*": simplePtrR("bool"), "char": simpleR("rune"), "unsigned char": simpleR("uint"), "unsigned char*": {"*uint", "(*uint)(unsafe.Pointer(%s))"}, // NOTE: This should work but I'm not 100% sure @@ -34,6 +36,7 @@ func getReturnWrapper( "double": simpleR("float64"), "double*": simplePtrR("float64"), "int": simpleR("int32"), + "int32_t": simpleR("int32"), "int*": simplePtrR("int32"), "unsigned int": simpleR("uint32"), "unsigned int*": simplePtrR("uint32"), @@ -52,6 +55,7 @@ func getReturnWrapper( "ImU16*": simplePtrR("uint16"), "ImU32": simpleR("uint32"), "ImU32*": simplePtrR("uint32"), + "const ImU32*": simplePtrR("uint32"), "ImU64": simpleR("uint64"), "ImU64*": simplePtrR("uint64"), "ImVec4": wrappableR(prefixGoPackage("Vec4", "imgui", context)), @@ -61,8 +65,11 @@ func getReturnWrapper( "ImPlotPoint": wrappableR(prefixGoPackage("PlotPoint", "implot", context)), "ImRect": wrappableR(prefixGoPackage("Rect", "imgui", context)), "ImPlotTime": wrappableR(prefixGoPackage("PlotTime", "implot", context)), + "tm": wrappableR(prefixGoPackage("Tm", "implot", context)), + "const tm": wrappableR(prefixGoPackage("Tm", "implot", context)), "uintptr_t": simpleR("uintptr"), "size_t": simpleR("uint64"), + "time_t": simpleR("uint64"), } pureType := TrimPrefix(TrimSuffix(t, "*"), "const ") @@ -71,7 +78,7 @@ func getReturnWrapper( _, isRefTypedef := context.refTypedefs[pureType] _, shouldSkipRefTypedef := skippedTypedefs[pureType] _, isStruct := context.structNames[pureType] - isStruct = isStruct || (isRefStruct && !shouldSkipRefTypedef) + isStruct = isStruct || ((isRefStruct || (isRefTypedef && !isEnum(pureType, context.refEnumNames))) && !shouldSkipRefTypedef) w, known := returnWrapperMap[t] // check if is array (match regex) isArray, err := regexp.Match(".*\\[\\d+\\]", []byte(t)) @@ -87,7 +94,8 @@ func getReturnWrapper( switch { case known: return w, nil - case (context.structNames[t] || context.refStructNames[t]) && !shouldSkipStruct(t): + // case (context.structNames[t] || context.refStructNames[t]) && !shouldSkipStruct(t): + case !HasSuffix(t, "*") && isStruct && !shouldSkipStruct(pureType): return returnWrapper{ returnType: prefixGoPackage(t.renameGoIdentifier(), srcPackage, context), // this is a small trick as using prefixGoPackage isn't in fact intended to be used in such a way, but it should treat the whole string as a "type" and prefix it correctly diff --git a/imgui/cimgui_funcs.go b/imgui/cimgui_funcs.go index a0cd3e41b..a454e87cc 100644 --- a/imgui/cimgui_funcs.go +++ b/imgui/cimgui_funcs.go @@ -2711,6 +2711,19 @@ func (self *Storage) BoolV(key ID, default_val bool) bool { return C.ImGuiStorage_GetBool(datautils.ConvertCTypes[*C.ImGuiStorage](selfArg), datautils.ConvertCTypes[C.ImGuiID](keyArg), C.bool(default_val)) == C.bool(true) } +// BoolRefV parameter default value hint: +// default_val: false +func (self *Storage) BoolRefV(key ID, default_val bool) *bool { + selfArg, selfFin := self.Handle() + keyArg, keyFin := key.C() + + defer func() { + selfFin() + keyFin() + }() + return (*bool)(C.ImGuiStorage_GetBoolRef(datautils.ConvertCTypes[*C.ImGuiStorage](selfArg), datautils.ConvertCTypes[C.ImGuiID](keyArg), C.bool(default_val))) +} + // FloatV parameter default value hint: // default_val: 0.0f func (self *Storage) FloatV(key ID, default_val float32) float32 { @@ -11717,6 +11730,17 @@ func (self *Storage) Bool(key ID) bool { return C.wrap_ImGuiStorage_GetBool(datautils.ConvertCTypes[*C.ImGuiStorage](selfArg), datautils.ConvertCTypes[C.ImGuiID](keyArg)) == C.bool(true) } +func (self *Storage) BoolRef(key ID) *bool { + selfArg, selfFin := self.Handle() + keyArg, keyFin := key.C() + + defer func() { + selfFin() + keyFin() + }() + return (*bool)(C.wrap_ImGuiStorage_GetBoolRef(datautils.ConvertCTypes[*C.ImGuiStorage](selfArg), datautils.ConvertCTypes[C.ImGuiID](keyArg))) +} + func (self *Storage) Float(key ID) float32 { selfArg, selfFin := self.Handle() keyArg, keyFin := key.C() diff --git a/immarkdown/cimmarkdown_funcs.go b/immarkdown/cimmarkdown_funcs.go index f98094448..f235bdb6a 100644 --- a/immarkdown/cimmarkdown_funcs.go +++ b/immarkdown/cimmarkdown_funcs.go @@ -515,6 +515,21 @@ func (self *MarkdownFormatInfo) Type() MarkdownFormatType { return MarkdownFormatType(C.wrap_MarkdownFormatInfo_GetType(datautils.ConvertCTypes[*C.MarkdownFormatInfo](selfArg))) } +func (self MarkdownFormatInfo) SetLevel(v int32) { + selfArg, selfFin := self.Handle() + defer selfFin() + C.wrap_MarkdownFormatInfo_SetLevel(selfArg, C.int32_t(v)) +} + +func (self *MarkdownFormatInfo) Level() int32 { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return int32(C.wrap_MarkdownFormatInfo_GetLevel(datautils.ConvertCTypes[*C.MarkdownFormatInfo](selfArg))) +} + func (self MarkdownFormatInfo) SetItemHovered(v bool) { selfArg, selfFin := self.Handle() defer selfFin() @@ -617,6 +632,18 @@ func (self MarkdownImageData) SetUsertextureid(v imgui.TextureID) { C.wrap_MarkdownImageData_SetUser_texture_id(selfArg, datautils.ConvertCTypes[C.ImTextureID](vArg)) } +func (self *MarkdownImageData) Usertextureid() imgui.TextureID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewTextureIDFromC(func() *C.ImTextureID { + result := C.wrap_MarkdownImageData_GetUser_texture_id(datautils.ConvertCTypes[*C.MarkdownImageData](selfArg)) + return &result + }()) +} + func (self MarkdownImageData) SetSize(v imgui.Vec2) { selfArg, selfFin := self.Handle() defer selfFin() diff --git a/imnodes/cimnodes_funcs.go b/imnodes/cimnodes_funcs.go index 157d1738c..369ee4f79 100644 --- a/imnodes/cimnodes_funcs.go +++ b/imnodes/cimnodes_funcs.go @@ -631,6 +631,23 @@ func ImNodesStyleColorsLight() { C.wrap_imnodes_StyleColorsLight() } +func (self EmulateThreeButtonMouse) SetModifier(v *bool) { + vArg, _ := datautils.WrapBool[C.bool](v) + + selfArg, selfFin := self.Handle() + defer selfFin() + C.wrap_EmulateThreeButtonMouse_SetModifier(selfArg, vArg) +} + +func (self *EmulateThreeButtonMouse) Modifier() *bool { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return (*bool)(C.wrap_EmulateThreeButtonMouse_GetModifier(datautils.ConvertCTypes[*C.EmulateThreeButtonMouse](selfArg))) +} + func (self NodesIO) SetEmulateThreeButtonMouse(v EmulateThreeButtonMouse) { vArg, _ := v.C() @@ -1001,3 +1018,37 @@ func (self *NodesStyle) Colors() [29]uint32 { return result }() } + +func (self LinkDetachWithModifierClick) SetModifier(v *bool) { + vArg, _ := datautils.WrapBool[C.bool](v) + + selfArg, selfFin := self.Handle() + defer selfFin() + C.wrap_LinkDetachWithModifierClick_SetModifier(selfArg, vArg) +} + +func (self *LinkDetachWithModifierClick) Modifier() *bool { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return (*bool)(C.wrap_LinkDetachWithModifierClick_GetModifier(datautils.ConvertCTypes[*C.LinkDetachWithModifierClick](selfArg))) +} + +func (self MultipleSelectModifier) SetModifier(v *bool) { + vArg, _ := datautils.WrapBool[C.bool](v) + + selfArg, selfFin := self.Handle() + defer selfFin() + C.wrap_MultipleSelectModifier_SetModifier(selfArg, vArg) +} + +func (self *MultipleSelectModifier) Modifier() *bool { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return (*bool)(C.wrap_MultipleSelectModifier_GetModifier(datautils.ConvertCTypes[*C.MultipleSelectModifier](selfArg))) +} diff --git a/implot/cimplot_funcs.go b/implot/cimplot_funcs.go index a20c0e5eb..35bd90aac 100644 --- a/implot/cimplot_funcs.go +++ b/implot/cimplot_funcs.go @@ -478,6 +478,15 @@ func (self *PlotColormapData) KeyCount(cmap PlotColormap) int32 { return int32(C.ImPlotColormapData_GetKeyCount(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg), C.ImPlotColormap(cmap))) } +func (self *PlotColormapData) Keys(cmap PlotColormap) *uint32 { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return (*uint32)(C.ImPlotColormapData_GetKeys(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg), C.ImPlotColormap(cmap))) +} + func (self *PlotColormapData) Name(cmap PlotColormap) string { selfArg, selfFin := self.Handle() @@ -487,6 +496,15 @@ func (self *PlotColormapData) Name(cmap PlotColormap) string { return C.GoString(C.ImPlotColormapData_GetName(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg), C.ImPlotColormap(cmap))) } +func (self *PlotColormapData) Table(cmap PlotColormap) *uint32 { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return (*uint32)(C.ImPlotColormapData_GetTable(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg), C.ImPlotColormap(cmap))) +} + func (self *PlotColormapData) TableColor(cmap PlotColormap, idx int32) uint32 { selfArg, selfFin := self.Handle() @@ -602,6 +620,20 @@ func (self *PlotItemGroup) ItemCount() int32 { return int32(C.ImPlotItemGroup_GetItemCount(datautils.ConvertCTypes[*C.ImPlotItemGroup](selfArg))) } +func (self *PlotItemGroup) ItemID(label_id string) imgui.ID { + selfArg, selfFin := self.Handle() + label_idArg, label_idFin := datautils.WrapString[C.char](label_id) + + defer func() { + selfFin() + label_idFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.ImPlotItemGroup_GetItemID(datautils.ConvertCTypes[*C.ImPlotItemGroup](selfArg), label_idArg) + return &result + }()) +} + func (self *PlotItemGroup) ItemIndex(item *PlotItem) int32 { selfArg, selfFin := self.Handle() itemArg, itemFin := item.Handle() @@ -13719,6 +13751,18 @@ func (self PlotAxis) SetID(v imgui.ID) { C.wrap_ImPlotAxis_SetID(selfArg, datautils.ConvertCTypes[C.ImGuiID](vArg)) } +func (self *PlotAxis) ID() imgui.ID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.wrap_ImPlotAxis_GetID(datautils.ConvertCTypes[*C.ImPlotAxis](selfArg)) + return &result + }()) +} + func (self PlotAxis) SetFlags(v PlotAxisFlags) { selfArg, selfFin := self.Handle() defer selfFin() @@ -14607,6 +14651,15 @@ func (self PlotColormapData) SetQuals(v datautils.Vector[*bool]) { C.wrap_ImPlotColormapData_SetQuals(selfArg, *vVecArg) } +func (self *PlotColormapData) Quals() datautils.Vector[*bool] { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return datautils.NewVectorFromC(C.wrap_ImPlotColormapData_GetQuals(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg)).Size, C.wrap_ImPlotColormapData_GetQuals(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg)).Capacity, (*bool)(C.wrap_ImPlotColormapData_GetQuals(datautils.ConvertCTypes[*C.ImPlotColormapData](selfArg)).Data)) +} + func (self PlotColormapData) SetMap(v imgui.Storage) { vArg, _ := v.C() @@ -14882,6 +14935,24 @@ func (self *PlotContext) ColormapModifiers() datautils.Vector[*PlotColormap] { return datautils.NewVectorFromC(C.wrap_ImPlotContext_GetColormapModifiers(datautils.ConvertCTypes[*C.ImPlotContext](selfArg)).Size, C.wrap_ImPlotContext_GetColormapModifiers(datautils.ConvertCTypes[*C.ImPlotContext](selfArg)).Capacity, (*PlotColormap)(C.wrap_ImPlotContext_GetColormapModifiers(datautils.ConvertCTypes[*C.ImPlotContext](selfArg)).Data)) } +func (self PlotContext) SetTm(v Tm) { + selfArg, selfFin := self.Handle() + defer selfFin() + C.wrap_ImPlotContext_SetTm(selfArg, datautils.ConvertCTypes[C.struct_tm](v.ToC())) +} + +func (self *PlotContext) Tm() Tm { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return func() Tm { + out := C.wrap_ImPlotContext_GetTm(datautils.ConvertCTypes[*C.ImPlotContext](selfArg)) + return *(&Tm{}).FromC(unsafe.Pointer(&out)) + }() +} + func (self PlotContext) SetTempDouble1(v datautils.Vector[*float64]) { vData := v.Data vDataArg, _ := datautils.WrapNumberPtr[C.double, float64](vData) @@ -15375,6 +15446,18 @@ func (self PlotItem) SetID(v imgui.ID) { C.wrap_ImPlotItem_SetID(selfArg, datautils.ConvertCTypes[C.ImGuiID](vArg)) } +func (self *PlotItem) ID() imgui.ID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.wrap_ImPlotItem_GetID(datautils.ConvertCTypes[*C.ImPlotItem](selfArg)) + return &result + }()) +} + func (self PlotItem) SetColor(v uint32) { selfArg, selfFin := self.Handle() defer selfFin() @@ -15476,6 +15559,18 @@ func (self PlotItemGroup) SetID(v imgui.ID) { C.wrap_ImPlotItemGroup_SetID(selfArg, datautils.ConvertCTypes[C.ImGuiID](vArg)) } +func (self *PlotItemGroup) ID() imgui.ID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.wrap_ImPlotItemGroup_GetID(datautils.ConvertCTypes[*C.ImPlotItemGroup](selfArg)) + return &result + }()) +} + func (self PlotItemGroup) SetLegend(v PlotLegend) { vArg, _ := v.C() @@ -16191,6 +16286,18 @@ func (self PlotPlot) SetID(v imgui.ID) { C.wrap_ImPlotPlot_SetID(selfArg, datautils.ConvertCTypes[C.ImGuiID](vArg)) } +func (self *PlotPlot) ID() imgui.ID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.wrap_ImPlotPlot_GetID(datautils.ConvertCTypes[*C.ImPlotPlot](selfArg)) + return &result + }()) +} + func (self PlotPlot) SetFlags(v PlotFlags) { selfArg, selfFin := self.Handle() defer selfFin() @@ -17298,6 +17405,18 @@ func (self PlotSubplot) SetID(v imgui.ID) { C.wrap_ImPlotSubplot_SetID(selfArg, datautils.ConvertCTypes[C.ImGuiID](vArg)) } +func (self *PlotSubplot) ID() imgui.ID { + selfArg, selfFin := self.Handle() + + defer func() { + selfFin() + }() + return *imgui.NewIDFromC(func() *C.ImGuiID { + result := C.wrap_ImPlotSubplot_GetID(datautils.ConvertCTypes[*C.ImPlotSubplot](selfArg)) + return &result + }()) +} + func (self PlotSubplot) SetFlags(v PlotSubplotFlags) { selfArg, selfFin := self.Handle() defer selfFin() @@ -17997,6 +18116,15 @@ func (self *PlotTicker) Levels() int32 { return int32(C.wrap_ImPlotTicker_GetLevels(datautils.ConvertCTypes[*C.ImPlotTicker](selfArg))) } +func (self *PlotTime) S() uint64 { + selfArg, selfFin := datautils.Wrap(self) + + defer func() { + selfFin() + }() + return uint64(C.wrap_ImPlotTime_GetS(datautils.ConvertCTypes[*C.ImPlotTime](selfArg))) +} + func (self *PlotTime) Us() int32 { selfArg, selfFin := datautils.Wrap(self) diff --git a/implot/extra_types.go b/implot/extra_types.go index 16842b3c0..dd66b8ccc 100644 --- a/implot/extra_types.go +++ b/implot/extra_types.go @@ -34,20 +34,20 @@ func (p PlotPoint) ToC() C.ImPlotPoint { } type PlotTime struct { - S int // second part + Seconds int // second part FieldUs int // microsecond part } func NewPlotTime(t time.Time) PlotTime { ts := t.UnixMicro() return PlotTime{ - S: int(ts / 1e6), + Seconds: int(ts / 1e6), FieldUs: int(ts % 1e6), } } func (i PlotTime) Time() time.Time { - return time.Unix(int64(i.S), int64(i.FieldUs)*int64(time.Microsecond)) + return time.Unix(int64(i.Seconds), int64(i.FieldUs)*int64(time.Microsecond)) } // pAny is ~C.ImPlotTime and will be free converted! @@ -58,5 +58,55 @@ func (i *PlotTime) FromC(pAny unsafe.Pointer) *PlotTime { } func (p PlotTime) ToC() C.ImPlotTime { - return C.ImPlotTime{S: C.xlong(p.S), Us: C.int(p.FieldUs)} + return C.ImPlotTime{S: C.xlong(p.Seconds), Us: C.int(p.FieldUs)} +} + +var _ datautils.WrappableType[C.struct_tm, *Tm] = &Tm{} + +// Tm is an implemenation of tm C type +// ref: https://en.cppreference.com/w/c/chrono/tm +type Tm struct { + Seconds int32 + Minutes int32 + Hours int32 + MDay int32 + Month int32 + Year int32 + WDay int32 + YDay int32 + IsDST int32 +} + +func NewTm(S, M, H, MD, MO, Y, WD, YD, DST int32) Tm { + return Tm{ + Seconds: S, + Minutes: M, + Hours: H, + MDay: MD, + Month: MO, + Year: Y, + WDay: WD, + YDay: YD, + IsDST: DST, + } +} + +func (i Tm) ToC() C.struct_tm { + return C.struct_tm{ + tm_sec: C.int(i.Seconds), + tm_min: C.int(i.Minutes), + tm_hour: C.int(i.Hours), + tm_mday: C.int(i.MDay), + tm_mon: C.int(i.Month), + tm_year: C.int(i.Year), + tm_wday: C.int(i.WDay), + tm_yday: C.int(i.YDay), + tm_isdst: C.int(i.IsDST), + } +} + +func (i *Tm) FromC(pAny unsafe.Pointer) *Tm { + p := *(*C.struct_tm)(pAny) + *i = NewTm(int32(p.tm_sec), int32(p.tm_min), int32(p.tm_hour), int32(p.tm_mday), int32(p.tm_mon), int32(p.tm_year), int32(p.tm_wday), int32(p.tm_yday), int32(p.tm_isdst)) + return i }