Skip to content
Snippets Groups Projects

Draft: json: create two static lib to serialize and deserialize input_item_t

Open Gabriel Lafond-Thenaille requested to merge gabriel_lt/vlc:serial.1 into master
1 unresolved thread

This merge request is the first part of making the preparser running in a different process. Its purpose is to discuss and be sure that's the way to go.

This introduce de/serialization to and from json of the useful part input_item_t. The function's name and the two static lib structure are open to discussion and will perhaps be merge in one static library with all other de/serialization functions needed and not done yet.

Next step:

  • preparser binary that receive preparse request and send responce.
  • an API that spawn the preparser process and send preparse request.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Steve Lhomme
  • Steve Lhomme
  • Steve Lhomme
  • Steve Lhomme
  • Steve Lhomme
  • added 2 commits

    • 80855c2e - meta: add getter for meta value priority
    • b92b8c41 - misc: Create two static library to de/serialize input_item_t with json

    Compare with previous version

  • resolved all threads

  • added 1 commit

    • 368cc336 - misc: Create two static library to de/serialize input_item_t with json

    Compare with previous version

  • 68 * an integer. */
    69 static inline bool json_object_to_integer(const struct json_object *obj,
    70 const char *name, int *number,
    71 bool *error, int MIN, int MAX)
    72 {
    73 vlc_assert(obj != NULL);
    74 vlc_assert(name != NULL);
    75 vlc_assert(number != NULL);
    76 vlc_assert(error != NULL);
    77
    78 double n = NAN;
    79 json_object_to_number(obj, name, &n, error, MIN, MAX);
    80 if (*error || isnan(n) || isinf(n) || (floor(n) != ceil(n))) {
    81 *error = true;
    82 return *error;
    83 }
    • Comment on lines +80 to +83

      Zero is not signed in two's complement representation. I wonder if it should error out with -0.0, as that is also information loss.

    • Isn't isinf implied by isnan?

      And then there are more straightforward means to check that a number is an integer, e.g. modf(x, 1) == 0 or floor(x) == x. But I'm not sure why that should be an error in the first place. We don't want to trigger UB, but we don't care about losing precision (especially if it cannot happen from a non-broken sender).

    • The only concrete way I see to check if information was lost (in other words, number is integer) is by casting the integer output back into double and comparing it with the input double number.

    • But I'm not sure why that should be an error in the first place.

      I think it may signal information loss like that, that should be fair and may be convenient, but it should continue providing the number. I think it should be up to the caller whether to use the crooked integer.

      I also think why there is such json_object_to_integer() besides json_object_to_double()? Double to integer is a broader thing than serialization, so if there is such a need then it should probably be in the core so that it can be used anywhere.

    • Please register or sign in to reply
    Please register or sign in to reply
    Loading