Commit Graph

369 Commits (dustin/master)

Author SHA1 Message Date
Dustin Oprea 1a430b7457 ifd_enumerate.go: Drop `(*Ifd).Value` and `.FormatValue()`
This can and should be done directly on the ITEs themselves.
2020-01-12 18:56:35 -05:00
Dustin Oprea 0c670ca7c2 ifd_tag_entry.go: Renamed RawBytes() to GetRawBytes()
It used to be a simple getter but now it does stuff.
2020-01-12 18:56:35 -05:00
Dustin Oprea 173d686dd9 Visit interface now just gets the ITE struct
That, rather than just a couple of values from it. Primarily because we
want to not have callers involve themselves with the value context
unless they want to.

- ifd_tag_entry.go: ITEs now provide `Format()` and `FormatFirst()`
  methods.

- We dumped several spots of code that could just reuse functions to
  format, decode, or get raw bytes rather than dealing with undefined
  vs not undefined logic themselves.

  - This is now possible due to prior change.

- ifd_tag_entry.go: No longer exports GetValueContext(). Users shouldn't
  usually have to touch it, now.

- Added some commenting.

This commit almost represents everything we have been trying to achieve,
now made possible by the last several commits.
2020-01-12 18:56:35 -05:00
Dustin Oprea 1bdfa9b10e Empower ITEs to resolve values and raw bytes directly
They'll also now embed all of the information they need to know since it
is all known where the ITEs are created. This prevents the user from
having to be involved in it. This makes it much more straightforward and
enjoyable to use.

- ifd_tag_entry.go
  - newIfdTagEntry now takes and embeds `addressableBytes` and
    `byteOrder`.
  - We've dumped the `value` member that let the caller preload a parsed
    value (or bytes?). It's no longer necessary since this led to
    inconsistencies and the ITE can produce these values directly, now.
  - `Value()` obviously no longer takes `addressableValue` and
    `byteOrder` since now embedded.
  - `Value()` will now see and return ErrUnhandledUnknownTypedTag
    directly (not wrapping it, since this is a handled case).

- common/type.go: FormatFromType now uses Stringer as a fallback if
  possible. All undefined-tag wrapper types implement it, so the same
  function can handle both undefined and non-undefined values, and the
  individual types can control the strings presented in simple listing.

- Dropped "resolveValue" parameters from all of the collect, visit, and
  parsing functions. Resolution is now a later step performed by the
  caller on the ITEs, directly.

  - This parameter was protection against undefined-type values
    disrupting simple enumeration, but now the user can simply produce
    the list of tags and can either choose to decode their value or not,
    directly. If they do, they, as of earlier, recent commits, also have
    the ability to properly manage unhandled undefined-values so they
    don't crash.

- The ITEs can now create ValueContext structs directly
  (GetValueContext()), though it might not be necessary now that the
  ITEs can produce the values and encodings directly.

  - This also allowed us to dump several other GetValueContext()
    implementations elsewhere since it is now self-reliant on this type
    and those methods were essentially kludges for the lack of this.

- Dump a bunch of "Value" methods from ITEs which just weren't useful or
  simple enough. Replaced by the above.

