In this post we will look at the RNA tree and
use several tool functions from
to inspect the structure of RNA.
We also will have a brief overview of polymorphism
As a user of Blender reflection system, the first questions are where is the root of RNA tree defined and what is its lifetime/ownership?
The root of RNA tree is a
which is a collection of structure RNAs(
The instance of
BlenderRNA is called
which is defined in the file
rna_ID_gen.c as a global variable
in static storage.
BLENDER_RNA is also declared in the file
so you can access it by including
When a new module type is registered to Blender,
a corresponding new
StructRNA is created and
get appended to
Take Blender operators as an example:
When a new operator is registered,
StructRNA is created by
and then passed to custom operator registration code
where operator-specific properties will be defined.
The source code of above process can be found in
To inspect the RNA informations I write an operator
The source code can be found here.
This operator just iterates all RNA nodes and output the sub-tree for a given root node.
For example, the sub-tree for
Lamp type is shown below:
We can use functions such as
in the header
RNA_access.h) to check
runtime information of a type.
For “is-a” checking, Blender has to traverse through the parent link
to find a match.
As an extension reading, I suggest to look at how LLVM handles the runtime information in constant time1.