ProtoDef-io / protodefc

Compiler for protodef written in Rust
11 stars 3 forks source link

Difference in the interface of generated js #13

Closed rom1504 closed 6 years ago

rom1504 commented 7 years ago

https://github.com/ProtoDef-io/node-protodef/blob/master/src/datatypes/utils.js#L135 vs https://github.com/ProtoDef-io/node-protodefc/blob/master/lib/types/utils.js#L55

ie deserialize return [value,size] with protodefc while protodef return {value,size}

The second difference is an object {serialize,deserialize,size_of} vs an array {deserialize,serialize,size_of} but that's less important because it can be transformed after compilation without loss of performance.

It's important to have the same interface in order to use existing native types , for example https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/datatypes/minecraft.js#L7

I don't think any of the two interfaces is better, I just think it should be the same.

Would it be a problem to make deserialize return a {value,size} in protodefc js backend ? Does anything use protodefc js backend yet ?