-
Notifications
You must be signed in to change notification settings - Fork 82
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
cannot parse high u64 default values in the API files #118
Comments
I will have a look at other VPP bindings generators to see how they react to that. |
I have played around a bit with this and so far it seems the library we are using to process JSON does not seem to be flexible for parsing numbers. There is I also tried standard I don't want to spend much more time than I already did, but I plan to come back to this issue later after I am done with other more urgent matters. The Anyone is welcome to take a shot and open PR if you find a fix for this. |
I just had a look at the Python bindings. The json library commonly used in Python does differentiate between int and float. If the number contains a dot, it is considered as a float, otherwise, it is considered as an int. Thus, the problem does not appear in Python. |
As Govpp doesn't know in advance the exact template of the json it parses, it uses a generic parsing with
json.Unmarshal
hereHowever, when unmarshalling generic json in Go, numbers are casted in
float64
. Now, if the Json containuint64
numbers, we lose precision casting them asfloat64
.As we allow u64 types in the VPP API, we may end up with a wrong value after parsing the API. And casting float64 into uint64 depends on the hardware implementation.
In Govpp, the conversion happens here
Let's take a VPP API exmaple:
If we generate Go bindings with this Json, we get:
u64,name=value,default=9223372036854775808
if we run it on x86 devicesu64,name=value,default=18446744073709551615
if we run it on arm devicesThe text was updated successfully, but these errors were encountered: