Fix typing problems in TH that generates field code
Fix typing problems in TH that generates field code

See #677: The code generated by TH had different types depending on if
a field had a default value and/or custom reader. Simple cases worked by
accident, but more complex ones failed.

This patch distinguishes properly between optional fields and mandatory
fields and applies custom field reader functions and default values
accordingly.

This also covers the problem fixed in [5b4ed56e].

Also remove unneeded makeReadOptional. Now that handling optional
fields is corrected, this helper function is no longer necessary.

Signed-off-by: Petr Pudlak <9d19625f8ee825a2c398462ed335cbcf98f79c32@google.com>
Reviewed-by: Klaus Aehlig <4ce51de36d9068cd7db2eec1151e0f3f95419008@google.com>

leshchevds/ganeti,ganeti-github-testing/ganeti-test-1,apyrgio/ganeti,onponomarev/ganeti,mbakke/ganeti,grnet/snf-ganeti,dimara/ganeti,mbakke/ganeti,mbakke/ganeti,andir/ganeti,ganeti/ganeti,andir/ganeti,bitemyapp/ganeti,dimara/ganeti,apyrgio/ganeti,yiannist/ganeti,ganeti/ganeti,yiannist/ganeti,leshchevds/ganeti,bitemyapp/ganeti,grnet/snf-ganeti,yiannist/ganeti,ganeti/ganeti,leshchevds/ganeti,andir/ganeti,onponomarev/ganeti,ganeti-github-testing/ganeti-test-1