godot_parser icon indicating copy to clipboard operation
godot_parser copied to clipboard

Add support for typed arrays and match Godot 4 formatting.

Open bolinfest opened this issue 11 months ago • 3 comments

I have been using this project to parse my .tscn files on Godot 4, which required some updates here to make things work:

  • Now .tscn files seem to be saved without spaces around args, so ExtResource("7") instead of ExtResource( "7" )
  • My files have properties like polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 0, 3, 5)]) that did not seem to be accounted for in the existing grammar, so I had to add new rules in values.py and a GDTypedArray class to parse these new types into.
  • Not all objects have arguments (e.g., PackedStringArray()), so made the arg list for obj_type optional

This isn't well-tested, but empirically, it works for my purposes, so feel free to adapt as you see fit! Even if this isn't upstreamed, perhaps it will help someone else.

bolinfest avatar Mar 06 '25 19:03 bolinfest

I'm happy to merge this! Would just require:

  1. A test for the typed arrays in test_parser.py
  2. A simple test for typed arrays in test_objects.py
  3. Fix the failing tests

I think that the CI has rotted a bit in general. I'll see if I can get it back to a green state on master

stevearc avatar Mar 11 '25 05:03 stevearc

@stevearc if you can get CI healthy on master, then I'm happy to add tests!

bolinfest avatar Mar 15 '25 01:03 bolinfest

@bolinfest builds are working on master again

stevearc avatar Mar 19 '25 22:03 stevearc