MetaTheme is divided into three parts:
Core library
Toolkit backends
Theme engines
Toolkit backends are the most complex pieces of MetaTheme. They are supposed to narrow the toolkit API to MetaTheme API. Some toolkits provide good support for changing things, others don't. To workaround these limitations the toolkit backends often uses various hacks, like run-time replacing of code. Though they are written in a safe fashion (if not, they should be done in another way or removed).
Toolkit backends are implemented mostly as a native theme engine for particular toolkit. Some can be implented as a patch, but our goal is to avoid this way if possible.
General rules for writing toolkit backends are covered in the chapter about Toolkit backends.