-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API break between 0.1.1 and 0.1.2 #52
Comments
I think current ( 0.1.2 ) behaviour is consistent with pre 0.1 and what you had with 0.1.1 was an accidental bug ( most of the deserialising code is rewritten by #41 ) The idea is that by default given message top level signature and message data you should be able to generate back exactly the same binary representation of the message. This is something not necessary to most users, so that default might be changed ( but still exist behind a flag ) in favour of more compact. This is especially important when you handle json-like list of properties where "full" view of Documentation is probably on top of my priority list and any help would be appreciated In short:
For example, if we switch to 'lightweight' results by default api might be like this // 0.1.1 - like behaviour:
var sysbus = dbus.systemBus({ preserveTypes: true });
// new default: compact (de)searialisation of variands
var sysbus1 = dbus.systemBus(); wdyt? |
Aha, I see. Im not very familiar with the details of dbus, could you give an example of a case where data is lost when converting from dbus types to javascript types? In your example, you write that the default should be the default, with default do you mean the behaviour in 0.1.1? Also, would preserveTypes mean to not loose any data, that is to preserve the dbus types or does it mean that we preserver javascript types? However I think the idea in general is good, I guess you could also expose some utility to convert from one format to the other, dunno if thats better though. var niceSysBus = new dbus.NiceBus(dbus.systemBus()); In order to give a better response I think I need to study the dbus type system some more, do you have any good references I could read? |
If you have "ay" array and JS data like [ 1, 2, 3, "aaa" ] you can only guess actual type of elements - first 3 can be any of y,n,q,i,u,x,d,t types and fourth any of s,o,g. If data is [
[ [ { type: 'b', child: [] } ], [ true ] ],
[ [ { type: 'i', child: [] } ], [ 123 ] ],
[ [ { type: 'y', child: [] } ], [ 123 ] ],
[ [ { type: 's', child: [] } ], [ "aaa"] ],
] then you know exactly how to serialise your data I'll try to describe dbus type system in details (hopefully copy something from here to readme) D-bus uses simple string type representation to describe how message should be serialised to and from raw binary data. Each character in the "signature" represents simple type, start of array/struct/hash or variant. Simple types:
String-like types are prefixed with length ( 8 bit for "g" and 32 for "o" and "s" )
arrays, structs and maps: array signature is "a" followed by full signature ( simple type, structure, array, struct or variant )
structure is described with "(" and ")" and a list if full types in between. Often used to describe single type for array or tuple element
structure described with "{" and "}" is similar to "()" with exception that it can only contain have exactly two values - it's a tuple. Usually goes together with "a" to represent map
Variants are prefixed with signature followed by encoded value
( to be continued ... ) |
Aha, I see, I did not think the dbus type system was so detailed. That explains quite a lot, thank you :) I also think that you can steal most of this and put it in the documenation. When I considered this problem I originaly did not think of the case converting from js types to dbus types (which isn't fully possible). However converting from dbus types from js types should work fine. With that in mind though, I guess its not ever really possible to convert from js types to dbus types in a good manner, that is the "preserveTypes" mode doesnt work very well going from js -> dbus, right? However when reading (which is what I mostly do) it should be fine providing two difrerent modes (or a way to convert from dbus types to js types). Basically, what I will do when I get time is to rewrite my dbus-native wrapper to convert from dbus-types to javascript types. It would be nice if that utility could be provided by dbus-native. |
Automatic conversion draft: JS -> dbus serialisation
|
I recently upgraded from dbus-native 0.1.1 to 0.1.2 and now get crashes that
appear to be because of a change in API.
Bisecting the issue I found that my code stopped working with commit
f21eab6
I deviced the following small test to illustrate the difference:
With version 0.1.1 I get the following output:
While with version 0.1.2 I get the following:
Obiously this is a breaking change, my question is if this is an intentional
API break or if I should consider it a bug?
If it is an intentional break I think we should add some documentation
detailing the new API.
The text was updated successfully, but these errors were encountered: