From 7b7ae9d7ce2aa6f99677fde7b8a0c21c7024e3e9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 13:43:05 -0400 Subject: [PATCH] More control migration. Everything beyond this point is nontrivial. --- .../multilineentry.go => multilineentry.go | 11 ++++------ pkgui.c | 20 +++++++++++++++++++ pkgui.h | 12 +++++++++++ .../radiobuttons.go => radiobuttons.go | 11 ++++------ BBB_GOFILES/separator.go => separator.go | 2 +- BBB_GOFILES/slider.go => slider.go | 11 ++++------ BBB_GOFILES/spinbox.go => spinbox.go | 11 ++++------ BBB_GOFILES/tab.go => tab.go | 2 +- 8 files changed, 50 insertions(+), 30 deletions(-) rename BBB_GOFILES/multilineentry.go => multilineentry.go (85%) rename BBB_GOFILES/radiobuttons.go => radiobuttons.go (78%) rename BBB_GOFILES/separator.go => separator.go (96%) rename BBB_GOFILES/slider.go => slider.go (78%) rename BBB_GOFILES/spinbox.go => spinbox.go (77%) rename BBB_GOFILES/tab.go => tab.go (98%) diff --git a/BBB_GOFILES/multilineentry.go b/multilineentry.go similarity index 85% rename from BBB_GOFILES/multilineentry.go rename to multilineentry.go index 88a75c4..34ba637 100644 --- a/BBB_GOFILES/multilineentry.go +++ b/multilineentry.go @@ -10,10 +10,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doMultilineEntryOnChanged(uiMultilineEntry *, void *); -// // see golang/go#19835 -// typedef void (*multilineEntryCallback)(uiMultilineEntry *, void *); +// #include "pkgui.h" import "C" // MultilineEntry is a Control that represents a space that the user @@ -29,7 +26,7 @@ func finishNewMultilineEntry(ee *C.uiMultilineEntry) *MultilineEntry { m.e = ee - C.uiMultilineEntryOnChanged(m.e, C.multilineEntryCallback(C.doMultilineEntryOnChanged), nil) + C.pkguiMultilineEntryOnChanged(m.e) m.ControlBase = NewControlBase(m, uintptr(unsafe.Pointer(m.e))) return m @@ -78,8 +75,8 @@ func (m *MultilineEntry) OnChanged(f func(*MultilineEntry)) { m.onChanged = f } -//export doMultilineEntryOnChanged -func doMultilineEntryOnChanged(ee *C.uiMultilineEntry, data unsafe.Pointer) { +//export pkguiDoMultilineEntryOnChanged +func pkguiDoMultilineEntryOnChanged(ee *C.uiMultilineEntry, data unsafe.Pointer) { m := ControlFromLibui(uintptr(unsafe.Pointer(ee))).(*MultilineEntry) if m.onChanged != nil { m.onChanged(m) diff --git a/pkgui.c b/pkgui.c index 643f50e..cdc2a3f 100644 --- a/pkgui.c +++ b/pkgui.c @@ -51,3 +51,23 @@ void pkguiEntryOnChanged(uiEntry *e) { uiEntryOnChanged(e, pkguiDoEntryOnChanged, NULL); } + +void pkguiMultilineEntryOnChanged(uiMultilineEntry *e) +{ + uiMultilineEntryOnChanged(e, pkguiDoMultilineEntryOnChanged, NULL); +} + +void pkguiRadioButtonsOnSelected(uiRadioButtons *r) +{ + uiRadioButtonsOnSelected(r, pkguiDoRadioButtonsOnSelected, NULL); +} + +void pkguiSliderOnChanged(uiSlider *s) +{ + uiSliderOnChanged(s, pkguiDoSliderOnChanged, NULL); +} + +void pkguiSpinboxOnChanged(uiSpinbox *s) +{ + uiSpinboxOnChanged(s, pkguiDoSpinboxOnChanged, NULL); +} diff --git a/pkgui.h b/pkgui.h index eefea53..418f781 100644 --- a/pkgui.h +++ b/pkgui.h @@ -29,4 +29,16 @@ extern void pkguiEditableComboboxOnChanged(uiEditableCombobox *c); // entry.go extern void pkguiEntryOnChanged(uiEntry *e); +// multilineentry.go +extern void pkguiMultilineEntryOnChanged(uiMultilineEntry *e); + +// radiobuttons.go +extern void pkguiRadioButtonsOnSelected(uiRadioButtons *r); + +// slider.go +extern void pkguiSliderOnChanged(uiSlider *s); + +// spinbox.go +extern void pkguiSpinboxOnChanged(uiSpinbox *s); + #endif diff --git a/BBB_GOFILES/radiobuttons.go b/radiobuttons.go similarity index 78% rename from BBB_GOFILES/radiobuttons.go rename to radiobuttons.go index 2413544..7f39933 100644 --- a/BBB_GOFILES/radiobuttons.go +++ b/radiobuttons.go @@ -6,10 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doRadioButtonsOnSelected(uiRadioButtons *, void *); -// // see golang/go#19835 -// typedef void (*radioButtonsCallback)(uiRadioButtons *, void *); +// #include "pkgui.h" import "C" // RadioButtons is a Control that represents a set of checkable @@ -26,7 +23,7 @@ func NewRadioButtons() *RadioButtons { r.r = C.uiNewRadioButtons() - C.uiRadioButtonsOnSelected(r.r, C.radioButtonsCallback(C.doRadioButtonsOnSelected), nil) + C.pkguiRadioButtonsOnSelected(r.r) r.ControlBase = NewControlBase(r, uintptr(unsafe.Pointer(r.r))) return r @@ -57,8 +54,8 @@ func (r *RadioButtons) OnSelected(f func(*RadioButtons)) { r.onSelected = f } -//export doRadioButtonsOnSelected -func doRadioButtonsOnSelected(rr *C.uiRadioButtons, data unsafe.Pointer) { +//export pkguiDoRadioButtonsOnSelected +func pkguiDoRadioButtonsOnSelected(rr *C.uiRadioButtons, data unsafe.Pointer) { r := ControlFromLibui(uintptr(unsafe.Pointer(rr))).(*RadioButtons) if r.onSelected != nil { r.onSelected(r) diff --git a/BBB_GOFILES/separator.go b/separator.go similarity index 96% rename from BBB_GOFILES/separator.go rename to separator.go index 67dea4f..f1a1249 100644 --- a/BBB_GOFILES/separator.go +++ b/separator.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Separator is a Control that represents a horizontal line that diff --git a/BBB_GOFILES/slider.go b/slider.go similarity index 78% rename from BBB_GOFILES/slider.go rename to slider.go index 91656cf..19bc31b 100644 --- a/BBB_GOFILES/slider.go +++ b/slider.go @@ -6,10 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doSliderOnChanged(uiSlider *, void *); -// // see golang/go#19835 -// typedef void (*sliderCallback)(uiSlider *, void *); +// #include "pkgui.h" import "C" // Slider is a Control that represents a horizontal bar that represents @@ -27,7 +24,7 @@ func NewSlider(min int, max int) *Slider { s.s = C.uiNewSlider(C.int(min), C.int(max)) - C.uiSliderOnChanged(s.s, C.sliderCallback(C.doSliderOnChanged), nil) + C.pkguiSliderOnChanged(s.s) s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s))) return s @@ -49,8 +46,8 @@ func (s *Slider) OnChanged(f func(*Slider)) { s.onChanged = f } -//export doSliderOnChanged -func doSliderOnChanged(ss *C.uiSlider, data unsafe.Pointer) { +//export pkguiDoSliderOnChanged +func pkguiDoSliderOnChanged(ss *C.uiSlider, data unsafe.Pointer) { s := ControlFromLibui(uintptr(unsafe.Pointer(ss))).(*Slider) if s.onChanged != nil { s.onChanged(s) diff --git a/BBB_GOFILES/spinbox.go b/spinbox.go similarity index 77% rename from BBB_GOFILES/spinbox.go rename to spinbox.go index 27dd287..a7161f3 100644 --- a/BBB_GOFILES/spinbox.go +++ b/spinbox.go @@ -6,10 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" -// extern void doSpinboxOnChanged(uiSpinbox *, void *); -// // see golang/go#19835 -// typedef void (*spinboxCallback)(uiSpinbox *, void *); +// #include "pkgui.h" import "C" // Spinbox is a Control that represents a space where the user can @@ -27,7 +24,7 @@ func NewSpinbox(min int, max int) *Spinbox { s.s = C.uiNewSpinbox(C.int(min), C.int(max)) - C.uiSpinboxOnChanged(s.s, C.spinboxCallback(C.doSpinboxOnChanged), nil) + C.pkguiSpinboxOnChanged(s.s) s.ControlBase = NewControlBase(s, uintptr(unsafe.Pointer(s.s))) return s @@ -49,8 +46,8 @@ func (s *Spinbox) OnChanged(f func(*Spinbox)) { s.onChanged = f } -//export doSpinboxOnChanged -func doSpinboxOnChanged(ss *C.uiSpinbox, data unsafe.Pointer) { +//export pkguiDoSpinboxOnChanged +func pkguiDoSpinboxOnChanged(ss *C.uiSpinbox, data unsafe.Pointer) { s := ControlFromLibui(uintptr(unsafe.Pointer(ss))).(*Spinbox) if s.onChanged != nil { s.onChanged(s) diff --git a/BBB_GOFILES/tab.go b/tab.go similarity index 98% rename from BBB_GOFILES/tab.go rename to tab.go index 0b0b0b9..d744769 100644 --- a/BBB_GOFILES/tab.go +++ b/tab.go @@ -6,7 +6,7 @@ import ( "unsafe" ) -// #include "ui.h" +// #include "pkgui.h" import "C" // Tab is a Control that holds tabbed pages of Controls. Each tab