)]}'
{
  "commit": "95feb99a9d65641ee022ad7fa087be27a3ed4b84",
  "tree": "83104f6fefed6bacf809a087ff21de3beebb498d",
  "parents": [
    "386755b1acede97cbf88a074bd99dc2c54bedada"
  ],
  "author": {
    "name": "Ben Clayton",
    "email": "bclayton@google.com",
    "time": "Mon Nov 30 22:50:25 2020 +0000"
  },
  "committer": {
    "name": "Commit Bot service account",
    "email": "commit-bot@chromium.org",
    "time": "Mon Nov 30 22:50:25 2020 +0000"
  },
  "message": "Add Castable template class\n\nImplements `As\u003cBlah\u003e()` and `Is\u003cBlah\u003e()` automatically.\n\nThere are several benefits to using this over the pattern of hand-rolled `IsBlah()`, `AsBlah()` methods:\n(1) We don\u0027t have to maintain a whole lot of hand written code.\n(2) These allow us to cast from the base type to _any_ derived type in a single cast. The existing hand-rolled methods usually require a couple of intermediary casts to go from the base type to the leaf type.\n(3) The use of a template parameter means these casts can be called from other template logic.\n\nNote: Unlike the hand-rolled `AsBlah()` methods, it is safe to call `As\u003cT\u003e()` even if the type does not derive from `T`. If the object does not derive from `T` then  `As` will simply return `nullptr`. This allows the calling logic to replace the common pattern of:\n\n```\nif (obj.IsBlah()) {\n   auto* b \u003d obj.AsBlah();\n   ...\n}\n```\n\nwith:\n\n```\nif (auto* b \u003d obj.As\u003cBlah\u003e()) {\n   ...\n}\n```\n\nThis halves the number of virtual method calls, and is one line shorter.\n\nChange-Id: I4312e9831d7de6703a97184640864b8050a34177\nReviewed-on: https://dawn-review.googlesource.com/c/tint/+/34260\nReviewed-by: dan sinclair \u003cdsinclair@chromium.org\u003e\nCommit-Queue: Ben Clayton \u003cbclayton@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "cd9c72a9eb2fb8872c199a4f78ae62838b9de736",
      "old_mode": 33188,
      "old_path": "BUILD.gn",
      "new_id": "af036e5bb20e73585401042f04594f52324f9a70",
      "new_mode": 33188,
      "new_path": "BUILD.gn"
    },
    {
      "type": "modify",
      "old_id": "45b2c88be0d4a1e42925d062d314019d36adfcd6",
      "old_mode": 33188,
      "old_path": "src/CMakeLists.txt",
      "new_id": "b5c44775cfee77e8eb38a3334b25025d33dd9ca0",
      "new_mode": 33188,
      "new_path": "src/CMakeLists.txt"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "0ddfdb2fd75710a710136e4abadd3b22b0fcd2a5",
      "new_mode": 33188,
      "new_path": "src/castable.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "165b6fcf6e530128b1df952e7e2d814275b2b8fe",
      "new_mode": 33188,
      "new_path": "src/castable.h"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5c7a9bd3ac00cb9d2e2bc210efa441ba8383b62e",
      "new_mode": 33188,
      "new_path": "src/castable_test.cc"
    }
  ]
}
