Closed ritzow closed 5 months ago
Thanks for the report. The generated classes are all fine. The problem is that the generator did not remember the struct class names it already created. This will then create the same struct class name multiple times when determining the class to use for method signature.
I fixed this in my latest commit.
I also improved the naming for the created struct classes to include the name of the argument/parameter it belongs to. This means you will get a StartTransientUnitAuxStruct and a StartTransientUnitPropertiesStruct class. I think this would improve the understanding on where the struct classes are used instead of naming them StartTransientUnitStruct and StartTransientUnitStructStruct etc.
Fantastic. I've updated my code to use your latest code and it works perfectly. Thank you!
It isn't a concern for me, but wouldn't the new naming scheme for structs be a backwards-incompatible change? It seems like that could be a suprising change in a minor release. I don't know what your compatibility model for the library is, or if this change only affects the broken codegen anyways.
Yes this is indeed a breaking change, but it only affects the code generator - therefore I'm fine that. Also the breaking change will result in compile errors which are easily to spot and fix (other than various runtime issues you never see in advance).
The InterfaceCodeGenerator is usually used once by a developer to create the required classes/interfaces. After that there is no need to re-run it. The only reason to re-run would be updating the interfaces due to changes on the program exposing those interfaces on DBus. In this case it would be necessary to review and test your own code anyway.
The compatibility model is usually "no breaking changes in same major". But this is only true for the library (core) and the required transports - not for the utils or examples.
The code generated by the code generator seems to add an extra parameter, or maybe I'm just confused about what the parameter should contain?
Code generation code snippet:
Generated method in the generated class:
Based on this dbus spec:
The "properties" parameter should be a key-value pairs array where the key is a string and the value is a Variant. D-Spy lists it as
StartTransientUnit(string name, string mode, a(sv) properties, a(sa(sv)) aux) -> (Object Path job)
(also not sure whyproperties
andaux
are the same in the generated code when they have different dbus signatures).Here's what a run of
systemd-run --user --pty ps aux
looks like in Bustle (dbus traffic capture):Signature
ssa(sv)a(sa(sv))
Body (notice that the angle brackets represent a Variant, and the aux param is the empty array starting with
@a
):"run-u228.service", "fail", [("Description", <"/usr/bin/ps aux">), ("AddRef", <true>), ("StandardInput", <"tty">), ("StandardOutput", <"tty">), ("StandardError", <"tty">), ("TTYPath", <"/dev/pts/1">), ("Environment", <["TERM=xterm-256color"]>), ("ExecStart", <[("/usr/bin/ps", ["/usr/bin/ps", "aux"], false)]>)], @a(sa(sv)) [])
Generated StartTransientUnitStruct class (see my inserted java comments):
I think
StartTransientUnitStruct
may actually be the type for the aux array type, but it's using it for bothproperties
andaux
?StartTransientUnitStructStruct
seems like it's the actual appropriate type for values in theproperties
array.Generated StartTransientUnitStructStruct class:
Lastly, here's my data types that I'm using for now since the generated code isn't correct:
And here's my code to call
StartTransientUnit
:Thank you for your time. Please let me know if I can provide any more information.
dbus-java version info: Commit 0e8a16db97dce8d0c878852f3f26b7e8f01060c2 (built from master 2024-3-24) (5.0.1-SNAPSHOT)