cunarist / rinf

Rust for native business logic, Flutter for flexible and beautiful GUI
MIT License
1.88k stars 65 forks source link

Fix: #306: send_signal_to_dart() function in rust code isn't generated when message contains enum and oneof fields in .protofile #307

Closed yeoupooh closed 6 months ago

yeoupooh commented 6 months ago

Changes

I've found if enum and oneof are used in the message definition, then statement can be like }\n\n// [RINF:RUST-SIGNAL] in parsing proto file. That causes not generating send_signal_to_dart() function. So, my fix is simply string compare logic using contains() instead of startsWith(). I think in most cases it works. But I would suggest using a grammar parser in the future.

Also added a unit test to verify the fix. To run it flutter test on flutter_ffi_plugin folder.

Hope this helps.

temeddix commented 6 months ago

Hello @yeoupooh, indeed, it would be nice to implement a grammar parser someday. For now, I will publish a new version as soon as the tests pass. Thanks for your contribution :)

temeddix commented 6 months ago

Currently, the CI system as well as Python scripts utilizes the example app directory for tests, so I moved some Protobuf definitions into that folder. Will merge it soon!