- Fixed `(Ifd).String()` to have a pointer receiver.
2020-01-12 18:56:35 -05:00
Dustin Oprea e7e1e89ffb undefined/accessor.go: Drop unnecessary parameters from Decode() 2020-01-12 18:56:35 -05:00
Dustin Oprea 6554f89879 common/type.go: Rename Format() to FormatFromBytes() 2020-01-12 18:56:35 -05:00
Dustin Oprea 82afccee6b Removed concept of ITEVRs
This was from a time long past, from the beginning of the project, and
was just an ineffective bandaid that made things complicated.
2020-01-12 18:56:35 -05:00
Dustin Oprea 9441507683 common/parser.go: An ASCII string not being terminated with NUL now panics
This likely means an offset error or something else that's very bad. We
shouldn't be forgiving it.
2020-01-12 18:56:35 -05:00
Dustin Oprea 351f1b7549 undefined/type.go: Formalized requirement for undefined-types being Stringers 2020-01-12 18:56:35 -05:00
Dustin Oprea 9a4bd45d39 undefined/type.go: Drop TagUndefinedType_UnknownValue
Not used anywhere
2020-01-12 18:56:35 -05:00
Dustin Oprea d293fcac9c undefined/exif_8828_oecf.go: Add Encode() 2020-01-12 18:56:35 -05:00
Dustin Oprea f7701a222a ifd_enumerator.go: Drop resolveTagValue
Was only used in one place and it's just a redundancy.
2020-01-12 18:56:35 -05:00
Dustin Oprea 32a5d88770 New integration of common/ and undefined/ subpackages
- common/type.go: Add FormatFromType() .
- Renamed common/type_encode.go to common/value_encoder.go .
2020-01-12 18:56:35 -05:00
Dustin Oprea 5c7dc45079 Added all tests for type.go, type_encode.go, parser.go, value_context.go, and utility.go
- Add .MODULE_ROOT anchor file to support testing.
2020-01-12 18:56:35 -05:00
Dustin Oprea bf3bc4e542 Refactor undefined-type tag processing 2020-01-12 18:56:35 -05:00
Dustin Oprea 903910b6a7 Add v2 release module 2020-01-02 07:06:28 -05:00
Dustin Oprea 74567945ac v1/value_context.go: Bugfix for incorrectly handled ErrUnhandledUnknownTypedTag error 2020-01-02 07:06:28 -05:00
Dustin Oprea 254a6b902a ifd_builder.go: Very minor simplification 2020-01-02 00:01:06 -05:00
Dustin Oprea 1ae6e31ca9 type_encode.go: Add redundancy comments 2020-01-01 23:59:12 -05:00
Felix Kaiser 3a4fc51e30 exif-read-tool/main.go: exit 1 on panic (#23) 2020-01-01 11:13:14 -05:00
Dustin Oprea 8fd2b91cd6 Modulize project 2020-01-01 11:10:01 -05:00
Dustin Oprea 0b891977a5 .travis.yml: Extend Go versions being tested 2020-01-01 10:52:23 -05:00
Dustin Oprea 1fe423a045 Revert rename of testing_common.go
We need this to not run unless we're in a testing context. This is prep
for module support, where the relative path required there only works in
this package but will fail if used in reads in an `init()` function upon
import from subpackages.
2020-01-01 10:40:03 -05:00
Dustin Oprea c8c0acaebc Use global for name of test image
- Moved logic from common_test.go to testing_common.go . That was legacy
  naming.
2020-01-01 10:05:56 -05:00
Dustin Oprea 128e17cf5b Remove no-longer obsolete TODO files 2020-01-01 09:54:43 -05:00
Dustin Oprea f63d2907c8 Innocent rename for correctness
- Added comments for all of the "unknown" symbols that will have to be
  renamed as well. See https://github.com/dsoprea/go-exif/issues/27 .
2020-01-01 09:46:43 -05:00
Dustin Oprea 6c9ad5e3df README.md: Updates to documentation
- tags_unknown.go: Mention lingering undefined-types in issue.
2020-01-01 09:28:37 -05:00
Dustin Oprea 9aa2497f7b Revert "type.go: Deinegrated `ErrUnhandledUnknownTypedTag`"
This reverts commit 4f2f9044e6.

Reintroduces errors from `UndefinedValue()` when the undefined-type is
unhandled.

- We now just return it rather than panic with it so that we can check
  for it directly rather than use `log.Is()`.

- We've updated the checks across the code accordingly.
2020-01-01 09:05:06 -05:00
Dustin Oprea 439148e767 Add commenting to unknown-type handling 2020-01-01 02:57:34 -05:00
Dustin Oprea fdb5de93d2 ifd_tag_entry.go: Reimplement value/bytes using ValueContext
This is just a kludge until we can totally kill this type. Now fully
obsolete and no longer internally required.
2020-01-01 02:46:38 -05:00
Dustin Oprea 22222b24d0 Minor tweaks/renamings 2020-01-01 02:45:37 -05:00
Dustin Oprea 78e9e28053 ifd_enumerate_test.go: Moved and refactored some ITEVR tests to be for ValueContext instead
Per our recent change to deimplement ITEVRs.

- ifd_enumerate_test.go: Fixed some test naming.
- ifd_builder_test.go: Dropped some now-unnecessary implementations of
  ITEVRs.
2020-01-01 02:22:28 -05:00
Dustin Oprea 88612c1cf8 ifd_builder.go: No longer use ITEVRs
This was an early way of resolving tag values that is now obsolete.
`ValueContext` structs should be used, and these, in many cases, should
be able to be constructed from the current context without passing
additional arguments.

- ifd_builder_test.go: Refactors to several tests due to loss of ITEVR support.
- ifd_builder_encode_test.go: Moved test-IB populate to testing_common.go .
- ifd_builder.go: Fixed test naming (in most cases, omitted type name).
2020-01-01 00:16:11 -05:00
Dustin Oprea 9946007f05 ifd_builder.go: Bugfix for incorrectly-sized undefined-value copy
Fixes #14
2019-12-31 18:45:21 -05:00
Dustin Oprea 4f2f9044e6 type.go: Deinegrated `ErrUnhandledUnknownTypedTag`
Not actually used anywhere.
2019-12-31 07:39:41 -05:00
Dustin Oprea fb1db098b9 value_context.go: Add and integrate `(*ValueContext).Undefined()` method 2019-12-31 06:45:05 -05:00
Dustin Oprea 79b37fc0e1 value_context.go: No longer support override for unit-count
It's never set to anything different.
2019-12-31 06:45:05 -05:00
Dustin Oprea 71b242c269 value_context.go: We now store the IFD-path and tag-ID on the value-context
This allows us to add an API for accessing an undefined-value/structure
directly on ValueContext.

- ifd_tag_entry.go: Fixed several methods on `IfdTagEntry` to be by-
  reference. It was a latent bug that they weren't.

- value_context.go: Added `newValueContextFromTag` to streamline
  the changes above.
2019-12-31 06:45:05 -05:00
Dustin Oprea e6b94637a3 Eliminate unnecessary byte-order code verbosity 2019-12-29 21:20:40 -05:00
Dustin Oprea e5cdeb0aa4 ifd_builder.go: Fix `(*IfdBuilder).printTagTree()` printing of child IFDs 2019-12-29 20:56:35 -05:00
Dustin Oprea a4b93837a7 ifd_builder_encode_test.go: Bugfix for error-squashing in tests 2019-12-29 05:48:36 -05:00
Dustin Oprea 69821c417f value_context.go: ValueContext now embeds value processing
The upshot of this is that generating a list of type-correct slices or a
string from a tag's value is now stupidly easy.

- Broke parsing into an independent type (parser.go:Parser).

- Moved primary value-processing logic to `ValueContext` so that it
  coexists with the actual data (though as much basic functionality as
  possible is implemented independently and reused here). This
  eliminates extremely ridiculously obtuse usage procedure.

- Deprecated almost all existing TagType functionality (in order to
  distance us from this now-legacy usage pattern). Existing
  functionality maintained for now. We'll drop it when we do the next
  release major.

- `ValueContext` is now passed by reference.
2019-12-29 05:48:34 -05:00
Dustin Oprea 7fb09bbf9f value_context.go: `ValueContext` now wraps members in accessors
It also embeds the type and byte-order so the VC can materialize/process
values self-sufficiently.
2019-12-29 00:35:35 -05:00
Dustin Oprea a69c3987eb type.go: Created `TagTypePrimitive` alias for `uint16`
Added a `Size()` method to it and decommissioned redundant
`TagTypeSize()` and `(TagType).Size()`.

- ifd_enumerate.go: Moved `ValueContext` definition to
  value_context.go .
2019-12-29 00:03:58 -05:00
Dustin Oprea 483dbacf14 type.go: Bugfix for math with embedded data. Add Format().
- ifd_builder.go
  - `BuilderTag` now embeds `ByteOrder`.
  - `BuilderTag` `String()` now prints value.

- type.go
  - `TagType` `ValueIsEmbedded()` renamed to `valueIsEmbedded()`.
  - Add `readRawEncoded()` method to `TagType`.
  - Add `Format()` method to `TagType` to isolate code for processing
    output strings for all types.
    - This will also print a suffixing ellipsis when `justFirst` is
      `true`.

  - Important bugfix for embedded values always being presented as
    four-bytes rather than being truncated to their reported unit-count
    bytes first. We tripped over this when some of our corresponding
    math was found to be wrong elsewhere.

- Minor reformatting.
2019-12-28 23:35:32 -05:00
Dustin Oprea 636417e4ae README.md: Add mention of philip-firstorder 2019-12-23 00:44:58 -05:00
Dustin Oprea 3dda8c2115 MakerNotes now print size and SHA1
- tags_unknown.go: Unhandled unknown values are now wrapped in a
  TagUnknownType_UnknownValue rather than returning an error. This is
  now used to print byte-counts and SHA1s for unhandled values.

- tags_unknown.go: UnparseableUnknownTagValuePlaceholder now has message
  "!UNKNOWN" rather than "!UNPARSEABLE".
2019-11-02 04:23:58 -04:00
Dustin Oprea 4802cf93f4 utility.go: Add GetFlatExifData for convenience to external 2019-11-02 03:44:37 -04:00
Dustin Oprea 3ce78807c9 Add license 2019-09-01 13:30:45 -04:00
Keith Woelke 12b8993a44 Change Ifd.GpsInfo() to calculate Degrees, Mintutes, and Seconds as float64 instead of int 2019-06-24 06:34:42 -04:00