Skip to content

Conversation

@antongrbin
Copy link

@antongrbin antongrbin commented Apr 22, 2022

Motivation

https://docs.google.com/document/d/1p5LUSTWrVBcT9F2wXBgHBDT3OJyOm5BpXAyTpwwDVts/edit#

Changes

  • Change _ConvertScalarFieldValue so it throws a special exception when unknown enum string value is encountered.
  • Wrap every invocation of _ConvertScalarFieldValue to optionally ignore the new exception thrown.
  • Add unit tests

Tested

Executed the test plan from here: #1 to test this within the protobuf repo.

Also tested as part of noom-contracts repo: https://github.com/noom/noom-contracts/pull/293

@antongrbin antongrbin changed the base branch from json_unknown_enum_fork_baseline to json_unknown_enum_fork April 22, 2022 14:58
@antongrbin antongrbin changed the base branch from json_unknown_enum_fork to min-2432/make-the-json-format-standalone April 22, 2022 15:03
@antongrbin antongrbin requested a review from ifabijanovic May 30, 2022 09:01
antongrbin and others added 2 commits June 20, 2022 17:19
…terface

# Note to reviewer

* The baseline here is a fork, please review documentation on #1 and [tech doc section](https://docs.google.com/document/d/1p5LUSTWrVBcT9F2wXBgHBDT3OJyOm5BpXAyTpwwDVts/edit#heading=h.b8v2uff99l8v).

# Motivation

Reducing the dependencies that `json_format.py` is making is helping us create a more stable fork of that file in noom-contracts.

See concrete problem [here](https://github.com/noom/noom-contracts/runs/6651503347?check_suite_focus=true), where `mypy` fails because it can't find type hints on the `google.protobuf.internal` library.

See code comment above `TruncateToFourByteFloat`

# Testing completed

Ran python unit tests as described in test plan in #1.
@antongrbin
Copy link
Author

Reopened by a mistake as #4. Closing this one

@antongrbin antongrbin closed this Jun 20, 2022
antongrbin pushed a commit that referenced this pull request Jan 10, 2024
antongrbin pushed a commit that referenced this pull request Jan 10, 2024
```
int com.google.android.test.Outer.computeUInt32SizeNoTag(int) [24 bytes]
    0x000024d0    mov w0, #0x160
    0x000024d4    clz w1, w1
    0x000024d8    add w1, w1, w1, lsl #3
    0x000024dc    sub w0, w0, w1
    0x000024e0    lsr w0, w0, #6
    0x000024e4    ret
```
versus existing:
```
int com.google.android.test.Outer.computeUInt32SizeNoTag(int) [72 bytes]
    0x000022a0    and w0, w1, #0xffffff80
    0x000022a4    cbnz w0, #+0xc (addr 0x22b0)
    0x000022a8    mov w0, #0x1
    0x000022ac    b #+0x38 (addr 0x22e4)
    0x000022b0    and w0, w1, #0xffffc000
    0x000022b4    cbnz w0, #+0xc (addr 0x22c0)
    0x000022b8    mov w0, #0x2
    0x000022bc    b #+0x28 (addr 0x22e4)
    0x000022c0    and w0, w1, #0xffe00000
    0x000022c4    cbnz w0, #+0xc (addr 0x22d0)
    0x000022c8    mov w0, #0x3
    0x000022cc    b #+0x18 (addr 0x22e4)
    0x000022d0    mov w2, #0x5
    0x000022d4    mov w0, #0x4
    0x000022d8    and w1, w1, #0xf0000000
    0x000022dc    cmp w1, #0x0 (0)
    0x000022e0    csel w0, w2, w0, ne
    0x000022e4    ret
```

PiperOrigin-RevId: 591113652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants