From bfb37ba6c9ec38da75f874150a496ebfa7668c25 Mon Sep 17 00:00:00 2001 From: davu Date: Sat, 18 Nov 2023 14:34:54 +0100 Subject: [PATCH] Fixing mutable strings parameters --- META6.json | 2 +- README.md | 9 +++++++++ lib/Raygui/Actions.rakumod | 4 ++++ lib/Raygui/Bindings.rakumod | 6 +++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/META6.json b/META6.json index 4c64fc7..91be58d 100644 --- a/META6.json +++ b/META6.json @@ -35,7 +35,7 @@ "libraries/raygui" ], "test-depends": [], - "version": "0.0.5", + "version": "0.0.6", "source-url": "https://github.com/vushu/raygui-raku.git", "builder": "Distribution::Builder::MakeFromJSON", "build": { diff --git a/README.md b/README.md index 595cf70..62a610f 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,15 @@ zef install . raku examples/portable-window.raku ``` +### Mutable strings +Some functions in raygui requires a mutable string so we can't parse a normal Raku `Str` since they are immutable. +Please parse a `CArray[uint8]` for these cases, it's important to encode it as `utf-8`. +Example: +``` +my $text = CArray[uint8].new("Foo".encode('utf-8')); +gui-text-box($message-box-rect, $text, 3, True) +``` + #### More info https://github.com/raysan5/raygui diff --git a/lib/Raygui/Actions.rakumod b/lib/Raygui/Actions.rakumod index 178576b..1683561 100644 --- a/lib/Raygui/Actions.rakumod +++ b/lib/Raygui/Actions.rakumod @@ -400,6 +400,10 @@ class Actions { make "int32 \$$ is rw, {$.map: *.made.join(',')}"; } + multi method parameters($/ where $ && $ eq 'char' && !$) { + make "CArray[uint8] \$$, {$.map: *.made.join(',')}"; + } + multi method parameters($/) { if (!$) { make ''; diff --git a/lib/Raygui/Bindings.rakumod b/lib/Raygui/Bindings.rakumod index 4d00d59..d6fde4b 100644 --- a/lib/Raygui/Bindings.rakumod +++ b/lib/Raygui/Bindings.rakumod @@ -1,5 +1,5 @@ # This Raku module is generated from raygui.h -unit module Raygui::Bindings:ver<0.0.5>:auth; +unit module Raygui::Bindings:ver<0.0.6>:auth; use Raylib::Bindings; use NativeCall; constant LIBRAYGUI = %?RESOURCES; @@ -426,7 +426,7 @@ our sub gui-combo-box (Rectangle $bounds, Str $text, int32 $active is rw, ) retu our sub gui-dropdown-box (Rectangle $bounds, Str $text, int32 $active is rw, bool $editMode) returns int32 is export is native(LIBRAYGUI) is symbol('GuiDropdownBox_pointerized'){ * } our sub gui-spinner (Rectangle $bounds, Str $text, int32 $value is rw, int32 $minValue, int32 $maxValue, bool $editMode) returns int32 is export is native(LIBRAYGUI) is symbol('GuiSpinner_pointerized'){ * } our sub gui-value-box (Rectangle $bounds, Str $text, int32 $value is rw, int32 $minValue, int32 $maxValue, bool $editMode) returns int32 is export is native(LIBRAYGUI) is symbol('GuiValueBox_pointerized'){ * } -our sub gui-text-box (Rectangle $bounds, Str $text, int32 $textSize, bool $editMode) returns int32 is export is native(LIBRAYGUI) is symbol('GuiTextBox_pointerized'){ * } +our sub gui-text-box (Rectangle $bounds, CArray[uint8] $text, int32 $textSize, bool $editMode) returns int32 is export is native(LIBRAYGUI) is symbol('GuiTextBox_pointerized'){ * } our sub gui-slider (Rectangle $bounds, Str $textLeft, Str $textRight, num32 $value is rw, num32 $minValue, num32 $maxValue) returns int32 is export is native(LIBRAYGUI) is symbol('GuiSlider_pointerized'){ * } our sub gui-slider-bar (Rectangle $bounds, Str $textLeft, Str $textRight, num32 $value is rw, num32 $minValue, num32 $maxValue) returns int32 is export is native(LIBRAYGUI) is symbol('GuiSliderBar_pointerized'){ * } our sub gui-progress-bar (Rectangle $bounds, Str $textLeft, Str $textRight, num32 $value is rw, num32 $minValue, num32 $maxValue) returns int32 is export is native(LIBRAYGUI) is symbol('GuiProgressBar_pointerized'){ * } @@ -436,7 +436,7 @@ our sub gui-grid (Rectangle $bounds, Str $text, num32 $spacing, int32 $subdivs, our sub gui-list-view (Rectangle $bounds, Str $text, int32 $scrollIndex is rw, int32 $active is rw, ) returns int32 is export is native(LIBRAYGUI) is symbol('GuiListView_pointerized'){ * } our sub gui-list-view-ex (Rectangle $bounds, Str $text, int32 $count, int32 $scrollIndex is rw, int32 $active is rw, int32 $focus is rw, ) returns int32 is export is native(LIBRAYGUI) is symbol('GuiListViewEx_pointerized'){ * } our sub gui-message-box (Rectangle $bounds, Str $title, Str $message, Str $buttons) returns int32 is export is native(LIBRAYGUI) is symbol('GuiMessageBox_pointerized'){ * } -our sub gui-text-input-box (Rectangle $bounds, Str $title, Str $message, Str $buttons, Str $text, int32 $textMaxSize, bool $secretViewActive is rw) returns int32 is export is native(LIBRAYGUI) is symbol('GuiTextInputBox_pointerized'){ * } +our sub gui-text-input-box (Rectangle $bounds, Str $title, Str $message, Str $buttons, CArray[uint8] $text, int32 $textMaxSize, bool $secretViewActive is rw) returns int32 is export is native(LIBRAYGUI) is symbol('GuiTextInputBox_pointerized'){ * } our sub gui-color-picker (Rectangle $bounds, Str $text, Color $color is rw) returns int32 is export is native(LIBRAYGUI) is symbol('GuiColorPicker_pointerized'){ * } our sub gui-color-panel (Rectangle $bounds, Str $text, Color $color is rw) returns int32 is export is native(LIBRAYGUI) is symbol('GuiColorPanel_pointerized'){ * } our sub gui-color-bar-alpha (Rectangle $bounds, Str $text, num32 $alpha is rw) returns int32 is export is native(LIBRAYGUI) is symbol('GuiColorBarAlpha_pointerized'){ * }