[blend_info] Emit value using nodes

Blender 2.79

In Blender 2.79 we were able to misuse the old material settings to store e.g. a value for light emitting geometry:

Emission in Shader Editor

# list the material names used in the Cornell Box scene
$ blend_info -n Material.ID.name cornell_box_v2_79.blend 
Material.ID.name = "MAcbox"
Material.ID.name = "MAcbox_green"
Material.ID.name = "MAcbox_red"
Material.ID.name = "MAlarge_box"
Material.ID.name = "MALight"
Material.ID.name = "MAsmall_box"
# only the Light material has an emit value > 0 set
$ blend_info -n Material.emit cornell_box_v2_79.blend
Material.emit = 0_f32
Material.emit = 0_f32
Material.emit = 0_f32
Material.emit = 0_f32
Material.emit = 100_f32
Material.emit = 0_f32

Blender 3.0

In Blender 3.0 we have to use the Shader Editor and nodes:

Emission in Shader Editor

# list the material names used in the Cornell Box scene
$ blend_info -n Material.ID.name cornell_box_v3_00.blend
Material.ID.name = "MAcbox"
Material.ID.name = "MAcbox_green"
Material.ID.name = "MAcbox_red"
Material.ID.name = "MAlarge_box"
Material.ID.name = "MALight"
Material.ID.name = "MAsmall_box"
# only one of them has to use the Shader Editor
$ blend_info -n Material.use_nodes cornell_box_v3_00.blend
Material.use_nodes = 0
Material.use_nodes = 0
Material.use_nodes = 0
Material.use_nodes = 0
Material.use_nodes = 1
Material.use_nodes = 0

Data API

We can see that Use Nodes is turned on in the Blender 3.0 Outliner (showing the Data API):

Outliner showing Data API

We also see that there should be a Node Tree:

$ blend_info -n Material cornell_box_v3_00.blend | grep nodetree
  bNodeTree *nodetree; // 8

And that bNodeTree should have a bunch of nodes:

bNodeTree has two nodes

# list of nodes
$ blend_info -n bNodeTree cornell_box_v3_00.blend | grep nodes
  ListBase nodes; // 16
# what's a ListBase?
$ blend_info -n ListBase cornell_box_v3_00.blend
ListBase 16
struct ListBase { // SDNAnr = 2
  void *first; // 8
  void *last; // 8
}; // 16

We can kind of guess what data struct we have to look for:

# do we have some float values?
$ blend_info --dna cornell_box_v3_00.blend | grep bNode | grep Float
  bNodeSocketValueFloat (len=16) {
# do we have such a value?
$ blend_info -n bNodeSocketValueFloat.value cornell_box_v3_00.blend
bNodeSocketValueFloat.value = 100_f32

We found the value we need, but we have to change the API of blend_info to be able to follow pointers and savely know that this is actually an emit value belonging to the Light material.