Skip to content

Commit

Permalink
Fixing mutable strings parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vushu committed Nov 18, 2023
1 parent ca5b6b2 commit bfb37ba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions lib/Raygui/Actions.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ class Actions {
make "int32 \$$<identifier> is rw, {$<parameters>.map: *.made.join(',')}";
}

multi method parameters($/ where $<pointer> && $<type> eq 'char' && !$<const>) {
make "CArray[uint8] \$$<identifier>, {$<parameters>.map: *.made.join(',')}";
}

multi method parameters($/) {
if (!$<type>) {
make '';
Expand Down
6 changes: 3 additions & 3 deletions lib/Raygui/Bindings.rakumod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This Raku module is generated from raygui.h
unit module Raygui::Bindings:ver<0.0.5>:auth<zef:vushu>;
unit module Raygui::Bindings:ver<0.0.6>:auth<zef:vushu>;
use Raylib::Bindings;
use NativeCall;
constant LIBRAYGUI = %?RESOURCES<libraries/raygui>;
Expand Down Expand Up @@ -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'){ * }
Expand All @@ -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'){ * }
Expand Down

0 comments on commit bfb37ba

Please sign in to comment.