Skip to content
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

Allow lists as indata for bytes fields. #66

Conversation

lukebakken
Copy link
Contributor

@lukebakken lukebakken commented Jul 19, 2016

Another piece of epb compatibility.

See #63

TODO:

  • NIF support

@lukebakken
Copy link
Contributor Author

@tomas-abrahamsson - I added the following nif test, expecting it to fail, but it didn't:

https://github.com/basho/gpb/blob/feature/lrb/epb-encode-list-bytes-compat/test/gpb_compile_tests.erl#L1681-L1704

I thought I would have to add something here, but apparently the list must be converted to a binary before reaching this point:

https://github.com/basho/gpb/blob/feature/lrb/epb-encode-list-bytes-compat/src/gpb_compile.erl#L6670-L6678

Am I missing something?

@lukebakken lukebakken force-pushed the feature/lrb/epb-encode-list-bytes-compat branch from 77bbbf8 to ba7b98d Compare July 20, 2016 15:31
@tomas-abrahamsson
Copy link
Owner

blush ahemm, mea culpa. Thanks! On the branch verify-separate-vm-catches-errors (to be merged to master soon) there's a fix plus a unit test to make sure such errors do not go unnoticed again. With that fix, your newly added eunit test fails as expected.

A useful trick for debugging such issues is to change with_tmpdir(fun...end) into with_tmpdir(save, fun..end) and you'll get a debug printout, and in the case of nif code, some C++ code, and a Makefile for further debugging. In that directory, there's also a file, fun-run-result, which in this case actually did contain an (undetected due to the bug) error.

@tomas-abrahamsson
Copy link
Owner

Easiest for you might be to either rebase your branch on top of this, or cherry-pick that commit into your branch (or just temporarily-while-developing change the line to fixes the issue)

@lukebakken
Copy link
Contributor Author

@tomas-abrahamsson thank you, I'll look further into this 😄

@lukebakken lukebakken force-pushed the feature/lrb/epb-encode-list-bytes-compat branch from ba7b98d to 70d6b4f Compare July 21, 2016 13:39
@lukebakken
Copy link
Contributor Author

lukebakken commented Jul 21, 2016

@tomas-abrahamsson - all set. I rebased this branch onto verify-separate-vm-catches-errors and fixed the last bits of code that needed fixing, then rebased back onto master. All set for final review.

@lukebakken lukebakken force-pushed the feature/lrb/epb-encode-list-bytes-compat branch 2 times, most recently from e3fcb91 to 6de3a0a Compare July 21, 2016 14:56
@@ -1387,6 +1399,7 @@ nif_code_test_() ->
{"Nif enums in msgs", fun nif_enum_in_msg/0},
{"Nif enums with pkgs", fun nif_enum_with_pkgs/0},
{"Nif with strbin", fun nif_with_strbin/0},
{"Nif with list indata for bytes", fun nif_with_list_indata_for_bytes/0},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is >80 characters

@tomas-abrahamsson
Copy link
Owner

Looks good

Small issues: A comment on length of one line, and maybe we can squash the changes into one commit? (it'll help any future git bisect if there isn't a failing eunit test in one of the commits (I know it is deliberate during development; tdd))

@tomas-abrahamsson
Copy link
Owner

Hmm... just remembered... the eunit test wasn't failing after all... :)

Another thing: I can add a sentence to the README after I've merged them all, about iolist being ok for encoding. Since the README table rewrite is in the other branch, I figure it might be easier to add that after merge.

Allow using a list as indata for a bytes field.

add nif test

Put in last bits of magic to accept lists as bytes indata
@lukebakken lukebakken force-pushed the feature/lrb/epb-encode-list-bytes-compat branch from 55ee336 to fda55c1 Compare July 23, 2016 00:04
@lukebakken
Copy link
Contributor Author

@tomas-abrahamsson - all set I think, line length addressed, commits squashed. If you could add something to the README that would be great. Have a good weekend.

@tomas-abrahamsson
Copy link
Owner

Looks good, thanks for your patience, and have a nice weekend, too!

@tomas-abrahamsson tomas-abrahamsson merged commit fda55c1 into tomas-abrahamsson:master Jul 23, 2016
@tomas-abrahamsson
Copy link
Owner

This is now included in 3.24.0

@lukebakken lukebakken deleted the feature/lrb/epb-encode-list-bytes-compat branch July 25, 2016 13:12
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.

None yet

2 participants