[PATCH] D24162: [yaml] Add the ability to pass in context at the map level

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 15:06:18 PDT 2016


zturner created this revision.
zturner added reviewers: lhames, majnemer.
zturner added a subscriber: llvm-commits.

When doing `mapRequired` or `mapOptional` it is useful to be able to pass context to the operation.  This has been partially addressed by having a `void *context` in the `IO` instance, but this is inflexible when you context is constructed on the fly, for example, and needs to be passed to only one specific mapping.

The solution implemented here adds an additional overload of `mapRequired` and `mapOptional`, taking a parameterized type.  If you invoke this overload, you are expected to specialize a `MappingTraits` with not only the default implementation which takes a n `IO&` and a `T &`, but an additional overload that takes an `IO&`, `T &`, and `Context &`.    This object is then passed into the map operation.  The original no context overload is still required

https://reviews.llvm.org/D24162

Files:
  include/llvm/Support/YAMLTraits.h
  unittests/Support/YAMLIOTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24162.70079.patch
Type: text/x-patch
Size: 14210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160901/473607ee/attachment.bin>


More information about the llvm-commits mailing list